blob: 8adbdc3a800a950dccefe02d8b3f0ca2c0c28a1f [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
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200377MAX_CONTENT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
378MAX_IN_LEN=$( ../scripts/config.py get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
379MAX_OUT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
Angus Grattonc4dd0732018-04-11 16:28:39 +1000380
381if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
382 MAX_CONTENT_LEN="$MAX_IN_LEN"
383fi
384if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
385 MAX_CONTENT_LEN="$MAX_OUT_LEN"
386fi
387
388# skip the next test if the SSL output buffer is less than 16KB
389requires_full_size_output_buffer() {
390 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
391 SKIP_NEXT="YES"
392 fi
393}
394
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200395# skip the next test if valgrind is in use
396not_with_valgrind() {
397 if [ "$MEMCHECK" -gt 0 ]; then
398 SKIP_NEXT="YES"
399 fi
400}
401
Paul Bakker362689d2016-05-13 10:33:25 +0100402# skip the next test if valgrind is NOT in use
403only_with_valgrind() {
404 if [ "$MEMCHECK" -eq 0 ]; then
405 SKIP_NEXT="YES"
406 fi
407}
408
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200409# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100410client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200411 CLI_DELAY_FACTOR=$1
412}
413
Janos Follath74537a62016-09-02 13:45:28 +0100414# wait for the given seconds after the client finished in the next test
415server_needs_more_time() {
416 SRV_DELAY_SECONDS=$1
417}
418
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100419# print_name <name>
420print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100421 TESTS=$(( $TESTS + 1 ))
422 LINE=""
423
424 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
425 LINE="$TESTS "
426 fi
427
428 LINE="$LINE$1"
429 printf "$LINE "
430 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100431 for i in `seq 1 $LEN`; do printf '.'; done
432 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100433
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100434}
435
Gilles Peskine560280b2019-09-16 15:17:38 +0200436# record_outcome <outcome> [<failure-reason>]
437# The test name must be in $NAME.
438record_outcome() {
439 echo "$1"
440 if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ]; then
441 printf '%s;%s;%s;%s;%s;%s\n' \
442 "$MBEDTLS_TEST_PLATFORM" "$MBEDTLS_TEST_CONFIGURATION" \
443 "ssl-opt" "$NAME" \
444 "$1" "${2-}" \
445 >>"$MBEDTLS_TEST_OUTCOME_FILE"
446 fi
447}
448
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100449# fail <message>
450fail() {
Gilles Peskine560280b2019-09-16 15:17:38 +0200451 record_outcome "FAIL" "$1"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100452 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100453
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200454 mv $SRV_OUT o-srv-${TESTS}.log
455 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200456 if [ -n "$PXY_CMD" ]; then
457 mv $PXY_OUT o-pxy-${TESTS}.log
458 fi
459 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100460
Manuel Pégourié-Gonnard3f3302f2020-06-08 11:49:05 +0200461 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200462 echo " ! server output:"
463 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200464 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200465 echo " ! client output:"
466 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200467 if [ -n "$PXY_CMD" ]; then
468 echo " ! ========================================================"
469 echo " ! proxy output:"
470 cat o-pxy-${TESTS}.log
471 fi
472 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200473 fi
474
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200475 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100476}
477
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100478# is_polar <cmd_line>
479is_polar() {
Gilles Peskine64457492020-08-26 21:53:33 +0200480 case "$1" in
481 *ssl_client2*) true;;
482 *ssl_server2*) true;;
483 *) false;;
484 esac
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100485}
486
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200487# openssl s_server doesn't have -www with DTLS
488check_osrv_dtls() {
Gilles Peskine64457492020-08-26 21:53:33 +0200489 case "$SRV_CMD" in
490 *s_server*-dtls*)
491 NEEDS_INPUT=1
492 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )";;
493 *) NEEDS_INPUT=0;;
494 esac
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200495}
496
497# provide input to commands that need it
498provide_input() {
499 if [ $NEEDS_INPUT -eq 0 ]; then
500 return
501 fi
502
503 while true; do
504 echo "HTTP/1.0 200 OK"
505 sleep 1
506 done
507}
508
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100509# has_mem_err <log_file_name>
510has_mem_err() {
511 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
512 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
513 then
514 return 1 # false: does not have errors
515 else
516 return 0 # true: has errors
517 fi
518}
519
Unknownd364f4c2019-09-02 10:42:57 -0400520# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100521if type lsof >/dev/null 2>/dev/null; then
Unknownd364f4c2019-09-02 10:42:57 -0400522 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100523 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200524 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100525 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200526 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100527 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200528 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100529 # Make a tight loop, server normally takes less than 1s to start.
530 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
531 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknownd364f4c2019-09-02 10:42:57 -0400532 echo "$3 START TIMEOUT"
533 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100534 break
535 fi
536 # Linux and *BSD support decimal arguments to sleep. On other
537 # OSes this may be a tight loop.
538 sleep 0.1 2>/dev/null || true
539 done
540 }
541else
Unknownd364f4c2019-09-02 10:42:57 -0400542 echo "Warning: lsof not available, wait_app_start = sleep"
543 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200544 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100545 }
546fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200547
Unknownd364f4c2019-09-02 10:42:57 -0400548# Wait for server process $2 to be listening on port $1.
549wait_server_start() {
550 wait_app_start $1 $2 "SERVER" $SRV_OUT
551}
552
553# Wait for proxy process $2 to be listening on port $1.
554wait_proxy_start() {
555 wait_app_start $1 $2 "PROXY" $PXY_OUT
556}
557
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100558# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100559# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100560# acceptable bounds
561check_server_hello_time() {
562 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100563 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100564 # Get the Unix timestamp for now
565 CUR_TIME=$(date +'%s')
566 THRESHOLD_IN_SECS=300
567
568 # Check if the ServerHello time was printed
569 if [ -z "$SERVER_HELLO_TIME" ]; then
570 return 1
571 fi
572
573 # Check the time in ServerHello is within acceptable bounds
574 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
575 # The time in ServerHello is at least 5 minutes before now
576 return 1
577 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100578 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100579 return 1
580 else
581 return 0
582 fi
583}
584
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100585# Get handshake memory usage from server or client output and put it into the variable specified by the first argument
586handshake_memory_get() {
587 OUTPUT_VARIABLE="$1"
588 OUTPUT_FILE="$2"
589
590 # Get memory usage from a pattern like "Heap memory usage after handshake: 23112 bytes. Peak memory usage was 33112"
591 MEM_USAGE=$(sed -n 's/.*Heap memory usage after handshake: //p' < "$OUTPUT_FILE" | grep -o "[0-9]*" | head -1)
592
593 # Check if memory usage was read
594 if [ -z "$MEM_USAGE" ]; then
595 echo "Error: Can not read the value of handshake memory usage"
596 return 1
597 else
598 eval "$OUTPUT_VARIABLE=$MEM_USAGE"
599 return 0
600 fi
601}
602
603# Get handshake memory usage from server or client output and check if this value
604# is not higher than the maximum given by the first argument
605handshake_memory_check() {
606 MAX_MEMORY="$1"
607 OUTPUT_FILE="$2"
608
609 # Get memory usage
610 if ! handshake_memory_get "MEMORY_USAGE" "$OUTPUT_FILE"; then
611 return 1
612 fi
613
614 # Check if memory usage is below max value
615 if [ "$MEMORY_USAGE" -gt "$MAX_MEMORY" ]; then
616 echo "\nFailed: Handshake memory usage was $MEMORY_USAGE bytes," \
617 "but should be below $MAX_MEMORY bytes"
618 return 1
619 else
620 return 0
621 fi
622}
623
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200624# wait for client to terminate and set CLI_EXIT
625# must be called right after starting the client
626wait_client_done() {
627 CLI_PID=$!
628
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200629 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
630 CLI_DELAY_FACTOR=1
631
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200632 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200633 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200634
635 wait $CLI_PID
636 CLI_EXIT=$?
637
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200638 kill $DOG_PID >/dev/null 2>&1
639 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200640
641 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100642
643 sleep $SRV_DELAY_SECONDS
644 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200645}
646
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200647# check if the given command uses dtls and sets global variable DTLS
648detect_dtls() {
Gilles Peskine64457492020-08-26 21:53:33 +0200649 case "$1" in
650 *dtls=1*|-dtls|-u) DTLS=1;;
651 *) DTLS=0;;
652 esac
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200653}
654
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200655# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100656# Options: -s pattern pattern that must be present in server output
657# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100658# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100659# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100660# -S pattern pattern that must be absent in server output
661# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100662# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100663# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100664run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100665 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200666 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100667
Gilles Peskine9fa4ed62020-08-26 22:35:46 +0200668 if is_excluded "$NAME"; then
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200669 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200670 # There was no request to run the test, so don't record its outcome.
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100671 return
672 fi
673
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100674 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100675
Paul Bakkerb7584a52016-05-10 10:50:43 +0100676 # Do we only run numbered tests?
Gilles Peskine64457492020-08-26 21:53:33 +0200677 if [ -n "$RUN_TEST_NUMBER" ]; then
678 case ",$RUN_TEST_NUMBER," in
679 *",$TESTS,"*) :;;
680 *) SKIP_NEXT="YES";;
681 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100682 fi
683
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200684 # does this test use a proxy?
685 if [ "X$1" = "X-p" ]; then
686 PXY_CMD="$2"
687 shift 2
688 else
689 PXY_CMD=""
690 fi
691
692 # get commands and client output
693 SRV_CMD="$1"
694 CLI_CMD="$2"
695 CLI_EXPECT="$3"
696 shift 3
697
Hanno Becker91e72c32019-05-10 14:38:42 +0100698 # Check if test uses files
Gilles Peskine64457492020-08-26 21:53:33 +0200699 case "$SRV_CMD $CLI_CMD" in
700 *data_files/*)
701 requires_config_enabled MBEDTLS_FS_IO;;
702 esac
Hanno Becker91e72c32019-05-10 14:38:42 +0100703
Gilles Peskine0d721652020-06-26 23:35:53 +0200704 # If the client or serve requires a ciphersuite, check that it's enabled.
705 maybe_requires_ciphersuite_enabled "$SRV_CMD" "$@"
706 maybe_requires_ciphersuite_enabled "$CLI_CMD" "$@"
Hanno Becker9d76d562018-11-16 17:27:29 +0000707
708 # should we skip?
709 if [ "X$SKIP_NEXT" = "XYES" ]; then
710 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200711 record_outcome "SKIP"
Hanno Becker9d76d562018-11-16 17:27:29 +0000712 SKIPS=$(( $SKIPS + 1 ))
713 return
714 fi
715
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200716 # update DTLS variable
717 detect_dtls "$SRV_CMD"
718
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200719 # if the test uses DTLS but no custom proxy, add a simple proxy
720 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard70fce982020-06-25 09:54:46 +0200721 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200722 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard8779e9a2020-07-16 10:19:32 +0200723 case " $SRV_CMD " in
724 *' server_addr=::1 '*)
725 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
726 esac
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200727 fi
728
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100729 # fix client port
730 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200731 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
732 else
733 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
734 fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200735
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100736 # prepend valgrind to our commands if active
737 if [ "$MEMCHECK" -gt 0 ]; then
738 if is_polar "$SRV_CMD"; then
739 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
740 fi
741 if is_polar "$CLI_CMD"; then
742 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
743 fi
744 fi
745
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200746 TIMES_LEFT=2
747 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200748 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200749
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200750 # run the commands
751 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda3b994f2020-07-27 09:45:32 +0200752 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200753 $PXY_CMD >> $PXY_OUT 2>&1 &
754 PXY_PID=$!
Unknownd364f4c2019-09-02 10:42:57 -0400755 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200756 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200757
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200758 check_osrv_dtls
Manuel Pégourié-Gonnardd06125c2020-06-08 12:06:21 +0200759 printf "# $NAME\n$SRV_CMD\n" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200760 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
761 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100762 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200763
Manuel Pégourié-Gonnardd06125c2020-06-08 12:06:21 +0200764 printf "# $NAME\n$CLI_CMD\n" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200765 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
766 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100767
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100768 sleep 0.05
769
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200770 # terminate the server (and the proxy)
771 kill $SRV_PID
772 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100773
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200774 if [ -n "$PXY_CMD" ]; then
775 kill $PXY_PID >/dev/null 2>&1
776 wait $PXY_PID
777 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100778
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200779 # retry only on timeouts
780 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
781 printf "RETRY "
782 else
783 TIMES_LEFT=0
784 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200785 done
786
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100787 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200788 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100789 # expected client exit to incorrectly succeed in case of catastrophic
790 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100791 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200792 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100793 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100794 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100795 return
796 fi
797 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100798 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200799 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100800 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100801 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100802 return
803 fi
804 fi
805
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100806 # check server exit code
807 if [ $? != 0 ]; then
808 fail "server fail"
809 return
810 fi
811
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100812 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100813 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
814 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100815 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200816 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100817 return
818 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100819
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100820 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200821 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100822 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100823 while [ $# -gt 0 ]
824 do
825 case $1 in
826 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100827 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 +0100828 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100829 return
830 fi
831 ;;
832
833 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100834 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 +0100835 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100836 return
837 fi
838 ;;
839
840 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100841 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 +0100842 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100843 return
844 fi
845 ;;
846
847 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100848 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 +0100849 fail "pattern '$2' MUST NOT be present in the Client output"
850 return
851 fi
852 ;;
853
854 # The filtering in the following two options (-u and -U) do the following
855 # - ignore valgrind output
Antonin Décimo36e89b52019-01-23 15:24:37 +0100856 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100857 # - keep one of each non-unique line
858 # - count how many lines remain
859 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
860 # if there were no duplicates.
861 "-U")
862 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
863 fail "lines following pattern '$2' must be unique in Server output"
864 return
865 fi
866 ;;
867
868 "-u")
869 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
870 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100871 return
872 fi
873 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100874 "-F")
875 if ! $2 "$SRV_OUT"; then
876 fail "function call to '$2' failed on Server output"
877 return
878 fi
879 ;;
880 "-f")
881 if ! $2 "$CLI_OUT"; then
882 fail "function call to '$2' failed on Client output"
883 return
884 fi
885 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100886
887 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200888 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100889 exit 1
890 esac
891 shift 2
892 done
893
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100894 # check valgrind's results
895 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200896 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100897 fail "Server has memory errors"
898 return
899 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200900 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100901 fail "Client has memory errors"
902 return
903 fi
904 fi
905
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100906 # if we're here, everything is ok
Gilles Peskine560280b2019-09-16 15:17:38 +0200907 record_outcome "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100908 if [ "$PRESERVE_LOGS" -gt 0 ]; then
909 mv $SRV_OUT o-srv-${TESTS}.log
910 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100911 if [ -n "$PXY_CMD" ]; then
912 mv $PXY_OUT o-pxy-${TESTS}.log
913 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100914 fi
915
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200916 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100917}
918
Hanno Becker9b5853c2018-11-16 17:28:40 +0000919run_test_psa() {
920 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
Hanno Beckere9420c22018-11-20 11:37:34 +0000921 run_test "PSA-supported ciphersuite: $1" \
Hanno Becker4c8c7aa2019-04-10 09:25:41 +0100922 "$P_SRV debug_level=3 force_version=tls1_2" \
923 "$P_CLI debug_level=3 force_version=tls1_2 force_ciphersuite=$1" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000924 0 \
925 -c "Successfully setup PSA-based decryption cipher context" \
926 -c "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500927 -c "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500928 -c "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000929 -s "Successfully setup PSA-based decryption cipher context" \
930 -s "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500931 -s "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500932 -s "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000933 -C "Failed to setup PSA-based cipher context"\
934 -S "Failed to setup PSA-based cipher context"\
935 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000936 -c "Perform PSA-based ECDH computation."\
Andrzej Kureke85414e2019-01-15 05:23:59 -0500937 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000938 -S "error" \
939 -C "error"
940}
941
Hanno Becker354e2482019-01-08 11:40:25 +0000942run_test_psa_force_curve() {
943 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
944 run_test "PSA - ECDH with $1" \
945 "$P_SRV debug_level=4 force_version=tls1_2" \
946 "$P_CLI debug_level=4 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=$1" \
947 0 \
Hanno Becker28f78442019-02-18 16:47:50 +0000948 -c "Successfully setup PSA-based decryption cipher context" \
949 -c "Successfully setup PSA-based encryption cipher context" \
950 -c "PSA calc verify" \
951 -c "calc PSA finished" \
952 -s "Successfully setup PSA-based decryption cipher context" \
953 -s "Successfully setup PSA-based encryption cipher context" \
954 -s "PSA calc verify" \
955 -s "calc PSA finished" \
956 -C "Failed to setup PSA-based cipher context"\
957 -S "Failed to setup PSA-based cipher context"\
Hanno Becker354e2482019-01-08 11:40:25 +0000958 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000959 -c "Perform PSA-based ECDH computation."\
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100960 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200961 -S "error" \
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200962 -C "error"
963}
964
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100965# Test that the server's memory usage after a handshake is reduced when a client specifies
966# a maximum fragment length.
967# first argument ($1) is MFL for SSL client
968# second argument ($2) is memory usage for SSL client with default MFL (16k)
969run_test_memory_after_hanshake_with_mfl()
970{
971 # The test passes if the difference is around 2*(16k-MFL)
Gilles Peskine5b428d72020-08-26 21:52:23 +0200972 MEMORY_USAGE_LIMIT="$(( $2 - ( 2 * ( 16384 - $1 )) ))"
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100973
974 # Leave some margin for robustness
975 MEMORY_USAGE_LIMIT="$(( ( MEMORY_USAGE_LIMIT * 110 ) / 100 ))"
976
977 run_test "Handshake memory usage (MFL $1)" \
978 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
979 "$P_CLI debug_level=3 force_version=tls1_2 \
980 crt_file=data_files/server5.crt key_file=data_files/server5.key \
981 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM max_frag_len=$1" \
982 0 \
983 -F "handshake_memory_check $MEMORY_USAGE_LIMIT"
984}
985
986
987# Test that the server's memory usage after a handshake is reduced when a client specifies
988# different values of Maximum Fragment Length: default (16k), 4k, 2k, 1k and 512 bytes
989run_tests_memory_after_hanshake()
990{
991 # all tests in this sequence requires the same configuration (see requires_config_enabled())
992 SKIP_THIS_TESTS="$SKIP_NEXT"
993
994 # first test with default MFU is to get reference memory usage
995 MEMORY_USAGE_MFL_16K=0
996 run_test "Handshake memory usage initial (MFL 16384 - default)" \
997 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
998 "$P_CLI debug_level=3 force_version=tls1_2 \
999 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1000 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM" \
1001 0 \
1002 -F "handshake_memory_get MEMORY_USAGE_MFL_16K"
1003
1004 SKIP_NEXT="$SKIP_THIS_TESTS"
1005 run_test_memory_after_hanshake_with_mfl 4096 "$MEMORY_USAGE_MFL_16K"
1006
1007 SKIP_NEXT="$SKIP_THIS_TESTS"
1008 run_test_memory_after_hanshake_with_mfl 2048 "$MEMORY_USAGE_MFL_16K"
1009
1010 SKIP_NEXT="$SKIP_THIS_TESTS"
1011 run_test_memory_after_hanshake_with_mfl 1024 "$MEMORY_USAGE_MFL_16K"
1012
1013 SKIP_NEXT="$SKIP_THIS_TESTS"
1014 run_test_memory_after_hanshake_with_mfl 512 "$MEMORY_USAGE_MFL_16K"
1015}
1016
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001017cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001018 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Piotr Nowicki3de298f2020-04-16 14:35:19 +02001019 rm -f context_srv.txt
1020 rm -f context_cli.txt
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +02001021 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
1022 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
1023 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
1024 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001025 exit 1
1026}
1027
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +01001028#
1029# MAIN
1030#
1031
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +01001032get_options "$@"
1033
Gilles Peskine9fa4ed62020-08-26 22:35:46 +02001034# Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell
1035# patterns rather than regular expressions, use a case statement instead
1036# of calling grep. To keep the optimizer simple, it is incomplete and only
1037# detects simple cases: plain substring, everything, nothing.
1038#
1039# As an exception, the character '.' is treated as an ordinary character
1040# if it is the only special character in the string. This is because it's
1041# rare to need "any one character", but needing a literal '.' is common
1042# (e.g. '-f "DTLS 1.2"').
1043need_grep=
1044case "$FILTER" in
1045 '^$') simple_filter=;;
1046 '.*') simple_filter='*';;
1047 *[][\$^+*?{|}]*) # Regexp special characters (other than .), we need grep
1048 need_grep=1;;
1049 *) # No regexp or shell-pattern special character
1050 simple_filter="*$FILTER*";;
1051esac
1052case "$EXCLUDE" in
1053 '^$') simple_exclude=;;
1054 '.*') simple_exclude='*';;
1055 *[][\$^+*?{|}]*) # Regexp special characters (other than .), we need grep
1056 need_grep=1;;
1057 *) # No regexp or shell-pattern special character
1058 simple_exclude="*$EXCLUDE*";;
1059esac
1060if [ -n "$need_grep" ]; then
1061 is_excluded () {
1062 ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE"
1063 }
1064else
1065 is_excluded () {
1066 case "$1" in
1067 $simple_exclude) true;;
1068 $simple_filter) false;;
1069 *) true;;
1070 esac
1071 }
1072fi
1073
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001074# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +01001075P_SRV_BIN="${P_SRV%%[ ]*}"
1076P_CLI_BIN="${P_CLI%%[ ]*}"
1077P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +01001078if [ ! -x "$P_SRV_BIN" ]; then
1079 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001080 exit 1
1081fi
Hanno Becker17c04932017-10-10 14:44:53 +01001082if [ ! -x "$P_CLI_BIN" ]; then
1083 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001084 exit 1
1085fi
Hanno Becker17c04932017-10-10 14:44:53 +01001086if [ ! -x "$P_PXY_BIN" ]; then
1087 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001088 exit 1
1089fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +01001090if [ "$MEMCHECK" -gt 0 ]; then
1091 if which valgrind >/dev/null 2>&1; then :; else
1092 echo "Memcheck not possible. Valgrind not found"
1093 exit 1
1094 fi
1095fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001096if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1097 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001098 exit 1
1099fi
1100
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001101# used by watchdog
1102MAIN_PID="$$"
1103
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001104# We use somewhat arbitrary delays for tests:
1105# - how long do we wait for the server to start (when lsof not available)?
1106# - how long do we allow for the client to finish?
1107# (not to check performance, just to avoid waiting indefinitely)
1108# Things are slower with valgrind, so give extra time here.
1109#
1110# Note: without lsof, there is a trade-off between the running time of this
1111# script and the risk of spurious errors because we didn't wait long enough.
1112# The watchdog delay on the other hand doesn't affect normal running time of
1113# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001114if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001115 START_DELAY=6
1116 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001117else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001118 START_DELAY=2
1119 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001120fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001121
1122# some particular tests need more time:
1123# - for the client, we multiply the usual watchdog limit by a factor
1124# - for the server, we sleep for a number of seconds after the client exits
1125# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001126CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001127SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001128
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001129# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001130# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001131P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1132P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001133P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +02001134O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001135O_CLI="$O_CLI -connect localhost:+SRV_PORT"
1136G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001137G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001138
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001139if [ -n "${OPENSSL_LEGACY:-}" ]; then
1140 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1141 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1142fi
1143
Hanno Becker58e9dc32018-08-17 15:53:21 +01001144if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001145 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1146fi
1147
Hanno Becker58e9dc32018-08-17 15:53:21 +01001148if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001149 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001150fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001151
Gilles Peskine62469d92017-05-10 10:13:59 +02001152# Allow SHA-1, because many of our test certificates use it
1153P_SRV="$P_SRV allow_sha1=1"
1154P_CLI="$P_CLI allow_sha1=1"
1155
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001156# Also pick a unique name for intermediate files
1157SRV_OUT="srv_out.$$"
1158CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001159PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001160SESSION="session.$$"
1161
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001162SKIP_NEXT="NO"
1163
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001164trap cleanup INT TERM HUP
1165
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001166# Basic test
1167
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001168# Checks that:
1169# - things work with all ciphersuites active (used with config-full in all.sh)
1170# - the expected (highest security) parameters are selected
1171# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001172run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001173 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001174 "$P_CLI" \
1175 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001176 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001177 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001178 -s "client hello v3, signature_algorithm ext: 6" \
1179 -s "ECDHE curve: secp521r1" \
1180 -S "error" \
1181 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001182
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001183run_test "Default, DTLS" \
1184 "$P_SRV dtls=1" \
1185 "$P_CLI dtls=1" \
1186 0 \
1187 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001188 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001189
Hanno Becker721f7c12020-08-17 12:17:32 +01001190run_test "TLS client auth: required" \
1191 "$P_SRV auth_mode=required" \
1192 "$P_CLI" \
1193 0 \
1194 -s "Verifying peer X.509 certificate... ok"
1195
Hanno Becker2f54a3c2020-08-17 12:14:06 +01001196requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1197requires_config_enabled MBEDTLS_ECDSA_C
1198requires_config_enabled MBEDTLS_SHA256_C
1199run_test "TLS: password protected client key" \
1200 "$P_SRV auth_mode=required" \
1201 "$P_CLI crt_file=data_files/server5.crt key_file=data_files/server5.key.enc key_pwd=PolarSSLTest" \
1202 0
1203
1204requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1205requires_config_enabled MBEDTLS_ECDSA_C
1206requires_config_enabled MBEDTLS_SHA256_C
1207run_test "TLS: password protected server key" \
1208 "$P_SRV crt_file=data_files/server5.crt key_file=data_files/server5.key.enc key_pwd=PolarSSLTest" \
1209 "$P_CLI" \
1210 0
1211
1212requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1213requires_config_enabled MBEDTLS_ECDSA_C
1214requires_config_enabled MBEDTLS_RSA_C
1215requires_config_enabled MBEDTLS_SHA256_C
1216run_test "TLS: password protected server key, two certificates" \
1217 "$P_SRV \
1218 key_file=data_files/server5.key.enc key_pwd=PolarSSLTest crt_file=data_files/server5.crt \
1219 key_file2=data_files/server2.key.enc key_pwd2=PolarSSLTest crt_file2=data_files/server2.crt" \
1220 "$P_CLI" \
1221 0
1222
Manuel Pégourié-Gonnard342d2ca2020-01-02 11:58:00 +01001223requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1224run_test "Default (compression enabled)" \
1225 "$P_SRV debug_level=3" \
1226 "$P_CLI debug_level=3" \
1227 0 \
1228 -s "Allocating compression buffer" \
1229 -c "Allocating compression buffer" \
1230 -s "Record expansion is unknown (compression)" \
1231 -c "Record expansion is unknown (compression)" \
1232 -S "error" \
1233 -C "error"
1234
Hanno Becker746aaf32019-03-28 15:25:23 +00001235requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1236run_test "CA callback on client" \
1237 "$P_SRV debug_level=3" \
1238 "$P_CLI ca_callback=1 debug_level=3 " \
1239 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001240 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001241 -S "error" \
1242 -C "error"
1243
1244requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1245requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1246requires_config_enabled MBEDTLS_ECDSA_C
1247requires_config_enabled MBEDTLS_SHA256_C
1248run_test "CA callback on server" \
1249 "$P_SRV auth_mode=required" \
1250 "$P_CLI ca_callback=1 debug_level=3 crt_file=data_files/server5.crt \
1251 key_file=data_files/server5.key" \
1252 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001253 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001254 -s "Verifying peer X.509 certificate... ok" \
1255 -S "error" \
1256 -C "error"
1257
Manuel Pégourié-Gonnardcfdf8f42018-11-08 09:52:25 +01001258# Test using an opaque private key for client authentication
1259requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
1260requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1261requires_config_enabled MBEDTLS_ECDSA_C
1262requires_config_enabled MBEDTLS_SHA256_C
1263run_test "Opaque key for client authentication" \
1264 "$P_SRV auth_mode=required" \
1265 "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \
1266 key_file=data_files/server5.key" \
1267 0 \
1268 -c "key type: Opaque" \
1269 -s "Verifying peer X.509 certificate... ok" \
1270 -S "error" \
1271 -C "error"
1272
Hanno Becker9b5853c2018-11-16 17:28:40 +00001273# Test ciphersuites which we expect to be fully supported by PSA Crypto
1274# and check that we don't fall back to Mbed TLS' internal crypto primitives.
1275run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM
1276run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
1277run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM
1278run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8
1279run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
1280run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384
1281run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA
1282run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
1283run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384
1284
Hanno Becker354e2482019-01-08 11:40:25 +00001285requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1286run_test_psa_force_curve "secp521r1"
1287requires_config_enabled MBEDTLS_ECP_DP_BP512R1_ENABLED
1288run_test_psa_force_curve "brainpoolP512r1"
1289requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
1290run_test_psa_force_curve "secp384r1"
1291requires_config_enabled MBEDTLS_ECP_DP_BP384R1_ENABLED
1292run_test_psa_force_curve "brainpoolP384r1"
1293requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED
1294run_test_psa_force_curve "secp256r1"
1295requires_config_enabled MBEDTLS_ECP_DP_SECP256K1_ENABLED
1296run_test_psa_force_curve "secp256k1"
1297requires_config_enabled MBEDTLS_ECP_DP_BP256R1_ENABLED
1298run_test_psa_force_curve "brainpoolP256r1"
1299requires_config_enabled MBEDTLS_ECP_DP_SECP224R1_ENABLED
1300run_test_psa_force_curve "secp224r1"
1301requires_config_enabled MBEDTLS_ECP_DP_SECP224K1_ENABLED
1302run_test_psa_force_curve "secp224k1"
1303requires_config_enabled MBEDTLS_ECP_DP_SECP192R1_ENABLED
1304run_test_psa_force_curve "secp192r1"
1305requires_config_enabled MBEDTLS_ECP_DP_SECP192K1_ENABLED
1306run_test_psa_force_curve "secp192k1"
1307
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001308# Test current time in ServerHello
1309requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001310run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001311 "$P_SRV debug_level=3" \
1312 "$P_CLI debug_level=3" \
1313 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001314 -f "check_server_hello_time" \
1315 -F "check_server_hello_time"
1316
Simon Butcher8e004102016-10-14 00:48:33 +01001317# Test for uniqueness of IVs in AEAD ciphersuites
1318run_test "Unique IV in GCM" \
1319 "$P_SRV exchanges=20 debug_level=4" \
1320 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1321 0 \
1322 -u "IV used" \
1323 -U "IV used"
1324
Janos Follathee11be62019-04-04 12:03:30 +01001325# Tests for certificate verification callback
1326run_test "Configuration-specific CRT verification callback" \
1327 "$P_SRV debug_level=3" \
1328 "$P_CLI context_crt_cb=0 debug_level=3" \
1329 0 \
Janos Follathee11be62019-04-04 12:03:30 +01001330 -S "error" \
1331 -c "Verify requested for " \
1332 -c "Use configuration-specific verification callback" \
1333 -C "Use context-specific verification callback" \
1334 -C "error"
1335
Hanno Beckerefb440a2019-04-03 13:04:33 +01001336run_test "Context-specific CRT verification callback" \
1337 "$P_SRV debug_level=3" \
1338 "$P_CLI context_crt_cb=1 debug_level=3" \
1339 0 \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001340 -S "error" \
Janos Follathee11be62019-04-04 12:03:30 +01001341 -c "Verify requested for " \
1342 -c "Use context-specific verification callback" \
1343 -C "Use configuration-specific verification callback" \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001344 -C "error"
1345
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001346# Tests for rc4 option
1347
Simon Butchera410af52016-05-19 22:12:18 +01001348requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001349run_test "RC4: server disabled, client enabled" \
1350 "$P_SRV" \
1351 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1352 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001353 -s "SSL - The server has no ciphersuites in common"
1354
Simon Butchera410af52016-05-19 22:12:18 +01001355requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001356run_test "RC4: server half, client enabled" \
1357 "$P_SRV arc4=1" \
1358 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1359 1 \
1360 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001361
1362run_test "RC4: server enabled, client disabled" \
1363 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1364 "$P_CLI" \
1365 1 \
1366 -s "SSL - The server has no ciphersuites in common"
1367
1368run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001369 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001370 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1371 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001372 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001373 -S "SSL - The server has no ciphersuites in common"
1374
Hanno Beckerd26bb202018-08-17 09:54:10 +01001375# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1376
1377requires_gnutls
1378requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1379run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1380 "$G_SRV"\
1381 "$P_CLI force_version=tls1_1" \
1382 0
1383
1384requires_gnutls
1385requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1386run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1387 "$G_SRV"\
1388 "$P_CLI force_version=tls1" \
1389 0
1390
Gilles Peskinebc70a182017-05-09 15:59:24 +02001391# Tests for SHA-1 support
1392
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001393requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001394run_test "SHA-1 forbidden by default in server certificate" \
1395 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1396 "$P_CLI debug_level=2 allow_sha1=0" \
1397 1 \
1398 -c "The certificate is signed with an unacceptable hash"
1399
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001400requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02001401run_test "SHA-1 allowed by default in server certificate" \
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001402 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1403 "$P_CLI debug_level=2 allow_sha1=0" \
1404 0
1405
Gilles Peskinebc70a182017-05-09 15:59:24 +02001406run_test "SHA-1 explicitly allowed in server certificate" \
1407 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1408 "$P_CLI allow_sha1=1" \
1409 0
1410
1411run_test "SHA-256 allowed by default in server certificate" \
1412 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1413 "$P_CLI allow_sha1=0" \
1414 0
1415
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001416requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001417run_test "SHA-1 forbidden by default in client certificate" \
1418 "$P_SRV auth_mode=required allow_sha1=0" \
1419 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1420 1 \
1421 -s "The certificate is signed with an unacceptable hash"
1422
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001423requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02001424run_test "SHA-1 allowed by default in client certificate" \
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001425 "$P_SRV auth_mode=required allow_sha1=0" \
1426 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1427 0
1428
Gilles Peskinebc70a182017-05-09 15:59:24 +02001429run_test "SHA-1 explicitly allowed in client certificate" \
1430 "$P_SRV auth_mode=required allow_sha1=1" \
1431 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1432 0
1433
1434run_test "SHA-256 allowed by default in client certificate" \
1435 "$P_SRV auth_mode=required allow_sha1=0" \
1436 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1437 0
1438
Hanno Becker7ae8a762018-08-14 15:43:35 +01001439# Tests for datagram packing
1440run_test "DTLS: multiple records in same datagram, client and server" \
1441 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1442 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1443 0 \
1444 -c "next record in same datagram" \
1445 -s "next record in same datagram"
1446
1447run_test "DTLS: multiple records in same datagram, client only" \
1448 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1449 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1450 0 \
1451 -s "next record in same datagram" \
1452 -C "next record in same datagram"
1453
1454run_test "DTLS: multiple records in same datagram, server only" \
1455 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1456 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1457 0 \
1458 -S "next record in same datagram" \
1459 -c "next record in same datagram"
1460
1461run_test "DTLS: multiple records in same datagram, neither client nor server" \
1462 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1463 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1464 0 \
1465 -S "next record in same datagram" \
1466 -C "next record in same datagram"
1467
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001468# Tests for Truncated HMAC extension
1469
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001470run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001471 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001472 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001473 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001474 -s "dumping 'expected mac' (20 bytes)" \
1475 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001476
Hanno Becker32c55012017-11-10 08:42:54 +00001477requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001478run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001479 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001480 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001481 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001482 -s "dumping 'expected mac' (20 bytes)" \
1483 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001484
Hanno Becker32c55012017-11-10 08:42:54 +00001485requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001486run_test "Truncated HMAC: client enabled, server default" \
1487 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001488 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001489 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001490 -s "dumping 'expected mac' (20 bytes)" \
1491 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001492
Hanno Becker32c55012017-11-10 08:42:54 +00001493requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001494run_test "Truncated HMAC: client enabled, server disabled" \
1495 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001496 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001497 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001498 -s "dumping 'expected mac' (20 bytes)" \
1499 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001500
Hanno Becker32c55012017-11-10 08:42:54 +00001501requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001502run_test "Truncated HMAC: client disabled, server enabled" \
1503 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001504 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001505 0 \
1506 -s "dumping 'expected mac' (20 bytes)" \
1507 -S "dumping 'expected mac' (10 bytes)"
1508
1509requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001510run_test "Truncated HMAC: client enabled, server enabled" \
1511 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001512 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001513 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001514 -S "dumping 'expected mac' (20 bytes)" \
1515 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001516
Hanno Becker4c4f4102017-11-10 09:16:05 +00001517run_test "Truncated HMAC, DTLS: client default, server default" \
1518 "$P_SRV dtls=1 debug_level=4" \
1519 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1520 0 \
1521 -s "dumping 'expected mac' (20 bytes)" \
1522 -S "dumping 'expected mac' (10 bytes)"
1523
1524requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1525run_test "Truncated HMAC, DTLS: client disabled, server default" \
1526 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001527 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001528 0 \
1529 -s "dumping 'expected mac' (20 bytes)" \
1530 -S "dumping 'expected mac' (10 bytes)"
1531
1532requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1533run_test "Truncated HMAC, DTLS: client enabled, server default" \
1534 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001535 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001536 0 \
1537 -s "dumping 'expected mac' (20 bytes)" \
1538 -S "dumping 'expected mac' (10 bytes)"
1539
1540requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1541run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1542 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001543 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001544 0 \
1545 -s "dumping 'expected mac' (20 bytes)" \
1546 -S "dumping 'expected mac' (10 bytes)"
1547
1548requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1549run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1550 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001551 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001552 0 \
1553 -s "dumping 'expected mac' (20 bytes)" \
1554 -S "dumping 'expected mac' (10 bytes)"
1555
1556requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1557run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1558 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001559 "$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 +01001560 0 \
1561 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001562 -s "dumping 'expected mac' (10 bytes)"
1563
Jarno Lamsa2937d812019-06-04 11:33:23 +03001564# Tests for Context serialization
1565
1566requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001567run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001568 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001569 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1570 0 \
1571 -c "Deserializing connection..." \
1572 -S "Deserializing connection..."
1573
1574requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1575run_test "Context serialization, client serializes, ChaChaPoly" \
1576 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1577 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1578 0 \
1579 -c "Deserializing connection..." \
1580 -S "Deserializing connection..."
1581
1582requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1583run_test "Context serialization, client serializes, GCM" \
1584 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1585 "$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 +03001586 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001587 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001588 -S "Deserializing connection..."
1589
1590requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001591requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1592run_test "Context serialization, client serializes, with CID" \
1593 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1594 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1595 0 \
1596 -c "Deserializing connection..." \
1597 -S "Deserializing connection..."
1598
1599requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001600run_test "Context serialization, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001601 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001602 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1603 0 \
1604 -C "Deserializing connection..." \
1605 -s "Deserializing connection..."
1606
1607requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1608run_test "Context serialization, server serializes, ChaChaPoly" \
1609 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1610 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1611 0 \
1612 -C "Deserializing connection..." \
1613 -s "Deserializing connection..."
1614
1615requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1616run_test "Context serialization, server serializes, GCM" \
1617 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1618 "$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 +03001619 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001620 -C "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001621 -s "Deserializing connection..."
1622
1623requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001624requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1625run_test "Context serialization, server serializes, with CID" \
1626 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1627 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1628 0 \
1629 -C "Deserializing connection..." \
1630 -s "Deserializing connection..."
1631
1632requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001633run_test "Context serialization, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001634 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001635 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1636 0 \
1637 -c "Deserializing connection..." \
1638 -s "Deserializing connection..."
1639
1640requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1641run_test "Context serialization, both serialize, ChaChaPoly" \
1642 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1643 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1644 0 \
1645 -c "Deserializing connection..." \
1646 -s "Deserializing connection..."
1647
1648requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1649run_test "Context serialization, both serialize, GCM" \
1650 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1651 "$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 +03001652 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001653 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001654 -s "Deserializing connection..."
1655
Jarno Lamsac2376f02019-06-06 10:44:14 +03001656requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001657requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1658run_test "Context serialization, both serialize, with CID" \
1659 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1660 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1661 0 \
1662 -c "Deserializing connection..." \
1663 -s "Deserializing connection..."
1664
1665requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001666run_test "Context serialization, re-init, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001667 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001668 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1669 0 \
1670 -c "Deserializing connection..." \
1671 -S "Deserializing connection..."
1672
1673requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1674run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1675 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1676 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1677 0 \
1678 -c "Deserializing connection..." \
1679 -S "Deserializing connection..."
1680
1681requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1682run_test "Context serialization, re-init, client serializes, GCM" \
1683 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1684 "$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 +03001685 0 \
1686 -c "Deserializing connection..." \
1687 -S "Deserializing connection..."
1688
Jarno Lamsac2376f02019-06-06 10:44:14 +03001689requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001690requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1691run_test "Context serialization, re-init, client serializes, with CID" \
1692 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1693 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1694 0 \
1695 -c "Deserializing connection..." \
1696 -S "Deserializing connection..."
1697
1698requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001699run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001700 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001701 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1702 0 \
1703 -C "Deserializing connection..." \
1704 -s "Deserializing connection..."
1705
1706requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1707run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1708 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1709 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1710 0 \
1711 -C "Deserializing connection..." \
1712 -s "Deserializing connection..."
1713
1714requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1715run_test "Context serialization, re-init, server serializes, GCM" \
1716 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1717 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001718 0 \
1719 -C "Deserializing connection..." \
1720 -s "Deserializing connection..."
1721
Jarno Lamsac2376f02019-06-06 10:44:14 +03001722requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001723requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1724run_test "Context serialization, re-init, server serializes, with CID" \
1725 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1726 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1727 0 \
1728 -C "Deserializing connection..." \
1729 -s "Deserializing connection..."
1730
1731requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001732run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001733 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001734 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1735 0 \
1736 -c "Deserializing connection..." \
1737 -s "Deserializing connection..."
1738
1739requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1740run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1741 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1742 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1743 0 \
1744 -c "Deserializing connection..." \
1745 -s "Deserializing connection..."
1746
1747requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1748run_test "Context serialization, re-init, both serialize, GCM" \
1749 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1750 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001751 0 \
1752 -c "Deserializing connection..." \
1753 -s "Deserializing connection..."
1754
Hanno Becker1b18fd32019-08-30 11:18:59 +01001755requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1756requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1757run_test "Context serialization, re-init, both serialize, with CID" \
1758 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1759 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1760 0 \
1761 -c "Deserializing connection..." \
1762 -s "Deserializing connection..."
1763
Piotr Nowicki3de298f2020-04-16 14:35:19 +02001764requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1765run_test "Saving the serialized context to a file" \
1766 "$P_SRV dtls=1 serialize=1 context_file=context_srv.txt" \
1767 "$P_CLI dtls=1 serialize=1 context_file=context_cli.txt" \
1768 0 \
1769 -s "Save serialized context to a file... ok" \
1770 -c "Save serialized context to a file... ok"
1771rm -f context_srv.txt
1772rm -f context_cli.txt
1773
Hanno Becker7cf463e2019-04-09 18:08:47 +01001774# Tests for DTLS Connection ID extension
1775
Hanno Becker7cf463e2019-04-09 18:08:47 +01001776# So far, the CID API isn't implemented, so we can't
1777# grep for output witnessing its use. This needs to be
1778# changed once the CID extension is implemented.
1779
Hanno Beckera0e20d02019-05-15 14:03:01 +01001780requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001781run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001782 "$P_SRV debug_level=3 dtls=1 cid=0" \
1783 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1784 0 \
1785 -s "Disable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001786 -s "found CID extension" \
1787 -s "Client sent CID extension, but CID disabled" \
Hanno Becker6b78c832019-04-25 17:01:43 +01001788 -c "Enable use of CID extension." \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001789 -c "client hello, adding CID extension" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001790 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001791 -C "found CID extension" \
1792 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001793 -C "Copy CIDs into SSL transform" \
1794 -c "Use of Connection ID was rejected by the server"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001795
Hanno Beckera0e20d02019-05-15 14:03:01 +01001796requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001797run_test "Connection ID: Cli disabled, Srv enabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001798 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1799 "$P_CLI debug_level=3 dtls=1 cid=0" \
1800 0 \
1801 -c "Disable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001802 -C "client hello, adding CID extension" \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001803 -S "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001804 -s "Enable use of CID extension." \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001805 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001806 -C "found CID extension" \
1807 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001808 -C "Copy CIDs into SSL transform" \
Hanno Beckerb3e9dd52019-05-08 13:19:53 +01001809 -s "Use of Connection ID was not offered by client"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001810
Hanno Beckera0e20d02019-05-15 14:03:01 +01001811requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001812run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001813 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1814 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1815 0 \
1816 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001817 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001818 -c "client hello, adding CID extension" \
1819 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001820 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001821 -s "server hello, adding CID extension" \
1822 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001823 -c "Use of CID extension negotiated" \
1824 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001825 -c "Copy CIDs into SSL transform" \
1826 -c "Peer CID (length 2 Bytes): de ad" \
1827 -s "Peer CID (length 2 Bytes): be ef" \
1828 -s "Use of Connection ID has been negotiated" \
1829 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001830
Hanno Beckera0e20d02019-05-15 14:03:01 +01001831requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001832run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001833 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001834 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1835 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1836 0 \
1837 -c "Enable use of CID extension." \
1838 -s "Enable use of CID extension." \
1839 -c "client hello, adding CID extension" \
1840 -s "found CID extension" \
1841 -s "Use of CID extension negotiated" \
1842 -s "server hello, adding CID extension" \
1843 -c "found CID extension" \
1844 -c "Use of CID extension negotiated" \
1845 -s "Copy CIDs into SSL transform" \
1846 -c "Copy CIDs into SSL transform" \
1847 -c "Peer CID (length 2 Bytes): de ad" \
1848 -s "Peer CID (length 2 Bytes): be ef" \
1849 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001850 -c "Use of Connection ID has been negotiated" \
1851 -c "ignoring unexpected CID" \
1852 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001853
Hanno Beckera0e20d02019-05-15 14:03:01 +01001854requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001855run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1856 -p "$P_PXY mtu=800" \
1857 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1858 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1859 0 \
1860 -c "Enable use of CID extension." \
1861 -s "Enable use of CID extension." \
1862 -c "client hello, adding CID extension" \
1863 -s "found CID extension" \
1864 -s "Use of CID extension negotiated" \
1865 -s "server hello, adding CID extension" \
1866 -c "found CID extension" \
1867 -c "Use of CID extension negotiated" \
1868 -s "Copy CIDs into SSL transform" \
1869 -c "Copy CIDs into SSL transform" \
1870 -c "Peer CID (length 2 Bytes): de ad" \
1871 -s "Peer CID (length 2 Bytes): be ef" \
1872 -s "Use of Connection ID has been negotiated" \
1873 -c "Use of Connection ID has been negotiated"
1874
Hanno Beckera0e20d02019-05-15 14:03:01 +01001875requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001876run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001877 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001878 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1879 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1880 0 \
1881 -c "Enable use of CID extension." \
1882 -s "Enable use of CID extension." \
1883 -c "client hello, adding CID extension" \
1884 -s "found CID extension" \
1885 -s "Use of CID extension negotiated" \
1886 -s "server hello, adding CID extension" \
1887 -c "found CID extension" \
1888 -c "Use of CID extension negotiated" \
1889 -s "Copy CIDs into SSL transform" \
1890 -c "Copy CIDs into SSL transform" \
1891 -c "Peer CID (length 2 Bytes): de ad" \
1892 -s "Peer CID (length 2 Bytes): be ef" \
1893 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001894 -c "Use of Connection ID has been negotiated" \
1895 -c "ignoring unexpected CID" \
1896 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001897
Hanno Beckera0e20d02019-05-15 14:03:01 +01001898requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001899run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001900 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1901 "$P_CLI debug_level=3 dtls=1 cid=1" \
1902 0 \
1903 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001904 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001905 -c "client hello, adding CID extension" \
1906 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001907 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001908 -s "server hello, adding CID extension" \
1909 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001910 -c "Use of CID extension negotiated" \
1911 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001912 -c "Copy CIDs into SSL transform" \
1913 -c "Peer CID (length 4 Bytes): de ad be ef" \
1914 -s "Peer CID (length 0 Bytes):" \
1915 -s "Use of Connection ID has been negotiated" \
1916 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001917
Hanno Beckera0e20d02019-05-15 14:03:01 +01001918requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001919run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001920 "$P_SRV debug_level=3 dtls=1 cid=1" \
1921 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1922 0 \
1923 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001924 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001925 -c "client hello, adding CID extension" \
1926 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001927 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001928 -s "server hello, adding CID extension" \
1929 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001930 -c "Use of CID extension negotiated" \
1931 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001932 -c "Copy CIDs into SSL transform" \
1933 -s "Peer CID (length 4 Bytes): de ad be ef" \
1934 -c "Peer CID (length 0 Bytes):" \
1935 -s "Use of Connection ID has been negotiated" \
1936 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001937
Hanno Beckera0e20d02019-05-15 14:03:01 +01001938requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001939run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001940 "$P_SRV debug_level=3 dtls=1 cid=1" \
1941 "$P_CLI debug_level=3 dtls=1 cid=1" \
1942 0 \
1943 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001944 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001945 -c "client hello, adding CID extension" \
1946 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001947 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001948 -s "server hello, adding CID extension" \
1949 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001950 -c "Use of CID extension negotiated" \
1951 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001952 -c "Copy CIDs into SSL transform" \
1953 -S "Use of Connection ID has been negotiated" \
1954 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001955
Hanno Beckera0e20d02019-05-15 14:03:01 +01001956requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001957run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001958 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1959 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1960 0 \
1961 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001962 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001963 -c "client hello, adding CID extension" \
1964 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001965 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001966 -s "server hello, adding CID extension" \
1967 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001968 -c "Use of CID extension negotiated" \
1969 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001970 -c "Copy CIDs into SSL transform" \
1971 -c "Peer CID (length 2 Bytes): de ad" \
1972 -s "Peer CID (length 2 Bytes): be ef" \
1973 -s "Use of Connection ID has been negotiated" \
1974 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001975
Hanno Beckera0e20d02019-05-15 14:03:01 +01001976requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001977run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001978 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1979 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1980 0 \
1981 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001982 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001983 -c "client hello, adding CID extension" \
1984 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001985 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001986 -s "server hello, adding CID extension" \
1987 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001988 -c "Use of CID extension negotiated" \
1989 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001990 -c "Copy CIDs into SSL transform" \
1991 -c "Peer CID (length 4 Bytes): de ad be ef" \
1992 -s "Peer CID (length 0 Bytes):" \
1993 -s "Use of Connection ID has been negotiated" \
1994 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001995
Hanno Beckera0e20d02019-05-15 14:03:01 +01001996requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001997run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001998 "$P_SRV debug_level=3 dtls=1 cid=1" \
1999 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
2000 0 \
2001 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002002 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002003 -c "client hello, adding CID extension" \
2004 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002005 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002006 -s "server hello, adding CID extension" \
2007 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002008 -c "Use of CID extension negotiated" \
2009 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01002010 -c "Copy CIDs into SSL transform" \
2011 -s "Peer CID (length 4 Bytes): de ad be ef" \
2012 -c "Peer CID (length 0 Bytes):" \
2013 -s "Use of Connection ID has been negotiated" \
2014 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002015
Hanno Beckera0e20d02019-05-15 14:03:01 +01002016requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002017run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002018 "$P_SRV debug_level=3 dtls=1 cid=1" \
2019 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
2020 0 \
2021 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002022 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002023 -c "client hello, adding CID extension" \
2024 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002025 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002026 -s "server hello, adding CID extension" \
2027 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002028 -c "Use of CID extension negotiated" \
2029 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01002030 -c "Copy CIDs into SSL transform" \
2031 -S "Use of Connection ID has been negotiated" \
2032 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002033
Hanno Beckera0e20d02019-05-15 14:03:01 +01002034requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002035run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002036 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
2037 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
2038 0 \
2039 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002040 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002041 -c "client hello, adding CID extension" \
2042 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002043 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002044 -s "server hello, adding CID extension" \
2045 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002046 -c "Use of CID extension negotiated" \
2047 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01002048 -c "Copy CIDs into SSL transform" \
2049 -c "Peer CID (length 2 Bytes): de ad" \
2050 -s "Peer CID (length 2 Bytes): be ef" \
2051 -s "Use of Connection ID has been negotiated" \
2052 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002053
Hanno Beckera0e20d02019-05-15 14:03:01 +01002054requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002055run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002056 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
2057 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
2058 0 \
2059 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002060 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002061 -c "client hello, adding CID extension" \
2062 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002063 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002064 -s "server hello, adding CID extension" \
2065 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002066 -c "Use of CID extension negotiated" \
2067 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01002068 -c "Copy CIDs into SSL transform" \
2069 -c "Peer CID (length 4 Bytes): de ad be ef" \
2070 -s "Peer CID (length 0 Bytes):" \
2071 -s "Use of Connection ID has been negotiated" \
2072 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002073
Hanno Beckera0e20d02019-05-15 14:03:01 +01002074requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002075run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002076 "$P_SRV debug_level=3 dtls=1 cid=1" \
2077 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
2078 0 \
2079 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002080 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002081 -c "client hello, adding CID extension" \
2082 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002083 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002084 -s "server hello, adding CID extension" \
2085 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002086 -c "Use of CID extension negotiated" \
2087 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01002088 -c "Copy CIDs into SSL transform" \
2089 -s "Peer CID (length 4 Bytes): de ad be ef" \
2090 -c "Peer CID (length 0 Bytes):" \
2091 -s "Use of Connection ID has been negotiated" \
2092 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002093
Hanno Beckera0e20d02019-05-15 14:03:01 +01002094requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002095run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002096 "$P_SRV debug_level=3 dtls=1 cid=1" \
2097 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
2098 0 \
2099 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002100 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002101 -c "client hello, adding CID extension" \
2102 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002103 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002104 -s "server hello, adding CID extension" \
2105 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002106 -c "Use of CID extension negotiated" \
2107 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01002108 -c "Copy CIDs into SSL transform" \
2109 -S "Use of Connection ID has been negotiated" \
2110 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002111
Hanno Beckera0e20d02019-05-15 14:03:01 +01002112requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker9bae30d2019-04-23 11:52:44 +01002113requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002114run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002115 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2116 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2117 0 \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002118 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2119 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2120 -s "(initial handshake) Use of Connection ID has been negotiated" \
2121 -c "(initial handshake) Use of Connection ID has been negotiated" \
2122 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2123 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2124 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2125 -c "(after renegotiation) Use of Connection ID has been negotiated"
2126
Hanno Beckera0e20d02019-05-15 14:03:01 +01002127requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002128requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002129run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002130 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2131 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2132 0 \
2133 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2134 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2135 -s "(initial handshake) Use of Connection ID has been negotiated" \
2136 -c "(initial handshake) Use of Connection ID has been negotiated" \
2137 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2138 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2139 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2140 -c "(after renegotiation) Use of Connection ID has been negotiated"
2141
Hanno Beckera0e20d02019-05-15 14:03:01 +01002142requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002143requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002144run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
2145 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
2146 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2147 0 \
2148 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2149 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2150 -s "(initial handshake) Use of Connection ID has been negotiated" \
2151 -c "(initial handshake) Use of Connection ID has been negotiated" \
2152 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2153 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2154 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2155 -c "(after renegotiation) Use of Connection ID has been negotiated"
2156
Hanno Beckera0e20d02019-05-15 14:03:01 +01002157requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002158requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002159run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002160 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002161 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2162 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2163 0 \
2164 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2165 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2166 -s "(initial handshake) Use of Connection ID has been negotiated" \
2167 -c "(initial handshake) Use of Connection ID has been negotiated" \
2168 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2169 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2170 -s "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002171 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2172 -c "ignoring unexpected CID" \
2173 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002174
Hanno Beckera0e20d02019-05-15 14:03:01 +01002175requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002176requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2177run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002178 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2179 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2180 0 \
2181 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2182 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2183 -s "(initial handshake) Use of Connection ID has been negotiated" \
2184 -c "(initial handshake) Use of Connection ID has been negotiated" \
2185 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2186 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2187 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2188 -S "(after renegotiation) Use of Connection ID has been negotiated"
2189
Hanno Beckera0e20d02019-05-15 14:03:01 +01002190requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002191requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002192run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
2193 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2194 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2195 0 \
2196 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2197 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2198 -s "(initial handshake) Use of Connection ID has been negotiated" \
2199 -c "(initial handshake) Use of Connection ID has been negotiated" \
2200 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2201 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2202 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2203 -S "(after renegotiation) Use of Connection ID has been negotiated"
2204
Hanno Beckera0e20d02019-05-15 14:03:01 +01002205requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002206requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002207run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002208 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002209 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2210 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2211 0 \
2212 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2213 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2214 -s "(initial handshake) Use of Connection ID has been negotiated" \
2215 -c "(initial handshake) Use of Connection ID has been negotiated" \
2216 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2217 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2218 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002219 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2220 -c "ignoring unexpected CID" \
2221 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002222
Hanno Beckera0e20d02019-05-15 14:03:01 +01002223requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002224requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2225run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002226 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2227 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2228 0 \
2229 -S "(initial handshake) Use of Connection ID has been negotiated" \
2230 -C "(initial handshake) Use of Connection ID has been negotiated" \
2231 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2232 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2233 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2234 -s "(after renegotiation) Use of Connection ID has been negotiated"
2235
Hanno Beckera0e20d02019-05-15 14:03:01 +01002236requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002237requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002238run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2239 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2240 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2241 0 \
2242 -S "(initial handshake) Use of Connection ID has been negotiated" \
2243 -C "(initial handshake) Use of Connection ID has been negotiated" \
2244 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2245 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2246 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2247 -s "(after renegotiation) Use of Connection ID has been negotiated"
2248
Hanno Beckera0e20d02019-05-15 14:03:01 +01002249requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002250requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002251run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002252 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002253 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2254 "$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" \
2255 0 \
2256 -S "(initial handshake) Use of Connection ID has been negotiated" \
2257 -C "(initial handshake) Use of Connection ID has been negotiated" \
2258 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2259 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2260 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002261 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2262 -c "ignoring unexpected CID" \
2263 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002264
Hanno Beckera0e20d02019-05-15 14:03:01 +01002265requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002266requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2267run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002268 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2269 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2270 0 \
2271 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2272 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2273 -s "(initial handshake) Use of Connection ID has been negotiated" \
2274 -c "(initial handshake) Use of Connection ID has been negotiated" \
2275 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2276 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2277 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2278 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2279 -s "(after renegotiation) Use of Connection ID was not offered by client"
2280
Hanno Beckera0e20d02019-05-15 14:03:01 +01002281requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002282requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002283run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002284 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002285 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2286 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2287 0 \
2288 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2289 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2290 -s "(initial handshake) Use of Connection ID has been negotiated" \
2291 -c "(initial handshake) Use of Connection ID has been negotiated" \
2292 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2293 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2294 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2295 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002296 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2297 -c "ignoring unexpected CID" \
2298 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002299
Hanno Beckera0e20d02019-05-15 14:03:01 +01002300requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002301requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2302run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2303 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2304 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2305 0 \
2306 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2307 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2308 -s "(initial handshake) Use of Connection ID has been negotiated" \
2309 -c "(initial handshake) Use of Connection ID has been negotiated" \
2310 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2311 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2312 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2313 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2314 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2315
Hanno Beckera0e20d02019-05-15 14:03:01 +01002316requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002317requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2318run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002319 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002320 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2321 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2322 0 \
2323 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2324 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2325 -s "(initial handshake) Use of Connection ID has been negotiated" \
2326 -c "(initial handshake) Use of Connection ID has been negotiated" \
2327 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2328 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2329 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2330 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002331 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2332 -c "ignoring unexpected CID" \
2333 -s "ignoring unexpected CID"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002334
Andrzej Kurekb6577832020-06-08 07:08:03 -04002335requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2336requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2337run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=512" \
2338 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
2339 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=512 dtls=1 cid=1 cid_val=beef" \
2340 0 \
2341 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2342 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2343 -s "(initial handshake) Use of Connection ID has been negotiated" \
2344 -c "(initial handshake) Use of Connection ID has been negotiated" \
2345 -s "Reallocating in_buf" \
2346 -s "Reallocating out_buf"
2347
2348requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2349requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2350run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=1024" \
2351 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
2352 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=1024 dtls=1 cid=1 cid_val=beef" \
2353 0 \
2354 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2355 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2356 -s "(initial handshake) Use of Connection ID has been negotiated" \
2357 -c "(initial handshake) Use of Connection ID has been negotiated" \
2358 -s "Reallocating in_buf" \
2359 -s "Reallocating out_buf"
2360
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002361# Tests for Encrypt-then-MAC extension
2362
2363run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002364 "$P_SRV debug_level=3 \
2365 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002366 "$P_CLI debug_level=3" \
2367 0 \
2368 -c "client hello, adding encrypt_then_mac extension" \
2369 -s "found encrypt then mac extension" \
2370 -s "server hello, adding encrypt then mac extension" \
2371 -c "found encrypt_then_mac extension" \
2372 -c "using encrypt then mac" \
2373 -s "using encrypt then mac"
2374
2375run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002376 "$P_SRV debug_level=3 etm=0 \
2377 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002378 "$P_CLI debug_level=3 etm=1" \
2379 0 \
2380 -c "client hello, adding encrypt_then_mac extension" \
2381 -s "found encrypt then mac extension" \
2382 -S "server hello, adding encrypt then mac extension" \
2383 -C "found encrypt_then_mac extension" \
2384 -C "using encrypt then mac" \
2385 -S "using encrypt then mac"
2386
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002387run_test "Encrypt then MAC: client enabled, aead cipher" \
2388 "$P_SRV debug_level=3 etm=1 \
2389 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2390 "$P_CLI debug_level=3 etm=1" \
2391 0 \
2392 -c "client hello, adding encrypt_then_mac extension" \
2393 -s "found encrypt then mac extension" \
2394 -S "server hello, adding encrypt then mac extension" \
2395 -C "found encrypt_then_mac extension" \
2396 -C "using encrypt then mac" \
2397 -S "using encrypt then mac"
2398
2399run_test "Encrypt then MAC: client enabled, stream cipher" \
2400 "$P_SRV debug_level=3 etm=1 \
2401 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002402 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002403 0 \
2404 -c "client hello, adding encrypt_then_mac extension" \
2405 -s "found encrypt then mac extension" \
2406 -S "server hello, adding encrypt then mac extension" \
2407 -C "found encrypt_then_mac extension" \
2408 -C "using encrypt then mac" \
2409 -S "using encrypt then mac"
2410
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002411run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002412 "$P_SRV debug_level=3 etm=1 \
2413 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002414 "$P_CLI debug_level=3 etm=0" \
2415 0 \
2416 -C "client hello, adding encrypt_then_mac extension" \
2417 -S "found encrypt then mac extension" \
2418 -S "server hello, adding encrypt then mac extension" \
2419 -C "found encrypt_then_mac extension" \
2420 -C "using encrypt then mac" \
2421 -S "using encrypt then mac"
2422
Janos Follathe2681a42016-03-07 15:57:05 +00002423requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002424run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002425 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002426 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002427 "$P_CLI debug_level=3 force_version=ssl3" \
2428 0 \
2429 -C "client hello, adding encrypt_then_mac extension" \
2430 -S "found encrypt then mac extension" \
2431 -S "server hello, adding encrypt then mac extension" \
2432 -C "found encrypt_then_mac extension" \
2433 -C "using encrypt then mac" \
2434 -S "using encrypt then mac"
2435
Janos Follathe2681a42016-03-07 15:57:05 +00002436requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002437run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002438 "$P_SRV debug_level=3 force_version=ssl3 \
2439 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002440 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002441 0 \
2442 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002443 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002444 -S "server hello, adding encrypt then mac extension" \
2445 -C "found encrypt_then_mac extension" \
2446 -C "using encrypt then mac" \
2447 -S "using encrypt then mac"
2448
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002449# Tests for Extended Master Secret extension
2450
2451run_test "Extended Master Secret: default" \
2452 "$P_SRV debug_level=3" \
2453 "$P_CLI debug_level=3" \
2454 0 \
2455 -c "client hello, adding extended_master_secret extension" \
2456 -s "found extended master secret extension" \
2457 -s "server hello, adding extended master secret extension" \
2458 -c "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002459 -c "session hash for extended master secret" \
2460 -s "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002461
2462run_test "Extended Master Secret: client enabled, server disabled" \
2463 "$P_SRV debug_level=3 extended_ms=0" \
2464 "$P_CLI debug_level=3 extended_ms=1" \
2465 0 \
2466 -c "client hello, adding extended_master_secret extension" \
2467 -s "found extended master secret extension" \
2468 -S "server hello, adding extended master secret extension" \
2469 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002470 -C "session hash for extended master secret" \
2471 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002472
2473run_test "Extended Master Secret: client disabled, server enabled" \
2474 "$P_SRV debug_level=3 extended_ms=1" \
2475 "$P_CLI debug_level=3 extended_ms=0" \
2476 0 \
2477 -C "client hello, adding extended_master_secret extension" \
2478 -S "found extended master secret extension" \
2479 -S "server hello, adding extended master secret extension" \
2480 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002481 -C "session hash for extended master secret" \
2482 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002483
Janos Follathe2681a42016-03-07 15:57:05 +00002484requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002485run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002486 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002487 "$P_CLI debug_level=3 force_version=ssl3" \
2488 0 \
2489 -C "client hello, adding extended_master_secret extension" \
2490 -S "found extended master secret extension" \
2491 -S "server hello, adding extended master secret extension" \
2492 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002493 -C "session hash for extended master secret" \
2494 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002495
Janos Follathe2681a42016-03-07 15:57:05 +00002496requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002497run_test "Extended Master Secret: client enabled, server SSLv3" \
2498 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002499 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002500 0 \
2501 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002502 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002503 -S "server hello, adding extended master secret extension" \
2504 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002505 -C "session hash for extended master secret" \
2506 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002507
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002508# Tests for FALLBACK_SCSV
2509
2510run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002511 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002512 "$P_CLI debug_level=3 force_version=tls1_1" \
2513 0 \
2514 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002515 -S "received FALLBACK_SCSV" \
2516 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002517 -C "is a fatal alert message (msg 86)"
2518
2519run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002520 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002521 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2522 0 \
2523 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002524 -S "received FALLBACK_SCSV" \
2525 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002526 -C "is a fatal alert message (msg 86)"
2527
2528run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002529 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002530 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002531 1 \
2532 -c "adding FALLBACK_SCSV" \
2533 -s "received FALLBACK_SCSV" \
2534 -s "inapropriate fallback" \
2535 -c "is a fatal alert message (msg 86)"
2536
2537run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002538 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002539 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002540 0 \
2541 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002542 -s "received FALLBACK_SCSV" \
2543 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002544 -C "is a fatal alert message (msg 86)"
2545
2546requires_openssl_with_fallback_scsv
2547run_test "Fallback SCSV: default, openssl server" \
2548 "$O_SRV" \
2549 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2550 0 \
2551 -C "adding FALLBACK_SCSV" \
2552 -C "is a fatal alert message (msg 86)"
2553
2554requires_openssl_with_fallback_scsv
2555run_test "Fallback SCSV: enabled, openssl server" \
2556 "$O_SRV" \
2557 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
2558 1 \
2559 -c "adding FALLBACK_SCSV" \
2560 -c "is a fatal alert message (msg 86)"
2561
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002562requires_openssl_with_fallback_scsv
2563run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002564 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002565 "$O_CLI -tls1_1" \
2566 0 \
2567 -S "received FALLBACK_SCSV" \
2568 -S "inapropriate fallback"
2569
2570requires_openssl_with_fallback_scsv
2571run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002572 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002573 "$O_CLI -tls1_1 -fallback_scsv" \
2574 1 \
2575 -s "received FALLBACK_SCSV" \
2576 -s "inapropriate fallback"
2577
2578requires_openssl_with_fallback_scsv
2579run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002580 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002581 "$O_CLI -fallback_scsv" \
2582 0 \
2583 -s "received FALLBACK_SCSV" \
2584 -S "inapropriate fallback"
2585
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002586# Test sending and receiving empty application data records
2587
2588run_test "Encrypt then MAC: empty application data record" \
2589 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2590 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2591 0 \
2592 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2593 -s "dumping 'input payload after decrypt' (0 bytes)" \
2594 -c "0 bytes written in 1 fragments"
2595
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002596run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002597 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2598 "$P_CLI auth_mode=none etm=0 request_size=0" \
2599 0 \
2600 -s "dumping 'input payload after decrypt' (0 bytes)" \
2601 -c "0 bytes written in 1 fragments"
2602
2603run_test "Encrypt then MAC, DTLS: empty application data record" \
2604 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2605 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2606 0 \
2607 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2608 -s "dumping 'input payload after decrypt' (0 bytes)" \
2609 -c "0 bytes written in 1 fragments"
2610
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002611run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002612 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2613 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2614 0 \
2615 -s "dumping 'input payload after decrypt' (0 bytes)" \
2616 -c "0 bytes written in 1 fragments"
2617
Gilles Peskined50177f2017-05-16 17:53:03 +02002618## ClientHello generated with
2619## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2620## then manually twiddling the ciphersuite list.
2621## The ClientHello content is spelled out below as a hex string as
2622## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2623## The expected response is an inappropriate_fallback alert.
2624requires_openssl_with_fallback_scsv
2625run_test "Fallback SCSV: beginning of list" \
2626 "$P_SRV debug_level=2" \
2627 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2628 0 \
2629 -s "received FALLBACK_SCSV" \
2630 -s "inapropriate fallback"
2631
2632requires_openssl_with_fallback_scsv
2633run_test "Fallback SCSV: end of list" \
2634 "$P_SRV debug_level=2" \
2635 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2636 0 \
2637 -s "received FALLBACK_SCSV" \
2638 -s "inapropriate fallback"
2639
2640## Here the expected response is a valid ServerHello prefix, up to the random.
2641requires_openssl_with_fallback_scsv
2642run_test "Fallback SCSV: not in list" \
2643 "$P_SRV debug_level=2" \
2644 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2645 0 \
2646 -S "received FALLBACK_SCSV" \
2647 -S "inapropriate fallback"
2648
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002649# Tests for CBC 1/n-1 record splitting
2650
2651run_test "CBC Record splitting: TLS 1.2, no splitting" \
2652 "$P_SRV" \
2653 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2654 request_size=123 force_version=tls1_2" \
2655 0 \
2656 -s "Read from client: 123 bytes read" \
2657 -S "Read from client: 1 bytes read" \
2658 -S "122 bytes read"
2659
2660run_test "CBC Record splitting: TLS 1.1, no splitting" \
2661 "$P_SRV" \
2662 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2663 request_size=123 force_version=tls1_1" \
2664 0 \
2665 -s "Read from client: 123 bytes read" \
2666 -S "Read from client: 1 bytes read" \
2667 -S "122 bytes read"
2668
2669run_test "CBC Record splitting: TLS 1.0, splitting" \
2670 "$P_SRV" \
2671 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2672 request_size=123 force_version=tls1" \
2673 0 \
2674 -S "Read from client: 123 bytes read" \
2675 -s "Read from client: 1 bytes read" \
2676 -s "122 bytes read"
2677
Janos Follathe2681a42016-03-07 15:57:05 +00002678requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002679run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002680 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002681 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2682 request_size=123 force_version=ssl3" \
2683 0 \
2684 -S "Read from client: 123 bytes read" \
2685 -s "Read from client: 1 bytes read" \
2686 -s "122 bytes read"
2687
2688run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002689 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002690 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2691 request_size=123 force_version=tls1" \
2692 0 \
2693 -s "Read from client: 123 bytes read" \
2694 -S "Read from client: 1 bytes read" \
2695 -S "122 bytes read"
2696
2697run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2698 "$P_SRV" \
2699 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2700 request_size=123 force_version=tls1 recsplit=0" \
2701 0 \
2702 -s "Read from client: 123 bytes read" \
2703 -S "Read from client: 1 bytes read" \
2704 -S "122 bytes read"
2705
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002706run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2707 "$P_SRV nbio=2" \
2708 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2709 request_size=123 force_version=tls1" \
2710 0 \
2711 -S "Read from client: 123 bytes read" \
2712 -s "Read from client: 1 bytes read" \
2713 -s "122 bytes read"
2714
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002715# Tests for Session Tickets
2716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002717run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002718 "$P_SRV debug_level=3 tickets=1" \
2719 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002720 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002721 -c "client hello, adding session ticket extension" \
2722 -s "found session ticket extension" \
2723 -s "server hello, adding session ticket extension" \
2724 -c "found session_ticket extension" \
2725 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002726 -S "session successfully restored from cache" \
2727 -s "session successfully restored from ticket" \
2728 -s "a session has been resumed" \
2729 -c "a session has been resumed"
2730
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002731run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002732 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2733 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002745run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002746 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2747 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +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
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002759run_test "Session resume using tickets: session copy" \
2760 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2761 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2762 0 \
2763 -c "client hello, adding session ticket extension" \
2764 -s "found session ticket extension" \
2765 -s "server hello, adding session ticket extension" \
2766 -c "found session_ticket extension" \
2767 -c "parse new session ticket" \
2768 -S "session successfully restored from cache" \
2769 -s "session successfully restored from ticket" \
2770 -s "a session has been resumed" \
2771 -c "a session has been resumed"
2772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002773run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002774 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002775 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002776 0 \
2777 -c "client hello, adding session ticket extension" \
2778 -c "found session_ticket extension" \
2779 -c "parse new session ticket" \
2780 -c "a session has been resumed"
2781
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002782run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002783 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002784 "( $O_CLI -sess_out $SESSION; \
2785 $O_CLI -sess_in $SESSION; \
2786 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002787 0 \
2788 -s "found session ticket extension" \
2789 -s "server hello, adding session ticket extension" \
2790 -S "session successfully restored from cache" \
2791 -s "session successfully restored from ticket" \
2792 -s "a session has been resumed"
2793
Hanno Becker1d739932018-08-21 13:55:22 +01002794# Tests for Session Tickets with DTLS
2795
2796run_test "Session resume using tickets, DTLS: basic" \
2797 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002798 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002799 0 \
2800 -c "client hello, adding session ticket extension" \
2801 -s "found session ticket extension" \
2802 -s "server hello, adding session ticket extension" \
2803 -c "found session_ticket extension" \
2804 -c "parse new session ticket" \
2805 -S "session successfully restored from cache" \
2806 -s "session successfully restored from ticket" \
2807 -s "a session has been resumed" \
2808 -c "a session has been resumed"
2809
2810run_test "Session resume using tickets, DTLS: cache disabled" \
2811 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002812 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002813 0 \
2814 -c "client hello, adding session ticket extension" \
2815 -s "found session ticket extension" \
2816 -s "server hello, adding session ticket extension" \
2817 -c "found session_ticket extension" \
2818 -c "parse new session ticket" \
2819 -S "session successfully restored from cache" \
2820 -s "session successfully restored from ticket" \
2821 -s "a session has been resumed" \
2822 -c "a session has been resumed"
2823
2824run_test "Session resume using tickets, DTLS: timeout" \
2825 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002826 "$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 +01002827 0 \
2828 -c "client hello, adding session ticket extension" \
2829 -s "found session ticket extension" \
2830 -s "server hello, adding session ticket extension" \
2831 -c "found session_ticket extension" \
2832 -c "parse new session ticket" \
2833 -S "session successfully restored from cache" \
2834 -S "session successfully restored from ticket" \
2835 -S "a session has been resumed" \
2836 -C "a session has been resumed"
2837
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002838run_test "Session resume using tickets, DTLS: session copy" \
2839 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002840 "$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 +02002841 0 \
2842 -c "client hello, adding session ticket extension" \
2843 -s "found session ticket extension" \
2844 -s "server hello, adding session ticket extension" \
2845 -c "found session_ticket extension" \
2846 -c "parse new session ticket" \
2847 -S "session successfully restored from cache" \
2848 -s "session successfully restored from ticket" \
2849 -s "a session has been resumed" \
2850 -c "a session has been resumed"
2851
Hanno Becker1d739932018-08-21 13:55:22 +01002852run_test "Session resume using tickets, DTLS: openssl server" \
2853 "$O_SRV -dtls1" \
2854 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2855 0 \
2856 -c "client hello, adding session ticket extension" \
2857 -c "found session_ticket extension" \
2858 -c "parse new session ticket" \
2859 -c "a session has been resumed"
2860
2861run_test "Session resume using tickets, DTLS: openssl client" \
2862 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2863 "( $O_CLI -dtls1 -sess_out $SESSION; \
2864 $O_CLI -dtls1 -sess_in $SESSION; \
2865 rm -f $SESSION )" \
2866 0 \
2867 -s "found session ticket extension" \
2868 -s "server hello, adding session ticket extension" \
2869 -S "session successfully restored from cache" \
2870 -s "session successfully restored from ticket" \
2871 -s "a session has been resumed"
2872
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002873# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002875run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002876 "$P_SRV debug_level=3 tickets=0" \
2877 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002878 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002879 -c "client hello, adding session ticket extension" \
2880 -s "found session ticket extension" \
2881 -S "server hello, adding session ticket extension" \
2882 -C "found session_ticket extension" \
2883 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002884 -s "session successfully restored from cache" \
2885 -S "session successfully restored from ticket" \
2886 -s "a session has been resumed" \
2887 -c "a session has been resumed"
2888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002889run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002890 "$P_SRV debug_level=3 tickets=1" \
2891 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002892 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002893 -C "client hello, adding session ticket extension" \
2894 -S "found session ticket extension" \
2895 -S "server hello, adding session ticket extension" \
2896 -C "found session_ticket extension" \
2897 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002898 -s "session successfully restored from cache" \
2899 -S "session successfully restored from ticket" \
2900 -s "a session has been resumed" \
2901 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002903run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002904 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2905 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002906 0 \
2907 -S "session successfully restored from cache" \
2908 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002909 -S "a session has been resumed" \
2910 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002911
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002912run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002913 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2914 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002915 0 \
2916 -s "session successfully restored from cache" \
2917 -S "session successfully restored from ticket" \
2918 -s "a session has been resumed" \
2919 -c "a session has been resumed"
2920
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002921run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002922 "$P_SRV debug_level=3 tickets=0" \
2923 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002924 0 \
2925 -s "session successfully restored from cache" \
2926 -S "session successfully restored from ticket" \
2927 -s "a session has been resumed" \
2928 -c "a session has been resumed"
2929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002930run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002931 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2932 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002933 0 \
2934 -S "session successfully restored from cache" \
2935 -S "session successfully restored from ticket" \
2936 -S "a session has been resumed" \
2937 -C "a session has been resumed"
2938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002939run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002940 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2941 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002942 0 \
2943 -s "session successfully restored from cache" \
2944 -S "session successfully restored from ticket" \
2945 -s "a session has been resumed" \
2946 -c "a session has been resumed"
2947
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002948run_test "Session resume using cache: session copy" \
2949 "$P_SRV debug_level=3 tickets=0" \
2950 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2951 0 \
2952 -s "session successfully restored from cache" \
2953 -S "session successfully restored from ticket" \
2954 -s "a session has been resumed" \
2955 -c "a session has been resumed"
2956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002957run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002958 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002959 "( $O_CLI -sess_out $SESSION; \
2960 $O_CLI -sess_in $SESSION; \
2961 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002962 0 \
2963 -s "found session ticket extension" \
2964 -S "server hello, adding session ticket extension" \
2965 -s "session successfully restored from cache" \
2966 -S "session successfully restored from ticket" \
2967 -s "a session has been resumed"
2968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002969run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002970 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002971 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002972 0 \
2973 -C "found session_ticket extension" \
2974 -C "parse new session ticket" \
2975 -c "a session has been resumed"
2976
Hanno Becker1d739932018-08-21 13:55:22 +01002977# Tests for Session Resume based on session-ID and cache, DTLS
2978
2979run_test "Session resume using cache, DTLS: tickets enabled on client" \
2980 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002981 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002982 0 \
2983 -c "client hello, adding session ticket extension" \
2984 -s "found session ticket extension" \
2985 -S "server hello, adding session ticket extension" \
2986 -C "found session_ticket extension" \
2987 -C "parse new session ticket" \
2988 -s "session successfully restored from cache" \
2989 -S "session successfully restored from ticket" \
2990 -s "a session has been resumed" \
2991 -c "a session has been resumed"
2992
2993run_test "Session resume using cache, DTLS: tickets enabled on server" \
2994 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002995 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002996 0 \
2997 -C "client hello, adding session ticket extension" \
2998 -S "found session ticket extension" \
2999 -S "server hello, adding session ticket extension" \
3000 -C "found session_ticket extension" \
3001 -C "parse new session ticket" \
3002 -s "session successfully restored from cache" \
3003 -S "session successfully restored from ticket" \
3004 -s "a session has been resumed" \
3005 -c "a session has been resumed"
3006
3007run_test "Session resume using cache, DTLS: cache_max=0" \
3008 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01003009 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01003010 0 \
3011 -S "session successfully restored from cache" \
3012 -S "session successfully restored from ticket" \
3013 -S "a session has been resumed" \
3014 -C "a session has been resumed"
3015
3016run_test "Session resume using cache, DTLS: cache_max=1" \
3017 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01003018 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01003019 0 \
3020 -s "session successfully restored from cache" \
3021 -S "session successfully restored from ticket" \
3022 -s "a session has been resumed" \
3023 -c "a session has been resumed"
3024
3025run_test "Session resume using cache, DTLS: timeout > delay" \
3026 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01003027 "$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 +01003028 0 \
3029 -s "session successfully restored from cache" \
3030 -S "session successfully restored from ticket" \
3031 -s "a session has been resumed" \
3032 -c "a session has been resumed"
3033
3034run_test "Session resume using cache, DTLS: timeout < delay" \
3035 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01003036 "$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 +01003037 0 \
3038 -S "session successfully restored from cache" \
3039 -S "session successfully restored from ticket" \
3040 -S "a session has been resumed" \
3041 -C "a session has been resumed"
3042
3043run_test "Session resume using cache, DTLS: no timeout" \
3044 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01003045 "$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 +01003046 0 \
3047 -s "session successfully restored from cache" \
3048 -S "session successfully restored from ticket" \
3049 -s "a session has been resumed" \
3050 -c "a session has been resumed"
3051
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02003052run_test "Session resume using cache, DTLS: session copy" \
3053 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01003054 "$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 +02003055 0 \
3056 -s "session successfully restored from cache" \
3057 -S "session successfully restored from ticket" \
3058 -s "a session has been resumed" \
3059 -c "a session has been resumed"
3060
Hanno Becker1d739932018-08-21 13:55:22 +01003061run_test "Session resume using cache, DTLS: openssl client" \
3062 "$P_SRV dtls=1 debug_level=3 tickets=0" \
3063 "( $O_CLI -dtls1 -sess_out $SESSION; \
3064 $O_CLI -dtls1 -sess_in $SESSION; \
3065 rm -f $SESSION )" \
3066 0 \
3067 -s "found session ticket extension" \
3068 -S "server hello, adding session ticket extension" \
3069 -s "session successfully restored from cache" \
3070 -S "session successfully restored from ticket" \
3071 -s "a session has been resumed"
3072
3073run_test "Session resume using cache, DTLS: openssl server" \
3074 "$O_SRV -dtls1" \
3075 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
3076 0 \
3077 -C "found session_ticket extension" \
3078 -C "parse new session ticket" \
3079 -c "a session has been resumed"
3080
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003081# Tests for Max Fragment Length extension
3082
Angus Grattonc4dd0732018-04-11 16:28:39 +10003083if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
3084 printf "${CONFIG_H} defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n"
Hanno Becker6428f8d2017-09-22 16:58:50 +01003085 exit 1
3086fi
3087
Angus Grattonc4dd0732018-04-11 16:28:39 +10003088if [ $MAX_CONTENT_LEN -ne 16384 ]; then
3089 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
3090fi
3091
Hanno Becker4aed27e2017-09-18 15:00:34 +01003092requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003093run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003094 "$P_SRV debug_level=3" \
3095 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003096 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003097 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3098 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3099 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3100 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003101 -C "client hello, adding max_fragment_length extension" \
3102 -S "found max fragment length extension" \
3103 -S "server hello, max_fragment_length extension" \
3104 -C "found max_fragment_length extension"
3105
Hanno Becker4aed27e2017-09-18 15:00:34 +01003106requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003107run_test "Max fragment length: enabled, default, larger message" \
3108 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003109 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003110 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003111 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3112 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3113 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3114 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003115 -C "client hello, adding max_fragment_length extension" \
3116 -S "found max fragment length extension" \
3117 -S "server hello, max_fragment_length extension" \
3118 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003119 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3120 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003121 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003122
3123requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3124run_test "Max fragment length, DTLS: enabled, default, larger message" \
3125 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003126 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003127 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003128 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3129 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3130 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3131 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003132 -C "client hello, adding max_fragment_length extension" \
3133 -S "found max fragment length extension" \
3134 -S "server hello, max_fragment_length extension" \
3135 -C "found max_fragment_length extension" \
3136 -c "fragment larger than.*maximum "
3137
Angus Grattonc4dd0732018-04-11 16:28:39 +10003138# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3139# (session fragment length will be 16384 regardless of mbedtls
3140# content length configuration.)
3141
Hanno Beckerc5266962017-09-18 15:01:50 +01003142requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3143run_test "Max fragment length: disabled, larger message" \
3144 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003145 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003146 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003147 -C "Maximum input fragment length is 16384" \
3148 -C "Maximum output fragment length is 16384" \
3149 -S "Maximum input fragment length is 16384" \
3150 -S "Maximum output fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003151 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3152 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003153 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003154
3155requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3156run_test "Max fragment length DTLS: disabled, larger message" \
3157 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003158 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003159 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003160 -C "Maximum input fragment length is 16384" \
3161 -C "Maximum output fragment length is 16384" \
3162 -S "Maximum input fragment length is 16384" \
3163 -S "Maximum output fragment length is 16384" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003164 -c "fragment larger than.*maximum "
3165
3166requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003167run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003168 "$P_SRV debug_level=3" \
3169 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003170 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003171 -c "Maximum input fragment length is 4096" \
3172 -c "Maximum output fragment length is 4096" \
3173 -s "Maximum input fragment length is 4096" \
3174 -s "Maximum output fragment length is 4096" \
3175 -c "client hello, adding max_fragment_length extension" \
3176 -s "found max fragment length extension" \
3177 -s "server hello, max_fragment_length extension" \
3178 -c "found max_fragment_length extension"
3179
3180requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3181run_test "Max fragment length: client 512, server 1024" \
3182 "$P_SRV debug_level=3 max_frag_len=1024" \
3183 "$P_CLI debug_level=3 max_frag_len=512" \
3184 0 \
3185 -c "Maximum input fragment length is 512" \
3186 -c "Maximum output fragment length is 512" \
3187 -s "Maximum input fragment length is 512" \
3188 -s "Maximum output fragment length is 512" \
3189 -c "client hello, adding max_fragment_length extension" \
3190 -s "found max fragment length extension" \
3191 -s "server hello, max_fragment_length extension" \
3192 -c "found max_fragment_length extension"
3193
3194requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3195run_test "Max fragment length: client 512, server 2048" \
3196 "$P_SRV debug_level=3 max_frag_len=2048" \
3197 "$P_CLI debug_level=3 max_frag_len=512" \
3198 0 \
3199 -c "Maximum input fragment length is 512" \
3200 -c "Maximum output fragment length is 512" \
3201 -s "Maximum input fragment length is 512" \
3202 -s "Maximum output fragment length is 512" \
3203 -c "client hello, adding max_fragment_length extension" \
3204 -s "found max fragment length extension" \
3205 -s "server hello, max_fragment_length extension" \
3206 -c "found max_fragment_length extension"
3207
3208requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3209run_test "Max fragment length: client 512, server 4096" \
3210 "$P_SRV debug_level=3 max_frag_len=4096" \
3211 "$P_CLI debug_level=3 max_frag_len=512" \
3212 0 \
3213 -c "Maximum input fragment length is 512" \
3214 -c "Maximum output fragment length is 512" \
3215 -s "Maximum input fragment length is 512" \
3216 -s "Maximum output fragment length is 512" \
3217 -c "client hello, adding max_fragment_length extension" \
3218 -s "found max fragment length extension" \
3219 -s "server hello, max_fragment_length extension" \
3220 -c "found max_fragment_length extension"
3221
3222requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3223run_test "Max fragment length: client 1024, server 512" \
3224 "$P_SRV debug_level=3 max_frag_len=512" \
3225 "$P_CLI debug_level=3 max_frag_len=1024" \
3226 0 \
3227 -c "Maximum input fragment length is 1024" \
3228 -c "Maximum output fragment length is 1024" \
3229 -s "Maximum input fragment length is 1024" \
3230 -s "Maximum output fragment length is 512" \
3231 -c "client hello, adding max_fragment_length extension" \
3232 -s "found max fragment length extension" \
3233 -s "server hello, max_fragment_length extension" \
3234 -c "found max_fragment_length extension"
3235
3236requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3237run_test "Max fragment length: client 1024, server 2048" \
3238 "$P_SRV debug_level=3 max_frag_len=2048" \
3239 "$P_CLI debug_level=3 max_frag_len=1024" \
3240 0 \
3241 -c "Maximum input fragment length is 1024" \
3242 -c "Maximum output fragment length is 1024" \
3243 -s "Maximum input fragment length is 1024" \
3244 -s "Maximum output fragment length is 1024" \
3245 -c "client hello, adding max_fragment_length extension" \
3246 -s "found max fragment length extension" \
3247 -s "server hello, max_fragment_length extension" \
3248 -c "found max_fragment_length extension"
3249
3250requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3251run_test "Max fragment length: client 1024, server 4096" \
3252 "$P_SRV debug_level=3 max_frag_len=4096" \
3253 "$P_CLI debug_level=3 max_frag_len=1024" \
3254 0 \
3255 -c "Maximum input fragment length is 1024" \
3256 -c "Maximum output fragment length is 1024" \
3257 -s "Maximum input fragment length is 1024" \
3258 -s "Maximum output fragment length is 1024" \
3259 -c "client hello, adding max_fragment_length extension" \
3260 -s "found max fragment length extension" \
3261 -s "server hello, max_fragment_length extension" \
3262 -c "found max_fragment_length extension"
3263
3264requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3265run_test "Max fragment length: client 2048, server 512" \
3266 "$P_SRV debug_level=3 max_frag_len=512" \
3267 "$P_CLI debug_level=3 max_frag_len=2048" \
3268 0 \
3269 -c "Maximum input fragment length is 2048" \
3270 -c "Maximum output fragment length is 2048" \
3271 -s "Maximum input fragment length is 2048" \
3272 -s "Maximum output fragment length is 512" \
3273 -c "client hello, adding max_fragment_length extension" \
3274 -s "found max fragment length extension" \
3275 -s "server hello, max_fragment_length extension" \
3276 -c "found max_fragment_length extension"
3277
3278requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3279run_test "Max fragment length: client 2048, server 1024" \
3280 "$P_SRV debug_level=3 max_frag_len=1024" \
3281 "$P_CLI debug_level=3 max_frag_len=2048" \
3282 0 \
3283 -c "Maximum input fragment length is 2048" \
3284 -c "Maximum output fragment length is 2048" \
3285 -s "Maximum input fragment length is 2048" \
3286 -s "Maximum output fragment length is 1024" \
3287 -c "client hello, adding max_fragment_length extension" \
3288 -s "found max fragment length extension" \
3289 -s "server hello, max_fragment_length extension" \
3290 -c "found max_fragment_length extension"
3291
3292requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3293run_test "Max fragment length: client 2048, server 4096" \
3294 "$P_SRV debug_level=3 max_frag_len=4096" \
3295 "$P_CLI debug_level=3 max_frag_len=2048" \
3296 0 \
3297 -c "Maximum input fragment length is 2048" \
3298 -c "Maximum output fragment length is 2048" \
3299 -s "Maximum input fragment length is 2048" \
3300 -s "Maximum output fragment length is 2048" \
3301 -c "client hello, adding max_fragment_length extension" \
3302 -s "found max fragment length extension" \
3303 -s "server hello, max_fragment_length extension" \
3304 -c "found max_fragment_length extension"
3305
3306requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3307run_test "Max fragment length: client 4096, server 512" \
3308 "$P_SRV debug_level=3 max_frag_len=512" \
3309 "$P_CLI debug_level=3 max_frag_len=4096" \
3310 0 \
3311 -c "Maximum input fragment length is 4096" \
3312 -c "Maximum output fragment length is 4096" \
3313 -s "Maximum input fragment length is 4096" \
3314 -s "Maximum output fragment length is 512" \
3315 -c "client hello, adding max_fragment_length extension" \
3316 -s "found max fragment length extension" \
3317 -s "server hello, max_fragment_length extension" \
3318 -c "found max_fragment_length extension"
3319
3320requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3321run_test "Max fragment length: client 4096, server 1024" \
3322 "$P_SRV debug_level=3 max_frag_len=1024" \
3323 "$P_CLI debug_level=3 max_frag_len=4096" \
3324 0 \
3325 -c "Maximum input fragment length is 4096" \
3326 -c "Maximum output fragment length is 4096" \
3327 -s "Maximum input fragment length is 4096" \
3328 -s "Maximum output fragment length is 1024" \
3329 -c "client hello, adding max_fragment_length extension" \
3330 -s "found max fragment length extension" \
3331 -s "server hello, max_fragment_length extension" \
3332 -c "found max_fragment_length extension"
3333
3334requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3335run_test "Max fragment length: client 4096, server 2048" \
3336 "$P_SRV debug_level=3 max_frag_len=2048" \
3337 "$P_CLI debug_level=3 max_frag_len=4096" \
3338 0 \
3339 -c "Maximum input fragment length is 4096" \
3340 -c "Maximum output fragment length is 4096" \
3341 -s "Maximum input fragment length is 4096" \
3342 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003343 -c "client hello, adding max_fragment_length extension" \
3344 -s "found max fragment length extension" \
3345 -s "server hello, max_fragment_length extension" \
3346 -c "found max_fragment_length extension"
3347
Hanno Becker4aed27e2017-09-18 15:00:34 +01003348requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003349run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003350 "$P_SRV debug_level=3 max_frag_len=4096" \
3351 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003352 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003353 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3354 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3355 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3356 -s "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003357 -C "client hello, adding max_fragment_length extension" \
3358 -S "found max fragment length extension" \
3359 -S "server hello, max_fragment_length extension" \
3360 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003361
Hanno Becker4aed27e2017-09-18 15:00:34 +01003362requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003363requires_gnutls
3364run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003365 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003366 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003367 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003368 -c "Maximum input fragment length is 4096" \
3369 -c "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003370 -c "client hello, adding max_fragment_length extension" \
3371 -c "found max_fragment_length extension"
3372
Hanno Becker4aed27e2017-09-18 15:00:34 +01003373requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003374run_test "Max fragment length: client, message just fits" \
3375 "$P_SRV debug_level=3" \
3376 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3377 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003378 -c "Maximum input fragment length is 2048" \
3379 -c "Maximum output fragment length is 2048" \
3380 -s "Maximum input fragment length is 2048" \
3381 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003382 -c "client hello, adding max_fragment_length extension" \
3383 -s "found max fragment length extension" \
3384 -s "server hello, max_fragment_length extension" \
3385 -c "found max_fragment_length extension" \
3386 -c "2048 bytes written in 1 fragments" \
3387 -s "2048 bytes read"
3388
Hanno Becker4aed27e2017-09-18 15:00:34 +01003389requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003390run_test "Max fragment length: client, larger message" \
3391 "$P_SRV debug_level=3" \
3392 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3393 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003394 -c "Maximum input fragment length is 2048" \
3395 -c "Maximum output fragment length is 2048" \
3396 -s "Maximum input fragment length is 2048" \
3397 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003398 -c "client hello, adding max_fragment_length extension" \
3399 -s "found max fragment length extension" \
3400 -s "server hello, max_fragment_length extension" \
3401 -c "found max_fragment_length extension" \
3402 -c "2345 bytes written in 2 fragments" \
3403 -s "2048 bytes read" \
3404 -s "297 bytes read"
3405
Hanno Becker4aed27e2017-09-18 15:00:34 +01003406requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003407run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003408 "$P_SRV debug_level=3 dtls=1" \
3409 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3410 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003411 -c "Maximum input fragment length is 2048" \
3412 -c "Maximum output fragment length is 2048" \
3413 -s "Maximum input fragment length is 2048" \
3414 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003415 -c "client hello, adding max_fragment_length extension" \
3416 -s "found max fragment length extension" \
3417 -s "server hello, max_fragment_length extension" \
3418 -c "found max_fragment_length extension" \
3419 -c "fragment larger than.*maximum"
3420
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003421# Tests for renegotiation
3422
Hanno Becker6a243642017-10-12 15:18:45 +01003423# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003424run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003425 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003426 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003427 0 \
3428 -C "client hello, adding renegotiation extension" \
3429 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3430 -S "found renegotiation extension" \
3431 -s "server hello, secure renegotiation extension" \
3432 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003433 -C "=> renegotiate" \
3434 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003435 -S "write hello request"
3436
Hanno Becker6a243642017-10-12 15:18:45 +01003437requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003438run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003439 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003440 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003441 0 \
3442 -c "client hello, adding renegotiation extension" \
3443 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3444 -s "found renegotiation extension" \
3445 -s "server hello, secure renegotiation extension" \
3446 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003447 -c "=> renegotiate" \
3448 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003449 -S "write hello request"
3450
Hanno Becker6a243642017-10-12 15:18:45 +01003451requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003452run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003453 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003454 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003455 0 \
3456 -c "client hello, adding renegotiation extension" \
3457 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3458 -s "found renegotiation extension" \
3459 -s "server hello, secure renegotiation extension" \
3460 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003461 -c "=> renegotiate" \
3462 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003463 -s "write hello request"
3464
Janos Follathb0f148c2017-10-05 12:29:42 +01003465# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3466# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3467# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003468requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003469run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3470 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3471 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3472 0 \
3473 -c "client hello, adding renegotiation extension" \
3474 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3475 -s "found renegotiation extension" \
3476 -s "server hello, secure renegotiation extension" \
3477 -c "found renegotiation extension" \
3478 -c "=> renegotiate" \
3479 -s "=> renegotiate" \
3480 -S "write hello request" \
3481 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3482
3483# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3484# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3485# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003486requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003487run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3488 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3489 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3490 0 \
3491 -c "client hello, adding renegotiation extension" \
3492 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3493 -s "found renegotiation extension" \
3494 -s "server hello, secure renegotiation extension" \
3495 -c "found renegotiation extension" \
3496 -c "=> renegotiate" \
3497 -s "=> renegotiate" \
3498 -s "write hello request" \
3499 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3500
Hanno Becker6a243642017-10-12 15:18:45 +01003501requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003502run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003503 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003504 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003505 0 \
3506 -c "client hello, adding renegotiation extension" \
3507 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3508 -s "found renegotiation extension" \
3509 -s "server hello, secure renegotiation extension" \
3510 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003511 -c "=> renegotiate" \
3512 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003513 -s "write hello request"
3514
Hanno Becker6a243642017-10-12 15:18:45 +01003515requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andrzej Kurek8ea68722020-04-03 06:40:47 -04003516requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3517run_test "Renegotiation with max fragment length: client 2048, server 512" \
3518 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1 max_frag_len=512" \
3519 "$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" \
3520 0 \
3521 -c "Maximum input fragment length is 2048" \
3522 -c "Maximum output fragment length is 2048" \
3523 -s "Maximum input fragment length is 2048" \
3524 -s "Maximum output fragment length is 512" \
3525 -c "client hello, adding max_fragment_length extension" \
3526 -s "found max fragment length extension" \
3527 -s "server hello, max_fragment_length extension" \
3528 -c "found max_fragment_length extension" \
3529 -c "client hello, adding renegotiation extension" \
3530 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3531 -s "found renegotiation extension" \
3532 -s "server hello, secure renegotiation extension" \
3533 -c "found renegotiation extension" \
3534 -c "=> renegotiate" \
3535 -s "=> renegotiate" \
3536 -s "write hello request"
3537
3538requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003539run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003540 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003541 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003542 1 \
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" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003548 -c "=> renegotiate" \
3549 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003550 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003551 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003552 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003553
Hanno Becker6a243642017-10-12 15:18:45 +01003554requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003555run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003556 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003557 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003558 0 \
3559 -C "client hello, adding renegotiation extension" \
3560 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3561 -S "found renegotiation extension" \
3562 -s "server hello, secure renegotiation extension" \
3563 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003564 -C "=> renegotiate" \
3565 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003566 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003567 -S "SSL - An unexpected message was received from our peer" \
3568 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003569
Hanno Becker6a243642017-10-12 15:18:45 +01003570requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003571run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003572 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003573 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003574 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003575 0 \
3576 -C "client hello, adding renegotiation extension" \
3577 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3578 -S "found renegotiation extension" \
3579 -s "server hello, secure renegotiation extension" \
3580 -c "found renegotiation extension" \
3581 -C "=> renegotiate" \
3582 -S "=> renegotiate" \
3583 -s "write hello request" \
3584 -S "SSL - An unexpected message was received from our peer" \
3585 -S "failed"
3586
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003587# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003588requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003589run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003590 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003591 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003592 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003593 0 \
3594 -C "client hello, adding renegotiation extension" \
3595 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3596 -S "found renegotiation extension" \
3597 -s "server hello, secure renegotiation extension" \
3598 -c "found renegotiation extension" \
3599 -C "=> renegotiate" \
3600 -S "=> renegotiate" \
3601 -s "write hello request" \
3602 -S "SSL - An unexpected message was received from our peer" \
3603 -S "failed"
3604
Hanno Becker6a243642017-10-12 15:18:45 +01003605requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003606run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003607 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003608 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003609 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003610 0 \
3611 -C "client hello, adding renegotiation extension" \
3612 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3613 -S "found renegotiation extension" \
3614 -s "server hello, secure renegotiation extension" \
3615 -c "found renegotiation extension" \
3616 -C "=> renegotiate" \
3617 -S "=> renegotiate" \
3618 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003619 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003620
Hanno Becker6a243642017-10-12 15:18:45 +01003621requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003622run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003623 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003624 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003625 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003626 0 \
3627 -c "client hello, adding renegotiation extension" \
3628 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3629 -s "found renegotiation extension" \
3630 -s "server hello, secure renegotiation extension" \
3631 -c "found renegotiation extension" \
3632 -c "=> renegotiate" \
3633 -s "=> renegotiate" \
3634 -s "write hello request" \
3635 -S "SSL - An unexpected message was received from our peer" \
3636 -S "failed"
3637
Hanno Becker6a243642017-10-12 15:18:45 +01003638requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003639run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003640 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003641 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3642 0 \
3643 -C "client hello, adding renegotiation extension" \
3644 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3645 -S "found renegotiation extension" \
3646 -s "server hello, secure renegotiation extension" \
3647 -c "found renegotiation extension" \
3648 -S "record counter limit reached: renegotiate" \
3649 -C "=> renegotiate" \
3650 -S "=> renegotiate" \
3651 -S "write hello request" \
3652 -S "SSL - An unexpected message was received from our peer" \
3653 -S "failed"
3654
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003655# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003656requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003657run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003658 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003659 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003660 0 \
3661 -c "client hello, adding renegotiation extension" \
3662 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3663 -s "found renegotiation extension" \
3664 -s "server hello, secure renegotiation extension" \
3665 -c "found renegotiation extension" \
3666 -s "record counter limit reached: renegotiate" \
3667 -c "=> renegotiate" \
3668 -s "=> renegotiate" \
3669 -s "write hello request" \
3670 -S "SSL - An unexpected message was received from our peer" \
3671 -S "failed"
3672
Hanno Becker6a243642017-10-12 15:18:45 +01003673requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003674run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003675 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003676 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003677 0 \
3678 -c "client hello, adding renegotiation extension" \
3679 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3680 -s "found renegotiation extension" \
3681 -s "server hello, secure renegotiation extension" \
3682 -c "found renegotiation extension" \
3683 -s "record counter limit reached: renegotiate" \
3684 -c "=> renegotiate" \
3685 -s "=> renegotiate" \
3686 -s "write hello request" \
3687 -S "SSL - An unexpected message was received from our peer" \
3688 -S "failed"
3689
Hanno Becker6a243642017-10-12 15:18:45 +01003690requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003691run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003692 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003693 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3694 0 \
3695 -C "client hello, adding renegotiation extension" \
3696 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3697 -S "found renegotiation extension" \
3698 -s "server hello, secure renegotiation extension" \
3699 -c "found renegotiation extension" \
3700 -S "record counter limit reached: renegotiate" \
3701 -C "=> renegotiate" \
3702 -S "=> renegotiate" \
3703 -S "write hello request" \
3704 -S "SSL - An unexpected message was received from our peer" \
3705 -S "failed"
3706
Hanno Becker6a243642017-10-12 15:18:45 +01003707requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003708run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003709 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003710 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003711 0 \
3712 -c "client hello, adding renegotiation extension" \
3713 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3714 -s "found renegotiation extension" \
3715 -s "server hello, secure renegotiation extension" \
3716 -c "found renegotiation extension" \
3717 -c "=> renegotiate" \
3718 -s "=> renegotiate" \
3719 -S "write hello request"
3720
Hanno Becker6a243642017-10-12 15:18:45 +01003721requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003722run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003723 "$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 +02003724 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003725 0 \
3726 -c "client hello, adding renegotiation extension" \
3727 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3728 -s "found renegotiation extension" \
3729 -s "server hello, secure renegotiation extension" \
3730 -c "found renegotiation extension" \
3731 -c "=> renegotiate" \
3732 -s "=> renegotiate" \
3733 -s "write hello request"
3734
Hanno Becker6a243642017-10-12 15:18:45 +01003735requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003736run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003737 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003738 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003739 0 \
3740 -c "client hello, adding renegotiation extension" \
3741 -c "found renegotiation extension" \
3742 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003743 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003744 -C "error" \
3745 -c "HTTP/1.0 200 [Oo][Kk]"
3746
Paul Bakker539d9722015-02-08 16:18:35 +01003747requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003748requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003749run_test "Renegotiation: gnutls server strict, client-initiated" \
3750 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003751 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003752 0 \
3753 -c "client hello, adding renegotiation extension" \
3754 -c "found renegotiation extension" \
3755 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003756 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003757 -C "error" \
3758 -c "HTTP/1.0 200 [Oo][Kk]"
3759
Paul Bakker539d9722015-02-08 16:18:35 +01003760requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003761requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003762run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3763 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3764 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
3765 1 \
3766 -c "client hello, adding renegotiation extension" \
3767 -C "found renegotiation extension" \
3768 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003769 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003770 -c "error" \
3771 -C "HTTP/1.0 200 [Oo][Kk]"
3772
Paul Bakker539d9722015-02-08 16:18:35 +01003773requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003774requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003775run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3776 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3777 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3778 allow_legacy=0" \
3779 1 \
3780 -c "client hello, adding renegotiation extension" \
3781 -C "found renegotiation extension" \
3782 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003783 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003784 -c "error" \
3785 -C "HTTP/1.0 200 [Oo][Kk]"
3786
Paul Bakker539d9722015-02-08 16:18:35 +01003787requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003788requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003789run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3790 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3791 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3792 allow_legacy=1" \
3793 0 \
3794 -c "client hello, adding renegotiation extension" \
3795 -C "found renegotiation extension" \
3796 -c "=> renegotiate" \
3797 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003798 -C "error" \
3799 -c "HTTP/1.0 200 [Oo][Kk]"
3800
Hanno Becker6a243642017-10-12 15:18:45 +01003801requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003802run_test "Renegotiation: DTLS, client-initiated" \
3803 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3804 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3805 0 \
3806 -c "client hello, adding renegotiation extension" \
3807 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3808 -s "found renegotiation extension" \
3809 -s "server hello, secure renegotiation extension" \
3810 -c "found renegotiation extension" \
3811 -c "=> renegotiate" \
3812 -s "=> renegotiate" \
3813 -S "write hello request"
3814
Hanno Becker6a243642017-10-12 15:18:45 +01003815requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003816run_test "Renegotiation: DTLS, server-initiated" \
3817 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003818 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3819 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003820 0 \
3821 -c "client hello, adding renegotiation extension" \
3822 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3823 -s "found renegotiation extension" \
3824 -s "server hello, secure renegotiation extension" \
3825 -c "found renegotiation extension" \
3826 -c "=> renegotiate" \
3827 -s "=> renegotiate" \
3828 -s "write hello request"
3829
Hanno Becker6a243642017-10-12 15:18:45 +01003830requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003831run_test "Renegotiation: DTLS, renego_period overflow" \
3832 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3833 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3834 0 \
3835 -c "client hello, adding renegotiation extension" \
3836 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3837 -s "found renegotiation extension" \
3838 -s "server hello, secure renegotiation extension" \
3839 -s "record counter limit reached: renegotiate" \
3840 -c "=> renegotiate" \
3841 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003842 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003843
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003844requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003845requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003846run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3847 "$G_SRV -u --mtu 4096" \
3848 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
3849 0 \
3850 -c "client hello, adding renegotiation extension" \
3851 -c "found renegotiation extension" \
3852 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003853 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003854 -C "error" \
3855 -s "Extra-header:"
3856
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003857# Test for the "secure renegotation" extension only (no actual renegotiation)
3858
Paul Bakker539d9722015-02-08 16:18:35 +01003859requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003860run_test "Renego ext: gnutls server strict, client default" \
3861 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
3862 "$P_CLI debug_level=3" \
3863 0 \
3864 -c "found renegotiation extension" \
3865 -C "error" \
3866 -c "HTTP/1.0 200 [Oo][Kk]"
3867
Paul Bakker539d9722015-02-08 16:18:35 +01003868requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003869run_test "Renego ext: gnutls server unsafe, client default" \
3870 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3871 "$P_CLI debug_level=3" \
3872 0 \
3873 -C "found renegotiation extension" \
3874 -C "error" \
3875 -c "HTTP/1.0 200 [Oo][Kk]"
3876
Paul Bakker539d9722015-02-08 16:18:35 +01003877requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003878run_test "Renego ext: gnutls server unsafe, client break legacy" \
3879 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3880 "$P_CLI debug_level=3 allow_legacy=-1" \
3881 1 \
3882 -C "found renegotiation extension" \
3883 -c "error" \
3884 -C "HTTP/1.0 200 [Oo][Kk]"
3885
Paul Bakker539d9722015-02-08 16:18:35 +01003886requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003887run_test "Renego ext: gnutls client strict, server default" \
3888 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003889 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003890 0 \
3891 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3892 -s "server hello, secure renegotiation extension"
3893
Paul Bakker539d9722015-02-08 16:18:35 +01003894requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003895run_test "Renego ext: gnutls client unsafe, server default" \
3896 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003897 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003898 0 \
3899 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3900 -S "server hello, secure renegotiation extension"
3901
Paul Bakker539d9722015-02-08 16:18:35 +01003902requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003903run_test "Renego ext: gnutls client unsafe, server break legacy" \
3904 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003905 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003906 1 \
3907 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3908 -S "server hello, secure renegotiation extension"
3909
Janos Follath0b242342016-02-17 10:11:21 +00003910# Tests for silently dropping trailing extra bytes in .der certificates
3911
3912requires_gnutls
3913run_test "DER format: no trailing bytes" \
3914 "$P_SRV crt_file=data_files/server5-der0.crt \
3915 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003916 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003917 0 \
3918 -c "Handshake was completed" \
3919
3920requires_gnutls
3921run_test "DER format: with a trailing zero byte" \
3922 "$P_SRV crt_file=data_files/server5-der1a.crt \
3923 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003924 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003925 0 \
3926 -c "Handshake was completed" \
3927
3928requires_gnutls
3929run_test "DER format: with a trailing random byte" \
3930 "$P_SRV crt_file=data_files/server5-der1b.crt \
3931 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003932 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003933 0 \
3934 -c "Handshake was completed" \
3935
3936requires_gnutls
3937run_test "DER format: with 2 trailing random bytes" \
3938 "$P_SRV crt_file=data_files/server5-der2.crt \
3939 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003940 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003941 0 \
3942 -c "Handshake was completed" \
3943
3944requires_gnutls
3945run_test "DER format: with 4 trailing random bytes" \
3946 "$P_SRV crt_file=data_files/server5-der4.crt \
3947 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003948 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003949 0 \
3950 -c "Handshake was completed" \
3951
3952requires_gnutls
3953run_test "DER format: with 8 trailing random bytes" \
3954 "$P_SRV crt_file=data_files/server5-der8.crt \
3955 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003956 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003957 0 \
3958 -c "Handshake was completed" \
3959
3960requires_gnutls
3961run_test "DER format: with 9 trailing random bytes" \
3962 "$P_SRV crt_file=data_files/server5-der9.crt \
3963 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003964 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003965 0 \
3966 -c "Handshake was completed" \
3967
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03003968# Tests for auth_mode, there are duplicated tests using ca callback for authentication
3969# When updating these tests, modify the matching authentication tests accordingly
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003971run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003972 "$P_SRV crt_file=data_files/server5-badsign.crt \
3973 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003974 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003975 1 \
3976 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003977 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003978 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003979 -c "X509 - Certificate verification failed"
3980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003981run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003982 "$P_SRV crt_file=data_files/server5-badsign.crt \
3983 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003984 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003985 0 \
3986 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003987 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003988 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003989 -C "X509 - Certificate verification failed"
3990
Hanno Beckere6706e62017-05-15 16:05:15 +01003991run_test "Authentication: server goodcert, client optional, no trusted CA" \
3992 "$P_SRV" \
3993 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3994 0 \
3995 -c "x509_verify_cert() returned" \
3996 -c "! The certificate is not correctly signed by the trusted CA" \
3997 -c "! Certificate verification flags"\
3998 -C "! mbedtls_ssl_handshake returned" \
3999 -C "X509 - Certificate verification failed" \
4000 -C "SSL - No CA Chain is set, but required to operate"
4001
4002run_test "Authentication: server goodcert, client required, no trusted CA" \
4003 "$P_SRV" \
4004 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
4005 1 \
4006 -c "x509_verify_cert() returned" \
4007 -c "! The certificate is not correctly signed by the trusted CA" \
4008 -c "! Certificate verification flags"\
4009 -c "! mbedtls_ssl_handshake returned" \
4010 -c "SSL - No CA Chain is set, but required to operate"
4011
4012# The purpose of the next two tests is to test the client's behaviour when receiving a server
4013# certificate with an unsupported elliptic curve. This should usually not happen because
4014# the client informs the server about the supported curves - it does, though, in the
4015# corner case of a static ECDH suite, because the server doesn't check the curve on that
4016# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
4017# different means to have the server ignoring the client's supported curve list.
4018
4019requires_config_enabled MBEDTLS_ECP_C
4020run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
4021 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4022 crt_file=data_files/server5.ku-ka.crt" \
4023 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
4024 1 \
4025 -c "bad certificate (EC key curve)"\
4026 -c "! Certificate verification flags"\
4027 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
4028
4029requires_config_enabled MBEDTLS_ECP_C
4030run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
4031 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4032 crt_file=data_files/server5.ku-ka.crt" \
4033 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
4034 1 \
4035 -c "bad certificate (EC key curve)"\
4036 -c "! Certificate verification flags"\
4037 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
4038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004039run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01004040 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004041 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004042 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004043 0 \
4044 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004045 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004046 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004047 -C "X509 - Certificate verification failed"
4048
Simon Butcher99000142016-10-13 17:21:01 +01004049run_test "Authentication: client SHA256, server required" \
4050 "$P_SRV auth_mode=required" \
4051 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4052 key_file=data_files/server6.key \
4053 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
4054 0 \
4055 -c "Supported Signature Algorithm found: 4," \
4056 -c "Supported Signature Algorithm found: 5,"
4057
4058run_test "Authentication: client SHA384, server required" \
4059 "$P_SRV auth_mode=required" \
4060 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4061 key_file=data_files/server6.key \
4062 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
4063 0 \
4064 -c "Supported Signature Algorithm found: 4," \
4065 -c "Supported Signature Algorithm found: 5,"
4066
Gilles Peskinefd8332e2017-05-03 16:25:07 +02004067requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4068run_test "Authentication: client has no cert, server required (SSLv3)" \
4069 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
4070 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
4071 key_file=data_files/server5.key" \
4072 1 \
4073 -S "skip write certificate request" \
4074 -C "skip parse certificate request" \
4075 -c "got a certificate request" \
4076 -c "got no certificate to send" \
4077 -S "x509_verify_cert() returned" \
4078 -s "client has no certificate" \
4079 -s "! mbedtls_ssl_handshake returned" \
4080 -c "! mbedtls_ssl_handshake returned" \
4081 -s "No client certification received from the client, but required by the authentication mode"
4082
4083run_test "Authentication: client has no cert, server required (TLS)" \
4084 "$P_SRV debug_level=3 auth_mode=required" \
4085 "$P_CLI debug_level=3 crt_file=none \
4086 key_file=data_files/server5.key" \
4087 1 \
4088 -S "skip write certificate request" \
4089 -C "skip parse certificate request" \
4090 -c "got a certificate request" \
4091 -c "= write certificate$" \
4092 -C "skip write certificate$" \
4093 -S "x509_verify_cert() returned" \
4094 -s "client has no certificate" \
4095 -s "! mbedtls_ssl_handshake returned" \
4096 -c "! mbedtls_ssl_handshake returned" \
4097 -s "No client certification received from the client, but required by the authentication mode"
4098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004099run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004100 "$P_SRV debug_level=3 auth_mode=required" \
4101 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004102 key_file=data_files/server5.key" \
4103 1 \
4104 -S "skip write certificate request" \
4105 -C "skip parse certificate request" \
4106 -c "got a certificate request" \
4107 -C "skip write certificate" \
4108 -C "skip write certificate verify" \
4109 -S "skip parse certificate verify" \
4110 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004111 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004112 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02004113 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004114 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004115 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02004116# We don't check that the client receives the alert because it might
4117# detect that its write end of the connection is closed and abort
4118# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004119
Janos Follath89baba22017-04-10 14:34:35 +01004120run_test "Authentication: client cert not trusted, server required" \
4121 "$P_SRV debug_level=3 auth_mode=required" \
4122 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4123 key_file=data_files/server5.key" \
4124 1 \
4125 -S "skip write certificate request" \
4126 -C "skip parse certificate request" \
4127 -c "got a certificate request" \
4128 -C "skip write certificate" \
4129 -C "skip write certificate verify" \
4130 -S "skip parse certificate verify" \
4131 -s "x509_verify_cert() returned" \
4132 -s "! The certificate is not correctly signed by the trusted CA" \
4133 -s "! mbedtls_ssl_handshake returned" \
4134 -c "! mbedtls_ssl_handshake returned" \
4135 -s "X509 - Certificate verification failed"
4136
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004137run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004138 "$P_SRV debug_level=3 auth_mode=optional" \
4139 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004140 key_file=data_files/server5.key" \
4141 0 \
4142 -S "skip write certificate request" \
4143 -C "skip parse certificate request" \
4144 -c "got a certificate request" \
4145 -C "skip write certificate" \
4146 -C "skip write certificate verify" \
4147 -S "skip parse certificate verify" \
4148 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004149 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004150 -S "! mbedtls_ssl_handshake returned" \
4151 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004152 -S "X509 - Certificate verification failed"
4153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004154run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004155 "$P_SRV debug_level=3 auth_mode=none" \
4156 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004157 key_file=data_files/server5.key" \
4158 0 \
4159 -s "skip write certificate request" \
4160 -C "skip parse certificate request" \
4161 -c "got no certificate request" \
4162 -c "skip write certificate" \
4163 -c "skip write certificate verify" \
4164 -s "skip parse certificate verify" \
4165 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004166 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004167 -S "! mbedtls_ssl_handshake returned" \
4168 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004169 -S "X509 - Certificate verification failed"
4170
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004171run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004172 "$P_SRV debug_level=3 auth_mode=optional" \
4173 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004174 0 \
4175 -S "skip write certificate request" \
4176 -C "skip parse certificate request" \
4177 -c "got a certificate request" \
4178 -C "skip write certificate$" \
4179 -C "got no certificate to send" \
4180 -S "SSLv3 client has no certificate" \
4181 -c "skip write certificate verify" \
4182 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004183 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004184 -S "! mbedtls_ssl_handshake returned" \
4185 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004186 -S "X509 - Certificate verification failed"
4187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004188run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004189 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004190 "$O_CLI" \
4191 0 \
4192 -S "skip write certificate request" \
4193 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004194 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004195 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004196 -S "X509 - Certificate verification failed"
4197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004198run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004199 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004200 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004201 0 \
4202 -C "skip parse certificate request" \
4203 -c "got a certificate request" \
4204 -C "skip write certificate$" \
4205 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004206 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004207
Gilles Peskinefd8332e2017-05-03 16:25:07 +02004208run_test "Authentication: client no cert, openssl server required" \
4209 "$O_SRV -Verify 10" \
4210 "$P_CLI debug_level=3 crt_file=none key_file=none" \
4211 1 \
4212 -C "skip parse certificate request" \
4213 -c "got a certificate request" \
4214 -C "skip write certificate$" \
4215 -c "skip write certificate verify" \
4216 -c "! mbedtls_ssl_handshake returned"
4217
Janos Follathe2681a42016-03-07 15:57:05 +00004218requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004219run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004220 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004221 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004222 0 \
4223 -S "skip write certificate request" \
4224 -C "skip parse certificate request" \
4225 -c "got a certificate request" \
4226 -C "skip write certificate$" \
4227 -c "skip write certificate verify" \
4228 -c "got no certificate to send" \
4229 -s "SSLv3 client has no certificate" \
4230 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004231 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004232 -S "! mbedtls_ssl_handshake returned" \
4233 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004234 -S "X509 - Certificate verification failed"
4235
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02004236# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
4237# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004238
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004239MAX_IM_CA='8'
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02004240MAX_IM_CA_CONFIG=$( ../scripts/config.py get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004241
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004242if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01004243 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004244 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004245 printf "test value of ${MAX_IM_CA}. \n"
4246 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004247 printf "The tests assume this value and if it changes, the tests in this\n"
4248 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004249 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004250
4251 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004252fi
4253
Angus Grattonc4dd0732018-04-11 16:28:39 +10004254requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004255run_test "Authentication: server max_int chain, client default" \
4256 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4257 key_file=data_files/dir-maxpath/09.key" \
4258 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4259 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004260 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004261
Angus Grattonc4dd0732018-04-11 16:28:39 +10004262requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004263run_test "Authentication: server max_int+1 chain, client default" \
4264 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4265 key_file=data_files/dir-maxpath/10.key" \
4266 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4267 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004268 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004269
Angus Grattonc4dd0732018-04-11 16:28:39 +10004270requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004271run_test "Authentication: server max_int+1 chain, client optional" \
4272 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4273 key_file=data_files/dir-maxpath/10.key" \
4274 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4275 auth_mode=optional" \
4276 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004277 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004278
Angus Grattonc4dd0732018-04-11 16:28:39 +10004279requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004280run_test "Authentication: server max_int+1 chain, client none" \
4281 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4282 key_file=data_files/dir-maxpath/10.key" \
4283 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4284 auth_mode=none" \
4285 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004286 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004287
Angus Grattonc4dd0732018-04-11 16:28:39 +10004288requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004289run_test "Authentication: client max_int+1 chain, server default" \
4290 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4291 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4292 key_file=data_files/dir-maxpath/10.key" \
4293 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004294 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004295
Angus Grattonc4dd0732018-04-11 16:28:39 +10004296requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004297run_test "Authentication: client max_int+1 chain, server optional" \
4298 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4299 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4300 key_file=data_files/dir-maxpath/10.key" \
4301 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004302 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004303
Angus Grattonc4dd0732018-04-11 16:28:39 +10004304requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004305run_test "Authentication: client max_int+1 chain, server required" \
4306 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4307 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4308 key_file=data_files/dir-maxpath/10.key" \
4309 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004310 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004311
Angus Grattonc4dd0732018-04-11 16:28:39 +10004312requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004313run_test "Authentication: client max_int chain, server required" \
4314 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4315 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4316 key_file=data_files/dir-maxpath/09.key" \
4317 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004318 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004319
Janos Follath89baba22017-04-10 14:34:35 +01004320# Tests for CA list in CertificateRequest messages
4321
4322run_test "Authentication: send CA list in CertificateRequest (default)" \
4323 "$P_SRV debug_level=3 auth_mode=required" \
4324 "$P_CLI crt_file=data_files/server6.crt \
4325 key_file=data_files/server6.key" \
4326 0 \
4327 -s "requested DN"
4328
4329run_test "Authentication: do not send CA list in CertificateRequest" \
4330 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4331 "$P_CLI crt_file=data_files/server6.crt \
4332 key_file=data_files/server6.key" \
4333 0 \
4334 -S "requested DN"
4335
4336run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4337 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4338 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4339 key_file=data_files/server5.key" \
4340 1 \
4341 -S "requested DN" \
4342 -s "x509_verify_cert() returned" \
4343 -s "! The certificate is not correctly signed by the trusted CA" \
4344 -s "! mbedtls_ssl_handshake returned" \
4345 -c "! mbedtls_ssl_handshake returned" \
4346 -s "X509 - Certificate verification failed"
4347
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03004348# Tests for auth_mode, using CA callback, these are duplicated from the authentication tests
4349# When updating these tests, modify the matching authentication tests accordingly
Hanno Becker746aaf32019-03-28 15:25:23 +00004350
4351requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4352run_test "Authentication, CA callback: server badcert, client required" \
4353 "$P_SRV crt_file=data_files/server5-badsign.crt \
4354 key_file=data_files/server5.key" \
4355 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required" \
4356 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004357 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004358 -c "x509_verify_cert() returned" \
4359 -c "! The certificate is not correctly signed by the trusted CA" \
4360 -c "! mbedtls_ssl_handshake returned" \
4361 -c "X509 - Certificate verification failed"
4362
4363requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4364run_test "Authentication, CA callback: server badcert, client optional" \
4365 "$P_SRV crt_file=data_files/server5-badsign.crt \
4366 key_file=data_files/server5.key" \
4367 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional" \
4368 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004369 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004370 -c "x509_verify_cert() returned" \
4371 -c "! The certificate is not correctly signed by the trusted CA" \
4372 -C "! mbedtls_ssl_handshake returned" \
4373 -C "X509 - Certificate verification failed"
4374
4375# The purpose of the next two tests is to test the client's behaviour when receiving a server
4376# certificate with an unsupported elliptic curve. This should usually not happen because
4377# the client informs the server about the supported curves - it does, though, in the
4378# corner case of a static ECDH suite, because the server doesn't check the curve on that
4379# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
4380# different means to have the server ignoring the client's supported curve list.
4381
4382requires_config_enabled MBEDTLS_ECP_C
4383requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4384run_test "Authentication, CA callback: server ECDH p256v1, client required, p256v1 unsupported" \
4385 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4386 crt_file=data_files/server5.ku-ka.crt" \
4387 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required curves=secp521r1" \
4388 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004389 -c "use CA callback for X.509 CRT verification" \
4390 -c "bad certificate (EC key curve)" \
4391 -c "! Certificate verification flags" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004392 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
4393
4394requires_config_enabled MBEDTLS_ECP_C
4395requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4396run_test "Authentication, CA callback: server ECDH p256v1, client optional, p256v1 unsupported" \
4397 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4398 crt_file=data_files/server5.ku-ka.crt" \
4399 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional curves=secp521r1" \
4400 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004401 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004402 -c "bad certificate (EC key curve)"\
4403 -c "! Certificate verification flags"\
4404 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
4405
4406requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4407run_test "Authentication, CA callback: client SHA256, server required" \
4408 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4409 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4410 key_file=data_files/server6.key \
4411 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
4412 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004413 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004414 -c "Supported Signature Algorithm found: 4," \
4415 -c "Supported Signature Algorithm found: 5,"
4416
4417requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4418run_test "Authentication, CA callback: client SHA384, server required" \
4419 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4420 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4421 key_file=data_files/server6.key \
4422 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
4423 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004424 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004425 -c "Supported Signature Algorithm found: 4," \
4426 -c "Supported Signature Algorithm found: 5,"
4427
4428requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4429run_test "Authentication, CA callback: client badcert, server required" \
4430 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4431 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4432 key_file=data_files/server5.key" \
4433 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004434 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004435 -S "skip write certificate request" \
4436 -C "skip parse certificate request" \
4437 -c "got a certificate request" \
4438 -C "skip write certificate" \
4439 -C "skip write certificate verify" \
4440 -S "skip parse certificate verify" \
4441 -s "x509_verify_cert() returned" \
4442 -s "! The certificate is not correctly signed by the trusted CA" \
4443 -s "! mbedtls_ssl_handshake returned" \
4444 -s "send alert level=2 message=48" \
4445 -c "! mbedtls_ssl_handshake returned" \
4446 -s "X509 - Certificate verification failed"
4447# We don't check that the client receives the alert because it might
4448# detect that its write end of the connection is closed and abort
4449# before reading the alert message.
4450
4451requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4452run_test "Authentication, CA callback: client cert not trusted, server required" \
4453 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4454 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4455 key_file=data_files/server5.key" \
4456 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004457 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004458 -S "skip write certificate request" \
4459 -C "skip parse certificate request" \
4460 -c "got a certificate request" \
4461 -C "skip write certificate" \
4462 -C "skip write certificate verify" \
4463 -S "skip parse certificate verify" \
4464 -s "x509_verify_cert() returned" \
4465 -s "! The certificate is not correctly signed by the trusted CA" \
4466 -s "! mbedtls_ssl_handshake returned" \
4467 -c "! mbedtls_ssl_handshake returned" \
4468 -s "X509 - Certificate verification failed"
4469
4470requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4471run_test "Authentication, CA callback: client badcert, server optional" \
4472 "$P_SRV ca_callback=1 debug_level=3 auth_mode=optional" \
4473 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4474 key_file=data_files/server5.key" \
4475 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004476 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004477 -S "skip write certificate request" \
4478 -C "skip parse certificate request" \
4479 -c "got a certificate request" \
4480 -C "skip write certificate" \
4481 -C "skip write certificate verify" \
4482 -S "skip parse certificate verify" \
4483 -s "x509_verify_cert() returned" \
4484 -s "! The certificate is not correctly signed by the trusted CA" \
4485 -S "! mbedtls_ssl_handshake returned" \
4486 -C "! mbedtls_ssl_handshake returned" \
4487 -S "X509 - Certificate verification failed"
4488
4489requires_full_size_output_buffer
4490requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4491run_test "Authentication, CA callback: server max_int chain, client default" \
4492 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4493 key_file=data_files/dir-maxpath/09.key" \
4494 "$P_CLI ca_callback=1 debug_level=3 server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4495 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004496 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004497 -C "X509 - A fatal error occurred"
4498
4499requires_full_size_output_buffer
4500requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4501run_test "Authentication, CA callback: server max_int+1 chain, client default" \
4502 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4503 key_file=data_files/dir-maxpath/10.key" \
4504 "$P_CLI debug_level=3 ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4505 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004506 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004507 -c "X509 - A fatal error occurred"
4508
4509requires_full_size_output_buffer
4510requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4511run_test "Authentication, CA callback: server max_int+1 chain, client optional" \
4512 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4513 key_file=data_files/dir-maxpath/10.key" \
4514 "$P_CLI ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4515 debug_level=3 auth_mode=optional" \
4516 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004517 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004518 -c "X509 - A fatal error occurred"
4519
4520requires_full_size_output_buffer
4521requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4522run_test "Authentication, CA callback: client max_int+1 chain, server optional" \
4523 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4524 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4525 key_file=data_files/dir-maxpath/10.key" \
4526 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004527 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004528 -s "X509 - A fatal error occurred"
4529
4530requires_full_size_output_buffer
4531requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4532run_test "Authentication, CA callback: client max_int+1 chain, server required" \
4533 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4534 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4535 key_file=data_files/dir-maxpath/10.key" \
4536 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004537 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004538 -s "X509 - A fatal error occurred"
4539
4540requires_full_size_output_buffer
4541requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4542run_test "Authentication, CA callback: client max_int chain, server required" \
4543 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4544 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4545 key_file=data_files/dir-maxpath/09.key" \
4546 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004547 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004548 -S "X509 - A fatal error occurred"
4549
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004550# Tests for certificate selection based on SHA verson
4551
4552run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4553 "$P_SRV crt_file=data_files/server5.crt \
4554 key_file=data_files/server5.key \
4555 crt_file2=data_files/server5-sha1.crt \
4556 key_file2=data_files/server5.key" \
4557 "$P_CLI force_version=tls1_2" \
4558 0 \
4559 -c "signed using.*ECDSA with SHA256" \
4560 -C "signed using.*ECDSA with SHA1"
4561
4562run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4563 "$P_SRV crt_file=data_files/server5.crt \
4564 key_file=data_files/server5.key \
4565 crt_file2=data_files/server5-sha1.crt \
4566 key_file2=data_files/server5.key" \
4567 "$P_CLI force_version=tls1_1" \
4568 0 \
4569 -C "signed using.*ECDSA with SHA256" \
4570 -c "signed using.*ECDSA with SHA1"
4571
4572run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4573 "$P_SRV crt_file=data_files/server5.crt \
4574 key_file=data_files/server5.key \
4575 crt_file2=data_files/server5-sha1.crt \
4576 key_file2=data_files/server5.key" \
4577 "$P_CLI force_version=tls1" \
4578 0 \
4579 -C "signed using.*ECDSA with SHA256" \
4580 -c "signed using.*ECDSA with SHA1"
4581
4582run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4583 "$P_SRV crt_file=data_files/server5.crt \
4584 key_file=data_files/server5.key \
4585 crt_file2=data_files/server6.crt \
4586 key_file2=data_files/server6.key" \
4587 "$P_CLI force_version=tls1_1" \
4588 0 \
4589 -c "serial number.*09" \
4590 -c "signed using.*ECDSA with SHA256" \
4591 -C "signed using.*ECDSA with SHA1"
4592
4593run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4594 "$P_SRV crt_file=data_files/server6.crt \
4595 key_file=data_files/server6.key \
4596 crt_file2=data_files/server5.crt \
4597 key_file2=data_files/server5.key" \
4598 "$P_CLI force_version=tls1_1" \
4599 0 \
4600 -c "serial number.*0A" \
4601 -c "signed using.*ECDSA with SHA256" \
4602 -C "signed using.*ECDSA with SHA1"
4603
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004604# tests for SNI
4605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004606run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004607 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004608 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004609 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004610 0 \
4611 -S "parse ServerName extension" \
4612 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4613 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004615run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004616 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004617 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004618 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 +02004619 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004620 0 \
4621 -s "parse ServerName extension" \
4622 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4623 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004625run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004626 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004627 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004628 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 +02004629 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004630 0 \
4631 -s "parse ServerName extension" \
4632 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4633 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004635run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004636 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004637 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004638 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 +02004639 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004640 1 \
4641 -s "parse ServerName extension" \
4642 -s "ssl_sni_wrapper() returned" \
4643 -s "mbedtls_ssl_handshake returned" \
4644 -c "mbedtls_ssl_handshake returned" \
4645 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004646
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004647run_test "SNI: client auth no override: optional" \
4648 "$P_SRV debug_level=3 auth_mode=optional \
4649 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4650 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4651 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004652 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004653 -S "skip write certificate request" \
4654 -C "skip parse certificate request" \
4655 -c "got a certificate request" \
4656 -C "skip write certificate" \
4657 -C "skip write certificate verify" \
4658 -S "skip parse certificate verify"
4659
4660run_test "SNI: client auth override: none -> optional" \
4661 "$P_SRV debug_level=3 auth_mode=none \
4662 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4663 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4664 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004665 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004666 -S "skip write certificate request" \
4667 -C "skip parse certificate request" \
4668 -c "got a certificate request" \
4669 -C "skip write certificate" \
4670 -C "skip write certificate verify" \
4671 -S "skip parse certificate verify"
4672
4673run_test "SNI: client auth override: optional -> none" \
4674 "$P_SRV debug_level=3 auth_mode=optional \
4675 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4676 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4677 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004678 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004679 -s "skip write certificate request" \
4680 -C "skip parse certificate request" \
4681 -c "got no certificate request" \
4682 -c "skip write certificate" \
4683 -c "skip write certificate verify" \
4684 -s "skip parse certificate verify"
4685
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004686run_test "SNI: CA no override" \
4687 "$P_SRV debug_level=3 auth_mode=optional \
4688 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4689 ca_file=data_files/test-ca.crt \
4690 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4691 "$P_CLI debug_level=3 server_name=localhost \
4692 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4693 1 \
4694 -S "skip write certificate request" \
4695 -C "skip parse certificate request" \
4696 -c "got a certificate request" \
4697 -C "skip write certificate" \
4698 -C "skip write certificate verify" \
4699 -S "skip parse certificate verify" \
4700 -s "x509_verify_cert() returned" \
4701 -s "! The certificate is not correctly signed by the trusted CA" \
4702 -S "The certificate has been revoked (is on a CRL)"
4703
4704run_test "SNI: CA override" \
4705 "$P_SRV debug_level=3 auth_mode=optional \
4706 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4707 ca_file=data_files/test-ca.crt \
4708 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4709 "$P_CLI debug_level=3 server_name=localhost \
4710 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4711 0 \
4712 -S "skip write certificate request" \
4713 -C "skip parse certificate request" \
4714 -c "got a certificate request" \
4715 -C "skip write certificate" \
4716 -C "skip write certificate verify" \
4717 -S "skip parse certificate verify" \
4718 -S "x509_verify_cert() returned" \
4719 -S "! The certificate is not correctly signed by the trusted CA" \
4720 -S "The certificate has been revoked (is on a CRL)"
4721
4722run_test "SNI: CA override with CRL" \
4723 "$P_SRV debug_level=3 auth_mode=optional \
4724 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4725 ca_file=data_files/test-ca.crt \
4726 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4727 "$P_CLI debug_level=3 server_name=localhost \
4728 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4729 1 \
4730 -S "skip write certificate request" \
4731 -C "skip parse certificate request" \
4732 -c "got a certificate request" \
4733 -C "skip write certificate" \
4734 -C "skip write certificate verify" \
4735 -S "skip parse certificate verify" \
4736 -s "x509_verify_cert() returned" \
4737 -S "! The certificate is not correctly signed by the trusted CA" \
4738 -s "The certificate has been revoked (is on a CRL)"
4739
Andres AG1a834452016-12-07 10:01:30 +00004740# Tests for SNI and DTLS
4741
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004742run_test "SNI: DTLS, no SNI callback" \
4743 "$P_SRV debug_level=3 dtls=1 \
4744 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
4745 "$P_CLI server_name=localhost dtls=1" \
4746 0 \
4747 -S "parse ServerName extension" \
4748 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4749 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4750
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004751run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004752 "$P_SRV debug_level=3 dtls=1 \
4753 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4754 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4755 "$P_CLI server_name=localhost dtls=1" \
4756 0 \
4757 -s "parse ServerName extension" \
4758 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4759 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4760
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004761run_test "SNI: DTLS, matching cert 2" \
4762 "$P_SRV debug_level=3 dtls=1 \
4763 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4764 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4765 "$P_CLI server_name=polarssl.example dtls=1" \
4766 0 \
4767 -s "parse ServerName extension" \
4768 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4769 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4770
4771run_test "SNI: DTLS, no matching cert" \
4772 "$P_SRV debug_level=3 dtls=1 \
4773 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4774 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4775 "$P_CLI server_name=nonesuch.example dtls=1" \
4776 1 \
4777 -s "parse ServerName extension" \
4778 -s "ssl_sni_wrapper() returned" \
4779 -s "mbedtls_ssl_handshake returned" \
4780 -c "mbedtls_ssl_handshake returned" \
4781 -c "SSL - A fatal alert message was received from our peer"
4782
4783run_test "SNI: DTLS, client auth no override: optional" \
4784 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4785 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4786 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4787 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4788 0 \
4789 -S "skip write certificate request" \
4790 -C "skip parse certificate request" \
4791 -c "got a certificate request" \
4792 -C "skip write certificate" \
4793 -C "skip write certificate verify" \
4794 -S "skip parse certificate verify"
4795
4796run_test "SNI: DTLS, client auth override: none -> optional" \
4797 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4798 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4799 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4800 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4801 0 \
4802 -S "skip write certificate request" \
4803 -C "skip parse certificate request" \
4804 -c "got a certificate request" \
4805 -C "skip write certificate" \
4806 -C "skip write certificate verify" \
4807 -S "skip parse certificate verify"
4808
4809run_test "SNI: DTLS, client auth override: optional -> none" \
4810 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4811 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4812 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4813 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4814 0 \
4815 -s "skip write certificate request" \
4816 -C "skip parse certificate request" \
4817 -c "got no certificate request" \
4818 -c "skip write certificate" \
4819 -c "skip write certificate verify" \
4820 -s "skip parse certificate verify"
4821
4822run_test "SNI: DTLS, CA no override" \
4823 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4824 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4825 ca_file=data_files/test-ca.crt \
4826 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4827 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4828 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4829 1 \
4830 -S "skip write certificate request" \
4831 -C "skip parse certificate request" \
4832 -c "got a certificate request" \
4833 -C "skip write certificate" \
4834 -C "skip write certificate verify" \
4835 -S "skip parse certificate verify" \
4836 -s "x509_verify_cert() returned" \
4837 -s "! The certificate is not correctly signed by the trusted CA" \
4838 -S "The certificate has been revoked (is on a CRL)"
4839
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004840run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004841 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4842 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4843 ca_file=data_files/test-ca.crt \
4844 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4845 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4846 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4847 0 \
4848 -S "skip write certificate request" \
4849 -C "skip parse certificate request" \
4850 -c "got a certificate request" \
4851 -C "skip write certificate" \
4852 -C "skip write certificate verify" \
4853 -S "skip parse certificate verify" \
4854 -S "x509_verify_cert() returned" \
4855 -S "! The certificate is not correctly signed by the trusted CA" \
4856 -S "The certificate has been revoked (is on a CRL)"
4857
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004858run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004859 "$P_SRV debug_level=3 auth_mode=optional \
4860 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4861 ca_file=data_files/test-ca.crt \
4862 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4863 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4864 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4865 1 \
4866 -S "skip write certificate request" \
4867 -C "skip parse certificate request" \
4868 -c "got a certificate request" \
4869 -C "skip write certificate" \
4870 -C "skip write certificate verify" \
4871 -S "skip parse certificate verify" \
4872 -s "x509_verify_cert() returned" \
4873 -S "! The certificate is not correctly signed by the trusted CA" \
4874 -s "The certificate has been revoked (is on a CRL)"
4875
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004876# Tests for non-blocking I/O: exercise a variety of handshake flows
4877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004878run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004879 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4880 "$P_CLI nbio=2 tickets=0" \
4881 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004882 -S "mbedtls_ssl_handshake returned" \
4883 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004884 -c "Read from server: .* bytes read"
4885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004886run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004887 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4888 "$P_CLI nbio=2 tickets=0" \
4889 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004890 -S "mbedtls_ssl_handshake returned" \
4891 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004892 -c "Read from server: .* bytes read"
4893
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004894run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004895 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4896 "$P_CLI nbio=2 tickets=1" \
4897 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004898 -S "mbedtls_ssl_handshake returned" \
4899 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004900 -c "Read from server: .* bytes read"
4901
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004902run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004903 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4904 "$P_CLI nbio=2 tickets=1" \
4905 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004906 -S "mbedtls_ssl_handshake returned" \
4907 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004908 -c "Read from server: .* bytes read"
4909
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004910run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004911 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4912 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4913 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004914 -S "mbedtls_ssl_handshake returned" \
4915 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004916 -c "Read from server: .* bytes read"
4917
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004918run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004919 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4920 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4921 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004922 -S "mbedtls_ssl_handshake returned" \
4923 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004924 -c "Read from server: .* bytes read"
4925
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004926run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004927 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4928 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4929 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004930 -S "mbedtls_ssl_handshake returned" \
4931 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004932 -c "Read from server: .* bytes read"
4933
Hanno Becker00076712017-11-15 16:39:08 +00004934# Tests for event-driven I/O: exercise a variety of handshake flows
4935
4936run_test "Event-driven I/O: basic handshake" \
4937 "$P_SRV event=1 tickets=0 auth_mode=none" \
4938 "$P_CLI event=1 tickets=0" \
4939 0 \
4940 -S "mbedtls_ssl_handshake returned" \
4941 -C "mbedtls_ssl_handshake returned" \
4942 -c "Read from server: .* bytes read"
4943
4944run_test "Event-driven I/O: client auth" \
4945 "$P_SRV event=1 tickets=0 auth_mode=required" \
4946 "$P_CLI event=1 tickets=0" \
4947 0 \
4948 -S "mbedtls_ssl_handshake returned" \
4949 -C "mbedtls_ssl_handshake returned" \
4950 -c "Read from server: .* bytes read"
4951
4952run_test "Event-driven I/O: ticket" \
4953 "$P_SRV event=1 tickets=1 auth_mode=none" \
4954 "$P_CLI event=1 tickets=1" \
4955 0 \
4956 -S "mbedtls_ssl_handshake returned" \
4957 -C "mbedtls_ssl_handshake returned" \
4958 -c "Read from server: .* bytes read"
4959
4960run_test "Event-driven I/O: ticket + client auth" \
4961 "$P_SRV event=1 tickets=1 auth_mode=required" \
4962 "$P_CLI event=1 tickets=1" \
4963 0 \
4964 -S "mbedtls_ssl_handshake returned" \
4965 -C "mbedtls_ssl_handshake returned" \
4966 -c "Read from server: .* bytes read"
4967
4968run_test "Event-driven I/O: ticket + client auth + resume" \
4969 "$P_SRV event=1 tickets=1 auth_mode=required" \
4970 "$P_CLI event=1 tickets=1 reconnect=1" \
4971 0 \
4972 -S "mbedtls_ssl_handshake returned" \
4973 -C "mbedtls_ssl_handshake returned" \
4974 -c "Read from server: .* bytes read"
4975
4976run_test "Event-driven I/O: ticket + resume" \
4977 "$P_SRV event=1 tickets=1 auth_mode=none" \
4978 "$P_CLI event=1 tickets=1 reconnect=1" \
4979 0 \
4980 -S "mbedtls_ssl_handshake returned" \
4981 -C "mbedtls_ssl_handshake returned" \
4982 -c "Read from server: .* bytes read"
4983
4984run_test "Event-driven I/O: session-id resume" \
4985 "$P_SRV event=1 tickets=0 auth_mode=none" \
4986 "$P_CLI event=1 tickets=0 reconnect=1" \
4987 0 \
4988 -S "mbedtls_ssl_handshake returned" \
4989 -C "mbedtls_ssl_handshake returned" \
4990 -c "Read from server: .* bytes read"
4991
Hanno Becker6a33f592018-03-13 11:38:46 +00004992run_test "Event-driven I/O, DTLS: basic handshake" \
4993 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4994 "$P_CLI dtls=1 event=1 tickets=0" \
4995 0 \
4996 -c "Read from server: .* bytes read"
4997
4998run_test "Event-driven I/O, DTLS: client auth" \
4999 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
5000 "$P_CLI dtls=1 event=1 tickets=0" \
5001 0 \
5002 -c "Read from server: .* bytes read"
5003
5004run_test "Event-driven I/O, DTLS: ticket" \
5005 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
5006 "$P_CLI dtls=1 event=1 tickets=1" \
5007 0 \
5008 -c "Read from server: .* bytes read"
5009
5010run_test "Event-driven I/O, DTLS: ticket + client auth" \
5011 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
5012 "$P_CLI dtls=1 event=1 tickets=1" \
5013 0 \
5014 -c "Read from server: .* bytes read"
5015
5016run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
5017 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01005018 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00005019 0 \
5020 -c "Read from server: .* bytes read"
5021
5022run_test "Event-driven I/O, DTLS: ticket + resume" \
5023 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01005024 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00005025 0 \
5026 -c "Read from server: .* bytes read"
5027
5028run_test "Event-driven I/O, DTLS: session-id resume" \
5029 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01005030 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00005031 0 \
5032 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00005033
5034# This test demonstrates the need for the mbedtls_ssl_check_pending function.
5035# During session resumption, the client will send its ApplicationData record
5036# within the same datagram as the Finished messages. In this situation, the
5037# server MUST NOT idle on the underlying transport after handshake completion,
5038# because the ApplicationData request has already been queued internally.
5039run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00005040 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00005041 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01005042 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00005043 0 \
5044 -c "Read from server: .* bytes read"
5045
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005046# Tests for version negotiation
5047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005048run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005049 "$P_SRV" \
5050 "$P_CLI" \
5051 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005052 -S "mbedtls_ssl_handshake returned" \
5053 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005054 -s "Protocol is TLSv1.2" \
5055 -c "Protocol is TLSv1.2"
5056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005057run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005058 "$P_SRV" \
5059 "$P_CLI max_version=tls1_1" \
5060 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005061 -S "mbedtls_ssl_handshake returned" \
5062 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005063 -s "Protocol is TLSv1.1" \
5064 -c "Protocol is TLSv1.1"
5065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005066run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005067 "$P_SRV max_version=tls1_1" \
5068 "$P_CLI" \
5069 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005070 -S "mbedtls_ssl_handshake returned" \
5071 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005072 -s "Protocol is TLSv1.1" \
5073 -c "Protocol is TLSv1.1"
5074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005075run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005076 "$P_SRV max_version=tls1_1" \
5077 "$P_CLI max_version=tls1_1" \
5078 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005079 -S "mbedtls_ssl_handshake returned" \
5080 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005081 -s "Protocol is TLSv1.1" \
5082 -c "Protocol is TLSv1.1"
5083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005084run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005085 "$P_SRV min_version=tls1_1" \
5086 "$P_CLI max_version=tls1_1" \
5087 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005088 -S "mbedtls_ssl_handshake returned" \
5089 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005090 -s "Protocol is TLSv1.1" \
5091 -c "Protocol is TLSv1.1"
5092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005093run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005094 "$P_SRV max_version=tls1_1" \
5095 "$P_CLI min_version=tls1_1" \
5096 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005097 -S "mbedtls_ssl_handshake returned" \
5098 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005099 -s "Protocol is TLSv1.1" \
5100 -c "Protocol is TLSv1.1"
5101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005102run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005103 "$P_SRV max_version=tls1_1" \
5104 "$P_CLI min_version=tls1_2" \
5105 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005106 -s "mbedtls_ssl_handshake returned" \
5107 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005108 -c "SSL - Handshake protocol not within min/max boundaries"
5109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005110run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005111 "$P_SRV min_version=tls1_2" \
5112 "$P_CLI max_version=tls1_1" \
5113 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005114 -s "mbedtls_ssl_handshake returned" \
5115 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005116 -s "SSL - Handshake protocol not within min/max boundaries"
5117
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005118# Tests for ALPN extension
5119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005120run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005121 "$P_SRV debug_level=3" \
5122 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005123 0 \
5124 -C "client hello, adding alpn extension" \
5125 -S "found alpn extension" \
5126 -C "got an alert message, type: \\[2:120]" \
5127 -S "server hello, adding alpn extension" \
5128 -C "found alpn extension " \
5129 -C "Application Layer Protocol is" \
5130 -S "Application Layer Protocol is"
5131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005132run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005133 "$P_SRV debug_level=3" \
5134 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005135 0 \
5136 -c "client hello, adding alpn extension" \
5137 -s "found alpn extension" \
5138 -C "got an alert message, type: \\[2:120]" \
5139 -S "server hello, adding alpn extension" \
5140 -C "found alpn extension " \
5141 -c "Application Layer Protocol is (none)" \
5142 -S "Application Layer Protocol is"
5143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005144run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005145 "$P_SRV debug_level=3 alpn=abc,1234" \
5146 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005147 0 \
5148 -C "client hello, adding alpn extension" \
5149 -S "found alpn extension" \
5150 -C "got an alert message, type: \\[2:120]" \
5151 -S "server hello, adding alpn extension" \
5152 -C "found alpn extension " \
5153 -C "Application Layer Protocol is" \
5154 -s "Application Layer Protocol is (none)"
5155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005156run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005157 "$P_SRV debug_level=3 alpn=abc,1234" \
5158 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005159 0 \
5160 -c "client hello, adding alpn extension" \
5161 -s "found alpn extension" \
5162 -C "got an alert message, type: \\[2:120]" \
5163 -s "server hello, adding alpn extension" \
5164 -c "found alpn extension" \
5165 -c "Application Layer Protocol is abc" \
5166 -s "Application Layer Protocol is abc"
5167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005168run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005169 "$P_SRV debug_level=3 alpn=abc,1234" \
5170 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005171 0 \
5172 -c "client hello, adding alpn extension" \
5173 -s "found alpn extension" \
5174 -C "got an alert message, type: \\[2:120]" \
5175 -s "server hello, adding alpn extension" \
5176 -c "found alpn extension" \
5177 -c "Application Layer Protocol is abc" \
5178 -s "Application Layer Protocol is abc"
5179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005180run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005181 "$P_SRV debug_level=3 alpn=abc,1234" \
5182 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005183 0 \
5184 -c "client hello, adding alpn extension" \
5185 -s "found alpn extension" \
5186 -C "got an alert message, type: \\[2:120]" \
5187 -s "server hello, adding alpn extension" \
5188 -c "found alpn extension" \
5189 -c "Application Layer Protocol is 1234" \
5190 -s "Application Layer Protocol is 1234"
5191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005192run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005193 "$P_SRV debug_level=3 alpn=abc,123" \
5194 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005195 1 \
5196 -c "client hello, adding alpn extension" \
5197 -s "found alpn extension" \
5198 -c "got an alert message, type: \\[2:120]" \
5199 -S "server hello, adding alpn extension" \
5200 -C "found alpn extension" \
5201 -C "Application Layer Protocol is 1234" \
5202 -S "Application Layer Protocol is 1234"
5203
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02005204
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005205# Tests for keyUsage in leaf certificates, part 1:
5206# server-side certificate/suite selection
5207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005208run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005209 "$P_SRV key_file=data_files/server2.key \
5210 crt_file=data_files/server2.ku-ds.crt" \
5211 "$P_CLI" \
5212 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02005213 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005214
5215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005216run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005217 "$P_SRV key_file=data_files/server2.key \
5218 crt_file=data_files/server2.ku-ke.crt" \
5219 "$P_CLI" \
5220 0 \
5221 -c "Ciphersuite is TLS-RSA-WITH-"
5222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005223run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005224 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005225 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005226 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005227 1 \
5228 -C "Ciphersuite is "
5229
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005230run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005231 "$P_SRV key_file=data_files/server5.key \
5232 crt_file=data_files/server5.ku-ds.crt" \
5233 "$P_CLI" \
5234 0 \
5235 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
5236
5237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005238run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005239 "$P_SRV key_file=data_files/server5.key \
5240 crt_file=data_files/server5.ku-ka.crt" \
5241 "$P_CLI" \
5242 0 \
5243 -c "Ciphersuite is TLS-ECDH-"
5244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005245run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005246 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005247 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005248 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005249 1 \
5250 -C "Ciphersuite is "
5251
5252# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005253# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005255run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005256 "$O_SRV -key data_files/server2.key \
5257 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005258 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005259 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5260 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005261 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005262 -C "Processing of the Certificate handshake message failed" \
5263 -c "Ciphersuite is TLS-"
5264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005265run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005266 "$O_SRV -key data_files/server2.key \
5267 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005268 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005269 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5270 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005271 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005272 -C "Processing of the Certificate handshake message failed" \
5273 -c "Ciphersuite is TLS-"
5274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005275run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005276 "$O_SRV -key data_files/server2.key \
5277 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005278 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005279 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5280 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005281 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005282 -C "Processing of the Certificate handshake message failed" \
5283 -c "Ciphersuite is TLS-"
5284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005285run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005286 "$O_SRV -key data_files/server2.key \
5287 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005288 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005289 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5290 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005291 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005292 -c "Processing of the Certificate handshake message failed" \
5293 -C "Ciphersuite is TLS-"
5294
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01005295run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
5296 "$O_SRV -key data_files/server2.key \
5297 -cert data_files/server2.ku-ke.crt" \
5298 "$P_CLI debug_level=1 auth_mode=optional \
5299 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5300 0 \
5301 -c "bad certificate (usage extensions)" \
5302 -C "Processing of the Certificate handshake message failed" \
5303 -c "Ciphersuite is TLS-" \
5304 -c "! Usage does not match the keyUsage extension"
5305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005306run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005307 "$O_SRV -key data_files/server2.key \
5308 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005309 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005310 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5311 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005312 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005313 -C "Processing of the Certificate handshake message failed" \
5314 -c "Ciphersuite is TLS-"
5315
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005316run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005317 "$O_SRV -key data_files/server2.key \
5318 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005319 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005320 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5321 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005322 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005323 -c "Processing of the Certificate handshake message failed" \
5324 -C "Ciphersuite is TLS-"
5325
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01005326run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
5327 "$O_SRV -key data_files/server2.key \
5328 -cert data_files/server2.ku-ds.crt" \
5329 "$P_CLI debug_level=1 auth_mode=optional \
5330 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5331 0 \
5332 -c "bad certificate (usage extensions)" \
5333 -C "Processing of the Certificate handshake message failed" \
5334 -c "Ciphersuite is TLS-" \
5335 -c "! Usage does not match the keyUsage extension"
5336
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005337# Tests for keyUsage in leaf certificates, part 3:
5338# server-side checking of client cert
5339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005340run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005341 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005342 "$O_CLI -key data_files/server2.key \
5343 -cert data_files/server2.ku-ds.crt" \
5344 0 \
5345 -S "bad certificate (usage extensions)" \
5346 -S "Processing of the Certificate handshake message failed"
5347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005348run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005349 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005350 "$O_CLI -key data_files/server2.key \
5351 -cert data_files/server2.ku-ke.crt" \
5352 0 \
5353 -s "bad certificate (usage extensions)" \
5354 -S "Processing of the Certificate handshake message failed"
5355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005356run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005357 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005358 "$O_CLI -key data_files/server2.key \
5359 -cert data_files/server2.ku-ke.crt" \
5360 1 \
5361 -s "bad certificate (usage extensions)" \
5362 -s "Processing of the Certificate handshake message failed"
5363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005364run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005365 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005366 "$O_CLI -key data_files/server5.key \
5367 -cert data_files/server5.ku-ds.crt" \
5368 0 \
5369 -S "bad certificate (usage extensions)" \
5370 -S "Processing of the Certificate handshake message failed"
5371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005372run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005373 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005374 "$O_CLI -key data_files/server5.key \
5375 -cert data_files/server5.ku-ka.crt" \
5376 0 \
5377 -s "bad certificate (usage extensions)" \
5378 -S "Processing of the Certificate handshake message failed"
5379
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005380# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
5381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005382run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005383 "$P_SRV key_file=data_files/server5.key \
5384 crt_file=data_files/server5.eku-srv.crt" \
5385 "$P_CLI" \
5386 0
5387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005388run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005389 "$P_SRV key_file=data_files/server5.key \
5390 crt_file=data_files/server5.eku-srv.crt" \
5391 "$P_CLI" \
5392 0
5393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005394run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005395 "$P_SRV key_file=data_files/server5.key \
5396 crt_file=data_files/server5.eku-cs_any.crt" \
5397 "$P_CLI" \
5398 0
5399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005400run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005401 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005402 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005403 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005404 1
5405
5406# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005408run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005409 "$O_SRV -key data_files/server5.key \
5410 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005411 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005412 0 \
5413 -C "bad certificate (usage extensions)" \
5414 -C "Processing of the Certificate handshake message failed" \
5415 -c "Ciphersuite is TLS-"
5416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005417run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005418 "$O_SRV -key data_files/server5.key \
5419 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005420 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005421 0 \
5422 -C "bad certificate (usage extensions)" \
5423 -C "Processing of the Certificate handshake message failed" \
5424 -c "Ciphersuite is TLS-"
5425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005426run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005427 "$O_SRV -key data_files/server5.key \
5428 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005429 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005430 0 \
5431 -C "bad certificate (usage extensions)" \
5432 -C "Processing of the Certificate handshake message failed" \
5433 -c "Ciphersuite is TLS-"
5434
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005435run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005436 "$O_SRV -key data_files/server5.key \
5437 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005438 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005439 1 \
5440 -c "bad certificate (usage extensions)" \
5441 -c "Processing of the Certificate handshake message failed" \
5442 -C "Ciphersuite is TLS-"
5443
5444# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005446run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005447 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005448 "$O_CLI -key data_files/server5.key \
5449 -cert data_files/server5.eku-cli.crt" \
5450 0 \
5451 -S "bad certificate (usage extensions)" \
5452 -S "Processing of the Certificate handshake message failed"
5453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005454run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005455 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005456 "$O_CLI -key data_files/server5.key \
5457 -cert data_files/server5.eku-srv_cli.crt" \
5458 0 \
5459 -S "bad certificate (usage extensions)" \
5460 -S "Processing of the Certificate handshake message failed"
5461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005462run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005463 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005464 "$O_CLI -key data_files/server5.key \
5465 -cert data_files/server5.eku-cs_any.crt" \
5466 0 \
5467 -S "bad certificate (usage extensions)" \
5468 -S "Processing of the Certificate handshake message failed"
5469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005470run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005471 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005472 "$O_CLI -key data_files/server5.key \
5473 -cert data_files/server5.eku-cs.crt" \
5474 0 \
5475 -s "bad certificate (usage extensions)" \
5476 -S "Processing of the Certificate handshake message failed"
5477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005478run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005479 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005480 "$O_CLI -key data_files/server5.key \
5481 -cert data_files/server5.eku-cs.crt" \
5482 1 \
5483 -s "bad certificate (usage extensions)" \
5484 -s "Processing of the Certificate handshake message failed"
5485
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005486# Tests for DHM parameters loading
5487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005488run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005489 "$P_SRV" \
5490 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5491 debug_level=3" \
5492 0 \
5493 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005494 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005496run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005497 "$P_SRV dhm_file=data_files/dhparams.pem" \
5498 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5499 debug_level=3" \
5500 0 \
5501 -c "value of 'DHM: P ' (1024 bits)" \
5502 -c "value of 'DHM: G ' (2 bits)"
5503
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005504# Tests for DHM client-side size checking
5505
5506run_test "DHM size: server default, client default, OK" \
5507 "$P_SRV" \
5508 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5509 debug_level=1" \
5510 0 \
5511 -C "DHM prime too short:"
5512
5513run_test "DHM size: server default, client 2048, OK" \
5514 "$P_SRV" \
5515 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5516 debug_level=1 dhmlen=2048" \
5517 0 \
5518 -C "DHM prime too short:"
5519
5520run_test "DHM size: server 1024, client default, OK" \
5521 "$P_SRV dhm_file=data_files/dhparams.pem" \
5522 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5523 debug_level=1" \
5524 0 \
5525 -C "DHM prime too short:"
5526
5527run_test "DHM size: server 1000, client default, rejected" \
5528 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5529 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5530 debug_level=1" \
5531 1 \
5532 -c "DHM prime too short:"
5533
5534run_test "DHM size: server default, client 2049, rejected" \
5535 "$P_SRV" \
5536 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5537 debug_level=1 dhmlen=2049" \
5538 1 \
5539 -c "DHM prime too short:"
5540
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005541# Tests for PSK callback
5542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005543run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005544 "$P_SRV psk=abc123 psk_identity=foo" \
5545 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5546 psk_identity=foo psk=abc123" \
5547 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005548 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005549 -S "SSL - Unknown identity received" \
5550 -S "SSL - Verification of the message MAC failed"
5551
Hanno Beckerf7027512018-10-23 15:27:39 +01005552requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5553run_test "PSK callback: opaque psk on client, no callback" \
5554 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5555 "$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 +00005556 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005557 0 \
5558 -c "skip PMS generation for opaque PSK"\
5559 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005560 -C "session hash for extended master secret"\
5561 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005562 -S "SSL - None of the common ciphersuites is usable" \
5563 -S "SSL - Unknown identity received" \
5564 -S "SSL - Verification of the message MAC failed"
5565
5566requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5567run_test "PSK callback: opaque psk on client, no callback, SHA-384" \
5568 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5569 "$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 +00005570 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005571 0 \
5572 -c "skip PMS generation for opaque PSK"\
5573 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005574 -C "session hash for extended master secret"\
5575 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005576 -S "SSL - None of the common ciphersuites is usable" \
5577 -S "SSL - Unknown identity received" \
5578 -S "SSL - Verification of the message MAC failed"
5579
5580requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5581run_test "PSK callback: opaque psk on client, no callback, EMS" \
5582 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5583 "$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 +00005584 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005585 0 \
5586 -c "skip PMS generation for opaque PSK"\
5587 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005588 -c "session hash for extended master secret"\
5589 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005590 -S "SSL - None of the common ciphersuites is usable" \
5591 -S "SSL - Unknown identity received" \
5592 -S "SSL - Verification of the message MAC failed"
5593
5594requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5595run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \
5596 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5597 "$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 +00005598 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005599 0 \
5600 -c "skip PMS generation for opaque PSK"\
5601 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005602 -c "session hash for extended master secret"\
5603 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005604 -S "SSL - None of the common ciphersuites is usable" \
5605 -S "SSL - Unknown identity received" \
5606 -S "SSL - Verification of the message MAC failed"
5607
Hanno Becker28c79dc2018-10-26 13:15:08 +01005608requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5609run_test "PSK callback: raw psk on client, static opaque on server, no callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005610 "$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 +01005611 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5612 psk_identity=foo psk=abc123" \
5613 0 \
5614 -C "skip PMS generation for opaque PSK"\
5615 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005616 -C "session hash for extended master secret"\
5617 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005618 -S "SSL - None of the common ciphersuites is usable" \
5619 -S "SSL - Unknown identity received" \
5620 -S "SSL - Verification of the message MAC failed"
5621
5622requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5623run_test "PSK callback: raw psk on client, static opaque on server, no callback, SHA-384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005624 "$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 +01005625 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5626 psk_identity=foo psk=abc123" \
5627 0 \
5628 -C "skip PMS generation for opaque PSK"\
5629 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005630 -C "session hash for extended master secret"\
5631 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005632 -S "SSL - None of the common ciphersuites is usable" \
5633 -S "SSL - Unknown identity received" \
5634 -S "SSL - Verification of the message MAC failed"
5635
5636requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5637run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005638 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005639 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5640 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5641 psk_identity=foo psk=abc123 extended_ms=1" \
5642 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005643 -c "session hash for extended master secret"\
5644 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005645 -C "skip PMS generation for opaque PSK"\
5646 -s "skip PMS generation for opaque PSK"\
5647 -S "SSL - None of the common ciphersuites is usable" \
5648 -S "SSL - Unknown identity received" \
5649 -S "SSL - Verification of the message MAC failed"
5650
5651requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5652run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS, SHA384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005653 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005654 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5655 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5656 psk_identity=foo psk=abc123 extended_ms=1" \
5657 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005658 -c "session hash for extended master secret"\
5659 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005660 -C "skip PMS generation for opaque PSK"\
5661 -s "skip PMS generation for opaque PSK"\
5662 -S "SSL - None of the common ciphersuites is usable" \
5663 -S "SSL - Unknown identity received" \
5664 -S "SSL - Verification of the message MAC failed"
5665
5666requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5667run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005668 "$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 +01005669 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5670 psk_identity=def psk=beef" \
5671 0 \
5672 -C "skip PMS generation for opaque PSK"\
5673 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005674 -C "session hash for extended master secret"\
5675 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005676 -S "SSL - None of the common ciphersuites is usable" \
5677 -S "SSL - Unknown identity received" \
5678 -S "SSL - Verification of the message MAC failed"
5679
5680requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5681run_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 +00005682 "$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 +01005683 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5684 psk_identity=def psk=beef" \
5685 0 \
5686 -C "skip PMS generation for opaque PSK"\
5687 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005688 -C "session hash for extended master secret"\
5689 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005690 -S "SSL - None of the common ciphersuites is usable" \
5691 -S "SSL - Unknown identity received" \
5692 -S "SSL - Verification of the message MAC failed"
5693
5694requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5695run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005696 "$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 +01005697 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5698 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5699 psk_identity=abc psk=dead extended_ms=1" \
5700 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005701 -c "session hash for extended master secret"\
5702 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005703 -C "skip PMS generation for opaque PSK"\
5704 -s "skip PMS generation for opaque PSK"\
5705 -S "SSL - None of the common ciphersuites is usable" \
5706 -S "SSL - Unknown identity received" \
5707 -S "SSL - Verification of the message MAC failed"
5708
5709requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5710run_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 +00005711 "$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 +01005712 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5713 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5714 psk_identity=abc psk=dead extended_ms=1" \
5715 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005716 -c "session hash for extended master secret"\
5717 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005718 -C "skip PMS generation for opaque PSK"\
5719 -s "skip PMS generation for opaque PSK"\
5720 -S "SSL - None of the common ciphersuites is usable" \
5721 -S "SSL - Unknown identity received" \
5722 -S "SSL - Verification of the message MAC failed"
5723
5724requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5725run_test "PSK callback: raw psk on client, mismatching static raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005726 "$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 +01005727 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5728 psk_identity=def psk=beef" \
5729 0 \
5730 -C "skip PMS generation for opaque PSK"\
5731 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005732 -C "session hash for extended master secret"\
5733 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005734 -S "SSL - None of the common ciphersuites is usable" \
5735 -S "SSL - Unknown identity received" \
5736 -S "SSL - Verification of the message MAC failed"
5737
5738requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5739run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005740 "$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 +01005741 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5742 psk_identity=def psk=beef" \
5743 0 \
5744 -C "skip PMS generation for opaque PSK"\
5745 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005746 -C "session hash for extended master secret"\
5747 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005748 -S "SSL - None of the common ciphersuites is usable" \
5749 -S "SSL - Unknown identity received" \
5750 -S "SSL - Verification of the message MAC failed"
5751
5752requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5753run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, raw PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005754 "$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 +01005755 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5756 psk_identity=def psk=beef" \
5757 0 \
5758 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005759 -C "session hash for extended master secret"\
5760 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005761 -S "SSL - None of the common ciphersuites is usable" \
5762 -S "SSL - Unknown identity received" \
5763 -S "SSL - Verification of the message MAC failed"
5764
5765requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5766run_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 +00005767 "$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 +01005768 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5769 psk_identity=def psk=beef" \
5770 0 \
5771 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005772 -C "session hash for extended master secret"\
5773 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005774 -S "SSL - None of the common ciphersuites is usable" \
5775 -S "SSL - Unknown identity received" \
5776 -S "SSL - Verification of the message MAC failed"
5777
5778requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5779run_test "PSK callback: raw psk on client, matching opaque PSK on server, wrong opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005780 "$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 +01005781 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5782 psk_identity=def psk=beef" \
5783 1 \
5784 -s "SSL - Verification of the message MAC failed"
5785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005786run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005787 "$P_SRV" \
5788 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5789 psk_identity=foo psk=abc123" \
5790 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005791 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005792 -S "SSL - Unknown identity received" \
5793 -S "SSL - Verification of the message MAC failed"
5794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005795run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005796 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5797 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5798 psk_identity=foo psk=abc123" \
5799 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005800 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005801 -s "SSL - Unknown identity received" \
5802 -S "SSL - Verification of the message MAC failed"
5803
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005804run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005805 "$P_SRV psk_list=abc,dead,def,beef" \
5806 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5807 psk_identity=abc psk=dead" \
5808 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005809 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005810 -S "SSL - Unknown identity received" \
5811 -S "SSL - Verification of the message MAC failed"
5812
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005813run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005814 "$P_SRV psk_list=abc,dead,def,beef" \
5815 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5816 psk_identity=def psk=beef" \
5817 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005818 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005819 -S "SSL - Unknown identity received" \
5820 -S "SSL - Verification of the message MAC failed"
5821
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005822run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005823 "$P_SRV psk_list=abc,dead,def,beef" \
5824 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5825 psk_identity=ghi psk=beef" \
5826 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005827 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005828 -s "SSL - Unknown identity received" \
5829 -S "SSL - Verification of the message MAC failed"
5830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005831run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005832 "$P_SRV psk_list=abc,dead,def,beef" \
5833 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5834 psk_identity=abc psk=beef" \
5835 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005836 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005837 -S "SSL - Unknown identity received" \
5838 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005839
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005840# Tests for EC J-PAKE
5841
Hanno Beckerfa452c42020-08-14 15:42:49 +01005842requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005843run_test "ECJPAKE: client not configured" \
5844 "$P_SRV debug_level=3" \
5845 "$P_CLI debug_level=3" \
5846 0 \
Hanno Beckeree63af62020-08-14 15:41:23 +01005847 -C "add ciphersuite: 0xc0ff" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005848 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005849 -S "found ecjpake kkpp extension" \
5850 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005851 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005852 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005853 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005854 -S "None of the common ciphersuites is usable"
5855
Hanno Beckerfa452c42020-08-14 15:42:49 +01005856requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005857run_test "ECJPAKE: server not configured" \
5858 "$P_SRV debug_level=3" \
5859 "$P_CLI debug_level=3 ecjpake_pw=bla \
5860 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5861 1 \
Hanno Beckeree63af62020-08-14 15:41:23 +01005862 -c "add ciphersuite: 0xc0ff" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005863 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005864 -s "found ecjpake kkpp extension" \
5865 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005866 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005867 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005868 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005869 -s "None of the common ciphersuites is usable"
5870
Hanno Beckerfa452c42020-08-14 15:42:49 +01005871requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005872run_test "ECJPAKE: working, TLS" \
5873 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5874 "$P_CLI debug_level=3 ecjpake_pw=bla \
5875 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005876 0 \
Hanno Beckeree63af62020-08-14 15:41:23 +01005877 -c "add ciphersuite: 0xc0ff" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005878 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005879 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005880 -s "found ecjpake kkpp extension" \
5881 -S "skip ecjpake kkpp extension" \
5882 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005883 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005884 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005885 -S "None of the common ciphersuites is usable" \
5886 -S "SSL - Verification of the message MAC failed"
5887
Janos Follath74537a62016-09-02 13:45:28 +01005888server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005889requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005890run_test "ECJPAKE: password mismatch, TLS" \
5891 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5892 "$P_CLI debug_level=3 ecjpake_pw=bad \
5893 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5894 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005895 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005896 -s "SSL - Verification of the message MAC failed"
5897
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005898requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005899run_test "ECJPAKE: working, DTLS" \
5900 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5901 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5902 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5903 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005904 -c "re-using cached ecjpake parameters" \
5905 -S "SSL - Verification of the message MAC failed"
5906
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005907requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005908run_test "ECJPAKE: working, DTLS, no cookie" \
5909 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5910 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5911 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5912 0 \
5913 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005914 -S "SSL - Verification of the message MAC failed"
5915
Janos Follath74537a62016-09-02 13:45:28 +01005916server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005917requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005918run_test "ECJPAKE: password mismatch, DTLS" \
5919 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5920 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5921 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5922 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005923 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005924 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005925
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005926# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005927requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005928run_test "ECJPAKE: working, DTLS, nolog" \
5929 "$P_SRV dtls=1 ecjpake_pw=bla" \
5930 "$P_CLI dtls=1 ecjpake_pw=bla \
5931 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5932 0
5933
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005934# Tests for ciphersuites per version
5935
Janos Follathe2681a42016-03-07 15:57:05 +00005936requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005937requires_config_enabled MBEDTLS_CAMELLIA_C
5938requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005939run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005940 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005941 "$P_CLI force_version=ssl3" \
5942 0 \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005943 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005944
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005945requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5946requires_config_enabled MBEDTLS_CAMELLIA_C
5947requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005948run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005949 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01005950 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005951 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005952 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005953
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005954requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5955requires_config_enabled MBEDTLS_CAMELLIA_C
5956requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005957run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005958 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005959 "$P_CLI force_version=tls1_1" \
5960 0 \
5961 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5962
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005963requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5964requires_config_enabled MBEDTLS_CAMELLIA_C
5965requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005966run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005967 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005968 "$P_CLI force_version=tls1_2" \
5969 0 \
5970 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5971
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005972# Test for ClientHello without extensions
5973
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005974requires_gnutls
Manuel Pégourié-Gonnardbc4da292020-01-30 12:45:14 +01005975run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard77cbeff2020-01-30 10:58:57 +01005976 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005977 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005978 0 \
5979 -s "dumping 'client hello extensions' (0 bytes)"
5980
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005981# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005982
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005983run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005984 "$P_SRV" \
5985 "$P_CLI request_size=100" \
5986 0 \
5987 -s "Read from client: 100 bytes read$"
5988
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005989run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005990 "$P_SRV" \
5991 "$P_CLI request_size=500" \
5992 0 \
5993 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005994
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005995# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005996
Janos Follathe2681a42016-03-07 15:57:05 +00005997requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005998run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005999 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006000 "$P_CLI request_size=1 force_version=ssl3 \
6001 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6002 0 \
6003 -s "Read from client: 1 bytes read"
6004
Janos Follathe2681a42016-03-07 15:57:05 +00006005requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006006run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006007 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006008 "$P_CLI request_size=1 force_version=ssl3 \
6009 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6010 0 \
6011 -s "Read from client: 1 bytes read"
6012
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006013run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006014 "$P_SRV" \
6015 "$P_CLI request_size=1 force_version=tls1 \
6016 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6017 0 \
6018 -s "Read from client: 1 bytes read"
6019
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006020run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006021 "$P_SRV" \
6022 "$P_CLI request_size=1 force_version=tls1 etm=0 \
6023 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6024 0 \
6025 -s "Read from client: 1 bytes read"
6026
Hanno Becker32c55012017-11-10 08:42:54 +00006027requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006028run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006029 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006030 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006031 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006032 0 \
6033 -s "Read from client: 1 bytes read"
6034
Hanno Becker32c55012017-11-10 08:42:54 +00006035requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006036run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006037 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006038 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006039 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00006040 0 \
6041 -s "Read from client: 1 bytes read"
6042
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006043run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006044 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006045 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00006046 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6047 0 \
6048 -s "Read from client: 1 bytes read"
6049
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006050run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00006051 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6052 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006053 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00006054 0 \
6055 -s "Read from client: 1 bytes read"
6056
6057requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006058run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006059 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006060 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006061 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006062 0 \
6063 -s "Read from client: 1 bytes read"
6064
Hanno Becker8501f982017-11-10 08:59:04 +00006065requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006066run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006067 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6068 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6069 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006070 0 \
6071 -s "Read from client: 1 bytes read"
6072
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006073run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006074 "$P_SRV" \
6075 "$P_CLI request_size=1 force_version=tls1_1 \
6076 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6077 0 \
6078 -s "Read from client: 1 bytes read"
6079
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006080run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006081 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00006082 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006083 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00006084 0 \
6085 -s "Read from client: 1 bytes read"
6086
6087requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006088run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006089 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006090 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006091 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006092 0 \
6093 -s "Read from client: 1 bytes read"
6094
6095requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006096run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006097 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006098 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006099 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006100 0 \
6101 -s "Read from client: 1 bytes read"
6102
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006103run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006104 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006105 "$P_CLI request_size=1 force_version=tls1_1 \
6106 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6107 0 \
6108 -s "Read from client: 1 bytes read"
6109
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006110run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00006111 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006112 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006113 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006114 0 \
6115 -s "Read from client: 1 bytes read"
6116
Hanno Becker8501f982017-11-10 08:59:04 +00006117requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006118run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006119 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006120 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006121 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006122 0 \
6123 -s "Read from client: 1 bytes read"
6124
Hanno Becker32c55012017-11-10 08:42:54 +00006125requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006126run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006127 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006128 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006129 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006130 0 \
6131 -s "Read from client: 1 bytes read"
6132
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006133run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006134 "$P_SRV" \
6135 "$P_CLI request_size=1 force_version=tls1_2 \
6136 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6137 0 \
6138 -s "Read from client: 1 bytes read"
6139
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006140run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006141 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00006142 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006143 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006144 0 \
6145 -s "Read from client: 1 bytes read"
6146
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006147run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006148 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006149 "$P_CLI request_size=1 force_version=tls1_2 \
6150 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006151 0 \
6152 -s "Read from client: 1 bytes read"
6153
Hanno Becker32c55012017-11-10 08:42:54 +00006154requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006155run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006156 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006157 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006158 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006159 0 \
6160 -s "Read from client: 1 bytes read"
6161
Hanno Becker8501f982017-11-10 08:59:04 +00006162requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006163run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006164 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006165 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006166 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006167 0 \
6168 -s "Read from client: 1 bytes read"
6169
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006170run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006171 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006172 "$P_CLI request_size=1 force_version=tls1_2 \
6173 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6174 0 \
6175 -s "Read from client: 1 bytes read"
6176
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006177run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006178 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006179 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006180 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00006181 0 \
6182 -s "Read from client: 1 bytes read"
6183
Hanno Becker32c55012017-11-10 08:42:54 +00006184requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006185run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006186 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006187 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006188 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006189 0 \
6190 -s "Read from client: 1 bytes read"
6191
Hanno Becker8501f982017-11-10 08:59:04 +00006192requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006193run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006194 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006195 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006196 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006197 0 \
6198 -s "Read from client: 1 bytes read"
6199
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006200run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006201 "$P_SRV" \
6202 "$P_CLI request_size=1 force_version=tls1_2 \
6203 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6204 0 \
6205 -s "Read from client: 1 bytes read"
6206
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006207run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006208 "$P_SRV" \
6209 "$P_CLI request_size=1 force_version=tls1_2 \
6210 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6211 0 \
6212 -s "Read from client: 1 bytes read"
6213
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006214# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00006215
6216requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006217run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006218 "$P_SRV dtls=1 force_version=dtls1" \
6219 "$P_CLI dtls=1 request_size=1 \
6220 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6221 0 \
6222 -s "Read from client: 1 bytes read"
6223
6224requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006225run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00006226 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
6227 "$P_CLI dtls=1 request_size=1 \
6228 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6229 0 \
6230 -s "Read from client: 1 bytes read"
6231
6232requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6233requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006234run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006235 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
6236 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00006237 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6238 0 \
6239 -s "Read from client: 1 bytes read"
6240
6241requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6242requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006243run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006244 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006245 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006246 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00006247 0 \
6248 -s "Read from client: 1 bytes read"
6249
6250requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006251run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00006252 "$P_SRV dtls=1 force_version=dtls1_2" \
6253 "$P_CLI dtls=1 request_size=1 \
6254 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6255 0 \
6256 -s "Read from client: 1 bytes read"
6257
6258requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006259run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006260 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006261 "$P_CLI dtls=1 request_size=1 \
6262 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6263 0 \
6264 -s "Read from client: 1 bytes read"
6265
6266requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6267requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006268run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006269 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00006270 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006271 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00006272 0 \
6273 -s "Read from client: 1 bytes read"
6274
6275requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6276requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006277run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006278 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006279 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006280 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00006281 0 \
6282 -s "Read from client: 1 bytes read"
6283
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006284# Tests for small server packets
6285
6286requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6287run_test "Small server packet SSLv3 BlockCipher" \
6288 "$P_SRV response_size=1 min_version=ssl3" \
6289 "$P_CLI force_version=ssl3 \
6290 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6291 0 \
6292 -c "Read from server: 1 bytes read"
6293
6294requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6295run_test "Small server packet SSLv3 StreamCipher" \
6296 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6297 "$P_CLI force_version=ssl3 \
6298 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6299 0 \
6300 -c "Read from server: 1 bytes read"
6301
6302run_test "Small server packet TLS 1.0 BlockCipher" \
6303 "$P_SRV response_size=1" \
6304 "$P_CLI force_version=tls1 \
6305 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6306 0 \
6307 -c "Read from server: 1 bytes read"
6308
6309run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
6310 "$P_SRV response_size=1" \
6311 "$P_CLI force_version=tls1 etm=0 \
6312 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6313 0 \
6314 -c "Read from server: 1 bytes read"
6315
6316requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6317run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
6318 "$P_SRV response_size=1 trunc_hmac=1" \
6319 "$P_CLI force_version=tls1 \
6320 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6321 0 \
6322 -c "Read from server: 1 bytes read"
6323
6324requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6325run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
6326 "$P_SRV response_size=1 trunc_hmac=1" \
6327 "$P_CLI force_version=tls1 \
6328 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6329 0 \
6330 -c "Read from server: 1 bytes read"
6331
6332run_test "Small server packet TLS 1.0 StreamCipher" \
6333 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6334 "$P_CLI force_version=tls1 \
6335 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6336 0 \
6337 -c "Read from server: 1 bytes read"
6338
6339run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
6340 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6341 "$P_CLI force_version=tls1 \
6342 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6343 0 \
6344 -c "Read from server: 1 bytes read"
6345
6346requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6347run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
6348 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6349 "$P_CLI force_version=tls1 \
6350 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6351 0 \
6352 -c "Read from server: 1 bytes read"
6353
6354requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6355run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6356 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6357 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6358 trunc_hmac=1 etm=0" \
6359 0 \
6360 -c "Read from server: 1 bytes read"
6361
6362run_test "Small server packet TLS 1.1 BlockCipher" \
6363 "$P_SRV response_size=1" \
6364 "$P_CLI force_version=tls1_1 \
6365 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6366 0 \
6367 -c "Read from server: 1 bytes read"
6368
6369run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
6370 "$P_SRV response_size=1" \
6371 "$P_CLI force_version=tls1_1 \
6372 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
6373 0 \
6374 -c "Read from server: 1 bytes read"
6375
6376requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6377run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
6378 "$P_SRV response_size=1 trunc_hmac=1" \
6379 "$P_CLI force_version=tls1_1 \
6380 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6381 0 \
6382 -c "Read from server: 1 bytes read"
6383
6384requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6385run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6386 "$P_SRV response_size=1 trunc_hmac=1" \
6387 "$P_CLI force_version=tls1_1 \
6388 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6389 0 \
6390 -c "Read from server: 1 bytes read"
6391
6392run_test "Small server packet TLS 1.1 StreamCipher" \
6393 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6394 "$P_CLI force_version=tls1_1 \
6395 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6396 0 \
6397 -c "Read from server: 1 bytes read"
6398
6399run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
6400 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6401 "$P_CLI force_version=tls1_1 \
6402 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6403 0 \
6404 -c "Read from server: 1 bytes read"
6405
6406requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6407run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
6408 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6409 "$P_CLI force_version=tls1_1 \
6410 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6411 0 \
6412 -c "Read from server: 1 bytes read"
6413
6414requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6415run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6416 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6417 "$P_CLI force_version=tls1_1 \
6418 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6419 0 \
6420 -c "Read from server: 1 bytes read"
6421
6422run_test "Small server packet TLS 1.2 BlockCipher" \
6423 "$P_SRV response_size=1" \
6424 "$P_CLI force_version=tls1_2 \
6425 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6426 0 \
6427 -c "Read from server: 1 bytes read"
6428
6429run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
6430 "$P_SRV response_size=1" \
6431 "$P_CLI force_version=tls1_2 \
6432 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
6433 0 \
6434 -c "Read from server: 1 bytes read"
6435
6436run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
6437 "$P_SRV response_size=1" \
6438 "$P_CLI force_version=tls1_2 \
6439 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6440 0 \
6441 -c "Read from server: 1 bytes read"
6442
6443requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6444run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
6445 "$P_SRV response_size=1 trunc_hmac=1" \
6446 "$P_CLI force_version=tls1_2 \
6447 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6448 0 \
6449 -c "Read from server: 1 bytes read"
6450
6451requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6452run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6453 "$P_SRV response_size=1 trunc_hmac=1" \
6454 "$P_CLI force_version=tls1_2 \
6455 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6456 0 \
6457 -c "Read from server: 1 bytes read"
6458
6459run_test "Small server packet TLS 1.2 StreamCipher" \
6460 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6461 "$P_CLI force_version=tls1_2 \
6462 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6463 0 \
6464 -c "Read from server: 1 bytes read"
6465
6466run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
6467 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6468 "$P_CLI force_version=tls1_2 \
6469 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6470 0 \
6471 -c "Read from server: 1 bytes read"
6472
6473requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6474run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
6475 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6476 "$P_CLI force_version=tls1_2 \
6477 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6478 0 \
6479 -c "Read from server: 1 bytes read"
6480
6481requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6482run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6483 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6484 "$P_CLI force_version=tls1_2 \
6485 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6486 0 \
6487 -c "Read from server: 1 bytes read"
6488
6489run_test "Small server packet TLS 1.2 AEAD" \
6490 "$P_SRV response_size=1" \
6491 "$P_CLI force_version=tls1_2 \
6492 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6493 0 \
6494 -c "Read from server: 1 bytes read"
6495
6496run_test "Small server packet TLS 1.2 AEAD shorter tag" \
6497 "$P_SRV response_size=1" \
6498 "$P_CLI force_version=tls1_2 \
6499 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6500 0 \
6501 -c "Read from server: 1 bytes read"
6502
6503# Tests for small server packets in DTLS
6504
6505requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6506run_test "Small server packet DTLS 1.0" \
6507 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
6508 "$P_CLI dtls=1 \
6509 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6510 0 \
6511 -c "Read from server: 1 bytes read"
6512
6513requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6514run_test "Small server packet DTLS 1.0, without EtM" \
6515 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
6516 "$P_CLI dtls=1 \
6517 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6518 0 \
6519 -c "Read from server: 1 bytes read"
6520
6521requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6522requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6523run_test "Small server packet DTLS 1.0, truncated hmac" \
6524 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
6525 "$P_CLI dtls=1 trunc_hmac=1 \
6526 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6527 0 \
6528 -c "Read from server: 1 bytes read"
6529
6530requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6531requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6532run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
6533 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
6534 "$P_CLI dtls=1 \
6535 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
6536 0 \
6537 -c "Read from server: 1 bytes read"
6538
6539requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6540run_test "Small server packet DTLS 1.2" \
6541 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
6542 "$P_CLI dtls=1 \
6543 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6544 0 \
6545 -c "Read from server: 1 bytes read"
6546
6547requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6548run_test "Small server packet DTLS 1.2, without EtM" \
6549 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
6550 "$P_CLI dtls=1 \
6551 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6552 0 \
6553 -c "Read from server: 1 bytes read"
6554
6555requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6556requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6557run_test "Small server packet DTLS 1.2, truncated hmac" \
6558 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
6559 "$P_CLI dtls=1 \
6560 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6561 0 \
6562 -c "Read from server: 1 bytes read"
6563
6564requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6565requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6566run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
6567 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
6568 "$P_CLI dtls=1 \
6569 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
6570 0 \
6571 -c "Read from server: 1 bytes read"
6572
Janos Follath00efff72016-05-06 13:48:23 +01006573# A test for extensions in SSLv3
6574
6575requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6576run_test "SSLv3 with extensions, server side" \
6577 "$P_SRV min_version=ssl3 debug_level=3" \
6578 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
6579 0 \
6580 -S "dumping 'client hello extensions'" \
6581 -S "server hello, total extension length:"
6582
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006583# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006584
Angus Grattonc4dd0732018-04-11 16:28:39 +10006585# How many fragments do we expect to write $1 bytes?
6586fragments_for_write() {
6587 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
6588}
6589
Janos Follathe2681a42016-03-07 15:57:05 +00006590requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006591run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01006592 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006593 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006594 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6595 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006596 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6597 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006598
Janos Follathe2681a42016-03-07 15:57:05 +00006599requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006600run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006601 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006602 "$P_CLI request_size=16384 force_version=ssl3 \
6603 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6604 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006605 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6606 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006607
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006608run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006609 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006610 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006611 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6612 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006613 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6614 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006615
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006616run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006617 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006618 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
6619 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6620 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006621 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006622
Hanno Becker32c55012017-11-10 08:42:54 +00006623requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006624run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006625 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006626 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006627 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006628 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006629 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6630 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006631
Hanno Becker32c55012017-11-10 08:42:54 +00006632requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006633run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006634 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006635 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006636 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006637 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006638 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006639
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006640run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006641 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006642 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006643 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6644 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006645 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006646
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006647run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006648 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6649 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006650 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006651 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006652 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006653
6654requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006655run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006656 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006657 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006658 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006659 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006660 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006661
Hanno Becker278fc7a2017-11-10 09:16:28 +00006662requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006663run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006664 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006665 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006666 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006667 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006668 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6669 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006670
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006671run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006672 "$P_SRV" \
6673 "$P_CLI request_size=16384 force_version=tls1_1 \
6674 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6675 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006676 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6677 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006678
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006679run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006680 "$P_SRV" \
6681 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6682 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006683 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006684 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006685
Hanno Becker32c55012017-11-10 08:42:54 +00006686requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006687run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006688 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006689 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006690 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006691 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006692 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006693
Hanno Becker32c55012017-11-10 08:42:54 +00006694requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006695run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006696 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006697 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006698 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006699 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006700 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006701
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006702run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006703 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6704 "$P_CLI request_size=16384 force_version=tls1_1 \
6705 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6706 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006707 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6708 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006709
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006710run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006711 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006712 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006713 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006714 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006715 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6716 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006717
Hanno Becker278fc7a2017-11-10 09:16:28 +00006718requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006719run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006720 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006721 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006722 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006723 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006724 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006725
Hanno Becker278fc7a2017-11-10 09:16:28 +00006726requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006727run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006728 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006729 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006730 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006731 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006732 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6733 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006734
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006735run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006736 "$P_SRV" \
6737 "$P_CLI request_size=16384 force_version=tls1_2 \
6738 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6739 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006740 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6741 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006742
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006743run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006744 "$P_SRV" \
6745 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6746 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6747 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006748 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006749
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006750run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006751 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006752 "$P_CLI request_size=16384 force_version=tls1_2 \
6753 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006754 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006755 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6756 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006757
Hanno Becker32c55012017-11-10 08:42:54 +00006758requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006759run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006760 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006761 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006762 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006763 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006764 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006765
Hanno Becker278fc7a2017-11-10 09:16:28 +00006766requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006767run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006768 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006769 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006770 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006771 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006772 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6773 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006774
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006775run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006776 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006777 "$P_CLI request_size=16384 force_version=tls1_2 \
6778 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6779 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006780 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6781 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006782
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006783run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006784 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006785 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006786 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6787 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006788 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006789
Hanno Becker32c55012017-11-10 08:42:54 +00006790requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006791run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006792 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006793 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006794 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006795 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006796 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006797
Hanno Becker278fc7a2017-11-10 09:16:28 +00006798requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006799run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006800 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006801 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006802 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006803 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006804 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6805 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006806
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006807run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006808 "$P_SRV" \
6809 "$P_CLI request_size=16384 force_version=tls1_2 \
6810 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6811 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006812 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6813 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006814
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006815run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006816 "$P_SRV" \
6817 "$P_CLI request_size=16384 force_version=tls1_2 \
6818 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6819 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006820 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6821 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006822
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006823# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006824requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6825run_test "Large server packet SSLv3 StreamCipher" \
6826 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6827 "$P_CLI force_version=ssl3 \
6828 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6829 0 \
6830 -c "Read from server: 16384 bytes read"
6831
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006832# Checking next 4 tests logs for 1n-1 split against BEAST too
6833requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6834run_test "Large server packet SSLv3 BlockCipher" \
6835 "$P_SRV response_size=16384 min_version=ssl3" \
6836 "$P_CLI force_version=ssl3 recsplit=0 \
6837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6838 0 \
6839 -c "Read from server: 1 bytes read"\
6840 -c "16383 bytes read"\
6841 -C "Read from server: 16384 bytes read"
6842
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006843run_test "Large server packet TLS 1.0 BlockCipher" \
6844 "$P_SRV response_size=16384" \
6845 "$P_CLI force_version=tls1 recsplit=0 \
6846 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6847 0 \
6848 -c "Read from server: 1 bytes read"\
6849 -c "16383 bytes read"\
6850 -C "Read from server: 16384 bytes read"
6851
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006852run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6853 "$P_SRV response_size=16384" \
6854 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6855 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6856 0 \
6857 -c "Read from server: 1 bytes read"\
6858 -c "16383 bytes read"\
6859 -C "Read from server: 16384 bytes read"
6860
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006861requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6862run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6863 "$P_SRV response_size=16384" \
6864 "$P_CLI force_version=tls1 recsplit=0 \
6865 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6866 trunc_hmac=1" \
6867 0 \
6868 -c "Read from server: 1 bytes read"\
6869 -c "16383 bytes read"\
6870 -C "Read from server: 16384 bytes read"
6871
6872requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6873run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6874 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6875 "$P_CLI force_version=tls1 \
6876 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6877 trunc_hmac=1" \
6878 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006879 -s "16384 bytes written in 1 fragments" \
6880 -c "Read from server: 16384 bytes read"
6881
6882run_test "Large server packet TLS 1.0 StreamCipher" \
6883 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6884 "$P_CLI force_version=tls1 \
6885 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6886 0 \
6887 -s "16384 bytes written in 1 fragments" \
6888 -c "Read from server: 16384 bytes read"
6889
6890run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6891 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6892 "$P_CLI force_version=tls1 \
6893 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6894 0 \
6895 -s "16384 bytes written in 1 fragments" \
6896 -c "Read from server: 16384 bytes read"
6897
6898requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6899run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6900 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6901 "$P_CLI force_version=tls1 \
6902 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6903 0 \
6904 -s "16384 bytes written in 1 fragments" \
6905 -c "Read from server: 16384 bytes read"
6906
6907requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6908run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6909 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6910 "$P_CLI force_version=tls1 \
6911 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6912 0 \
6913 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006914 -c "Read from server: 16384 bytes read"
6915
6916run_test "Large server packet TLS 1.1 BlockCipher" \
6917 "$P_SRV response_size=16384" \
6918 "$P_CLI force_version=tls1_1 \
6919 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6920 0 \
6921 -c "Read from server: 16384 bytes read"
6922
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006923run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6924 "$P_SRV response_size=16384" \
6925 "$P_CLI force_version=tls1_1 etm=0 \
6926 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006927 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006928 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006929 -c "Read from server: 16384 bytes read"
6930
6931requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6932run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6933 "$P_SRV response_size=16384" \
6934 "$P_CLI force_version=tls1_1 \
6935 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6936 trunc_hmac=1" \
6937 0 \
6938 -c "Read from server: 16384 bytes read"
6939
6940requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006941run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6942 "$P_SRV response_size=16384 trunc_hmac=1" \
6943 "$P_CLI force_version=tls1_1 \
6944 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6945 0 \
6946 -s "16384 bytes written in 1 fragments" \
6947 -c "Read from server: 16384 bytes read"
6948
6949run_test "Large server packet TLS 1.1 StreamCipher" \
6950 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6951 "$P_CLI force_version=tls1_1 \
6952 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6953 0 \
6954 -c "Read from server: 16384 bytes read"
6955
6956run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6957 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6958 "$P_CLI force_version=tls1_1 \
6959 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6960 0 \
6961 -s "16384 bytes written in 1 fragments" \
6962 -c "Read from server: 16384 bytes read"
6963
6964requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006965run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6966 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6967 "$P_CLI force_version=tls1_1 \
6968 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6969 trunc_hmac=1" \
6970 0 \
6971 -c "Read from server: 16384 bytes read"
6972
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006973run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6974 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6975 "$P_CLI force_version=tls1_1 \
6976 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6977 0 \
6978 -s "16384 bytes written in 1 fragments" \
6979 -c "Read from server: 16384 bytes read"
6980
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006981run_test "Large server packet TLS 1.2 BlockCipher" \
6982 "$P_SRV response_size=16384" \
6983 "$P_CLI force_version=tls1_2 \
6984 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6985 0 \
6986 -c "Read from server: 16384 bytes read"
6987
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006988run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6989 "$P_SRV response_size=16384" \
6990 "$P_CLI force_version=tls1_2 etm=0 \
6991 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6992 0 \
6993 -s "16384 bytes written in 1 fragments" \
6994 -c "Read from server: 16384 bytes read"
6995
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006996run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6997 "$P_SRV response_size=16384" \
6998 "$P_CLI force_version=tls1_2 \
6999 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
7000 0 \
7001 -c "Read from server: 16384 bytes read"
7002
7003requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
7004run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
7005 "$P_SRV response_size=16384" \
7006 "$P_CLI force_version=tls1_2 \
7007 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
7008 trunc_hmac=1" \
7009 0 \
7010 -c "Read from server: 16384 bytes read"
7011
Andrzej Kurekc19fc552018-06-19 09:37:30 -04007012run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
7013 "$P_SRV response_size=16384 trunc_hmac=1" \
7014 "$P_CLI force_version=tls1_2 \
7015 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
7016 0 \
7017 -s "16384 bytes written in 1 fragments" \
7018 -c "Read from server: 16384 bytes read"
7019
Andrzej Kurek30e731d2017-10-12 13:50:29 +02007020run_test "Large server packet TLS 1.2 StreamCipher" \
7021 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
7022 "$P_CLI force_version=tls1_2 \
7023 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
7024 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04007025 -s "16384 bytes written in 1 fragments" \
7026 -c "Read from server: 16384 bytes read"
7027
7028run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
7029 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
7030 "$P_CLI force_version=tls1_2 \
7031 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
7032 0 \
7033 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02007034 -c "Read from server: 16384 bytes read"
7035
7036requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
7037run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
7038 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
7039 "$P_CLI force_version=tls1_2 \
7040 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
7041 trunc_hmac=1" \
7042 0 \
7043 -c "Read from server: 16384 bytes read"
7044
Andrzej Kurekc19fc552018-06-19 09:37:30 -04007045requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
7046run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
7047 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
7048 "$P_CLI force_version=tls1_2 \
7049 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
7050 0 \
7051 -s "16384 bytes written in 1 fragments" \
7052 -c "Read from server: 16384 bytes read"
7053
Andrzej Kurek30e731d2017-10-12 13:50:29 +02007054run_test "Large server packet TLS 1.2 AEAD" \
7055 "$P_SRV response_size=16384" \
7056 "$P_CLI force_version=tls1_2 \
7057 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
7058 0 \
7059 -c "Read from server: 16384 bytes read"
7060
7061run_test "Large server packet TLS 1.2 AEAD shorter tag" \
7062 "$P_SRV response_size=16384" \
7063 "$P_CLI force_version=tls1_2 \
7064 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
7065 0 \
7066 -c "Read from server: 16384 bytes read"
7067
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007068# Tests for restartable ECC
7069
7070requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7071run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007072 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007073 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007074 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007075 debug_level=1" \
7076 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007077 -C "x509_verify_cert.*4b00" \
7078 -C "mbedtls_pk_verify.*4b00" \
7079 -C "mbedtls_ecdh_make_public.*4b00" \
7080 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007081
7082requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7083run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007084 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007085 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007086 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007087 debug_level=1 ec_max_ops=0" \
7088 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007089 -C "x509_verify_cert.*4b00" \
7090 -C "mbedtls_pk_verify.*4b00" \
7091 -C "mbedtls_ecdh_make_public.*4b00" \
7092 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007093
7094requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7095run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007096 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007097 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007098 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007099 debug_level=1 ec_max_ops=65535" \
7100 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007101 -C "x509_verify_cert.*4b00" \
7102 -C "mbedtls_pk_verify.*4b00" \
7103 -C "mbedtls_ecdh_make_public.*4b00" \
7104 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007105
7106requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7107run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007108 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007109 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007110 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007111 debug_level=1 ec_max_ops=1000" \
7112 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007113 -c "x509_verify_cert.*4b00" \
7114 -c "mbedtls_pk_verify.*4b00" \
7115 -c "mbedtls_ecdh_make_public.*4b00" \
7116 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007117
7118requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007119run_test "EC restart: TLS, max_ops=1000, badsign" \
7120 "$P_SRV auth_mode=required \
7121 crt_file=data_files/server5-badsign.crt \
7122 key_file=data_files/server5.key" \
7123 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7124 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7125 debug_level=1 ec_max_ops=1000" \
7126 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007127 -c "x509_verify_cert.*4b00" \
7128 -C "mbedtls_pk_verify.*4b00" \
7129 -C "mbedtls_ecdh_make_public.*4b00" \
7130 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007131 -c "! The certificate is not correctly signed by the trusted CA" \
7132 -c "! mbedtls_ssl_handshake returned" \
7133 -c "X509 - Certificate verification failed"
7134
7135requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7136run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
7137 "$P_SRV auth_mode=required \
7138 crt_file=data_files/server5-badsign.crt \
7139 key_file=data_files/server5.key" \
7140 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7141 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7142 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
7143 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007144 -c "x509_verify_cert.*4b00" \
7145 -c "mbedtls_pk_verify.*4b00" \
7146 -c "mbedtls_ecdh_make_public.*4b00" \
7147 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007148 -c "! The certificate is not correctly signed by the trusted CA" \
7149 -C "! mbedtls_ssl_handshake returned" \
7150 -C "X509 - Certificate verification failed"
7151
7152requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7153run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
7154 "$P_SRV auth_mode=required \
7155 crt_file=data_files/server5-badsign.crt \
7156 key_file=data_files/server5.key" \
7157 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7158 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7159 debug_level=1 ec_max_ops=1000 auth_mode=none" \
7160 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007161 -C "x509_verify_cert.*4b00" \
7162 -c "mbedtls_pk_verify.*4b00" \
7163 -c "mbedtls_ecdh_make_public.*4b00" \
7164 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007165 -C "! The certificate is not correctly signed by the trusted CA" \
7166 -C "! mbedtls_ssl_handshake returned" \
7167 -C "X509 - Certificate verification failed"
7168
7169requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007170run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007171 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007172 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007173 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007174 dtls=1 debug_level=1 ec_max_ops=1000" \
7175 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007176 -c "x509_verify_cert.*4b00" \
7177 -c "mbedtls_pk_verify.*4b00" \
7178 -c "mbedtls_ecdh_make_public.*4b00" \
7179 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007180
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007181requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7182run_test "EC restart: TLS, max_ops=1000 no client auth" \
7183 "$P_SRV" \
7184 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7185 debug_level=1 ec_max_ops=1000" \
7186 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007187 -c "x509_verify_cert.*4b00" \
7188 -c "mbedtls_pk_verify.*4b00" \
7189 -c "mbedtls_ecdh_make_public.*4b00" \
7190 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007191
7192requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7193run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
7194 "$P_SRV psk=abc123" \
7195 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
7196 psk=abc123 debug_level=1 ec_max_ops=1000" \
7197 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007198 -C "x509_verify_cert.*4b00" \
7199 -C "mbedtls_pk_verify.*4b00" \
7200 -C "mbedtls_ecdh_make_public.*4b00" \
7201 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007202
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007203# Tests of asynchronous private key support in SSL
7204
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007205requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007206run_test "SSL async private: sign, delay=0" \
7207 "$P_SRV \
7208 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007209 "$P_CLI" \
7210 0 \
7211 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007212 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007213
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007214requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007215run_test "SSL async private: sign, delay=1" \
7216 "$P_SRV \
7217 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007218 "$P_CLI" \
7219 0 \
7220 -s "Async sign callback: using key slot " \
7221 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007222 -s "Async resume (slot [0-9]): sign done, status=0"
7223
Gilles Peskine12d0cc12018-04-26 15:06:56 +02007224requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7225run_test "SSL async private: sign, delay=2" \
7226 "$P_SRV \
7227 async_operations=s async_private_delay1=2 async_private_delay2=2" \
7228 "$P_CLI" \
7229 0 \
7230 -s "Async sign callback: using key slot " \
7231 -U "Async sign callback: using key slot " \
7232 -s "Async resume (slot [0-9]): call 1 more times." \
7233 -s "Async resume (slot [0-9]): call 0 more times." \
7234 -s "Async resume (slot [0-9]): sign done, status=0"
7235
Gilles Peskined3268832018-04-26 06:23:59 +02007236# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
7237# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
7238requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7239requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7240run_test "SSL async private: sign, RSA, TLS 1.1" \
7241 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
7242 async_operations=s async_private_delay1=0 async_private_delay2=0" \
7243 "$P_CLI force_version=tls1_1" \
7244 0 \
7245 -s "Async sign callback: using key slot " \
7246 -s "Async resume (slot [0-9]): sign done, status=0"
7247
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007248requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02007249run_test "SSL async private: sign, SNI" \
7250 "$P_SRV debug_level=3 \
7251 async_operations=s async_private_delay1=0 async_private_delay2=0 \
7252 crt_file=data_files/server5.crt key_file=data_files/server5.key \
7253 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
7254 "$P_CLI server_name=polarssl.example" \
7255 0 \
7256 -s "Async sign callback: using key slot " \
7257 -s "Async resume (slot [0-9]): sign done, status=0" \
7258 -s "parse ServerName extension" \
7259 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
7260 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
7261
7262requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007263run_test "SSL async private: decrypt, delay=0" \
7264 "$P_SRV \
7265 async_operations=d async_private_delay1=0 async_private_delay2=0" \
7266 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7267 0 \
7268 -s "Async decrypt callback: using key slot " \
7269 -s "Async resume (slot [0-9]): decrypt done, status=0"
7270
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007271requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007272run_test "SSL async private: decrypt, delay=1" \
7273 "$P_SRV \
7274 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7275 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7276 0 \
7277 -s "Async decrypt callback: using key slot " \
7278 -s "Async resume (slot [0-9]): call 0 more times." \
7279 -s "Async resume (slot [0-9]): decrypt done, status=0"
7280
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007281requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007282run_test "SSL async private: decrypt RSA-PSK, delay=0" \
7283 "$P_SRV psk=abc123 \
7284 async_operations=d async_private_delay1=0 async_private_delay2=0" \
7285 "$P_CLI psk=abc123 \
7286 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
7287 0 \
7288 -s "Async decrypt callback: using key slot " \
7289 -s "Async resume (slot [0-9]): decrypt done, status=0"
7290
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007291requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007292run_test "SSL async private: decrypt RSA-PSK, delay=1" \
7293 "$P_SRV psk=abc123 \
7294 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7295 "$P_CLI psk=abc123 \
7296 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
7297 0 \
7298 -s "Async decrypt callback: using key slot " \
7299 -s "Async resume (slot [0-9]): call 0 more times." \
7300 -s "Async resume (slot [0-9]): decrypt done, status=0"
7301
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007302requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007303run_test "SSL async private: sign callback not present" \
7304 "$P_SRV \
7305 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7306 "$P_CLI; [ \$? -eq 1 ] &&
7307 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7308 0 \
7309 -S "Async sign callback" \
7310 -s "! mbedtls_ssl_handshake returned" \
7311 -s "The own private key or pre-shared key is not set, but needed" \
7312 -s "Async resume (slot [0-9]): decrypt done, status=0" \
7313 -s "Successful connection"
7314
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007315requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007316run_test "SSL async private: decrypt callback not present" \
7317 "$P_SRV debug_level=1 \
7318 async_operations=s async_private_delay1=1 async_private_delay2=1" \
7319 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
7320 [ \$? -eq 1 ] && $P_CLI" \
7321 0 \
7322 -S "Async decrypt callback" \
7323 -s "! mbedtls_ssl_handshake returned" \
7324 -s "got no RSA private key" \
7325 -s "Async resume (slot [0-9]): sign done, status=0" \
7326 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007327
7328# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007329requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007330run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007331 "$P_SRV \
7332 async_operations=s async_private_delay1=1 \
7333 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7334 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007335 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7336 0 \
7337 -s "Async sign callback: using key slot 0," \
7338 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007339 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007340
7341# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007342requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007343run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007344 "$P_SRV \
7345 async_operations=s async_private_delay2=1 \
7346 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7347 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007348 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7349 0 \
7350 -s "Async sign callback: using key slot 0," \
7351 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007352 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007353
7354# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007355requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02007356run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007357 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02007358 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007359 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7360 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007361 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7362 0 \
7363 -s "Async sign callback: using key slot 1," \
7364 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007365 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007366
7367# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007368requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007369run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007370 "$P_SRV \
7371 async_operations=s async_private_delay1=1 \
7372 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7373 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007374 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7375 0 \
7376 -s "Async sign callback: no key matches this certificate."
7377
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007378requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007379run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007380 "$P_SRV \
7381 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7382 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007383 "$P_CLI" \
7384 1 \
7385 -s "Async sign callback: injected error" \
7386 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02007387 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007388 -s "! mbedtls_ssl_handshake returned"
7389
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007390requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007391run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007392 "$P_SRV \
7393 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7394 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007395 "$P_CLI" \
7396 1 \
7397 -s "Async sign callback: using key slot " \
7398 -S "Async resume" \
7399 -s "Async cancel"
7400
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007401requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007402run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007403 "$P_SRV \
7404 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7405 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007406 "$P_CLI" \
7407 1 \
7408 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007409 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02007410 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007411 -s "! mbedtls_ssl_handshake returned"
7412
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007413requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007414run_test "SSL async private: decrypt, error in start" \
7415 "$P_SRV \
7416 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7417 async_private_error=1" \
7418 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7419 1 \
7420 -s "Async decrypt callback: injected error" \
7421 -S "Async resume" \
7422 -S "Async cancel" \
7423 -s "! mbedtls_ssl_handshake returned"
7424
7425requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7426run_test "SSL async private: decrypt, cancel after start" \
7427 "$P_SRV \
7428 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7429 async_private_error=2" \
7430 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7431 1 \
7432 -s "Async decrypt callback: using key slot " \
7433 -S "Async resume" \
7434 -s "Async cancel"
7435
7436requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7437run_test "SSL async private: decrypt, error in resume" \
7438 "$P_SRV \
7439 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7440 async_private_error=3" \
7441 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7442 1 \
7443 -s "Async decrypt callback: using key slot " \
7444 -s "Async resume callback: decrypt done but injected error" \
7445 -S "Async cancel" \
7446 -s "! mbedtls_ssl_handshake returned"
7447
7448requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007449run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007450 "$P_SRV \
7451 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7452 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007453 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
7454 0 \
7455 -s "Async cancel" \
7456 -s "! mbedtls_ssl_handshake returned" \
7457 -s "Async resume" \
7458 -s "Successful connection"
7459
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007460requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007461run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007462 "$P_SRV \
7463 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7464 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007465 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
7466 0 \
7467 -s "! mbedtls_ssl_handshake returned" \
7468 -s "Async resume" \
7469 -s "Successful connection"
7470
7471# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007472requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007473run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007474 "$P_SRV \
7475 async_operations=s async_private_delay1=1 async_private_error=-2 \
7476 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7477 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007478 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
7479 [ \$? -eq 1 ] &&
7480 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7481 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02007482 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007483 -S "Async resume" \
7484 -s "Async cancel" \
7485 -s "! mbedtls_ssl_handshake returned" \
7486 -s "Async sign callback: no key matches this certificate." \
7487 -s "Successful connection"
7488
7489# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007490requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007491run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007492 "$P_SRV \
7493 async_operations=s async_private_delay1=1 async_private_error=-3 \
7494 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7495 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007496 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
7497 [ \$? -eq 1 ] &&
7498 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7499 0 \
7500 -s "Async resume" \
7501 -s "! mbedtls_ssl_handshake returned" \
7502 -s "Async sign callback: no key matches this certificate." \
7503 -s "Successful connection"
7504
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007505requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007506requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007507run_test "SSL async private: renegotiation: client-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007508 "$P_SRV \
7509 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007510 exchanges=2 renegotiation=1" \
7511 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
7512 0 \
7513 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007514 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007515
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007516requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007517requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007518run_test "SSL async private: renegotiation: server-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007519 "$P_SRV \
7520 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007521 exchanges=2 renegotiation=1 renegotiate=1" \
7522 "$P_CLI exchanges=2 renegotiation=1" \
7523 0 \
7524 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007525 -s "Async resume (slot [0-9]): sign done, status=0"
7526
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007527requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007528requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007529run_test "SSL async private: renegotiation: client-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007530 "$P_SRV \
7531 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7532 exchanges=2 renegotiation=1" \
7533 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
7534 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7535 0 \
7536 -s "Async decrypt callback: using key slot " \
7537 -s "Async resume (slot [0-9]): decrypt done, status=0"
7538
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007539requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007540requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007541run_test "SSL async private: renegotiation: server-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007542 "$P_SRV \
7543 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7544 exchanges=2 renegotiation=1 renegotiate=1" \
7545 "$P_CLI exchanges=2 renegotiation=1 \
7546 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7547 0 \
7548 -s "Async decrypt callback: using key slot " \
7549 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007550
Ron Eldor58093c82018-06-28 13:22:05 +03007551# Tests for ECC extensions (rfc 4492)
7552
Ron Eldor643df7c2018-06-28 16:17:00 +03007553requires_config_enabled MBEDTLS_AES_C
7554requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7555requires_config_enabled MBEDTLS_SHA256_C
7556requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007557run_test "Force a non ECC ciphersuite in the client side" \
7558 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03007559 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03007560 0 \
7561 -C "client hello, adding supported_elliptic_curves extension" \
7562 -C "client hello, adding supported_point_formats extension" \
7563 -S "found supported elliptic curves extension" \
7564 -S "found supported point formats extension"
7565
Ron Eldor643df7c2018-06-28 16:17:00 +03007566requires_config_enabled MBEDTLS_AES_C
7567requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7568requires_config_enabled MBEDTLS_SHA256_C
7569requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007570run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03007571 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03007572 "$P_CLI debug_level=3" \
7573 0 \
7574 -C "found supported_point_formats extension" \
7575 -S "server hello, supported_point_formats extension"
7576
Ron Eldor643df7c2018-06-28 16:17:00 +03007577requires_config_enabled MBEDTLS_AES_C
7578requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7579requires_config_enabled MBEDTLS_SHA256_C
7580requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007581run_test "Force an ECC ciphersuite in the client side" \
7582 "$P_SRV debug_level=3" \
7583 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7584 0 \
7585 -c "client hello, adding supported_elliptic_curves extension" \
7586 -c "client hello, adding supported_point_formats extension" \
7587 -s "found supported elliptic curves extension" \
7588 -s "found supported point formats extension"
7589
Ron Eldor643df7c2018-06-28 16:17:00 +03007590requires_config_enabled MBEDTLS_AES_C
7591requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7592requires_config_enabled MBEDTLS_SHA256_C
7593requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007594run_test "Force an ECC ciphersuite in the server side" \
7595 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7596 "$P_CLI debug_level=3" \
7597 0 \
7598 -c "found supported_point_formats extension" \
7599 -s "server hello, supported_point_formats extension"
7600
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007601# Tests for DTLS HelloVerifyRequest
7602
7603run_test "DTLS cookie: enabled" \
7604 "$P_SRV dtls=1 debug_level=2" \
7605 "$P_CLI dtls=1 debug_level=2" \
7606 0 \
7607 -s "cookie verification failed" \
7608 -s "cookie verification passed" \
7609 -S "cookie verification skipped" \
7610 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007611 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007612 -S "SSL - The requested feature is not available"
7613
7614run_test "DTLS cookie: disabled" \
7615 "$P_SRV dtls=1 debug_level=2 cookies=0" \
7616 "$P_CLI dtls=1 debug_level=2" \
7617 0 \
7618 -S "cookie verification failed" \
7619 -S "cookie verification passed" \
7620 -s "cookie verification skipped" \
7621 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007622 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007623 -S "SSL - The requested feature is not available"
7624
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007625run_test "DTLS cookie: default (failing)" \
7626 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
7627 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
7628 1 \
7629 -s "cookie verification failed" \
7630 -S "cookie verification passed" \
7631 -S "cookie verification skipped" \
7632 -C "received hello verify request" \
7633 -S "hello verification requested" \
7634 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007635
7636requires_ipv6
7637run_test "DTLS cookie: enabled, IPv6" \
7638 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
7639 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
7640 0 \
7641 -s "cookie verification failed" \
7642 -s "cookie verification passed" \
7643 -S "cookie verification skipped" \
7644 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007645 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007646 -S "SSL - The requested feature is not available"
7647
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007648run_test "DTLS cookie: enabled, nbio" \
7649 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7650 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7651 0 \
7652 -s "cookie verification failed" \
7653 -s "cookie verification passed" \
7654 -S "cookie verification skipped" \
7655 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007656 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007657 -S "SSL - The requested feature is not available"
7658
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007659# Tests for client reconnecting from the same port with DTLS
7660
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007661not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007662run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007663 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7664 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007665 0 \
7666 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007667 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007668 -S "Client initiated reconnection from same port"
7669
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007670not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007671run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007672 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7673 "$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 +02007674 0 \
7675 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007676 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007677 -s "Client initiated reconnection from same port"
7678
Paul Bakker362689d2016-05-13 10:33:25 +01007679not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
7680run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007681 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7682 "$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 +02007683 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007684 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007685 -s "Client initiated reconnection from same port"
7686
Paul Bakker362689d2016-05-13 10:33:25 +01007687only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
7688run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7689 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7690 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7691 0 \
7692 -S "The operation timed out" \
7693 -s "Client initiated reconnection from same port"
7694
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007695run_test "DTLS client reconnect from same port: no cookies" \
7696 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007697 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7698 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007699 -s "The operation timed out" \
7700 -S "Client initiated reconnection from same port"
7701
Manuel Pégourié-Gonnardbaad2de2020-03-13 11:11:02 +01007702run_test "DTLS client reconnect from same port: attacker-injected" \
7703 -p "$P_PXY inject_clihlo=1" \
7704 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
7705 "$P_CLI dtls=1 exchanges=2" \
7706 0 \
7707 -s "possible client reconnect from the same port" \
7708 -S "Client initiated reconnection from same port"
7709
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007710# Tests for various cases of client authentication with DTLS
7711# (focused on handshake flows and message parsing)
7712
7713run_test "DTLS client auth: required" \
7714 "$P_SRV dtls=1 auth_mode=required" \
7715 "$P_CLI dtls=1" \
7716 0 \
7717 -s "Verifying peer X.509 certificate... ok"
7718
7719run_test "DTLS client auth: optional, client has no cert" \
7720 "$P_SRV dtls=1 auth_mode=optional" \
7721 "$P_CLI dtls=1 crt_file=none key_file=none" \
7722 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007723 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007724
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007725run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007726 "$P_SRV dtls=1 auth_mode=none" \
7727 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7728 0 \
7729 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007730 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007731
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007732run_test "DTLS wrong PSK: badmac alert" \
7733 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7734 "$P_CLI dtls=1 psk=abc124" \
7735 1 \
7736 -s "SSL - Verification of the message MAC failed" \
7737 -c "SSL - A fatal alert message was received from our peer"
7738
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007739# Tests for receiving fragmented handshake messages with DTLS
7740
7741requires_gnutls
7742run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7743 "$G_SRV -u --mtu 2048 -a" \
7744 "$P_CLI dtls=1 debug_level=2" \
7745 0 \
7746 -C "found fragmented DTLS handshake message" \
7747 -C "error"
7748
7749requires_gnutls
7750run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7751 "$G_SRV -u --mtu 512" \
7752 "$P_CLI dtls=1 debug_level=2" \
7753 0 \
7754 -c "found fragmented DTLS handshake message" \
7755 -C "error"
7756
7757requires_gnutls
7758run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7759 "$G_SRV -u --mtu 128" \
7760 "$P_CLI dtls=1 debug_level=2" \
7761 0 \
7762 -c "found fragmented DTLS handshake message" \
7763 -C "error"
7764
7765requires_gnutls
7766run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7767 "$G_SRV -u --mtu 128" \
7768 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7769 0 \
7770 -c "found fragmented DTLS handshake message" \
7771 -C "error"
7772
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007773requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007774requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007775run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7776 "$G_SRV -u --mtu 256" \
7777 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
7778 0 \
7779 -c "found fragmented DTLS handshake message" \
7780 -c "client hello, adding renegotiation extension" \
7781 -c "found renegotiation extension" \
7782 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007783 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007784 -C "error" \
7785 -s "Extra-header:"
7786
7787requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007788requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007789run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7790 "$G_SRV -u --mtu 256" \
7791 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
7792 0 \
7793 -c "found fragmented DTLS handshake message" \
7794 -c "client hello, adding renegotiation extension" \
7795 -c "found renegotiation extension" \
7796 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007797 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007798 -C "error" \
7799 -s "Extra-header:"
7800
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007801run_test "DTLS reassembly: no fragmentation (openssl server)" \
7802 "$O_SRV -dtls1 -mtu 2048" \
7803 "$P_CLI dtls=1 debug_level=2" \
7804 0 \
7805 -C "found fragmented DTLS handshake message" \
7806 -C "error"
7807
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007808run_test "DTLS reassembly: some fragmentation (openssl server)" \
7809 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007810 "$P_CLI dtls=1 debug_level=2" \
7811 0 \
7812 -c "found fragmented DTLS handshake message" \
7813 -C "error"
7814
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007815run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007816 "$O_SRV -dtls1 -mtu 256" \
7817 "$P_CLI dtls=1 debug_level=2" \
7818 0 \
7819 -c "found fragmented DTLS handshake message" \
7820 -C "error"
7821
7822run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7823 "$O_SRV -dtls1 -mtu 256" \
7824 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7825 0 \
7826 -c "found fragmented DTLS handshake message" \
7827 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007828
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007829# Tests for sending fragmented handshake messages with DTLS
7830#
7831# Use client auth when we need the client to send large messages,
7832# and use large cert chains on both sides too (the long chains we have all use
7833# both RSA and ECDSA, but ideally we should have long chains with either).
7834# Sizes reached (UDP payload):
7835# - 2037B for server certificate
7836# - 1542B for client certificate
7837# - 1013B for newsessionticket
7838# - all others below 512B
7839# All those tests assume MAX_CONTENT_LEN is at least 2048
7840
7841requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7842requires_config_enabled MBEDTLS_RSA_C
7843requires_config_enabled MBEDTLS_ECDSA_C
7844requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7845run_test "DTLS fragmenting: none (for reference)" \
7846 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7847 crt_file=data_files/server7_int-ca.crt \
7848 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007849 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007850 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007851 "$P_CLI dtls=1 debug_level=2 \
7852 crt_file=data_files/server8_int-ca2.crt \
7853 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007854 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007855 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007856 0 \
7857 -S "found fragmented DTLS handshake message" \
7858 -C "found fragmented DTLS handshake message" \
7859 -C "error"
7860
7861requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7862requires_config_enabled MBEDTLS_RSA_C
7863requires_config_enabled MBEDTLS_ECDSA_C
7864requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007865run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007866 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7867 crt_file=data_files/server7_int-ca.crt \
7868 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007869 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007870 max_frag_len=1024" \
7871 "$P_CLI dtls=1 debug_level=2 \
7872 crt_file=data_files/server8_int-ca2.crt \
7873 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007874 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007875 max_frag_len=2048" \
7876 0 \
7877 -S "found fragmented DTLS handshake message" \
7878 -c "found fragmented DTLS handshake message" \
7879 -C "error"
7880
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007881# With the MFL extension, the server has no way of forcing
7882# the client to not exceed a certain MTU; hence, the following
7883# test can't be replicated with an MTU proxy such as the one
7884# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007885requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7886requires_config_enabled MBEDTLS_RSA_C
7887requires_config_enabled MBEDTLS_ECDSA_C
7888requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007889run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007890 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7891 crt_file=data_files/server7_int-ca.crt \
7892 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007893 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007894 max_frag_len=512" \
7895 "$P_CLI dtls=1 debug_level=2 \
7896 crt_file=data_files/server8_int-ca2.crt \
7897 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007898 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007899 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007900 0 \
7901 -S "found fragmented DTLS handshake message" \
7902 -c "found fragmented DTLS handshake message" \
7903 -C "error"
7904
7905requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7906requires_config_enabled MBEDTLS_RSA_C
7907requires_config_enabled MBEDTLS_ECDSA_C
7908requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007909run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007910 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7911 crt_file=data_files/server7_int-ca.crt \
7912 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007913 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007914 max_frag_len=2048" \
7915 "$P_CLI dtls=1 debug_level=2 \
7916 crt_file=data_files/server8_int-ca2.crt \
7917 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007918 hs_timeout=2500-60000 \
7919 max_frag_len=1024" \
7920 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007921 -S "found fragmented DTLS handshake message" \
7922 -c "found fragmented DTLS handshake message" \
7923 -C "error"
7924
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007925# While not required by the standard defining the MFL extension
7926# (according to which it only applies to records, not to datagrams),
7927# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7928# as otherwise there wouldn't be any means to communicate MTU restrictions
7929# to the peer.
7930# The next test checks that no datagrams significantly larger than the
7931# negotiated MFL are sent.
7932requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7933requires_config_enabled MBEDTLS_RSA_C
7934requires_config_enabled MBEDTLS_ECDSA_C
7935requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7936run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007937 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007938 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7939 crt_file=data_files/server7_int-ca.crt \
7940 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007941 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007942 max_frag_len=2048" \
7943 "$P_CLI dtls=1 debug_level=2 \
7944 crt_file=data_files/server8_int-ca2.crt \
7945 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007946 hs_timeout=2500-60000 \
7947 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007948 0 \
7949 -S "found fragmented DTLS handshake message" \
7950 -c "found fragmented DTLS handshake message" \
7951 -C "error"
7952
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007953requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7954requires_config_enabled MBEDTLS_RSA_C
7955requires_config_enabled MBEDTLS_ECDSA_C
7956requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007957run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007958 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7959 crt_file=data_files/server7_int-ca.crt \
7960 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007961 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007962 max_frag_len=2048" \
7963 "$P_CLI dtls=1 debug_level=2 \
7964 crt_file=data_files/server8_int-ca2.crt \
7965 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007966 hs_timeout=2500-60000 \
7967 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007968 0 \
7969 -s "found fragmented DTLS handshake message" \
7970 -c "found fragmented DTLS handshake message" \
7971 -C "error"
7972
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007973# While not required by the standard defining the MFL extension
7974# (according to which it only applies to records, not to datagrams),
7975# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7976# as otherwise there wouldn't be any means to communicate MTU restrictions
7977# to the peer.
7978# The next test checks that no datagrams significantly larger than the
7979# negotiated MFL are sent.
7980requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7981requires_config_enabled MBEDTLS_RSA_C
7982requires_config_enabled MBEDTLS_ECDSA_C
7983requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7984run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007985 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007986 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7987 crt_file=data_files/server7_int-ca.crt \
7988 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007989 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007990 max_frag_len=2048" \
7991 "$P_CLI dtls=1 debug_level=2 \
7992 crt_file=data_files/server8_int-ca2.crt \
7993 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007994 hs_timeout=2500-60000 \
7995 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007996 0 \
7997 -s "found fragmented DTLS handshake message" \
7998 -c "found fragmented DTLS handshake message" \
7999 -C "error"
8000
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008001requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8002requires_config_enabled MBEDTLS_RSA_C
8003requires_config_enabled MBEDTLS_ECDSA_C
8004run_test "DTLS fragmenting: none (for reference) (MTU)" \
8005 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8006 crt_file=data_files/server7_int-ca.crt \
8007 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008008 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01008009 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008010 "$P_CLI dtls=1 debug_level=2 \
8011 crt_file=data_files/server8_int-ca2.crt \
8012 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008013 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01008014 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008015 0 \
8016 -S "found fragmented DTLS handshake message" \
8017 -C "found fragmented DTLS handshake message" \
8018 -C "error"
8019
8020requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8021requires_config_enabled MBEDTLS_RSA_C
8022requires_config_enabled MBEDTLS_ECDSA_C
8023run_test "DTLS fragmenting: client (MTU)" \
8024 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8025 crt_file=data_files/server7_int-ca.crt \
8026 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008027 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01008028 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008029 "$P_CLI dtls=1 debug_level=2 \
8030 crt_file=data_files/server8_int-ca2.crt \
8031 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008032 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008033 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008034 0 \
8035 -s "found fragmented DTLS handshake message" \
8036 -C "found fragmented DTLS handshake message" \
8037 -C "error"
8038
8039requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8040requires_config_enabled MBEDTLS_RSA_C
8041requires_config_enabled MBEDTLS_ECDSA_C
8042run_test "DTLS fragmenting: server (MTU)" \
8043 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8044 crt_file=data_files/server7_int-ca.crt \
8045 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008046 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008047 mtu=512" \
8048 "$P_CLI dtls=1 debug_level=2 \
8049 crt_file=data_files/server8_int-ca2.crt \
8050 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008051 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008052 mtu=2048" \
8053 0 \
8054 -S "found fragmented DTLS handshake message" \
8055 -c "found fragmented DTLS handshake message" \
8056 -C "error"
8057
8058requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8059requires_config_enabled MBEDTLS_RSA_C
8060requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008061run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008062 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008063 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8064 crt_file=data_files/server7_int-ca.crt \
8065 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008066 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04008067 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008068 "$P_CLI dtls=1 debug_level=2 \
8069 crt_file=data_files/server8_int-ca2.crt \
8070 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008071 hs_timeout=2500-60000 \
8072 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008073 0 \
8074 -s "found fragmented DTLS handshake message" \
8075 -c "found fragmented DTLS handshake message" \
8076 -C "error"
8077
Andrzej Kurek77826052018-10-11 07:34:08 -04008078# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008079requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8080requires_config_enabled MBEDTLS_RSA_C
8081requires_config_enabled MBEDTLS_ECDSA_C
8082requires_config_enabled MBEDTLS_SHA256_C
8083requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8084requires_config_enabled MBEDTLS_AES_C
8085requires_config_enabled MBEDTLS_GCM_C
8086run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00008087 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00008088 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8089 crt_file=data_files/server7_int-ca.crt \
8090 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008091 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00008092 mtu=512" \
8093 "$P_CLI dtls=1 debug_level=2 \
8094 crt_file=data_files/server8_int-ca2.crt \
8095 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008096 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8097 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008098 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008099 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008100 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008101 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008102 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008103
Andrzej Kurek7311c782018-10-11 06:49:41 -04008104# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04008105# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008106# The ratio of max/min timeout should ideally equal 4 to accept two
8107# retransmissions, but in some cases (like both the server and client using
8108# fragmentation and auto-reduction) an extra retransmission might occur,
8109# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01008110not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008111requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8112requires_config_enabled MBEDTLS_RSA_C
8113requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008114requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8115requires_config_enabled MBEDTLS_AES_C
8116requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02008117run_test "DTLS fragmenting: proxy MTU: auto-reduction (not valgrind)" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008118 -p "$P_PXY mtu=508" \
8119 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8120 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008121 key_file=data_files/server7.key \
8122 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008123 "$P_CLI dtls=1 debug_level=2 \
8124 crt_file=data_files/server8_int-ca2.crt \
8125 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008126 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8127 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008128 0 \
8129 -s "found fragmented DTLS handshake message" \
8130 -c "found fragmented DTLS handshake message" \
8131 -C "error"
8132
Andrzej Kurek77826052018-10-11 07:34:08 -04008133# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01008134only_with_valgrind
8135requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8136requires_config_enabled MBEDTLS_RSA_C
8137requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008138requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8139requires_config_enabled MBEDTLS_AES_C
8140requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02008141run_test "DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)" \
Hanno Becker108992e2018-08-29 17:04:18 +01008142 -p "$P_PXY mtu=508" \
8143 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8144 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008145 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01008146 hs_timeout=250-10000" \
8147 "$P_CLI dtls=1 debug_level=2 \
8148 crt_file=data_files/server8_int-ca2.crt \
8149 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008150 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01008151 hs_timeout=250-10000" \
8152 0 \
8153 -s "found fragmented DTLS handshake message" \
8154 -c "found fragmented DTLS handshake message" \
8155 -C "error"
8156
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008157# 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 +02008158# OTOH the client might resend if the server is to slow to reset after sending
8159# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008160not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008161requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8162requires_config_enabled MBEDTLS_RSA_C
8163requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008164run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008165 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008166 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8167 crt_file=data_files/server7_int-ca.crt \
8168 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008169 hs_timeout=10000-60000 \
8170 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008171 "$P_CLI dtls=1 debug_level=2 \
8172 crt_file=data_files/server8_int-ca2.crt \
8173 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008174 hs_timeout=10000-60000 \
8175 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008176 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008177 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008178 -s "found fragmented DTLS handshake message" \
8179 -c "found fragmented DTLS handshake message" \
8180 -C "error"
8181
Andrzej Kurek77826052018-10-11 07:34:08 -04008182# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008183# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
8184# OTOH the client might resend if the server is to slow to reset after sending
8185# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008186not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008187requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8188requires_config_enabled MBEDTLS_RSA_C
8189requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008190requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8191requires_config_enabled MBEDTLS_AES_C
8192requires_config_enabled MBEDTLS_GCM_C
8193run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008194 -p "$P_PXY mtu=512" \
8195 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8196 crt_file=data_files/server7_int-ca.crt \
8197 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008198 hs_timeout=10000-60000 \
8199 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008200 "$P_CLI dtls=1 debug_level=2 \
8201 crt_file=data_files/server8_int-ca2.crt \
8202 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008203 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8204 hs_timeout=10000-60000 \
8205 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008206 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008207 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008208 -s "found fragmented DTLS handshake message" \
8209 -c "found fragmented DTLS handshake message" \
8210 -C "error"
8211
Andrzej Kurek7311c782018-10-11 06:49:41 -04008212not_with_valgrind # spurious autoreduction due to timeout
8213requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8214requires_config_enabled MBEDTLS_RSA_C
8215requires_config_enabled MBEDTLS_ECDSA_C
8216run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008217 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008218 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8219 crt_file=data_files/server7_int-ca.crt \
8220 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008221 hs_timeout=10000-60000 \
8222 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008223 "$P_CLI dtls=1 debug_level=2 \
8224 crt_file=data_files/server8_int-ca2.crt \
8225 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008226 hs_timeout=10000-60000 \
8227 mtu=1024 nbio=2" \
8228 0 \
8229 -S "autoreduction" \
8230 -s "found fragmented DTLS handshake message" \
8231 -c "found fragmented DTLS handshake message" \
8232 -C "error"
8233
Andrzej Kurek77826052018-10-11 07:34:08 -04008234# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008235not_with_valgrind # spurious autoreduction due to timeout
8236requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8237requires_config_enabled MBEDTLS_RSA_C
8238requires_config_enabled MBEDTLS_ECDSA_C
8239requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8240requires_config_enabled MBEDTLS_AES_C
8241requires_config_enabled MBEDTLS_GCM_C
8242run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
8243 -p "$P_PXY mtu=512" \
8244 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8245 crt_file=data_files/server7_int-ca.crt \
8246 key_file=data_files/server7.key \
8247 hs_timeout=10000-60000 \
8248 mtu=512 nbio=2" \
8249 "$P_CLI dtls=1 debug_level=2 \
8250 crt_file=data_files/server8_int-ca2.crt \
8251 key_file=data_files/server8.key \
8252 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8253 hs_timeout=10000-60000 \
8254 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008255 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008256 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008257 -s "found fragmented DTLS handshake message" \
8258 -c "found fragmented DTLS handshake message" \
8259 -C "error"
8260
Andrzej Kurek77826052018-10-11 07:34:08 -04008261# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01008262# This ensures things still work after session_reset().
8263# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008264# Since we don't support reading fragmented ClientHello yet,
8265# up the MTU to 1450 (larger than ClientHello with session ticket,
8266# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008267# An autoreduction on the client-side might happen if the server is
8268# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02008269# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008270# resumed listening, which would result in a spurious autoreduction.
8271not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008272requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8273requires_config_enabled MBEDTLS_RSA_C
8274requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008275requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8276requires_config_enabled MBEDTLS_AES_C
8277requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008278run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
8279 -p "$P_PXY mtu=1450" \
8280 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8281 crt_file=data_files/server7_int-ca.crt \
8282 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008283 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008284 mtu=1450" \
8285 "$P_CLI dtls=1 debug_level=2 \
8286 crt_file=data_files/server8_int-ca2.crt \
8287 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008288 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008289 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01008290 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008291 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008292 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008293 -s "found fragmented DTLS handshake message" \
8294 -c "found fragmented DTLS handshake message" \
8295 -C "error"
8296
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008297# An autoreduction on the client-side might happen if the server is
8298# slow to reset, therefore omitting '-C "autoreduction"' below.
8299not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008300requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8301requires_config_enabled MBEDTLS_RSA_C
8302requires_config_enabled MBEDTLS_ECDSA_C
8303requires_config_enabled MBEDTLS_SHA256_C
8304requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8305requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8306requires_config_enabled MBEDTLS_CHACHAPOLY_C
8307run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
8308 -p "$P_PXY mtu=512" \
8309 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8310 crt_file=data_files/server7_int-ca.crt \
8311 key_file=data_files/server7.key \
8312 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008313 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008314 mtu=512" \
8315 "$P_CLI dtls=1 debug_level=2 \
8316 crt_file=data_files/server8_int-ca2.crt \
8317 key_file=data_files/server8.key \
8318 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008319 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008320 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008321 mtu=512" \
8322 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008323 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008324 -s "found fragmented DTLS handshake message" \
8325 -c "found fragmented DTLS handshake message" \
8326 -C "error"
8327
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008328# An autoreduction on the client-side might happen if the server is
8329# slow to reset, therefore omitting '-C "autoreduction"' below.
8330not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008331requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8332requires_config_enabled MBEDTLS_RSA_C
8333requires_config_enabled MBEDTLS_ECDSA_C
8334requires_config_enabled MBEDTLS_SHA256_C
8335requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8336requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8337requires_config_enabled MBEDTLS_AES_C
8338requires_config_enabled MBEDTLS_GCM_C
8339run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
8340 -p "$P_PXY mtu=512" \
8341 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8342 crt_file=data_files/server7_int-ca.crt \
8343 key_file=data_files/server7.key \
8344 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008345 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008346 mtu=512" \
8347 "$P_CLI dtls=1 debug_level=2 \
8348 crt_file=data_files/server8_int-ca2.crt \
8349 key_file=data_files/server8.key \
8350 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008351 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008352 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008353 mtu=512" \
8354 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008355 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008356 -s "found fragmented DTLS handshake message" \
8357 -c "found fragmented DTLS handshake message" \
8358 -C "error"
8359
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008360# An autoreduction on the client-side might happen if the server is
8361# slow to reset, therefore omitting '-C "autoreduction"' below.
8362not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008363requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8364requires_config_enabled MBEDTLS_RSA_C
8365requires_config_enabled MBEDTLS_ECDSA_C
8366requires_config_enabled MBEDTLS_SHA256_C
8367requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8368requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8369requires_config_enabled MBEDTLS_AES_C
8370requires_config_enabled MBEDTLS_CCM_C
8371run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008372 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008373 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8374 crt_file=data_files/server7_int-ca.crt \
8375 key_file=data_files/server7.key \
8376 exchanges=2 renegotiation=1 \
8377 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008378 hs_timeout=10000-60000 \
8379 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008380 "$P_CLI dtls=1 debug_level=2 \
8381 crt_file=data_files/server8_int-ca2.crt \
8382 key_file=data_files/server8.key \
8383 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008384 hs_timeout=10000-60000 \
8385 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008386 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008387 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008388 -s "found fragmented DTLS handshake message" \
8389 -c "found fragmented DTLS handshake message" \
8390 -C "error"
8391
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008392# An autoreduction on the client-side might happen if the server is
8393# slow to reset, therefore omitting '-C "autoreduction"' below.
8394not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008395requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8396requires_config_enabled MBEDTLS_RSA_C
8397requires_config_enabled MBEDTLS_ECDSA_C
8398requires_config_enabled MBEDTLS_SHA256_C
8399requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8400requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8401requires_config_enabled MBEDTLS_AES_C
8402requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
8403requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
8404run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008405 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008406 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8407 crt_file=data_files/server7_int-ca.crt \
8408 key_file=data_files/server7.key \
8409 exchanges=2 renegotiation=1 \
8410 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008411 hs_timeout=10000-60000 \
8412 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008413 "$P_CLI dtls=1 debug_level=2 \
8414 crt_file=data_files/server8_int-ca2.crt \
8415 key_file=data_files/server8.key \
8416 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008417 hs_timeout=10000-60000 \
8418 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008419 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008420 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008421 -s "found fragmented DTLS handshake message" \
8422 -c "found fragmented DTLS handshake message" \
8423 -C "error"
8424
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008425# An autoreduction on the client-side might happen if the server is
8426# slow to reset, therefore omitting '-C "autoreduction"' below.
8427not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008428requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8429requires_config_enabled MBEDTLS_RSA_C
8430requires_config_enabled MBEDTLS_ECDSA_C
8431requires_config_enabled MBEDTLS_SHA256_C
8432requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8433requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8434requires_config_enabled MBEDTLS_AES_C
8435requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
8436run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008437 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008438 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8439 crt_file=data_files/server7_int-ca.crt \
8440 key_file=data_files/server7.key \
8441 exchanges=2 renegotiation=1 \
8442 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008443 hs_timeout=10000-60000 \
8444 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008445 "$P_CLI dtls=1 debug_level=2 \
8446 crt_file=data_files/server8_int-ca2.crt \
8447 key_file=data_files/server8.key \
8448 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008449 hs_timeout=10000-60000 \
8450 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008451 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008452 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008453 -s "found fragmented DTLS handshake message" \
8454 -c "found fragmented DTLS handshake message" \
8455 -C "error"
8456
Andrzej Kurek77826052018-10-11 07:34:08 -04008457# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008458requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8459requires_config_enabled MBEDTLS_RSA_C
8460requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008461requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8462requires_config_enabled MBEDTLS_AES_C
8463requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008464client_needs_more_time 2
8465run_test "DTLS fragmenting: proxy MTU + 3d" \
8466 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008467 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008468 crt_file=data_files/server7_int-ca.crt \
8469 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008470 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008471 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008472 crt_file=data_files/server8_int-ca2.crt \
8473 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008474 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008475 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008476 0 \
8477 -s "found fragmented DTLS handshake message" \
8478 -c "found fragmented DTLS handshake message" \
8479 -C "error"
8480
Andrzej Kurek77826052018-10-11 07:34:08 -04008481# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008482requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8483requires_config_enabled MBEDTLS_RSA_C
8484requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008485requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8486requires_config_enabled MBEDTLS_AES_C
8487requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008488client_needs_more_time 2
8489run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
8490 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
8491 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8492 crt_file=data_files/server7_int-ca.crt \
8493 key_file=data_files/server7.key \
8494 hs_timeout=250-10000 mtu=512 nbio=2" \
8495 "$P_CLI dtls=1 debug_level=2 \
8496 crt_file=data_files/server8_int-ca2.crt \
8497 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008498 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008499 hs_timeout=250-10000 mtu=512 nbio=2" \
8500 0 \
8501 -s "found fragmented DTLS handshake message" \
8502 -c "found fragmented DTLS handshake message" \
8503 -C "error"
8504
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008505# interop tests for DTLS fragmentating with reliable connection
8506#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008507# here and below we just want to test that the we fragment in a way that
8508# pleases other implementations, so we don't need the peer to fragment
8509requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8510requires_config_enabled MBEDTLS_RSA_C
8511requires_config_enabled MBEDTLS_ECDSA_C
8512requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008513requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008514run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
8515 "$G_SRV -u" \
8516 "$P_CLI dtls=1 debug_level=2 \
8517 crt_file=data_files/server8_int-ca2.crt \
8518 key_file=data_files/server8.key \
8519 mtu=512 force_version=dtls1_2" \
8520 0 \
8521 -c "fragmenting handshake message" \
8522 -C "error"
8523
8524requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8525requires_config_enabled MBEDTLS_RSA_C
8526requires_config_enabled MBEDTLS_ECDSA_C
8527requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008528requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008529run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
8530 "$G_SRV -u" \
8531 "$P_CLI dtls=1 debug_level=2 \
8532 crt_file=data_files/server8_int-ca2.crt \
8533 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008534 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008535 0 \
8536 -c "fragmenting handshake message" \
8537 -C "error"
8538
Hanno Beckerb9a00862018-08-28 10:20:22 +01008539# We use --insecure for the GnuTLS client because it expects
8540# the hostname / IP it connects to to be the name used in the
8541# certificate obtained from the server. Here, however, it
8542# connects to 127.0.0.1 while our test certificates use 'localhost'
8543# as the server name in the certificate. This will make the
8544# certifiate validation fail, but passing --insecure makes
8545# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008546requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8547requires_config_enabled MBEDTLS_RSA_C
8548requires_config_enabled MBEDTLS_ECDSA_C
8549requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008550requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008551requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008552run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008553 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008554 crt_file=data_files/server7_int-ca.crt \
8555 key_file=data_files/server7.key \
8556 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008557 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008558 0 \
8559 -s "fragmenting handshake message"
8560
Hanno Beckerb9a00862018-08-28 10:20:22 +01008561# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008562requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8563requires_config_enabled MBEDTLS_RSA_C
8564requires_config_enabled MBEDTLS_ECDSA_C
8565requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008566requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008567requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008568run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008569 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008570 crt_file=data_files/server7_int-ca.crt \
8571 key_file=data_files/server7.key \
8572 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008573 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008574 0 \
8575 -s "fragmenting handshake message"
8576
8577requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8578requires_config_enabled MBEDTLS_RSA_C
8579requires_config_enabled MBEDTLS_ECDSA_C
8580requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8581run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
8582 "$O_SRV -dtls1_2 -verify 10" \
8583 "$P_CLI dtls=1 debug_level=2 \
8584 crt_file=data_files/server8_int-ca2.crt \
8585 key_file=data_files/server8.key \
8586 mtu=512 force_version=dtls1_2" \
8587 0 \
8588 -c "fragmenting handshake message" \
8589 -C "error"
8590
8591requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8592requires_config_enabled MBEDTLS_RSA_C
8593requires_config_enabled MBEDTLS_ECDSA_C
8594requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8595run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
8596 "$O_SRV -dtls1 -verify 10" \
8597 "$P_CLI dtls=1 debug_level=2 \
8598 crt_file=data_files/server8_int-ca2.crt \
8599 key_file=data_files/server8.key \
8600 mtu=512 force_version=dtls1" \
8601 0 \
8602 -c "fragmenting handshake message" \
8603 -C "error"
8604
8605requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8606requires_config_enabled MBEDTLS_RSA_C
8607requires_config_enabled MBEDTLS_ECDSA_C
8608requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8609run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
8610 "$P_SRV dtls=1 debug_level=2 \
8611 crt_file=data_files/server7_int-ca.crt \
8612 key_file=data_files/server7.key \
8613 mtu=512 force_version=dtls1_2" \
8614 "$O_CLI -dtls1_2" \
8615 0 \
8616 -s "fragmenting handshake message"
8617
8618requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8619requires_config_enabled MBEDTLS_RSA_C
8620requires_config_enabled MBEDTLS_ECDSA_C
8621requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8622run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8623 "$P_SRV dtls=1 debug_level=2 \
8624 crt_file=data_files/server7_int-ca.crt \
8625 key_file=data_files/server7.key \
8626 mtu=512 force_version=dtls1" \
8627 "$O_CLI -dtls1" \
8628 0 \
8629 -s "fragmenting handshake message"
8630
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008631# interop tests for DTLS fragmentating with unreliable connection
8632#
8633# again we just want to test that the we fragment in a way that
8634# pleases other implementations, so we don't need the peer to fragment
8635requires_gnutls_next
8636requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8637requires_config_enabled MBEDTLS_RSA_C
8638requires_config_enabled MBEDTLS_ECDSA_C
8639requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008640client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008641run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8642 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8643 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008644 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008645 crt_file=data_files/server8_int-ca2.crt \
8646 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008647 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008648 0 \
8649 -c "fragmenting handshake message" \
8650 -C "error"
8651
8652requires_gnutls_next
8653requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8654requires_config_enabled MBEDTLS_RSA_C
8655requires_config_enabled MBEDTLS_ECDSA_C
8656requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008657client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008658run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8659 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8660 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008661 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008662 crt_file=data_files/server8_int-ca2.crt \
8663 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008664 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008665 0 \
8666 -c "fragmenting handshake message" \
8667 -C "error"
8668
k-stachowiak17a38d32019-02-18 15:29:56 +01008669requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008670requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8671requires_config_enabled MBEDTLS_RSA_C
8672requires_config_enabled MBEDTLS_ECDSA_C
8673requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8674client_needs_more_time 4
8675run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8676 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8677 "$P_SRV dtls=1 debug_level=2 \
8678 crt_file=data_files/server7_int-ca.crt \
8679 key_file=data_files/server7.key \
8680 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008681 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008682 0 \
8683 -s "fragmenting handshake message"
8684
k-stachowiak17a38d32019-02-18 15:29:56 +01008685requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008686requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8687requires_config_enabled MBEDTLS_RSA_C
8688requires_config_enabled MBEDTLS_ECDSA_C
8689requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8690client_needs_more_time 4
8691run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8692 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8693 "$P_SRV dtls=1 debug_level=2 \
8694 crt_file=data_files/server7_int-ca.crt \
8695 key_file=data_files/server7.key \
8696 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008697 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008698 0 \
8699 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008700
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008701## Interop test with OpenSSL might trigger a bug in recent versions (including
8702## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008703## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008704## They should be re-enabled once a fixed version of OpenSSL is available
8705## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008706skip_next_test
8707requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8708requires_config_enabled MBEDTLS_RSA_C
8709requires_config_enabled MBEDTLS_ECDSA_C
8710requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8711client_needs_more_time 4
8712run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8713 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8714 "$O_SRV -dtls1_2 -verify 10" \
8715 "$P_CLI dtls=1 debug_level=2 \
8716 crt_file=data_files/server8_int-ca2.crt \
8717 key_file=data_files/server8.key \
8718 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8719 0 \
8720 -c "fragmenting handshake message" \
8721 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008722
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008723skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008724requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8725requires_config_enabled MBEDTLS_RSA_C
8726requires_config_enabled MBEDTLS_ECDSA_C
8727requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008728client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008729run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8730 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008731 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008732 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008733 crt_file=data_files/server8_int-ca2.crt \
8734 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008735 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008736 0 \
8737 -c "fragmenting handshake message" \
8738 -C "error"
8739
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008740skip_next_test
8741requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8742requires_config_enabled MBEDTLS_RSA_C
8743requires_config_enabled MBEDTLS_ECDSA_C
8744requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8745client_needs_more_time 4
8746run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8747 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8748 "$P_SRV dtls=1 debug_level=2 \
8749 crt_file=data_files/server7_int-ca.crt \
8750 key_file=data_files/server7.key \
8751 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8752 "$O_CLI -dtls1_2" \
8753 0 \
8754 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008755
8756# -nbio is added to prevent s_client from blocking in case of duplicated
8757# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008758skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008759requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8760requires_config_enabled MBEDTLS_RSA_C
8761requires_config_enabled MBEDTLS_ECDSA_C
8762requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008763client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008764run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8765 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008766 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008767 crt_file=data_files/server7_int-ca.crt \
8768 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008769 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008770 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008771 0 \
8772 -s "fragmenting handshake message"
8773
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008774# Tests for specific things with "unreliable" UDP connection
8775
8776not_with_valgrind # spurious resend due to timeout
8777run_test "DTLS proxy: reference" \
8778 -p "$P_PXY" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008779 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
8780 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008781 0 \
8782 -C "replayed record" \
8783 -S "replayed record" \
Hanno Beckerb2a86c32019-07-19 15:43:09 +01008784 -C "Buffer record from epoch" \
8785 -S "Buffer record from epoch" \
8786 -C "ssl_buffer_message" \
8787 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008788 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008789 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008790 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008791 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008792 -c "HTTP/1.0 200 OK"
8793
8794not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008795run_test "DTLS proxy: duplicate every packet" \
8796 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008797 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
8798 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008799 0 \
8800 -c "replayed record" \
8801 -s "replayed record" \
8802 -c "record from another epoch" \
8803 -s "record from another epoch" \
8804 -S "resend" \
8805 -s "Extra-header:" \
8806 -c "HTTP/1.0 200 OK"
8807
8808run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8809 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008810 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8811 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008812 0 \
8813 -c "replayed record" \
8814 -S "replayed record" \
8815 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008816 -s "record from another epoch" \
8817 -c "resend" \
8818 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008819 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008820 -c "HTTP/1.0 200 OK"
8821
8822run_test "DTLS proxy: multiple records in same datagram" \
8823 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008824 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8825 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008826 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008827 -c "next record in same datagram" \
8828 -s "next record in same datagram"
8829
8830run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8831 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008832 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8833 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008834 0 \
8835 -c "next record in same datagram" \
8836 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008837
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008838run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8839 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008840 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8841 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008842 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008843 -c "discarding invalid record (mac)" \
8844 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008845 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008846 -c "HTTP/1.0 200 OK" \
8847 -S "too many records with bad MAC" \
8848 -S "Verification of the message MAC failed"
8849
8850run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8851 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008852 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8853 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008854 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008855 -C "discarding invalid record (mac)" \
8856 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008857 -S "Extra-header:" \
8858 -C "HTTP/1.0 200 OK" \
8859 -s "too many records with bad MAC" \
8860 -s "Verification of the message MAC failed"
8861
8862run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8863 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008864 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8865 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008866 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008867 -c "discarding invalid record (mac)" \
8868 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008869 -s "Extra-header:" \
8870 -c "HTTP/1.0 200 OK" \
8871 -S "too many records with bad MAC" \
8872 -S "Verification of the message MAC failed"
8873
8874run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8875 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008876 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8877 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008878 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008879 -c "discarding invalid record (mac)" \
8880 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008881 -s "Extra-header:" \
8882 -c "HTTP/1.0 200 OK" \
8883 -s "too many records with bad MAC" \
8884 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008885
8886run_test "DTLS proxy: delay ChangeCipherSpec" \
8887 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008888 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8889 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008890 0 \
8891 -c "record from another epoch" \
8892 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008893 -s "Extra-header:" \
8894 -c "HTTP/1.0 200 OK"
8895
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008896# Tests for reordering support with DTLS
8897
Hanno Becker56cdfd12018-08-17 13:42:15 +01008898run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8899 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008900 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8901 hs_timeout=2500-60000" \
8902 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8903 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008904 0 \
8905 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008906 -c "Next handshake message has been buffered - load"\
8907 -S "Buffering HS message" \
8908 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008909 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008910 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008911 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008912 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008913
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008914run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8915 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008916 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8917 hs_timeout=2500-60000" \
8918 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8919 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008920 0 \
8921 -c "Buffering HS message" \
8922 -c "found fragmented DTLS handshake message"\
8923 -c "Next handshake message 1 not or only partially bufffered" \
8924 -c "Next handshake message has been buffered - load"\
8925 -S "Buffering HS message" \
8926 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008927 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008928 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008929 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008930 -S "Remember CCS message"
8931
Hanno Beckera1adcca2018-08-24 14:41:07 +01008932# The client buffers the ServerKeyExchange before receiving the fragmented
8933# Certificate message; at the time of writing, together these are aroudn 1200b
8934# in size, so that the bound below ensures that the certificate can be reassembled
8935# while keeping the ServerKeyExchange.
8936requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8937run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008938 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008939 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8940 hs_timeout=2500-60000" \
8941 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8942 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008943 0 \
8944 -c "Buffering HS message" \
8945 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008946 -C "attempt to make space by freeing buffered messages" \
8947 -S "Buffering HS message" \
8948 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008949 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008950 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008951 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008952 -S "Remember CCS message"
8953
8954# The size constraints ensure that the delayed certificate message can't
8955# be reassembled while keeping the ServerKeyExchange message, but it can
8956# when dropping it first.
8957requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8958requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8959run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8960 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008961 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8962 hs_timeout=2500-60000" \
8963 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8964 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008965 0 \
8966 -c "Buffering HS message" \
8967 -c "attempt to make space by freeing buffered future messages" \
8968 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008969 -S "Buffering HS message" \
8970 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008971 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008972 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008973 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008974 -S "Remember CCS message"
8975
Hanno Becker56cdfd12018-08-17 13:42:15 +01008976run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8977 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008978 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8979 hs_timeout=2500-60000" \
8980 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8981 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008982 0 \
8983 -C "Buffering HS message" \
8984 -C "Next handshake message has been buffered - load"\
8985 -s "Buffering HS message" \
8986 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008987 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008988 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008989 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008990 -S "Remember CCS message"
8991
8992run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8993 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008994 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8995 hs_timeout=2500-60000" \
8996 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8997 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008998 0 \
8999 -C "Buffering HS message" \
9000 -C "Next handshake message has been buffered - load"\
9001 -S "Buffering HS message" \
9002 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01009003 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01009004 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01009005 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01009006 -S "Remember CCS message"
9007
9008run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
9009 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009010 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
9011 hs_timeout=2500-60000" \
9012 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
9013 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01009014 0 \
9015 -C "Buffering HS message" \
9016 -C "Next handshake message has been buffered - load"\
9017 -S "Buffering HS message" \
9018 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01009019 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01009020 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01009021 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01009022 -s "Remember CCS message"
9023
Hanno Beckera1adcca2018-08-24 14:41:07 +01009024run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01009025 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009026 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
9027 hs_timeout=2500-60000" \
9028 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
9029 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01009030 0 \
9031 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01009032 -s "Found buffered record from current epoch - load" \
9033 -c "Buffer record from epoch 1" \
9034 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009035
Hanno Beckera1adcca2018-08-24 14:41:07 +01009036# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
9037# from the server are delayed, so that the encrypted Finished message
9038# is received and buffered. When the fragmented NewSessionTicket comes
9039# in afterwards, the encrypted Finished message must be freed in order
9040# to make space for the NewSessionTicket to be reassembled.
9041# This works only in very particular circumstances:
9042# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
9043# of the NewSessionTicket, but small enough to also allow buffering of
9044# the encrypted Finished message.
9045# - The MTU setting on the server must be so small that the NewSessionTicket
9046# needs to be fragmented.
9047# - All messages sent by the server must be small enough to be either sent
9048# without fragmentation or be reassembled within the bounds of
9049# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
9050# handshake, omitting CRTs.
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02009051requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
9052requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01009053run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
9054 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02009055 "$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 +01009056 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
9057 0 \
9058 -s "Buffer record from epoch 1" \
9059 -s "Found buffered record from current epoch - load" \
9060 -c "Buffer record from epoch 1" \
9061 -C "Found buffered record from current epoch - load" \
9062 -c "Enough space available after freeing future epoch record"
9063
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02009064# Tests for "randomly unreliable connection": try a variety of flows and peers
9065
9066client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02009067run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
9068 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009069 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009070 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009071 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009072 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9073 0 \
9074 -s "Extra-header:" \
9075 -c "HTTP/1.0 200 OK"
9076
Janos Follath74537a62016-09-02 13:45:28 +01009077client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009078run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
9079 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009080 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
9081 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009082 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
9083 0 \
9084 -s "Extra-header:" \
9085 -c "HTTP/1.0 200 OK"
9086
Janos Follath74537a62016-09-02 13:45:28 +01009087client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009088run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
9089 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009090 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
9091 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009092 0 \
9093 -s "Extra-header:" \
9094 -c "HTTP/1.0 200 OK"
9095
Janos Follath74537a62016-09-02 13:45:28 +01009096client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009097run_test "DTLS proxy: 3d, FS, client auth" \
9098 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009099 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
9100 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009101 0 \
9102 -s "Extra-header:" \
9103 -c "HTTP/1.0 200 OK"
9104
Janos Follath74537a62016-09-02 13:45:28 +01009105client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009106run_test "DTLS proxy: 3d, FS, ticket" \
9107 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009108 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
9109 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009110 0 \
9111 -s "Extra-header:" \
9112 -c "HTTP/1.0 200 OK"
9113
Janos Follath74537a62016-09-02 13:45:28 +01009114client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009115run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
9116 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009117 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
9118 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02009119 0 \
9120 -s "Extra-header:" \
9121 -c "HTTP/1.0 200 OK"
9122
Janos Follath74537a62016-09-02 13:45:28 +01009123client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009124run_test "DTLS proxy: 3d, max handshake, nbio" \
9125 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009126 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009127 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009128 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009129 0 \
9130 -s "Extra-header:" \
9131 -c "HTTP/1.0 200 OK"
9132
Janos Follath74537a62016-09-02 13:45:28 +01009133client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02009134run_test "DTLS proxy: 3d, min handshake, resumption" \
9135 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009136 "$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 +02009137 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009138 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01009139 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02009140 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9141 0 \
9142 -s "a session has been resumed" \
9143 -c "a session has been resumed" \
9144 -s "Extra-header:" \
9145 -c "HTTP/1.0 200 OK"
9146
Janos Follath74537a62016-09-02 13:45:28 +01009147client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02009148run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
9149 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009150 "$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 +02009151 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009152 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01009153 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02009154 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
9155 0 \
9156 -s "a session has been resumed" \
9157 -c "a session has been resumed" \
9158 -s "Extra-header:" \
9159 -c "HTTP/1.0 200 OK"
9160
Janos Follath74537a62016-09-02 13:45:28 +01009161client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009162requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009163run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02009164 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009165 "$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 +02009166 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009167 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009168 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02009169 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9170 0 \
9171 -c "=> renegotiate" \
9172 -s "=> renegotiate" \
9173 -s "Extra-header:" \
9174 -c "HTTP/1.0 200 OK"
9175
Janos Follath74537a62016-09-02 13:45:28 +01009176client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009177requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009178run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
9179 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009180 "$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 +02009181 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009182 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009183 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009184 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9185 0 \
9186 -c "=> renegotiate" \
9187 -s "=> renegotiate" \
9188 -s "Extra-header:" \
9189 -c "HTTP/1.0 200 OK"
9190
Janos Follath74537a62016-09-02 13:45:28 +01009191client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009192requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009193run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009194 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009195 "$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 +02009196 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009197 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009198 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009199 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009200 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9201 0 \
9202 -c "=> renegotiate" \
9203 -s "=> renegotiate" \
9204 -s "Extra-header:" \
9205 -c "HTTP/1.0 200 OK"
9206
Janos Follath74537a62016-09-02 13:45:28 +01009207client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009208requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009209run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009210 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009211 "$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 +02009212 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009213 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009214 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009215 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009216 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9217 0 \
9218 -c "=> renegotiate" \
9219 -s "=> renegotiate" \
9220 -s "Extra-header:" \
9221 -c "HTTP/1.0 200 OK"
9222
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009223## Interop tests with OpenSSL might trigger a bug in recent versions (including
9224## all versions installed on the CI machines), reported here:
9225## Bug report: https://github.com/openssl/openssl/issues/6902
9226## They should be re-enabled once a fixed version of OpenSSL is available
9227## (this should happen in some 1.1.1_ release according to the ticket).
9228skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01009229client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009230not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009231run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009232 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9233 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009234 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009235 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009236 -c "HTTP/1.0 200 OK"
9237
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009238skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01009239client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009240not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009241run_test "DTLS proxy: 3d, openssl server, fragmentation" \
9242 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9243 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009244 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009245 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009246 -c "HTTP/1.0 200 OK"
9247
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009248skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01009249client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009250not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009251run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
9252 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9253 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009254 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009255 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009256 -c "HTTP/1.0 200 OK"
9257
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00009258requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01009259client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009260not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009261run_test "DTLS proxy: 3d, gnutls server" \
9262 -p "$P_PXY drop=5 delay=5 duplicate=5" \
9263 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009264 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009265 0 \
9266 -s "Extra-header:" \
9267 -c "Extra-header:"
9268
k-stachowiak17a38d32019-02-18 15:29:56 +01009269requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01009270client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009271not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009272run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
9273 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01009274 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009275 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009276 0 \
9277 -s "Extra-header:" \
9278 -c "Extra-header:"
9279
k-stachowiak17a38d32019-02-18 15:29:56 +01009280requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01009281client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009282not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009283run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
9284 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01009285 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009286 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009287 0 \
9288 -s "Extra-header:" \
9289 -c "Extra-header:"
9290
Ron Eldorf75e2522019-05-14 20:38:49 +03009291requires_config_enabled MBEDTLS_SSL_EXPORT_KEYS
9292run_test "export keys functionality" \
9293 "$P_SRV eap_tls=1 debug_level=3" \
9294 "$P_CLI eap_tls=1 debug_level=3" \
9295 0 \
9296 -s "exported maclen is " \
9297 -s "exported keylen is " \
9298 -s "exported ivlen is " \
9299 -c "exported maclen is " \
9300 -c "exported keylen is " \
Ron Eldor65d8c262019-06-04 13:05:36 +03009301 -c "exported ivlen is " \
9302 -c "EAP-TLS key material is:"\
9303 -s "EAP-TLS key material is:"\
9304 -c "EAP-TLS IV is:" \
9305 -s "EAP-TLS IV is:"
Ron Eldorf75e2522019-05-14 20:38:49 +03009306
Piotr Nowicki0937ed22019-11-26 16:32:40 +01009307# Test heap memory usage after handshake
9308requires_config_enabled MBEDTLS_MEMORY_DEBUG
9309requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C
9310requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
9311run_tests_memory_after_hanshake
9312
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01009313# Final report
9314
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009315echo "------------------------------------------------------------------------"
9316
9317if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01009318 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009319else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01009320 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009321fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02009322PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02009323echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009324
9325exit $FAILS