blob: 46dc83e94fcda31c80d8501f4f835a5bf9b6909e [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 Peskinef93c7d32017-04-14 17:55:28 +0200117 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
118 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\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
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100181# Skip next test; use this macro to skip tests which are legitimate
182# in theory and expected to be re-introduced at some point, but
183# aren't expected to succeed at the moment due to problems outside
184# our control (such as bugs in other TLS implementations).
185skip_next_test() {
186 SKIP_NEXT="YES"
187}
188
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100189# skip next test if the flag is not enabled in config.h
190requires_config_enabled() {
191 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
192 SKIP_NEXT="YES"
193 fi
194}
195
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200196# skip next test if the flag is enabled in config.h
197requires_config_disabled() {
198 if grep "^#define $1" $CONFIG_H > /dev/null; then
199 SKIP_NEXT="YES"
200 fi
201}
202
Hanno Becker7c48dd12018-08-28 16:09:22 +0100203get_config_value_or_default() {
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100204 # This function uses the query_config command line option to query the
205 # required Mbed TLS compile time configuration from the ssl_server2
206 # program. The command will always return a success value if the
207 # configuration is defined and the value will be printed to stdout.
208 #
209 # Note that if the configuration is not defined or is defined to nothing,
210 # the output of this function will be an empty string.
211 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100212}
213
214requires_config_value_at_least() {
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100215 VAL="$( get_config_value_or_default "$1" )"
216 if [ -z "$VAL" ]; then
217 # Should never happen
218 echo "Mbed TLS configuration $1 is not defined"
219 exit 1
220 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100221 SKIP_NEXT="YES"
222 fi
223}
224
225requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100226 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100227 if [ -z "$VAL" ]; then
228 # Should never happen
229 echo "Mbed TLS configuration $1 is not defined"
230 exit 1
231 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100232 SKIP_NEXT="YES"
233 fi
234}
235
Hanno Becker9d76d562018-11-16 17:27:29 +0000236requires_ciphersuite_enabled() {
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100237 if [ -z "$($P_CLI --help 2>/dev/null | grep $1)" ]; then
Hanno Becker9d76d562018-11-16 17:27:29 +0000238 SKIP_NEXT="YES"
239 fi
240}
241
Gilles Peskine0d721652020-06-26 23:35:53 +0200242# maybe_requires_ciphersuite_enabled CMD [RUN_TEST_OPTION...]
243# If CMD (call to a TLS client or server program) requires a specific
244# ciphersuite, arrange to only run the test case if this ciphersuite is
245# enabled. As an exception, do run the test case if it expects a ciphersuite
246# mismatch.
247maybe_requires_ciphersuite_enabled() {
248 case "$1" in
249 *\ force_ciphersuite=*) :;;
250 *) return;; # No specific required ciphersuite
251 esac
252 ciphersuite="${1##*\ force_ciphersuite=}"
253 ciphersuite="${ciphersuite%%[!-0-9A-Z_a-z]*}"
254 shift
255
256 case "$*" in
257 *"-s SSL - The server has no ciphersuites in common"*)
258 # This test case expects a ciphersuite mismatch, so it doesn't
259 # require the ciphersuite to be enabled.
260 ;;
261 *)
262 requires_ciphersuite_enabled "$ciphersuite"
263 ;;
264 esac
265
266 unset ciphersuite
267}
268
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200269# skip next test if OpenSSL doesn't support FALLBACK_SCSV
270requires_openssl_with_fallback_scsv() {
271 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
272 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
273 then
274 OPENSSL_HAS_FBSCSV="YES"
275 else
276 OPENSSL_HAS_FBSCSV="NO"
277 fi
278 fi
279 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
280 SKIP_NEXT="YES"
281 fi
282}
283
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200284# skip next test if GnuTLS isn't available
285requires_gnutls() {
286 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200287 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200288 GNUTLS_AVAILABLE="YES"
289 else
290 GNUTLS_AVAILABLE="NO"
291 fi
292 fi
293 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
294 SKIP_NEXT="YES"
295 fi
296}
297
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200298# skip next test if GnuTLS-next isn't available
299requires_gnutls_next() {
300 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
301 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
302 GNUTLS_NEXT_AVAILABLE="YES"
303 else
304 GNUTLS_NEXT_AVAILABLE="NO"
305 fi
306 fi
307 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
308 SKIP_NEXT="YES"
309 fi
310}
311
312# skip next test if OpenSSL-legacy isn't available
313requires_openssl_legacy() {
314 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
315 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
316 OPENSSL_LEGACY_AVAILABLE="YES"
317 else
318 OPENSSL_LEGACY_AVAILABLE="NO"
319 fi
320 fi
321 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
322 SKIP_NEXT="YES"
323 fi
324}
325
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200326# skip next test if IPv6 isn't available on this host
327requires_ipv6() {
328 if [ -z "${HAS_IPV6:-}" ]; then
329 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
330 SRV_PID=$!
331 sleep 1
332 kill $SRV_PID >/dev/null 2>&1
333 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
334 HAS_IPV6="NO"
335 else
336 HAS_IPV6="YES"
337 fi
338 rm -r $SRV_OUT
339 fi
340
341 if [ "$HAS_IPV6" = "NO" ]; then
342 SKIP_NEXT="YES"
343 fi
344}
345
Andrzej Kurekb4593462018-10-11 08:43:30 -0400346# skip next test if it's i686 or uname is not available
347requires_not_i686() {
348 if [ -z "${IS_I686:-}" ]; then
349 IS_I686="YES"
350 if which "uname" >/dev/null 2>&1; then
351 if [ -z "$(uname -a | grep i686)" ]; then
352 IS_I686="NO"
353 fi
354 fi
355 fi
356 if [ "$IS_I686" = "YES" ]; then
357 SKIP_NEXT="YES"
358 fi
359}
360
Angus Grattonc4dd0732018-04-11 16:28:39 +1000361# Calculate the input & output maximum content lengths set in the config
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200362MAX_CONTENT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
363MAX_IN_LEN=$( ../scripts/config.py get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
364MAX_OUT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
Angus Grattonc4dd0732018-04-11 16:28:39 +1000365
366if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
367 MAX_CONTENT_LEN="$MAX_IN_LEN"
368fi
369if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
370 MAX_CONTENT_LEN="$MAX_OUT_LEN"
371fi
372
373# skip the next test if the SSL output buffer is less than 16KB
374requires_full_size_output_buffer() {
375 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
376 SKIP_NEXT="YES"
377 fi
378}
379
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200380# skip the next test if valgrind is in use
381not_with_valgrind() {
382 if [ "$MEMCHECK" -gt 0 ]; then
383 SKIP_NEXT="YES"
384 fi
385}
386
Paul Bakker362689d2016-05-13 10:33:25 +0100387# skip the next test if valgrind is NOT in use
388only_with_valgrind() {
389 if [ "$MEMCHECK" -eq 0 ]; then
390 SKIP_NEXT="YES"
391 fi
392}
393
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200394# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100395client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200396 CLI_DELAY_FACTOR=$1
397}
398
Janos Follath74537a62016-09-02 13:45:28 +0100399# wait for the given seconds after the client finished in the next test
400server_needs_more_time() {
401 SRV_DELAY_SECONDS=$1
402}
403
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100404# print_name <name>
405print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100406 TESTS=$(( $TESTS + 1 ))
407 LINE=""
408
409 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
410 LINE="$TESTS "
411 fi
412
413 LINE="$LINE$1"
414 printf "$LINE "
415 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100416 for i in `seq 1 $LEN`; do printf '.'; done
417 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100418
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100419}
420
Gilles Peskine560280b2019-09-16 15:17:38 +0200421# record_outcome <outcome> [<failure-reason>]
422# The test name must be in $NAME.
423record_outcome() {
424 echo "$1"
425 if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ]; then
426 printf '%s;%s;%s;%s;%s;%s\n' \
427 "$MBEDTLS_TEST_PLATFORM" "$MBEDTLS_TEST_CONFIGURATION" \
428 "ssl-opt" "$NAME" \
429 "$1" "${2-}" \
430 >>"$MBEDTLS_TEST_OUTCOME_FILE"
431 fi
432}
433
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100434# fail <message>
435fail() {
Gilles Peskine560280b2019-09-16 15:17:38 +0200436 record_outcome "FAIL" "$1"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100437 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100438
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200439 mv $SRV_OUT o-srv-${TESTS}.log
440 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200441 if [ -n "$PXY_CMD" ]; then
442 mv $PXY_OUT o-pxy-${TESTS}.log
443 fi
444 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100445
Manuel Pégourié-Gonnard3f3302f2020-06-08 11:49:05 +0200446 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200447 echo " ! server output:"
448 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200449 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200450 echo " ! client output:"
451 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200452 if [ -n "$PXY_CMD" ]; then
453 echo " ! ========================================================"
454 echo " ! proxy output:"
455 cat o-pxy-${TESTS}.log
456 fi
457 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200458 fi
459
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200460 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100461}
462
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100463# is_polar <cmd_line>
464is_polar() {
465 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
466}
467
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200468# openssl s_server doesn't have -www with DTLS
469check_osrv_dtls() {
470 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
471 NEEDS_INPUT=1
472 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
473 else
474 NEEDS_INPUT=0
475 fi
476}
477
478# provide input to commands that need it
479provide_input() {
480 if [ $NEEDS_INPUT -eq 0 ]; then
481 return
482 fi
483
484 while true; do
485 echo "HTTP/1.0 200 OK"
486 sleep 1
487 done
488}
489
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100490# has_mem_err <log_file_name>
491has_mem_err() {
492 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
493 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
494 then
495 return 1 # false: does not have errors
496 else
497 return 0 # true: has errors
498 fi
499}
500
Unknownd364f4c2019-09-02 10:42:57 -0400501# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100502if type lsof >/dev/null 2>/dev/null; then
Unknownd364f4c2019-09-02 10:42:57 -0400503 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100504 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200505 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100506 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200507 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100508 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200509 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100510 # Make a tight loop, server normally takes less than 1s to start.
511 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
512 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknownd364f4c2019-09-02 10:42:57 -0400513 echo "$3 START TIMEOUT"
514 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100515 break
516 fi
517 # Linux and *BSD support decimal arguments to sleep. On other
518 # OSes this may be a tight loop.
519 sleep 0.1 2>/dev/null || true
520 done
521 }
522else
Unknownd364f4c2019-09-02 10:42:57 -0400523 echo "Warning: lsof not available, wait_app_start = sleep"
524 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200525 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100526 }
527fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200528
Unknownd364f4c2019-09-02 10:42:57 -0400529# Wait for server process $2 to be listening on port $1.
530wait_server_start() {
531 wait_app_start $1 $2 "SERVER" $SRV_OUT
532}
533
534# Wait for proxy process $2 to be listening on port $1.
535wait_proxy_start() {
536 wait_app_start $1 $2 "PROXY" $PXY_OUT
537}
538
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100539# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100540# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100541# acceptable bounds
542check_server_hello_time() {
543 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100544 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100545 # Get the Unix timestamp for now
546 CUR_TIME=$(date +'%s')
547 THRESHOLD_IN_SECS=300
548
549 # Check if the ServerHello time was printed
550 if [ -z "$SERVER_HELLO_TIME" ]; then
551 return 1
552 fi
553
554 # Check the time in ServerHello is within acceptable bounds
555 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
556 # The time in ServerHello is at least 5 minutes before now
557 return 1
558 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100559 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100560 return 1
561 else
562 return 0
563 fi
564}
565
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100566# Get handshake memory usage from server or client output and put it into the variable specified by the first argument
567handshake_memory_get() {
568 OUTPUT_VARIABLE="$1"
569 OUTPUT_FILE="$2"
570
571 # Get memory usage from a pattern like "Heap memory usage after handshake: 23112 bytes. Peak memory usage was 33112"
572 MEM_USAGE=$(sed -n 's/.*Heap memory usage after handshake: //p' < "$OUTPUT_FILE" | grep -o "[0-9]*" | head -1)
573
574 # Check if memory usage was read
575 if [ -z "$MEM_USAGE" ]; then
576 echo "Error: Can not read the value of handshake memory usage"
577 return 1
578 else
579 eval "$OUTPUT_VARIABLE=$MEM_USAGE"
580 return 0
581 fi
582}
583
584# Get handshake memory usage from server or client output and check if this value
585# is not higher than the maximum given by the first argument
586handshake_memory_check() {
587 MAX_MEMORY="$1"
588 OUTPUT_FILE="$2"
589
590 # Get memory usage
591 if ! handshake_memory_get "MEMORY_USAGE" "$OUTPUT_FILE"; then
592 return 1
593 fi
594
595 # Check if memory usage is below max value
596 if [ "$MEMORY_USAGE" -gt "$MAX_MEMORY" ]; then
597 echo "\nFailed: Handshake memory usage was $MEMORY_USAGE bytes," \
598 "but should be below $MAX_MEMORY bytes"
599 return 1
600 else
601 return 0
602 fi
603}
604
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200605# wait for client to terminate and set CLI_EXIT
606# must be called right after starting the client
607wait_client_done() {
608 CLI_PID=$!
609
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200610 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
611 CLI_DELAY_FACTOR=1
612
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200613 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200614 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200615
616 wait $CLI_PID
617 CLI_EXIT=$?
618
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200619 kill $DOG_PID >/dev/null 2>&1
620 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200621
622 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100623
624 sleep $SRV_DELAY_SECONDS
625 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200626}
627
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200628# check if the given command uses dtls and sets global variable DTLS
629detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200630 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200631 DTLS=1
632 else
633 DTLS=0
634 fi
635}
636
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200637# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100638# Options: -s pattern pattern that must be present in server output
639# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100640# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100641# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100642# -S pattern pattern that must be absent in server output
643# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100644# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100645# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100646run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100647 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200648 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100649
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100650 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
651 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200652 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200653 # There was no request to run the test, so don't record its outcome.
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100654 return
655 fi
656
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100657 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100658
Paul Bakkerb7584a52016-05-10 10:50:43 +0100659 # Do we only run numbered tests?
660 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
661 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
662 else
663 SKIP_NEXT="YES"
664 fi
665
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200666 # does this test use a proxy?
667 if [ "X$1" = "X-p" ]; then
668 PXY_CMD="$2"
669 shift 2
670 else
671 PXY_CMD=""
672 fi
673
674 # get commands and client output
675 SRV_CMD="$1"
676 CLI_CMD="$2"
677 CLI_EXPECT="$3"
678 shift 3
679
Hanno Becker91e72c32019-05-10 14:38:42 +0100680 # Check if test uses files
681 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
682 if [ ! -z "$TEST_USES_FILES" ]; then
683 requires_config_enabled MBEDTLS_FS_IO
684 fi
685
Gilles Peskine0d721652020-06-26 23:35:53 +0200686 # If the client or serve requires a ciphersuite, check that it's enabled.
687 maybe_requires_ciphersuite_enabled "$SRV_CMD" "$@"
688 maybe_requires_ciphersuite_enabled "$CLI_CMD" "$@"
Hanno Becker9d76d562018-11-16 17:27:29 +0000689
690 # should we skip?
691 if [ "X$SKIP_NEXT" = "XYES" ]; then
692 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200693 record_outcome "SKIP"
Hanno Becker9d76d562018-11-16 17:27:29 +0000694 SKIPS=$(( $SKIPS + 1 ))
695 return
696 fi
697
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200698 # update DTLS variable
699 detect_dtls "$SRV_CMD"
700
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200701 # if the test uses DTLS but no custom proxy, add a simple proxy
702 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard70fce982020-06-25 09:54:46 +0200703 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200704 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard8779e9a2020-07-16 10:19:32 +0200705 case " $SRV_CMD " in
706 *' server_addr=::1 '*)
707 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
708 esac
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200709 fi
710
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100711 # fix client port
712 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200713 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
714 else
715 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
716 fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200717
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100718 # prepend valgrind to our commands if active
719 if [ "$MEMCHECK" -gt 0 ]; then
720 if is_polar "$SRV_CMD"; then
721 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
722 fi
723 if is_polar "$CLI_CMD"; then
724 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
725 fi
726 fi
727
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200728 TIMES_LEFT=2
729 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200730 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200731
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200732 # run the commands
733 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda3b994f2020-07-27 09:45:32 +0200734 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200735 $PXY_CMD >> $PXY_OUT 2>&1 &
736 PXY_PID=$!
Unknownd364f4c2019-09-02 10:42:57 -0400737 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200738 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200739
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200740 check_osrv_dtls
Manuel Pégourié-Gonnardd06125c2020-06-08 12:06:21 +0200741 printf "# $NAME\n$SRV_CMD\n" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200742 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
743 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100744 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200745
Manuel Pégourié-Gonnardd06125c2020-06-08 12:06:21 +0200746 printf "# $NAME\n$CLI_CMD\n" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200747 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
748 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100749
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100750 sleep 0.05
751
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200752 # terminate the server (and the proxy)
753 kill $SRV_PID
754 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100755
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200756 if [ -n "$PXY_CMD" ]; then
757 kill $PXY_PID >/dev/null 2>&1
758 wait $PXY_PID
759 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100760
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200761 # retry only on timeouts
762 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
763 printf "RETRY "
764 else
765 TIMES_LEFT=0
766 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200767 done
768
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100769 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200770 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100771 # expected client exit to incorrectly succeed in case of catastrophic
772 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100773 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200774 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100775 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100776 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100777 return
778 fi
779 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100780 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200781 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100782 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100783 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100784 return
785 fi
786 fi
787
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100788 # check server exit code
789 if [ $? != 0 ]; then
790 fail "server fail"
791 return
792 fi
793
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100794 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100795 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
796 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100797 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200798 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100799 return
800 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100801
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100802 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200803 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100804 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100805 while [ $# -gt 0 ]
806 do
807 case $1 in
808 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100809 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 +0100810 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100811 return
812 fi
813 ;;
814
815 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100816 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 +0100817 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100818 return
819 fi
820 ;;
821
822 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100823 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 +0100824 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100825 return
826 fi
827 ;;
828
829 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100830 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 +0100831 fail "pattern '$2' MUST NOT be present in the Client output"
832 return
833 fi
834 ;;
835
836 # The filtering in the following two options (-u and -U) do the following
837 # - ignore valgrind output
Antonin Décimo36e89b52019-01-23 15:24:37 +0100838 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100839 # - keep one of each non-unique line
840 # - count how many lines remain
841 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
842 # if there were no duplicates.
843 "-U")
844 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
845 fail "lines following pattern '$2' must be unique in Server output"
846 return
847 fi
848 ;;
849
850 "-u")
851 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
852 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100853 return
854 fi
855 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100856 "-F")
857 if ! $2 "$SRV_OUT"; then
858 fail "function call to '$2' failed on Server output"
859 return
860 fi
861 ;;
862 "-f")
863 if ! $2 "$CLI_OUT"; then
864 fail "function call to '$2' failed on Client output"
865 return
866 fi
867 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100868
869 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200870 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100871 exit 1
872 esac
873 shift 2
874 done
875
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100876 # check valgrind's results
877 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200878 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100879 fail "Server has memory errors"
880 return
881 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200882 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100883 fail "Client has memory errors"
884 return
885 fi
886 fi
887
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100888 # if we're here, everything is ok
Gilles Peskine560280b2019-09-16 15:17:38 +0200889 record_outcome "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100890 if [ "$PRESERVE_LOGS" -gt 0 ]; then
891 mv $SRV_OUT o-srv-${TESTS}.log
892 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100893 if [ -n "$PXY_CMD" ]; then
894 mv $PXY_OUT o-pxy-${TESTS}.log
895 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100896 fi
897
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200898 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100899}
900
Hanno Becker9b5853c2018-11-16 17:28:40 +0000901run_test_psa() {
902 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
Hanno Beckere9420c22018-11-20 11:37:34 +0000903 run_test "PSA-supported ciphersuite: $1" \
Hanno Becker4c8c7aa2019-04-10 09:25:41 +0100904 "$P_SRV debug_level=3 force_version=tls1_2" \
905 "$P_CLI debug_level=3 force_version=tls1_2 force_ciphersuite=$1" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000906 0 \
907 -c "Successfully setup PSA-based decryption cipher context" \
908 -c "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500909 -c "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500910 -c "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000911 -s "Successfully setup PSA-based decryption cipher context" \
912 -s "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500913 -s "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500914 -s "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000915 -C "Failed to setup PSA-based cipher context"\
916 -S "Failed to setup PSA-based cipher context"\
917 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000918 -c "Perform PSA-based ECDH computation."\
Andrzej Kureke85414e2019-01-15 05:23:59 -0500919 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000920 -S "error" \
921 -C "error"
922}
923
Hanno Becker354e2482019-01-08 11:40:25 +0000924run_test_psa_force_curve() {
925 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
926 run_test "PSA - ECDH with $1" \
927 "$P_SRV debug_level=4 force_version=tls1_2" \
928 "$P_CLI debug_level=4 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=$1" \
929 0 \
Hanno Becker28f78442019-02-18 16:47:50 +0000930 -c "Successfully setup PSA-based decryption cipher context" \
931 -c "Successfully setup PSA-based encryption cipher context" \
932 -c "PSA calc verify" \
933 -c "calc PSA finished" \
934 -s "Successfully setup PSA-based decryption cipher context" \
935 -s "Successfully setup PSA-based encryption cipher context" \
936 -s "PSA calc verify" \
937 -s "calc PSA finished" \
938 -C "Failed to setup PSA-based cipher context"\
939 -S "Failed to setup PSA-based cipher context"\
Hanno Becker354e2482019-01-08 11:40:25 +0000940 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000941 -c "Perform PSA-based ECDH computation."\
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100942 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200943 -S "error" \
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200944 -C "error"
945}
946
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100947# Test that the server's memory usage after a handshake is reduced when a client specifies
948# a maximum fragment length.
949# first argument ($1) is MFL for SSL client
950# second argument ($2) is memory usage for SSL client with default MFL (16k)
951run_test_memory_after_hanshake_with_mfl()
952{
953 # The test passes if the difference is around 2*(16k-MFL)
954 local MEMORY_USAGE_LIMIT="$(( $2 - ( 2 * ( 16384 - $1 )) ))"
955
956 # Leave some margin for robustness
957 MEMORY_USAGE_LIMIT="$(( ( MEMORY_USAGE_LIMIT * 110 ) / 100 ))"
958
959 run_test "Handshake memory usage (MFL $1)" \
960 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
961 "$P_CLI debug_level=3 force_version=tls1_2 \
962 crt_file=data_files/server5.crt key_file=data_files/server5.key \
963 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM max_frag_len=$1" \
964 0 \
965 -F "handshake_memory_check $MEMORY_USAGE_LIMIT"
966}
967
968
969# Test that the server's memory usage after a handshake is reduced when a client specifies
970# different values of Maximum Fragment Length: default (16k), 4k, 2k, 1k and 512 bytes
971run_tests_memory_after_hanshake()
972{
973 # all tests in this sequence requires the same configuration (see requires_config_enabled())
974 SKIP_THIS_TESTS="$SKIP_NEXT"
975
976 # first test with default MFU is to get reference memory usage
977 MEMORY_USAGE_MFL_16K=0
978 run_test "Handshake memory usage initial (MFL 16384 - default)" \
979 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
980 "$P_CLI debug_level=3 force_version=tls1_2 \
981 crt_file=data_files/server5.crt key_file=data_files/server5.key \
982 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM" \
983 0 \
984 -F "handshake_memory_get MEMORY_USAGE_MFL_16K"
985
986 SKIP_NEXT="$SKIP_THIS_TESTS"
987 run_test_memory_after_hanshake_with_mfl 4096 "$MEMORY_USAGE_MFL_16K"
988
989 SKIP_NEXT="$SKIP_THIS_TESTS"
990 run_test_memory_after_hanshake_with_mfl 2048 "$MEMORY_USAGE_MFL_16K"
991
992 SKIP_NEXT="$SKIP_THIS_TESTS"
993 run_test_memory_after_hanshake_with_mfl 1024 "$MEMORY_USAGE_MFL_16K"
994
995 SKIP_NEXT="$SKIP_THIS_TESTS"
996 run_test_memory_after_hanshake_with_mfl 512 "$MEMORY_USAGE_MFL_16K"
997}
998
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100999cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001000 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Piotr Nowicki3de298f2020-04-16 14:35:19 +02001001 rm -f context_srv.txt
1002 rm -f context_cli.txt
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +02001003 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
1004 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
1005 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
1006 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001007 exit 1
1008}
1009
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +01001010#
1011# MAIN
1012#
1013
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +01001014get_options "$@"
1015
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001016# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +01001017P_SRV_BIN="${P_SRV%%[ ]*}"
1018P_CLI_BIN="${P_CLI%%[ ]*}"
1019P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +01001020if [ ! -x "$P_SRV_BIN" ]; then
1021 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001022 exit 1
1023fi
Hanno Becker17c04932017-10-10 14:44:53 +01001024if [ ! -x "$P_CLI_BIN" ]; then
1025 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001026 exit 1
1027fi
Hanno Becker17c04932017-10-10 14:44:53 +01001028if [ ! -x "$P_PXY_BIN" ]; then
1029 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001030 exit 1
1031fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +01001032if [ "$MEMCHECK" -gt 0 ]; then
1033 if which valgrind >/dev/null 2>&1; then :; else
1034 echo "Memcheck not possible. Valgrind not found"
1035 exit 1
1036 fi
1037fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001038if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1039 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001040 exit 1
1041fi
1042
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001043# used by watchdog
1044MAIN_PID="$$"
1045
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001046# We use somewhat arbitrary delays for tests:
1047# - how long do we wait for the server to start (when lsof not available)?
1048# - how long do we allow for the client to finish?
1049# (not to check performance, just to avoid waiting indefinitely)
1050# Things are slower with valgrind, so give extra time here.
1051#
1052# Note: without lsof, there is a trade-off between the running time of this
1053# script and the risk of spurious errors because we didn't wait long enough.
1054# The watchdog delay on the other hand doesn't affect normal running time of
1055# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001056if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001057 START_DELAY=6
1058 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001059else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001060 START_DELAY=2
1061 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001062fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001063
1064# some particular tests need more time:
1065# - for the client, we multiply the usual watchdog limit by a factor
1066# - for the server, we sleep for a number of seconds after the client exits
1067# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001068CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001069SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001070
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001071# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001072# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001073P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1074P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001075P_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 +02001076O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001077O_CLI="$O_CLI -connect localhost:+SRV_PORT"
1078G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001079G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001080
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001081if [ -n "${OPENSSL_LEGACY:-}" ]; then
1082 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1083 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1084fi
1085
Hanno Becker58e9dc32018-08-17 15:53:21 +01001086if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001087 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1088fi
1089
Hanno Becker58e9dc32018-08-17 15:53:21 +01001090if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001091 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001092fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001093
Gilles Peskine62469d92017-05-10 10:13:59 +02001094# Allow SHA-1, because many of our test certificates use it
1095P_SRV="$P_SRV allow_sha1=1"
1096P_CLI="$P_CLI allow_sha1=1"
1097
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001098# Also pick a unique name for intermediate files
1099SRV_OUT="srv_out.$$"
1100CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001101PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001102SESSION="session.$$"
1103
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001104SKIP_NEXT="NO"
1105
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001106trap cleanup INT TERM HUP
1107
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001108# Basic test
1109
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001110# Checks that:
1111# - things work with all ciphersuites active (used with config-full in all.sh)
1112# - the expected (highest security) parameters are selected
1113# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001114run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001115 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001116 "$P_CLI" \
1117 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001118 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001119 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001120 -s "client hello v3, signature_algorithm ext: 6" \
1121 -s "ECDHE curve: secp521r1" \
1122 -S "error" \
1123 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001124
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001125run_test "Default, DTLS" \
1126 "$P_SRV dtls=1" \
1127 "$P_CLI dtls=1" \
1128 0 \
1129 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001130 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001131
Manuel Pégourié-Gonnard342d2ca2020-01-02 11:58:00 +01001132requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1133run_test "Default (compression enabled)" \
1134 "$P_SRV debug_level=3" \
1135 "$P_CLI debug_level=3" \
1136 0 \
1137 -s "Allocating compression buffer" \
1138 -c "Allocating compression buffer" \
1139 -s "Record expansion is unknown (compression)" \
1140 -c "Record expansion is unknown (compression)" \
1141 -S "error" \
1142 -C "error"
1143
Hanno Becker746aaf32019-03-28 15:25:23 +00001144requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1145run_test "CA callback on client" \
1146 "$P_SRV debug_level=3" \
1147 "$P_CLI ca_callback=1 debug_level=3 " \
1148 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001149 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001150 -S "error" \
1151 -C "error"
1152
1153requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1154requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1155requires_config_enabled MBEDTLS_ECDSA_C
1156requires_config_enabled MBEDTLS_SHA256_C
1157run_test "CA callback on server" \
1158 "$P_SRV auth_mode=required" \
1159 "$P_CLI ca_callback=1 debug_level=3 crt_file=data_files/server5.crt \
1160 key_file=data_files/server5.key" \
1161 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001162 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001163 -s "Verifying peer X.509 certificate... ok" \
1164 -S "error" \
1165 -C "error"
1166
Manuel Pégourié-Gonnardcfdf8f42018-11-08 09:52:25 +01001167# Test using an opaque private key for client authentication
1168requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
1169requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1170requires_config_enabled MBEDTLS_ECDSA_C
1171requires_config_enabled MBEDTLS_SHA256_C
1172run_test "Opaque key for client authentication" \
1173 "$P_SRV auth_mode=required" \
1174 "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \
1175 key_file=data_files/server5.key" \
1176 0 \
1177 -c "key type: Opaque" \
1178 -s "Verifying peer X.509 certificate... ok" \
1179 -S "error" \
1180 -C "error"
1181
Hanno Becker9b5853c2018-11-16 17:28:40 +00001182# Test ciphersuites which we expect to be fully supported by PSA Crypto
1183# and check that we don't fall back to Mbed TLS' internal crypto primitives.
1184run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM
1185run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
1186run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM
1187run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8
1188run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
1189run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384
1190run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA
1191run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
1192run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384
1193
Hanno Becker354e2482019-01-08 11:40:25 +00001194requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1195run_test_psa_force_curve "secp521r1"
1196requires_config_enabled MBEDTLS_ECP_DP_BP512R1_ENABLED
1197run_test_psa_force_curve "brainpoolP512r1"
1198requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
1199run_test_psa_force_curve "secp384r1"
1200requires_config_enabled MBEDTLS_ECP_DP_BP384R1_ENABLED
1201run_test_psa_force_curve "brainpoolP384r1"
1202requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED
1203run_test_psa_force_curve "secp256r1"
1204requires_config_enabled MBEDTLS_ECP_DP_SECP256K1_ENABLED
1205run_test_psa_force_curve "secp256k1"
1206requires_config_enabled MBEDTLS_ECP_DP_BP256R1_ENABLED
1207run_test_psa_force_curve "brainpoolP256r1"
1208requires_config_enabled MBEDTLS_ECP_DP_SECP224R1_ENABLED
1209run_test_psa_force_curve "secp224r1"
1210requires_config_enabled MBEDTLS_ECP_DP_SECP224K1_ENABLED
1211run_test_psa_force_curve "secp224k1"
1212requires_config_enabled MBEDTLS_ECP_DP_SECP192R1_ENABLED
1213run_test_psa_force_curve "secp192r1"
1214requires_config_enabled MBEDTLS_ECP_DP_SECP192K1_ENABLED
1215run_test_psa_force_curve "secp192k1"
1216
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001217# Test current time in ServerHello
1218requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001219run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001220 "$P_SRV debug_level=3" \
1221 "$P_CLI debug_level=3" \
1222 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001223 -f "check_server_hello_time" \
1224 -F "check_server_hello_time"
1225
Simon Butcher8e004102016-10-14 00:48:33 +01001226# Test for uniqueness of IVs in AEAD ciphersuites
1227run_test "Unique IV in GCM" \
1228 "$P_SRV exchanges=20 debug_level=4" \
1229 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1230 0 \
1231 -u "IV used" \
1232 -U "IV used"
1233
Janos Follathee11be62019-04-04 12:03:30 +01001234# Tests for certificate verification callback
1235run_test "Configuration-specific CRT verification callback" \
1236 "$P_SRV debug_level=3" \
1237 "$P_CLI context_crt_cb=0 debug_level=3" \
1238 0 \
Janos Follathee11be62019-04-04 12:03:30 +01001239 -S "error" \
1240 -c "Verify requested for " \
1241 -c "Use configuration-specific verification callback" \
1242 -C "Use context-specific verification callback" \
1243 -C "error"
1244
Hanno Beckerefb440a2019-04-03 13:04:33 +01001245run_test "Context-specific CRT verification callback" \
1246 "$P_SRV debug_level=3" \
1247 "$P_CLI context_crt_cb=1 debug_level=3" \
1248 0 \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001249 -S "error" \
Janos Follathee11be62019-04-04 12:03:30 +01001250 -c "Verify requested for " \
1251 -c "Use context-specific verification callback" \
1252 -C "Use configuration-specific verification callback" \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001253 -C "error"
1254
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001255# Tests for rc4 option
1256
Simon Butchera410af52016-05-19 22:12:18 +01001257requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001258run_test "RC4: server disabled, client enabled" \
1259 "$P_SRV" \
1260 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1261 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001262 -s "SSL - The server has no ciphersuites in common"
1263
Simon Butchera410af52016-05-19 22:12:18 +01001264requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001265run_test "RC4: server half, client enabled" \
1266 "$P_SRV arc4=1" \
1267 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1268 1 \
1269 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001270
1271run_test "RC4: server enabled, client disabled" \
1272 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1273 "$P_CLI" \
1274 1 \
1275 -s "SSL - The server has no ciphersuites in common"
1276
1277run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001278 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001279 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1280 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001281 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001282 -S "SSL - The server has no ciphersuites in common"
1283
Hanno Beckerd26bb202018-08-17 09:54:10 +01001284# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1285
1286requires_gnutls
1287requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1288run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1289 "$G_SRV"\
1290 "$P_CLI force_version=tls1_1" \
1291 0
1292
1293requires_gnutls
1294requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1295run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1296 "$G_SRV"\
1297 "$P_CLI force_version=tls1" \
1298 0
1299
Gilles Peskinebc70a182017-05-09 15:59:24 +02001300# Tests for SHA-1 support
1301
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001302requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001303run_test "SHA-1 forbidden by default in server certificate" \
1304 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1305 "$P_CLI debug_level=2 allow_sha1=0" \
1306 1 \
1307 -c "The certificate is signed with an unacceptable hash"
1308
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001309requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02001310run_test "SHA-1 allowed by default in server certificate" \
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001311 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1312 "$P_CLI debug_level=2 allow_sha1=0" \
1313 0
1314
Gilles Peskinebc70a182017-05-09 15:59:24 +02001315run_test "SHA-1 explicitly allowed in server certificate" \
1316 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1317 "$P_CLI allow_sha1=1" \
1318 0
1319
1320run_test "SHA-256 allowed by default in server certificate" \
1321 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1322 "$P_CLI allow_sha1=0" \
1323 0
1324
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001325requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001326run_test "SHA-1 forbidden by default in client certificate" \
1327 "$P_SRV auth_mode=required allow_sha1=0" \
1328 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1329 1 \
1330 -s "The certificate is signed with an unacceptable hash"
1331
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001332requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02001333run_test "SHA-1 allowed by default in client certificate" \
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001334 "$P_SRV auth_mode=required allow_sha1=0" \
1335 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1336 0
1337
Gilles Peskinebc70a182017-05-09 15:59:24 +02001338run_test "SHA-1 explicitly allowed in client certificate" \
1339 "$P_SRV auth_mode=required allow_sha1=1" \
1340 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1341 0
1342
1343run_test "SHA-256 allowed by default in client certificate" \
1344 "$P_SRV auth_mode=required allow_sha1=0" \
1345 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1346 0
1347
Hanno Becker7ae8a762018-08-14 15:43:35 +01001348# Tests for datagram packing
1349run_test "DTLS: multiple records in same datagram, client and server" \
1350 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1351 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1352 0 \
1353 -c "next record in same datagram" \
1354 -s "next record in same datagram"
1355
1356run_test "DTLS: multiple records in same datagram, client only" \
1357 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1358 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1359 0 \
1360 -s "next record in same datagram" \
1361 -C "next record in same datagram"
1362
1363run_test "DTLS: multiple records in same datagram, server only" \
1364 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1365 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1366 0 \
1367 -S "next record in same datagram" \
1368 -c "next record in same datagram"
1369
1370run_test "DTLS: multiple records in same datagram, neither client nor server" \
1371 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1372 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1373 0 \
1374 -S "next record in same datagram" \
1375 -C "next record in same datagram"
1376
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001377# Tests for Truncated HMAC extension
1378
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001379run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001380 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001381 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001382 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001383 -s "dumping 'expected mac' (20 bytes)" \
1384 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001385
Hanno Becker32c55012017-11-10 08:42:54 +00001386requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001387run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001388 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001389 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001390 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001391 -s "dumping 'expected mac' (20 bytes)" \
1392 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001393
Hanno Becker32c55012017-11-10 08:42:54 +00001394requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001395run_test "Truncated HMAC: client enabled, server default" \
1396 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001397 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001398 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001399 -s "dumping 'expected mac' (20 bytes)" \
1400 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001401
Hanno Becker32c55012017-11-10 08:42:54 +00001402requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001403run_test "Truncated HMAC: client enabled, server disabled" \
1404 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001405 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001406 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001407 -s "dumping 'expected mac' (20 bytes)" \
1408 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001409
Hanno Becker32c55012017-11-10 08:42:54 +00001410requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001411run_test "Truncated HMAC: client disabled, server enabled" \
1412 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001413 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001414 0 \
1415 -s "dumping 'expected mac' (20 bytes)" \
1416 -S "dumping 'expected mac' (10 bytes)"
1417
1418requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001419run_test "Truncated HMAC: client enabled, server enabled" \
1420 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001421 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001422 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001423 -S "dumping 'expected mac' (20 bytes)" \
1424 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001425
Hanno Becker4c4f4102017-11-10 09:16:05 +00001426run_test "Truncated HMAC, DTLS: client default, server default" \
1427 "$P_SRV dtls=1 debug_level=4" \
1428 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1429 0 \
1430 -s "dumping 'expected mac' (20 bytes)" \
1431 -S "dumping 'expected mac' (10 bytes)"
1432
1433requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1434run_test "Truncated HMAC, DTLS: client disabled, server default" \
1435 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001436 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001437 0 \
1438 -s "dumping 'expected mac' (20 bytes)" \
1439 -S "dumping 'expected mac' (10 bytes)"
1440
1441requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1442run_test "Truncated HMAC, DTLS: client enabled, server default" \
1443 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001444 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001445 0 \
1446 -s "dumping 'expected mac' (20 bytes)" \
1447 -S "dumping 'expected mac' (10 bytes)"
1448
1449requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1450run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1451 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001452 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001453 0 \
1454 -s "dumping 'expected mac' (20 bytes)" \
1455 -S "dumping 'expected mac' (10 bytes)"
1456
1457requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1458run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1459 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001460 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001461 0 \
1462 -s "dumping 'expected mac' (20 bytes)" \
1463 -S "dumping 'expected mac' (10 bytes)"
1464
1465requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1466run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1467 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001468 "$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 +01001469 0 \
1470 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001471 -s "dumping 'expected mac' (10 bytes)"
1472
Jarno Lamsa2937d812019-06-04 11:33:23 +03001473# Tests for Context serialization
1474
1475requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001476run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001477 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001478 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1479 0 \
1480 -c "Deserializing connection..." \
1481 -S "Deserializing connection..."
1482
1483requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1484run_test "Context serialization, client serializes, ChaChaPoly" \
1485 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1486 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1487 0 \
1488 -c "Deserializing connection..." \
1489 -S "Deserializing connection..."
1490
1491requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1492run_test "Context serialization, client serializes, GCM" \
1493 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1494 "$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 +03001495 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001496 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001497 -S "Deserializing connection..."
1498
1499requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001500requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1501run_test "Context serialization, client serializes, with CID" \
1502 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1503 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1504 0 \
1505 -c "Deserializing connection..." \
1506 -S "Deserializing connection..."
1507
1508requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001509run_test "Context serialization, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001510 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001511 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1512 0 \
1513 -C "Deserializing connection..." \
1514 -s "Deserializing connection..."
1515
1516requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1517run_test "Context serialization, server serializes, ChaChaPoly" \
1518 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1519 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1520 0 \
1521 -C "Deserializing connection..." \
1522 -s "Deserializing connection..."
1523
1524requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1525run_test "Context serialization, server serializes, GCM" \
1526 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1527 "$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 +03001528 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001529 -C "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001530 -s "Deserializing connection..."
1531
1532requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001533requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1534run_test "Context serialization, server serializes, with CID" \
1535 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1536 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1537 0 \
1538 -C "Deserializing connection..." \
1539 -s "Deserializing connection..."
1540
1541requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001542run_test "Context serialization, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001543 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001544 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1545 0 \
1546 -c "Deserializing connection..." \
1547 -s "Deserializing connection..."
1548
1549requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1550run_test "Context serialization, both serialize, ChaChaPoly" \
1551 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1552 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1553 0 \
1554 -c "Deserializing connection..." \
1555 -s "Deserializing connection..."
1556
1557requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1558run_test "Context serialization, both serialize, GCM" \
1559 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1560 "$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 +03001561 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001562 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001563 -s "Deserializing connection..."
1564
Jarno Lamsac2376f02019-06-06 10:44:14 +03001565requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001566requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1567run_test "Context serialization, both serialize, with CID" \
1568 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1569 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1570 0 \
1571 -c "Deserializing connection..." \
1572 -s "Deserializing connection..."
1573
1574requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001575run_test "Context serialization, re-init, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001576 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001577 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1578 0 \
1579 -c "Deserializing connection..." \
1580 -S "Deserializing connection..."
1581
1582requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1583run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1584 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1585 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1586 0 \
1587 -c "Deserializing connection..." \
1588 -S "Deserializing connection..."
1589
1590requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1591run_test "Context serialization, re-init, client serializes, GCM" \
1592 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1593 "$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 +03001594 0 \
1595 -c "Deserializing connection..." \
1596 -S "Deserializing connection..."
1597
Jarno Lamsac2376f02019-06-06 10:44:14 +03001598requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001599requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1600run_test "Context serialization, re-init, client serializes, with CID" \
1601 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1602 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1603 0 \
1604 -c "Deserializing connection..." \
1605 -S "Deserializing connection..."
1606
1607requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001608run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001609 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001610 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1611 0 \
1612 -C "Deserializing connection..." \
1613 -s "Deserializing connection..."
1614
1615requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1616run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1617 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1618 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1619 0 \
1620 -C "Deserializing connection..." \
1621 -s "Deserializing connection..."
1622
1623requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1624run_test "Context serialization, re-init, server serializes, GCM" \
1625 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1626 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001627 0 \
1628 -C "Deserializing connection..." \
1629 -s "Deserializing connection..."
1630
Jarno Lamsac2376f02019-06-06 10:44:14 +03001631requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001632requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1633run_test "Context serialization, re-init, server serializes, with CID" \
1634 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1635 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1636 0 \
1637 -C "Deserializing connection..." \
1638 -s "Deserializing connection..."
1639
1640requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001641run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001642 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001643 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1644 0 \
1645 -c "Deserializing connection..." \
1646 -s "Deserializing connection..."
1647
1648requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1649run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1650 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1651 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1652 0 \
1653 -c "Deserializing connection..." \
1654 -s "Deserializing connection..."
1655
1656requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1657run_test "Context serialization, re-init, both serialize, GCM" \
1658 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1659 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001660 0 \
1661 -c "Deserializing connection..." \
1662 -s "Deserializing connection..."
1663
Hanno Becker1b18fd32019-08-30 11:18:59 +01001664requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1665requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1666run_test "Context serialization, re-init, both serialize, with CID" \
1667 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1668 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1669 0 \
1670 -c "Deserializing connection..." \
1671 -s "Deserializing connection..."
1672
Piotr Nowicki3de298f2020-04-16 14:35:19 +02001673requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1674run_test "Saving the serialized context to a file" \
1675 "$P_SRV dtls=1 serialize=1 context_file=context_srv.txt" \
1676 "$P_CLI dtls=1 serialize=1 context_file=context_cli.txt" \
1677 0 \
1678 -s "Save serialized context to a file... ok" \
1679 -c "Save serialized context to a file... ok"
1680rm -f context_srv.txt
1681rm -f context_cli.txt
1682
Hanno Becker7cf463e2019-04-09 18:08:47 +01001683# Tests for DTLS Connection ID extension
1684
Hanno Becker7cf463e2019-04-09 18:08:47 +01001685# So far, the CID API isn't implemented, so we can't
1686# grep for output witnessing its use. This needs to be
1687# changed once the CID extension is implemented.
1688
Hanno Beckera0e20d02019-05-15 14:03:01 +01001689requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001690run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001691 "$P_SRV debug_level=3 dtls=1 cid=0" \
1692 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1693 0 \
1694 -s "Disable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001695 -s "found CID extension" \
1696 -s "Client sent CID extension, but CID disabled" \
Hanno Becker6b78c832019-04-25 17:01:43 +01001697 -c "Enable use of CID extension." \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001698 -c "client hello, adding CID extension" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001699 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001700 -C "found CID extension" \
1701 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001702 -C "Copy CIDs into SSL transform" \
1703 -c "Use of Connection ID was rejected by the server"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001704
Hanno Beckera0e20d02019-05-15 14:03:01 +01001705requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001706run_test "Connection ID: Cli disabled, Srv enabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001707 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1708 "$P_CLI debug_level=3 dtls=1 cid=0" \
1709 0 \
1710 -c "Disable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001711 -C "client hello, adding CID extension" \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001712 -S "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001713 -s "Enable use of CID extension." \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001714 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001715 -C "found CID extension" \
1716 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001717 -C "Copy CIDs into SSL transform" \
Hanno Beckerb3e9dd52019-05-08 13:19:53 +01001718 -s "Use of Connection ID was not offered by client"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001719
Hanno Beckera0e20d02019-05-15 14:03:01 +01001720requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001721run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001722 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1723 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1724 0 \
1725 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001726 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001727 -c "client hello, adding CID extension" \
1728 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001729 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001730 -s "server hello, adding CID extension" \
1731 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001732 -c "Use of CID extension negotiated" \
1733 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001734 -c "Copy CIDs into SSL transform" \
1735 -c "Peer CID (length 2 Bytes): de ad" \
1736 -s "Peer CID (length 2 Bytes): be ef" \
1737 -s "Use of Connection ID has been negotiated" \
1738 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001739
Hanno Beckera0e20d02019-05-15 14:03:01 +01001740requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001741run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001742 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001743 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1744 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1745 0 \
1746 -c "Enable use of CID extension." \
1747 -s "Enable use of CID extension." \
1748 -c "client hello, adding CID extension" \
1749 -s "found CID extension" \
1750 -s "Use of CID extension negotiated" \
1751 -s "server hello, adding CID extension" \
1752 -c "found CID extension" \
1753 -c "Use of CID extension negotiated" \
1754 -s "Copy CIDs into SSL transform" \
1755 -c "Copy CIDs into SSL transform" \
1756 -c "Peer CID (length 2 Bytes): de ad" \
1757 -s "Peer CID (length 2 Bytes): be ef" \
1758 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001759 -c "Use of Connection ID has been negotiated" \
1760 -c "ignoring unexpected CID" \
1761 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001762
Hanno Beckera0e20d02019-05-15 14:03:01 +01001763requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001764run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1765 -p "$P_PXY mtu=800" \
1766 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1767 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1768 0 \
1769 -c "Enable use of CID extension." \
1770 -s "Enable use of CID extension." \
1771 -c "client hello, adding CID extension" \
1772 -s "found CID extension" \
1773 -s "Use of CID extension negotiated" \
1774 -s "server hello, adding CID extension" \
1775 -c "found CID extension" \
1776 -c "Use of CID extension negotiated" \
1777 -s "Copy CIDs into SSL transform" \
1778 -c "Copy CIDs into SSL transform" \
1779 -c "Peer CID (length 2 Bytes): de ad" \
1780 -s "Peer CID (length 2 Bytes): be ef" \
1781 -s "Use of Connection ID has been negotiated" \
1782 -c "Use of Connection ID has been negotiated"
1783
Hanno Beckera0e20d02019-05-15 14:03:01 +01001784requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001785run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001786 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001787 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1788 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1789 0 \
1790 -c "Enable use of CID extension." \
1791 -s "Enable use of CID extension." \
1792 -c "client hello, adding CID extension" \
1793 -s "found CID extension" \
1794 -s "Use of CID extension negotiated" \
1795 -s "server hello, adding CID extension" \
1796 -c "found CID extension" \
1797 -c "Use of CID extension negotiated" \
1798 -s "Copy CIDs into SSL transform" \
1799 -c "Copy CIDs into SSL transform" \
1800 -c "Peer CID (length 2 Bytes): de ad" \
1801 -s "Peer CID (length 2 Bytes): be ef" \
1802 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001803 -c "Use of Connection ID has been negotiated" \
1804 -c "ignoring unexpected CID" \
1805 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001806
Hanno Beckera0e20d02019-05-15 14:03:01 +01001807requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001808run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001809 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1810 "$P_CLI debug_level=3 dtls=1 cid=1" \
1811 0 \
1812 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001813 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001814 -c "client hello, adding CID extension" \
1815 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001816 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001817 -s "server hello, adding CID extension" \
1818 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001819 -c "Use of CID extension negotiated" \
1820 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001821 -c "Copy CIDs into SSL transform" \
1822 -c "Peer CID (length 4 Bytes): de ad be ef" \
1823 -s "Peer CID (length 0 Bytes):" \
1824 -s "Use of Connection ID has been negotiated" \
1825 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001826
Hanno Beckera0e20d02019-05-15 14:03:01 +01001827requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001828run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001829 "$P_SRV debug_level=3 dtls=1 cid=1" \
1830 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1831 0 \
1832 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001833 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001834 -c "client hello, adding CID extension" \
1835 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001836 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001837 -s "server hello, adding CID extension" \
1838 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001839 -c "Use of CID extension negotiated" \
1840 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001841 -c "Copy CIDs into SSL transform" \
1842 -s "Peer CID (length 4 Bytes): de ad be ef" \
1843 -c "Peer CID (length 0 Bytes):" \
1844 -s "Use of Connection ID has been negotiated" \
1845 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001846
Hanno Beckera0e20d02019-05-15 14:03:01 +01001847requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001848run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001849 "$P_SRV debug_level=3 dtls=1 cid=1" \
1850 "$P_CLI debug_level=3 dtls=1 cid=1" \
1851 0 \
1852 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001853 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001854 -c "client hello, adding CID extension" \
1855 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001856 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001857 -s "server hello, adding CID extension" \
1858 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001859 -c "Use of CID extension negotiated" \
1860 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001861 -c "Copy CIDs into SSL transform" \
1862 -S "Use of Connection ID has been negotiated" \
1863 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001864
Hanno Beckera0e20d02019-05-15 14:03:01 +01001865requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001866run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001867 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1868 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1869 0 \
1870 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001871 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001872 -c "client hello, adding CID extension" \
1873 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001874 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001875 -s "server hello, adding CID extension" \
1876 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001877 -c "Use of CID extension negotiated" \
1878 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001879 -c "Copy CIDs into SSL transform" \
1880 -c "Peer CID (length 2 Bytes): de ad" \
1881 -s "Peer CID (length 2 Bytes): be ef" \
1882 -s "Use of Connection ID has been negotiated" \
1883 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001884
Hanno Beckera0e20d02019-05-15 14:03:01 +01001885requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001886run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001887 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1888 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1889 0 \
1890 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001891 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001892 -c "client hello, adding CID extension" \
1893 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001894 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001895 -s "server hello, adding CID extension" \
1896 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001897 -c "Use of CID extension negotiated" \
1898 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001899 -c "Copy CIDs into SSL transform" \
1900 -c "Peer CID (length 4 Bytes): de ad be ef" \
1901 -s "Peer CID (length 0 Bytes):" \
1902 -s "Use of Connection ID has been negotiated" \
1903 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001904
Hanno Beckera0e20d02019-05-15 14:03:01 +01001905requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001906run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001907 "$P_SRV debug_level=3 dtls=1 cid=1" \
1908 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1909 0 \
1910 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001911 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001912 -c "client hello, adding CID extension" \
1913 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001914 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001915 -s "server hello, adding CID extension" \
1916 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001917 -c "Use of CID extension negotiated" \
1918 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001919 -c "Copy CIDs into SSL transform" \
1920 -s "Peer CID (length 4 Bytes): de ad be ef" \
1921 -c "Peer CID (length 0 Bytes):" \
1922 -s "Use of Connection ID has been negotiated" \
1923 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001924
Hanno Beckera0e20d02019-05-15 14:03:01 +01001925requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001926run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001927 "$P_SRV debug_level=3 dtls=1 cid=1" \
1928 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1929 0 \
1930 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001931 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001932 -c "client hello, adding CID extension" \
1933 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001934 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001935 -s "server hello, adding CID extension" \
1936 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001937 -c "Use of CID extension negotiated" \
1938 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001939 -c "Copy CIDs into SSL transform" \
1940 -S "Use of Connection ID has been negotiated" \
1941 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001942
Hanno Beckera0e20d02019-05-15 14:03:01 +01001943requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001944run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001945 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1946 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1947 0 \
1948 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001949 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001950 -c "client hello, adding CID extension" \
1951 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001952 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001953 -s "server hello, adding CID extension" \
1954 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001955 -c "Use of CID extension negotiated" \
1956 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001957 -c "Copy CIDs into SSL transform" \
1958 -c "Peer CID (length 2 Bytes): de ad" \
1959 -s "Peer CID (length 2 Bytes): be ef" \
1960 -s "Use of Connection ID has been negotiated" \
1961 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001962
Hanno Beckera0e20d02019-05-15 14:03:01 +01001963requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001964run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001965 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1966 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1967 0 \
1968 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001969 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001970 -c "client hello, adding CID extension" \
1971 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001972 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001973 -s "server hello, adding CID extension" \
1974 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001975 -c "Use of CID extension negotiated" \
1976 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001977 -c "Copy CIDs into SSL transform" \
1978 -c "Peer CID (length 4 Bytes): de ad be ef" \
1979 -s "Peer CID (length 0 Bytes):" \
1980 -s "Use of Connection ID has been negotiated" \
1981 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001982
Hanno Beckera0e20d02019-05-15 14:03:01 +01001983requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001984run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001985 "$P_SRV debug_level=3 dtls=1 cid=1" \
1986 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1987 0 \
1988 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001989 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001990 -c "client hello, adding CID extension" \
1991 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001992 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001993 -s "server hello, adding CID extension" \
1994 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001995 -c "Use of CID extension negotiated" \
1996 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001997 -c "Copy CIDs into SSL transform" \
1998 -s "Peer CID (length 4 Bytes): de ad be ef" \
1999 -c "Peer CID (length 0 Bytes):" \
2000 -s "Use of Connection ID has been negotiated" \
2001 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002002
Hanno Beckera0e20d02019-05-15 14:03:01 +01002003requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002004run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002005 "$P_SRV debug_level=3 dtls=1 cid=1" \
2006 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
2007 0 \
2008 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002009 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002010 -c "client hello, adding CID extension" \
2011 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002012 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002013 -s "server hello, adding CID extension" \
2014 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002015 -c "Use of CID extension negotiated" \
2016 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01002017 -c "Copy CIDs into SSL transform" \
2018 -S "Use of Connection ID has been negotiated" \
2019 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002020
Hanno Beckera0e20d02019-05-15 14:03:01 +01002021requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker9bae30d2019-04-23 11:52:44 +01002022requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002023run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002024 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2025 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2026 0 \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002027 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2028 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2029 -s "(initial handshake) Use of Connection ID has been negotiated" \
2030 -c "(initial handshake) Use of Connection ID has been negotiated" \
2031 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2032 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2033 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2034 -c "(after renegotiation) Use of Connection ID has been negotiated"
2035
Hanno Beckera0e20d02019-05-15 14:03:01 +01002036requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002037requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002038run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002039 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2040 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2041 0 \
2042 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2043 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2044 -s "(initial handshake) Use of Connection ID has been negotiated" \
2045 -c "(initial handshake) Use of Connection ID has been negotiated" \
2046 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2047 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2048 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2049 -c "(after renegotiation) Use of Connection ID has been negotiated"
2050
Hanno Beckera0e20d02019-05-15 14:03:01 +01002051requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002052requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002053run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
2054 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
2055 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2056 0 \
2057 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2058 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2059 -s "(initial handshake) Use of Connection ID has been negotiated" \
2060 -c "(initial handshake) Use of Connection ID has been negotiated" \
2061 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2062 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2063 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2064 -c "(after renegotiation) Use of Connection ID has been negotiated"
2065
Hanno Beckera0e20d02019-05-15 14:03:01 +01002066requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002067requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002068run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002069 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002070 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2071 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2072 0 \
2073 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2074 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2075 -s "(initial handshake) Use of Connection ID has been negotiated" \
2076 -c "(initial handshake) Use of Connection ID has been negotiated" \
2077 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2078 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2079 -s "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002080 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2081 -c "ignoring unexpected CID" \
2082 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002083
Hanno Beckera0e20d02019-05-15 14:03:01 +01002084requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002085requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2086run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002087 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2088 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2089 0 \
2090 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2091 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2092 -s "(initial handshake) Use of Connection ID has been negotiated" \
2093 -c "(initial handshake) Use of Connection ID has been negotiated" \
2094 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2095 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2096 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2097 -S "(after renegotiation) Use of Connection ID has been negotiated"
2098
Hanno Beckera0e20d02019-05-15 14:03:01 +01002099requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002100requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002101run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
2102 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2103 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2104 0 \
2105 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2106 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2107 -s "(initial handshake) Use of Connection ID has been negotiated" \
2108 -c "(initial handshake) Use of Connection ID has been negotiated" \
2109 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2110 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2111 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2112 -S "(after renegotiation) Use of Connection ID has been negotiated"
2113
Hanno Beckera0e20d02019-05-15 14:03:01 +01002114requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002115requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002116run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002117 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002118 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2119 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2120 0 \
2121 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2122 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2123 -s "(initial handshake) Use of Connection ID has been negotiated" \
2124 -c "(initial handshake) Use of Connection ID has been negotiated" \
2125 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2126 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2127 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002128 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2129 -c "ignoring unexpected CID" \
2130 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002131
Hanno Beckera0e20d02019-05-15 14:03:01 +01002132requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002133requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2134run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002135 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2136 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2137 0 \
2138 -S "(initial handshake) Use of Connection ID has been negotiated" \
2139 -C "(initial handshake) Use of Connection ID has been negotiated" \
2140 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2141 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2142 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2143 -s "(after renegotiation) Use of Connection ID has been negotiated"
2144
Hanno Beckera0e20d02019-05-15 14:03:01 +01002145requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002146requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002147run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2148 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2149 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2150 0 \
2151 -S "(initial handshake) Use of Connection ID has been negotiated" \
2152 -C "(initial handshake) Use of Connection ID has been negotiated" \
2153 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2154 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2155 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2156 -s "(after renegotiation) Use of Connection ID has been negotiated"
2157
Hanno Beckera0e20d02019-05-15 14:03:01 +01002158requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002159requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002160run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002161 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002162 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2163 "$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" \
2164 0 \
2165 -S "(initial handshake) Use of Connection ID has been negotiated" \
2166 -C "(initial handshake) Use of Connection ID has been negotiated" \
2167 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2168 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2169 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002170 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2171 -c "ignoring unexpected CID" \
2172 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002173
Hanno Beckera0e20d02019-05-15 14:03:01 +01002174requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002175requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2176run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002177 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2178 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2179 0 \
2180 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2181 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2182 -s "(initial handshake) Use of Connection ID has been negotiated" \
2183 -c "(initial handshake) Use of Connection ID has been negotiated" \
2184 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2185 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2186 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2187 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2188 -s "(after renegotiation) Use of Connection ID was not offered by client"
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 Becker78c91372019-05-08 13:31:15 +01002192run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002193 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002194 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2195 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2196 0 \
2197 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2198 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2199 -s "(initial handshake) Use of Connection ID has been negotiated" \
2200 -c "(initial handshake) Use of Connection ID has been negotiated" \
2201 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2202 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2203 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2204 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002205 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2206 -c "ignoring unexpected CID" \
2207 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002208
Hanno Beckera0e20d02019-05-15 14:03:01 +01002209requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002210requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2211run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2212 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2213 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2214 0 \
2215 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2216 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2217 -s "(initial handshake) Use of Connection ID has been negotiated" \
2218 -c "(initial handshake) Use of Connection ID has been negotiated" \
2219 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2220 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2221 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2222 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2223 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2224
Hanno Beckera0e20d02019-05-15 14:03:01 +01002225requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002226requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2227run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002228 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002229 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2230 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2231 0 \
2232 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2233 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2234 -s "(initial handshake) Use of Connection ID has been negotiated" \
2235 -c "(initial handshake) Use of Connection ID has been negotiated" \
2236 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2237 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2238 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2239 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002240 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2241 -c "ignoring unexpected CID" \
2242 -s "ignoring unexpected CID"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002243
Andrzej Kurekb6577832020-06-08 07:08:03 -04002244requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2245requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2246run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=512" \
2247 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
2248 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=512 dtls=1 cid=1 cid_val=beef" \
2249 0 \
2250 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2251 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2252 -s "(initial handshake) Use of Connection ID has been negotiated" \
2253 -c "(initial handshake) Use of Connection ID has been negotiated" \
2254 -s "Reallocating in_buf" \
2255 -s "Reallocating out_buf"
2256
2257requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2258requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2259run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=1024" \
2260 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
2261 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=1024 dtls=1 cid=1 cid_val=beef" \
2262 0 \
2263 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2264 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2265 -s "(initial handshake) Use of Connection ID has been negotiated" \
2266 -c "(initial handshake) Use of Connection ID has been negotiated" \
2267 -s "Reallocating in_buf" \
2268 -s "Reallocating out_buf"
2269
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002270# Tests for Encrypt-then-MAC extension
2271
2272run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002273 "$P_SRV debug_level=3 \
2274 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002275 "$P_CLI debug_level=3" \
2276 0 \
2277 -c "client hello, adding encrypt_then_mac extension" \
2278 -s "found encrypt then mac extension" \
2279 -s "server hello, adding encrypt then mac extension" \
2280 -c "found encrypt_then_mac extension" \
2281 -c "using encrypt then mac" \
2282 -s "using encrypt then mac"
2283
2284run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002285 "$P_SRV debug_level=3 etm=0 \
2286 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002287 "$P_CLI debug_level=3 etm=1" \
2288 0 \
2289 -c "client hello, adding encrypt_then_mac extension" \
2290 -s "found encrypt then mac extension" \
2291 -S "server hello, adding encrypt then mac extension" \
2292 -C "found encrypt_then_mac extension" \
2293 -C "using encrypt then mac" \
2294 -S "using encrypt then mac"
2295
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002296run_test "Encrypt then MAC: client enabled, aead cipher" \
2297 "$P_SRV debug_level=3 etm=1 \
2298 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2299 "$P_CLI debug_level=3 etm=1" \
2300 0 \
2301 -c "client hello, adding encrypt_then_mac extension" \
2302 -s "found encrypt then mac extension" \
2303 -S "server hello, adding encrypt then mac extension" \
2304 -C "found encrypt_then_mac extension" \
2305 -C "using encrypt then mac" \
2306 -S "using encrypt then mac"
2307
2308run_test "Encrypt then MAC: client enabled, stream cipher" \
2309 "$P_SRV debug_level=3 etm=1 \
2310 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002311 "$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 +01002312 0 \
2313 -c "client hello, adding encrypt_then_mac extension" \
2314 -s "found encrypt then mac extension" \
2315 -S "server hello, adding encrypt then mac extension" \
2316 -C "found encrypt_then_mac extension" \
2317 -C "using encrypt then mac" \
2318 -S "using encrypt then mac"
2319
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002320run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002321 "$P_SRV debug_level=3 etm=1 \
2322 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002323 "$P_CLI debug_level=3 etm=0" \
2324 0 \
2325 -C "client hello, adding encrypt_then_mac extension" \
2326 -S "found encrypt then mac extension" \
2327 -S "server hello, adding encrypt then mac extension" \
2328 -C "found encrypt_then_mac extension" \
2329 -C "using encrypt then mac" \
2330 -S "using encrypt then mac"
2331
Janos Follathe2681a42016-03-07 15:57:05 +00002332requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002333run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002334 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002335 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002336 "$P_CLI debug_level=3 force_version=ssl3" \
2337 0 \
2338 -C "client hello, adding encrypt_then_mac extension" \
2339 -S "found encrypt then mac extension" \
2340 -S "server hello, adding encrypt then mac extension" \
2341 -C "found encrypt_then_mac extension" \
2342 -C "using encrypt then mac" \
2343 -S "using encrypt then mac"
2344
Janos Follathe2681a42016-03-07 15:57:05 +00002345requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002346run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002347 "$P_SRV debug_level=3 force_version=ssl3 \
2348 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002349 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002350 0 \
2351 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002352 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002353 -S "server hello, adding encrypt then mac extension" \
2354 -C "found encrypt_then_mac extension" \
2355 -C "using encrypt then mac" \
2356 -S "using encrypt then mac"
2357
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002358# Tests for Extended Master Secret extension
2359
2360run_test "Extended Master Secret: default" \
2361 "$P_SRV debug_level=3" \
2362 "$P_CLI debug_level=3" \
2363 0 \
2364 -c "client hello, adding extended_master_secret extension" \
2365 -s "found extended master secret extension" \
2366 -s "server hello, adding extended master secret extension" \
2367 -c "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002368 -c "session hash for extended master secret" \
2369 -s "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002370
2371run_test "Extended Master Secret: client enabled, server disabled" \
2372 "$P_SRV debug_level=3 extended_ms=0" \
2373 "$P_CLI debug_level=3 extended_ms=1" \
2374 0 \
2375 -c "client hello, adding extended_master_secret extension" \
2376 -s "found extended master secret extension" \
2377 -S "server hello, adding extended master secret extension" \
2378 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002379 -C "session hash for extended master secret" \
2380 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002381
2382run_test "Extended Master Secret: client disabled, server enabled" \
2383 "$P_SRV debug_level=3 extended_ms=1" \
2384 "$P_CLI debug_level=3 extended_ms=0" \
2385 0 \
2386 -C "client hello, adding extended_master_secret extension" \
2387 -S "found extended master secret extension" \
2388 -S "server hello, adding extended master secret extension" \
2389 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002390 -C "session hash for extended master secret" \
2391 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002392
Janos Follathe2681a42016-03-07 15:57:05 +00002393requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002394run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002395 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002396 "$P_CLI debug_level=3 force_version=ssl3" \
2397 0 \
2398 -C "client hello, adding extended_master_secret extension" \
2399 -S "found extended master secret extension" \
2400 -S "server hello, adding extended master secret extension" \
2401 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002402 -C "session hash for extended master secret" \
2403 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002404
Janos Follathe2681a42016-03-07 15:57:05 +00002405requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002406run_test "Extended Master Secret: client enabled, server SSLv3" \
2407 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002408 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002409 0 \
2410 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002411 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002412 -S "server hello, adding extended master secret extension" \
2413 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002414 -C "session hash for extended master secret" \
2415 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002416
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002417# Tests for FALLBACK_SCSV
2418
2419run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002420 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002421 "$P_CLI debug_level=3 force_version=tls1_1" \
2422 0 \
2423 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002424 -S "received FALLBACK_SCSV" \
2425 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002426 -C "is a fatal alert message (msg 86)"
2427
2428run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002429 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002430 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2431 0 \
2432 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002433 -S "received FALLBACK_SCSV" \
2434 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002435 -C "is a fatal alert message (msg 86)"
2436
2437run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002438 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002439 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002440 1 \
2441 -c "adding FALLBACK_SCSV" \
2442 -s "received FALLBACK_SCSV" \
2443 -s "inapropriate fallback" \
2444 -c "is a fatal alert message (msg 86)"
2445
2446run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002447 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002448 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002449 0 \
2450 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002451 -s "received FALLBACK_SCSV" \
2452 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002453 -C "is a fatal alert message (msg 86)"
2454
2455requires_openssl_with_fallback_scsv
2456run_test "Fallback SCSV: default, openssl server" \
2457 "$O_SRV" \
2458 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2459 0 \
2460 -C "adding FALLBACK_SCSV" \
2461 -C "is a fatal alert message (msg 86)"
2462
2463requires_openssl_with_fallback_scsv
2464run_test "Fallback SCSV: enabled, openssl server" \
2465 "$O_SRV" \
2466 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
2467 1 \
2468 -c "adding FALLBACK_SCSV" \
2469 -c "is a fatal alert message (msg 86)"
2470
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002471requires_openssl_with_fallback_scsv
2472run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002473 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002474 "$O_CLI -tls1_1" \
2475 0 \
2476 -S "received FALLBACK_SCSV" \
2477 -S "inapropriate fallback"
2478
2479requires_openssl_with_fallback_scsv
2480run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002481 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002482 "$O_CLI -tls1_1 -fallback_scsv" \
2483 1 \
2484 -s "received FALLBACK_SCSV" \
2485 -s "inapropriate fallback"
2486
2487requires_openssl_with_fallback_scsv
2488run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002489 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002490 "$O_CLI -fallback_scsv" \
2491 0 \
2492 -s "received FALLBACK_SCSV" \
2493 -S "inapropriate fallback"
2494
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002495# Test sending and receiving empty application data records
2496
2497run_test "Encrypt then MAC: empty application data record" \
2498 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2499 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2500 0 \
2501 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2502 -s "dumping 'input payload after decrypt' (0 bytes)" \
2503 -c "0 bytes written in 1 fragments"
2504
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002505run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002506 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2507 "$P_CLI auth_mode=none etm=0 request_size=0" \
2508 0 \
2509 -s "dumping 'input payload after decrypt' (0 bytes)" \
2510 -c "0 bytes written in 1 fragments"
2511
2512run_test "Encrypt then MAC, DTLS: empty application data record" \
2513 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2514 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2515 0 \
2516 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2517 -s "dumping 'input payload after decrypt' (0 bytes)" \
2518 -c "0 bytes written in 1 fragments"
2519
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002520run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002521 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2522 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2523 0 \
2524 -s "dumping 'input payload after decrypt' (0 bytes)" \
2525 -c "0 bytes written in 1 fragments"
2526
Gilles Peskined50177f2017-05-16 17:53:03 +02002527## ClientHello generated with
2528## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2529## then manually twiddling the ciphersuite list.
2530## The ClientHello content is spelled out below as a hex string as
2531## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2532## The expected response is an inappropriate_fallback alert.
2533requires_openssl_with_fallback_scsv
2534run_test "Fallback SCSV: beginning of list" \
2535 "$P_SRV debug_level=2" \
2536 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2537 0 \
2538 -s "received FALLBACK_SCSV" \
2539 -s "inapropriate fallback"
2540
2541requires_openssl_with_fallback_scsv
2542run_test "Fallback SCSV: end of list" \
2543 "$P_SRV debug_level=2" \
2544 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2545 0 \
2546 -s "received FALLBACK_SCSV" \
2547 -s "inapropriate fallback"
2548
2549## Here the expected response is a valid ServerHello prefix, up to the random.
2550requires_openssl_with_fallback_scsv
2551run_test "Fallback SCSV: not in list" \
2552 "$P_SRV debug_level=2" \
2553 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2554 0 \
2555 -S "received FALLBACK_SCSV" \
2556 -S "inapropriate fallback"
2557
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002558# Tests for CBC 1/n-1 record splitting
2559
2560run_test "CBC Record splitting: TLS 1.2, no splitting" \
2561 "$P_SRV" \
2562 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2563 request_size=123 force_version=tls1_2" \
2564 0 \
2565 -s "Read from client: 123 bytes read" \
2566 -S "Read from client: 1 bytes read" \
2567 -S "122 bytes read"
2568
2569run_test "CBC Record splitting: TLS 1.1, no splitting" \
2570 "$P_SRV" \
2571 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2572 request_size=123 force_version=tls1_1" \
2573 0 \
2574 -s "Read from client: 123 bytes read" \
2575 -S "Read from client: 1 bytes read" \
2576 -S "122 bytes read"
2577
2578run_test "CBC Record splitting: TLS 1.0, splitting" \
2579 "$P_SRV" \
2580 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2581 request_size=123 force_version=tls1" \
2582 0 \
2583 -S "Read from client: 123 bytes read" \
2584 -s "Read from client: 1 bytes read" \
2585 -s "122 bytes read"
2586
Janos Follathe2681a42016-03-07 15:57:05 +00002587requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002588run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002589 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002590 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2591 request_size=123 force_version=ssl3" \
2592 0 \
2593 -S "Read from client: 123 bytes read" \
2594 -s "Read from client: 1 bytes read" \
2595 -s "122 bytes read"
2596
2597run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002598 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002599 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2600 request_size=123 force_version=tls1" \
2601 0 \
2602 -s "Read from client: 123 bytes read" \
2603 -S "Read from client: 1 bytes read" \
2604 -S "122 bytes read"
2605
2606run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2607 "$P_SRV" \
2608 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2609 request_size=123 force_version=tls1 recsplit=0" \
2610 0 \
2611 -s "Read from client: 123 bytes read" \
2612 -S "Read from client: 1 bytes read" \
2613 -S "122 bytes read"
2614
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002615run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2616 "$P_SRV nbio=2" \
2617 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2618 request_size=123 force_version=tls1" \
2619 0 \
2620 -S "Read from client: 123 bytes read" \
2621 -s "Read from client: 1 bytes read" \
2622 -s "122 bytes read"
2623
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002624# Tests for Session Tickets
2625
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002626run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002627 "$P_SRV debug_level=3 tickets=1" \
2628 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002629 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002630 -c "client hello, adding session ticket extension" \
2631 -s "found session ticket extension" \
2632 -s "server hello, adding session ticket extension" \
2633 -c "found session_ticket extension" \
2634 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002635 -S "session successfully restored from cache" \
2636 -s "session successfully restored from ticket" \
2637 -s "a session has been resumed" \
2638 -c "a session has been resumed"
2639
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002640run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002641 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2642 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002643 0 \
2644 -c "client hello, adding session ticket extension" \
2645 -s "found session ticket extension" \
2646 -s "server hello, adding session ticket extension" \
2647 -c "found session_ticket extension" \
2648 -c "parse new session ticket" \
2649 -S "session successfully restored from cache" \
2650 -s "session successfully restored from ticket" \
2651 -s "a session has been resumed" \
2652 -c "a session has been resumed"
2653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002654run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002655 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2656 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002657 0 \
2658 -c "client hello, adding session ticket extension" \
2659 -s "found session ticket extension" \
2660 -s "server hello, adding session ticket extension" \
2661 -c "found session_ticket extension" \
2662 -c "parse new session ticket" \
2663 -S "session successfully restored from cache" \
2664 -S "session successfully restored from ticket" \
2665 -S "a session has been resumed" \
2666 -C "a session has been resumed"
2667
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002668run_test "Session resume using tickets: session copy" \
2669 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2670 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2671 0 \
2672 -c "client hello, adding session ticket extension" \
2673 -s "found session ticket extension" \
2674 -s "server hello, adding session ticket extension" \
2675 -c "found session_ticket extension" \
2676 -c "parse new session ticket" \
2677 -S "session successfully restored from cache" \
2678 -s "session successfully restored from ticket" \
2679 -s "a session has been resumed" \
2680 -c "a session has been resumed"
2681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002682run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002683 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002684 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002685 0 \
2686 -c "client hello, adding session ticket extension" \
2687 -c "found session_ticket extension" \
2688 -c "parse new session ticket" \
2689 -c "a session has been resumed"
2690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002691run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002692 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002693 "( $O_CLI -sess_out $SESSION; \
2694 $O_CLI -sess_in $SESSION; \
2695 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002696 0 \
2697 -s "found session ticket extension" \
2698 -s "server hello, adding session ticket extension" \
2699 -S "session successfully restored from cache" \
2700 -s "session successfully restored from ticket" \
2701 -s "a session has been resumed"
2702
Hanno Becker1d739932018-08-21 13:55:22 +01002703# Tests for Session Tickets with DTLS
2704
2705run_test "Session resume using tickets, DTLS: basic" \
2706 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002707 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002708 0 \
2709 -c "client hello, adding session ticket extension" \
2710 -s "found session ticket extension" \
2711 -s "server hello, adding session ticket extension" \
2712 -c "found session_ticket extension" \
2713 -c "parse new session ticket" \
2714 -S "session successfully restored from cache" \
2715 -s "session successfully restored from ticket" \
2716 -s "a session has been resumed" \
2717 -c "a session has been resumed"
2718
2719run_test "Session resume using tickets, DTLS: cache disabled" \
2720 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002721 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002722 0 \
2723 -c "client hello, adding session ticket extension" \
2724 -s "found session ticket extension" \
2725 -s "server hello, adding session ticket extension" \
2726 -c "found session_ticket extension" \
2727 -c "parse new session ticket" \
2728 -S "session successfully restored from cache" \
2729 -s "session successfully restored from ticket" \
2730 -s "a session has been resumed" \
2731 -c "a session has been resumed"
2732
2733run_test "Session resume using tickets, DTLS: timeout" \
2734 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002735 "$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 +01002736 0 \
2737 -c "client hello, adding session ticket extension" \
2738 -s "found session ticket extension" \
2739 -s "server hello, adding session ticket extension" \
2740 -c "found session_ticket extension" \
2741 -c "parse new session ticket" \
2742 -S "session successfully restored from cache" \
2743 -S "session successfully restored from ticket" \
2744 -S "a session has been resumed" \
2745 -C "a session has been resumed"
2746
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002747run_test "Session resume using tickets, DTLS: session copy" \
2748 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002749 "$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 +02002750 0 \
2751 -c "client hello, adding session ticket extension" \
2752 -s "found session ticket extension" \
2753 -s "server hello, adding session ticket extension" \
2754 -c "found session_ticket extension" \
2755 -c "parse new session ticket" \
2756 -S "session successfully restored from cache" \
2757 -s "session successfully restored from ticket" \
2758 -s "a session has been resumed" \
2759 -c "a session has been resumed"
2760
Hanno Becker1d739932018-08-21 13:55:22 +01002761run_test "Session resume using tickets, DTLS: openssl server" \
2762 "$O_SRV -dtls1" \
2763 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2764 0 \
2765 -c "client hello, adding session ticket extension" \
2766 -c "found session_ticket extension" \
2767 -c "parse new session ticket" \
2768 -c "a session has been resumed"
2769
2770run_test "Session resume using tickets, DTLS: openssl client" \
2771 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2772 "( $O_CLI -dtls1 -sess_out $SESSION; \
2773 $O_CLI -dtls1 -sess_in $SESSION; \
2774 rm -f $SESSION )" \
2775 0 \
2776 -s "found session ticket extension" \
2777 -s "server hello, adding session ticket extension" \
2778 -S "session successfully restored from cache" \
2779 -s "session successfully restored from ticket" \
2780 -s "a session has been resumed"
2781
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002782# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002784run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002785 "$P_SRV debug_level=3 tickets=0" \
2786 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002787 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002788 -c "client hello, adding session ticket extension" \
2789 -s "found session ticket extension" \
2790 -S "server hello, adding session ticket extension" \
2791 -C "found session_ticket extension" \
2792 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002793 -s "session successfully restored from cache" \
2794 -S "session successfully restored from ticket" \
2795 -s "a session has been resumed" \
2796 -c "a session has been resumed"
2797
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002798run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002799 "$P_SRV debug_level=3 tickets=1" \
2800 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002801 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002802 -C "client hello, adding session ticket extension" \
2803 -S "found session ticket extension" \
2804 -S "server hello, adding session ticket extension" \
2805 -C "found session_ticket extension" \
2806 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002807 -s "session successfully restored from cache" \
2808 -S "session successfully restored from ticket" \
2809 -s "a session has been resumed" \
2810 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002812run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002813 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2814 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002815 0 \
2816 -S "session successfully restored from cache" \
2817 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002818 -S "a session has been resumed" \
2819 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002821run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002822 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2823 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002824 0 \
2825 -s "session successfully restored from cache" \
2826 -S "session successfully restored from ticket" \
2827 -s "a session has been resumed" \
2828 -c "a session has been resumed"
2829
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002830run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002831 "$P_SRV debug_level=3 tickets=0" \
2832 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002833 0 \
2834 -s "session successfully restored from cache" \
2835 -S "session successfully restored from ticket" \
2836 -s "a session has been resumed" \
2837 -c "a session has been resumed"
2838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002839run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002840 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2841 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002842 0 \
2843 -S "session successfully restored from cache" \
2844 -S "session successfully restored from ticket" \
2845 -S "a session has been resumed" \
2846 -C "a session has been resumed"
2847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002848run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002849 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2850 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002851 0 \
2852 -s "session successfully restored from cache" \
2853 -S "session successfully restored from ticket" \
2854 -s "a session has been resumed" \
2855 -c "a session has been resumed"
2856
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002857run_test "Session resume using cache: session copy" \
2858 "$P_SRV debug_level=3 tickets=0" \
2859 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2860 0 \
2861 -s "session successfully restored from cache" \
2862 -S "session successfully restored from ticket" \
2863 -s "a session has been resumed" \
2864 -c "a session has been resumed"
2865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002866run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002867 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002868 "( $O_CLI -sess_out $SESSION; \
2869 $O_CLI -sess_in $SESSION; \
2870 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002871 0 \
2872 -s "found session ticket extension" \
2873 -S "server hello, adding session ticket extension" \
2874 -s "session successfully restored from cache" \
2875 -S "session successfully restored from ticket" \
2876 -s "a session has been resumed"
2877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002878run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002879 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002880 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002881 0 \
2882 -C "found session_ticket extension" \
2883 -C "parse new session ticket" \
2884 -c "a session has been resumed"
2885
Hanno Becker1d739932018-08-21 13:55:22 +01002886# Tests for Session Resume based on session-ID and cache, DTLS
2887
2888run_test "Session resume using cache, DTLS: tickets enabled on client" \
2889 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002890 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002891 0 \
2892 -c "client hello, adding session ticket extension" \
2893 -s "found session ticket extension" \
2894 -S "server hello, adding session ticket extension" \
2895 -C "found session_ticket extension" \
2896 -C "parse new session ticket" \
2897 -s "session successfully restored from cache" \
2898 -S "session successfully restored from ticket" \
2899 -s "a session has been resumed" \
2900 -c "a session has been resumed"
2901
2902run_test "Session resume using cache, DTLS: tickets enabled on server" \
2903 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002904 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002905 0 \
2906 -C "client hello, adding session ticket extension" \
2907 -S "found session ticket extension" \
2908 -S "server hello, adding session ticket extension" \
2909 -C "found session_ticket extension" \
2910 -C "parse new session ticket" \
2911 -s "session successfully restored from cache" \
2912 -S "session successfully restored from ticket" \
2913 -s "a session has been resumed" \
2914 -c "a session has been resumed"
2915
2916run_test "Session resume using cache, DTLS: cache_max=0" \
2917 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002918 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002919 0 \
2920 -S "session successfully restored from cache" \
2921 -S "session successfully restored from ticket" \
2922 -S "a session has been resumed" \
2923 -C "a session has been resumed"
2924
2925run_test "Session resume using cache, DTLS: cache_max=1" \
2926 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002927 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002928 0 \
2929 -s "session successfully restored from cache" \
2930 -S "session successfully restored from ticket" \
2931 -s "a session has been resumed" \
2932 -c "a session has been resumed"
2933
2934run_test "Session resume using cache, DTLS: timeout > delay" \
2935 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002936 "$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 +01002937 0 \
2938 -s "session successfully restored from cache" \
2939 -S "session successfully restored from ticket" \
2940 -s "a session has been resumed" \
2941 -c "a session has been resumed"
2942
2943run_test "Session resume using cache, DTLS: timeout < delay" \
2944 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002945 "$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 +01002946 0 \
2947 -S "session successfully restored from cache" \
2948 -S "session successfully restored from ticket" \
2949 -S "a session has been resumed" \
2950 -C "a session has been resumed"
2951
2952run_test "Session resume using cache, DTLS: no timeout" \
2953 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002954 "$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 +01002955 0 \
2956 -s "session successfully restored from cache" \
2957 -S "session successfully restored from ticket" \
2958 -s "a session has been resumed" \
2959 -c "a session has been resumed"
2960
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002961run_test "Session resume using cache, DTLS: session copy" \
2962 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002963 "$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 +02002964 0 \
2965 -s "session successfully restored from cache" \
2966 -S "session successfully restored from ticket" \
2967 -s "a session has been resumed" \
2968 -c "a session has been resumed"
2969
Hanno Becker1d739932018-08-21 13:55:22 +01002970run_test "Session resume using cache, DTLS: openssl client" \
2971 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2972 "( $O_CLI -dtls1 -sess_out $SESSION; \
2973 $O_CLI -dtls1 -sess_in $SESSION; \
2974 rm -f $SESSION )" \
2975 0 \
2976 -s "found session ticket extension" \
2977 -S "server hello, adding session ticket extension" \
2978 -s "session successfully restored from cache" \
2979 -S "session successfully restored from ticket" \
2980 -s "a session has been resumed"
2981
2982run_test "Session resume using cache, DTLS: openssl server" \
2983 "$O_SRV -dtls1" \
2984 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2985 0 \
2986 -C "found session_ticket extension" \
2987 -C "parse new session ticket" \
2988 -c "a session has been resumed"
2989
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002990# Tests for Max Fragment Length extension
2991
Angus Grattonc4dd0732018-04-11 16:28:39 +10002992if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
2993 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 +01002994 exit 1
2995fi
2996
Angus Grattonc4dd0732018-04-11 16:28:39 +10002997if [ $MAX_CONTENT_LEN -ne 16384 ]; then
2998 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
2999fi
3000
Hanno Becker4aed27e2017-09-18 15:00:34 +01003001requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003002run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003003 "$P_SRV debug_level=3" \
3004 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003005 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003006 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3007 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3008 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3009 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003010 -C "client hello, adding max_fragment_length extension" \
3011 -S "found max fragment length extension" \
3012 -S "server hello, max_fragment_length extension" \
3013 -C "found max_fragment_length extension"
3014
Hanno Becker4aed27e2017-09-18 15:00:34 +01003015requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003016run_test "Max fragment length: enabled, default, larger message" \
3017 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003018 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003019 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003020 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3021 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3022 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3023 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003024 -C "client hello, adding max_fragment_length extension" \
3025 -S "found max fragment length extension" \
3026 -S "server hello, max_fragment_length extension" \
3027 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003028 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3029 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003030 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003031
3032requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3033run_test "Max fragment length, DTLS: enabled, default, larger message" \
3034 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003035 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003036 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003037 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3038 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3039 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3040 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003041 -C "client hello, adding max_fragment_length extension" \
3042 -S "found max fragment length extension" \
3043 -S "server hello, max_fragment_length extension" \
3044 -C "found max_fragment_length extension" \
3045 -c "fragment larger than.*maximum "
3046
Angus Grattonc4dd0732018-04-11 16:28:39 +10003047# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3048# (session fragment length will be 16384 regardless of mbedtls
3049# content length configuration.)
3050
Hanno Beckerc5266962017-09-18 15:01:50 +01003051requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3052run_test "Max fragment length: disabled, larger message" \
3053 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003054 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003055 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003056 -C "Maximum input fragment length is 16384" \
3057 -C "Maximum output fragment length is 16384" \
3058 -S "Maximum input fragment length is 16384" \
3059 -S "Maximum output fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003060 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3061 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003062 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003063
3064requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3065run_test "Max fragment length DTLS: disabled, larger message" \
3066 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003067 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003068 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003069 -C "Maximum input fragment length is 16384" \
3070 -C "Maximum output fragment length is 16384" \
3071 -S "Maximum input fragment length is 16384" \
3072 -S "Maximum output fragment length is 16384" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003073 -c "fragment larger than.*maximum "
3074
3075requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003076run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003077 "$P_SRV debug_level=3" \
3078 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003079 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003080 -c "Maximum input fragment length is 4096" \
3081 -c "Maximum output fragment length is 4096" \
3082 -s "Maximum input fragment length is 4096" \
3083 -s "Maximum output fragment length is 4096" \
3084 -c "client hello, adding max_fragment_length extension" \
3085 -s "found max fragment length extension" \
3086 -s "server hello, max_fragment_length extension" \
3087 -c "found max_fragment_length extension"
3088
3089requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3090run_test "Max fragment length: client 512, server 1024" \
3091 "$P_SRV debug_level=3 max_frag_len=1024" \
3092 "$P_CLI debug_level=3 max_frag_len=512" \
3093 0 \
3094 -c "Maximum input fragment length is 512" \
3095 -c "Maximum output fragment length is 512" \
3096 -s "Maximum input fragment length is 512" \
3097 -s "Maximum output fragment length is 512" \
3098 -c "client hello, adding max_fragment_length extension" \
3099 -s "found max fragment length extension" \
3100 -s "server hello, max_fragment_length extension" \
3101 -c "found max_fragment_length extension"
3102
3103requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3104run_test "Max fragment length: client 512, server 2048" \
3105 "$P_SRV debug_level=3 max_frag_len=2048" \
3106 "$P_CLI debug_level=3 max_frag_len=512" \
3107 0 \
3108 -c "Maximum input fragment length is 512" \
3109 -c "Maximum output fragment length is 512" \
3110 -s "Maximum input fragment length is 512" \
3111 -s "Maximum output fragment length is 512" \
3112 -c "client hello, adding max_fragment_length extension" \
3113 -s "found max fragment length extension" \
3114 -s "server hello, max_fragment_length extension" \
3115 -c "found max_fragment_length extension"
3116
3117requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3118run_test "Max fragment length: client 512, server 4096" \
3119 "$P_SRV debug_level=3 max_frag_len=4096" \
3120 "$P_CLI debug_level=3 max_frag_len=512" \
3121 0 \
3122 -c "Maximum input fragment length is 512" \
3123 -c "Maximum output fragment length is 512" \
3124 -s "Maximum input fragment length is 512" \
3125 -s "Maximum output fragment length is 512" \
3126 -c "client hello, adding max_fragment_length extension" \
3127 -s "found max fragment length extension" \
3128 -s "server hello, max_fragment_length extension" \
3129 -c "found max_fragment_length extension"
3130
3131requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3132run_test "Max fragment length: client 1024, server 512" \
3133 "$P_SRV debug_level=3 max_frag_len=512" \
3134 "$P_CLI debug_level=3 max_frag_len=1024" \
3135 0 \
3136 -c "Maximum input fragment length is 1024" \
3137 -c "Maximum output fragment length is 1024" \
3138 -s "Maximum input fragment length is 1024" \
3139 -s "Maximum output fragment length is 512" \
3140 -c "client hello, adding max_fragment_length extension" \
3141 -s "found max fragment length extension" \
3142 -s "server hello, max_fragment_length extension" \
3143 -c "found max_fragment_length extension"
3144
3145requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3146run_test "Max fragment length: client 1024, server 2048" \
3147 "$P_SRV debug_level=3 max_frag_len=2048" \
3148 "$P_CLI debug_level=3 max_frag_len=1024" \
3149 0 \
3150 -c "Maximum input fragment length is 1024" \
3151 -c "Maximum output fragment length is 1024" \
3152 -s "Maximum input fragment length is 1024" \
3153 -s "Maximum output fragment length is 1024" \
3154 -c "client hello, adding max_fragment_length extension" \
3155 -s "found max fragment length extension" \
3156 -s "server hello, max_fragment_length extension" \
3157 -c "found max_fragment_length extension"
3158
3159requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3160run_test "Max fragment length: client 1024, server 4096" \
3161 "$P_SRV debug_level=3 max_frag_len=4096" \
3162 "$P_CLI debug_level=3 max_frag_len=1024" \
3163 0 \
3164 -c "Maximum input fragment length is 1024" \
3165 -c "Maximum output fragment length is 1024" \
3166 -s "Maximum input fragment length is 1024" \
3167 -s "Maximum output fragment length is 1024" \
3168 -c "client hello, adding max_fragment_length extension" \
3169 -s "found max fragment length extension" \
3170 -s "server hello, max_fragment_length extension" \
3171 -c "found max_fragment_length extension"
3172
3173requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3174run_test "Max fragment length: client 2048, server 512" \
3175 "$P_SRV debug_level=3 max_frag_len=512" \
3176 "$P_CLI debug_level=3 max_frag_len=2048" \
3177 0 \
3178 -c "Maximum input fragment length is 2048" \
3179 -c "Maximum output fragment length is 2048" \
3180 -s "Maximum input fragment length is 2048" \
3181 -s "Maximum output fragment length is 512" \
3182 -c "client hello, adding max_fragment_length extension" \
3183 -s "found max fragment length extension" \
3184 -s "server hello, max_fragment_length extension" \
3185 -c "found max_fragment_length extension"
3186
3187requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3188run_test "Max fragment length: client 2048, server 1024" \
3189 "$P_SRV debug_level=3 max_frag_len=1024" \
3190 "$P_CLI debug_level=3 max_frag_len=2048" \
3191 0 \
3192 -c "Maximum input fragment length is 2048" \
3193 -c "Maximum output fragment length is 2048" \
3194 -s "Maximum input fragment length is 2048" \
3195 -s "Maximum output fragment length is 1024" \
3196 -c "client hello, adding max_fragment_length extension" \
3197 -s "found max fragment length extension" \
3198 -s "server hello, max_fragment_length extension" \
3199 -c "found max_fragment_length extension"
3200
3201requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3202run_test "Max fragment length: client 2048, server 4096" \
3203 "$P_SRV debug_level=3 max_frag_len=4096" \
3204 "$P_CLI debug_level=3 max_frag_len=2048" \
3205 0 \
3206 -c "Maximum input fragment length is 2048" \
3207 -c "Maximum output fragment length is 2048" \
3208 -s "Maximum input fragment length is 2048" \
3209 -s "Maximum output fragment length is 2048" \
3210 -c "client hello, adding max_fragment_length extension" \
3211 -s "found max fragment length extension" \
3212 -s "server hello, max_fragment_length extension" \
3213 -c "found max_fragment_length extension"
3214
3215requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3216run_test "Max fragment length: client 4096, server 512" \
3217 "$P_SRV debug_level=3 max_frag_len=512" \
3218 "$P_CLI debug_level=3 max_frag_len=4096" \
3219 0 \
3220 -c "Maximum input fragment length is 4096" \
3221 -c "Maximum output fragment length is 4096" \
3222 -s "Maximum input fragment length is 4096" \
3223 -s "Maximum output fragment length is 512" \
3224 -c "client hello, adding max_fragment_length extension" \
3225 -s "found max fragment length extension" \
3226 -s "server hello, max_fragment_length extension" \
3227 -c "found max_fragment_length extension"
3228
3229requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3230run_test "Max fragment length: client 4096, server 1024" \
3231 "$P_SRV debug_level=3 max_frag_len=1024" \
3232 "$P_CLI debug_level=3 max_frag_len=4096" \
3233 0 \
3234 -c "Maximum input fragment length is 4096" \
3235 -c "Maximum output fragment length is 4096" \
3236 -s "Maximum input fragment length is 4096" \
3237 -s "Maximum output fragment length is 1024" \
3238 -c "client hello, adding max_fragment_length extension" \
3239 -s "found max fragment length extension" \
3240 -s "server hello, max_fragment_length extension" \
3241 -c "found max_fragment_length extension"
3242
3243requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3244run_test "Max fragment length: client 4096, server 2048" \
3245 "$P_SRV debug_level=3 max_frag_len=2048" \
3246 "$P_CLI debug_level=3 max_frag_len=4096" \
3247 0 \
3248 -c "Maximum input fragment length is 4096" \
3249 -c "Maximum output fragment length is 4096" \
3250 -s "Maximum input fragment length is 4096" \
3251 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003252 -c "client hello, adding max_fragment_length extension" \
3253 -s "found max fragment length extension" \
3254 -s "server hello, max_fragment_length extension" \
3255 -c "found max_fragment_length extension"
3256
Hanno Becker4aed27e2017-09-18 15:00:34 +01003257requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003258run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003259 "$P_SRV debug_level=3 max_frag_len=4096" \
3260 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003261 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003262 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3263 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3264 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3265 -s "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003266 -C "client hello, adding max_fragment_length extension" \
3267 -S "found max fragment length extension" \
3268 -S "server hello, max_fragment_length extension" \
3269 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003270
Hanno Becker4aed27e2017-09-18 15:00:34 +01003271requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003272requires_gnutls
3273run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003274 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003275 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003276 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003277 -c "Maximum input fragment length is 4096" \
3278 -c "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003279 -c "client hello, adding max_fragment_length extension" \
3280 -c "found max_fragment_length extension"
3281
Hanno Becker4aed27e2017-09-18 15:00:34 +01003282requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003283run_test "Max fragment length: client, message just fits" \
3284 "$P_SRV debug_level=3" \
3285 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3286 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003287 -c "Maximum input fragment length is 2048" \
3288 -c "Maximum output fragment length is 2048" \
3289 -s "Maximum input fragment length is 2048" \
3290 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003291 -c "client hello, adding max_fragment_length extension" \
3292 -s "found max fragment length extension" \
3293 -s "server hello, max_fragment_length extension" \
3294 -c "found max_fragment_length extension" \
3295 -c "2048 bytes written in 1 fragments" \
3296 -s "2048 bytes read"
3297
Hanno Becker4aed27e2017-09-18 15:00:34 +01003298requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003299run_test "Max fragment length: client, larger message" \
3300 "$P_SRV debug_level=3" \
3301 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3302 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003303 -c "Maximum input fragment length is 2048" \
3304 -c "Maximum output fragment length is 2048" \
3305 -s "Maximum input fragment length is 2048" \
3306 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003307 -c "client hello, adding max_fragment_length extension" \
3308 -s "found max fragment length extension" \
3309 -s "server hello, max_fragment_length extension" \
3310 -c "found max_fragment_length extension" \
3311 -c "2345 bytes written in 2 fragments" \
3312 -s "2048 bytes read" \
3313 -s "297 bytes read"
3314
Hanno Becker4aed27e2017-09-18 15:00:34 +01003315requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003316run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003317 "$P_SRV debug_level=3 dtls=1" \
3318 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3319 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003320 -c "Maximum input fragment length is 2048" \
3321 -c "Maximum output fragment length is 2048" \
3322 -s "Maximum input fragment length is 2048" \
3323 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003324 -c "client hello, adding max_fragment_length extension" \
3325 -s "found max fragment length extension" \
3326 -s "server hello, max_fragment_length extension" \
3327 -c "found max_fragment_length extension" \
3328 -c "fragment larger than.*maximum"
3329
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003330# Tests for renegotiation
3331
Hanno Becker6a243642017-10-12 15:18:45 +01003332# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003333run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003334 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003335 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003336 0 \
3337 -C "client hello, adding renegotiation extension" \
3338 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3339 -S "found renegotiation extension" \
3340 -s "server hello, secure renegotiation extension" \
3341 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003342 -C "=> renegotiate" \
3343 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003344 -S "write hello request"
3345
Hanno Becker6a243642017-10-12 15:18:45 +01003346requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003347run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003348 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003349 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003350 0 \
3351 -c "client hello, adding renegotiation extension" \
3352 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3353 -s "found renegotiation extension" \
3354 -s "server hello, secure renegotiation extension" \
3355 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003356 -c "=> renegotiate" \
3357 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003358 -S "write hello request"
3359
Hanno Becker6a243642017-10-12 15:18:45 +01003360requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003361run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003362 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003363 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003364 0 \
3365 -c "client hello, adding renegotiation extension" \
3366 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3367 -s "found renegotiation extension" \
3368 -s "server hello, secure renegotiation extension" \
3369 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003370 -c "=> renegotiate" \
3371 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003372 -s "write hello request"
3373
Janos Follathb0f148c2017-10-05 12:29:42 +01003374# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3375# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3376# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003377requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003378run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3379 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3380 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3381 0 \
3382 -c "client hello, adding renegotiation extension" \
3383 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3384 -s "found renegotiation extension" \
3385 -s "server hello, secure renegotiation extension" \
3386 -c "found renegotiation extension" \
3387 -c "=> renegotiate" \
3388 -s "=> renegotiate" \
3389 -S "write hello request" \
3390 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3391
3392# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3393# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3394# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003395requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003396run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3397 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3398 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3399 0 \
3400 -c "client hello, adding renegotiation extension" \
3401 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3402 -s "found renegotiation extension" \
3403 -s "server hello, secure renegotiation extension" \
3404 -c "found renegotiation extension" \
3405 -c "=> renegotiate" \
3406 -s "=> renegotiate" \
3407 -s "write hello request" \
3408 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3409
Hanno Becker6a243642017-10-12 15:18:45 +01003410requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003411run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003412 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003413 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003414 0 \
3415 -c "client hello, adding renegotiation extension" \
3416 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3417 -s "found renegotiation extension" \
3418 -s "server hello, secure renegotiation extension" \
3419 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003420 -c "=> renegotiate" \
3421 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003422 -s "write hello request"
3423
Hanno Becker6a243642017-10-12 15:18:45 +01003424requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andrzej Kurek8ea68722020-04-03 06:40:47 -04003425requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3426run_test "Renegotiation with max fragment length: client 2048, server 512" \
3427 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1 max_frag_len=512" \
3428 "$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" \
3429 0 \
3430 -c "Maximum input fragment length is 2048" \
3431 -c "Maximum output fragment length is 2048" \
3432 -s "Maximum input fragment length is 2048" \
3433 -s "Maximum output fragment length is 512" \
3434 -c "client hello, adding max_fragment_length extension" \
3435 -s "found max fragment length extension" \
3436 -s "server hello, max_fragment_length extension" \
3437 -c "found max_fragment_length extension" \
3438 -c "client hello, adding renegotiation extension" \
3439 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3440 -s "found renegotiation extension" \
3441 -s "server hello, secure renegotiation extension" \
3442 -c "found renegotiation extension" \
3443 -c "=> renegotiate" \
3444 -s "=> renegotiate" \
3445 -s "write hello request"
3446
3447requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003448run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003449 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003450 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003451 1 \
3452 -c "client hello, adding renegotiation extension" \
3453 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3454 -S "found renegotiation extension" \
3455 -s "server hello, secure renegotiation extension" \
3456 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003457 -c "=> renegotiate" \
3458 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003459 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003460 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003461 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003462
Hanno Becker6a243642017-10-12 15:18:45 +01003463requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003464run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003465 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003466 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003467 0 \
3468 -C "client hello, adding renegotiation extension" \
3469 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3470 -S "found renegotiation extension" \
3471 -s "server hello, secure renegotiation extension" \
3472 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003473 -C "=> renegotiate" \
3474 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003475 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003476 -S "SSL - An unexpected message was received from our peer" \
3477 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003478
Hanno Becker6a243642017-10-12 15:18:45 +01003479requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003480run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003481 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003482 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003483 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003484 0 \
3485 -C "client hello, adding renegotiation extension" \
3486 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3487 -S "found renegotiation extension" \
3488 -s "server hello, secure renegotiation extension" \
3489 -c "found renegotiation extension" \
3490 -C "=> renegotiate" \
3491 -S "=> renegotiate" \
3492 -s "write hello request" \
3493 -S "SSL - An unexpected message was received from our peer" \
3494 -S "failed"
3495
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003496# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003497requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003498run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003499 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003500 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003501 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003502 0 \
3503 -C "client hello, adding renegotiation extension" \
3504 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3505 -S "found renegotiation extension" \
3506 -s "server hello, secure renegotiation extension" \
3507 -c "found renegotiation extension" \
3508 -C "=> renegotiate" \
3509 -S "=> renegotiate" \
3510 -s "write hello request" \
3511 -S "SSL - An unexpected message was received from our peer" \
3512 -S "failed"
3513
Hanno Becker6a243642017-10-12 15:18:45 +01003514requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003515run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003516 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003517 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003518 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003519 0 \
3520 -C "client hello, adding renegotiation extension" \
3521 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3522 -S "found renegotiation extension" \
3523 -s "server hello, secure renegotiation extension" \
3524 -c "found renegotiation extension" \
3525 -C "=> renegotiate" \
3526 -S "=> renegotiate" \
3527 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003528 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003529
Hanno Becker6a243642017-10-12 15:18:45 +01003530requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003531run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003532 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003533 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003534 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003535 0 \
3536 -c "client hello, adding renegotiation extension" \
3537 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3538 -s "found renegotiation extension" \
3539 -s "server hello, secure renegotiation extension" \
3540 -c "found renegotiation extension" \
3541 -c "=> renegotiate" \
3542 -s "=> renegotiate" \
3543 -s "write hello request" \
3544 -S "SSL - An unexpected message was received from our peer" \
3545 -S "failed"
3546
Hanno Becker6a243642017-10-12 15:18:45 +01003547requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003548run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003549 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003550 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3551 0 \
3552 -C "client hello, adding renegotiation extension" \
3553 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3554 -S "found renegotiation extension" \
3555 -s "server hello, secure renegotiation extension" \
3556 -c "found renegotiation extension" \
3557 -S "record counter limit reached: renegotiate" \
3558 -C "=> renegotiate" \
3559 -S "=> renegotiate" \
3560 -S "write hello request" \
3561 -S "SSL - An unexpected message was received from our peer" \
3562 -S "failed"
3563
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003564# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003565requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003566run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003567 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003568 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003569 0 \
3570 -c "client hello, adding renegotiation extension" \
3571 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3572 -s "found renegotiation extension" \
3573 -s "server hello, secure renegotiation extension" \
3574 -c "found renegotiation extension" \
3575 -s "record counter limit reached: renegotiate" \
3576 -c "=> renegotiate" \
3577 -s "=> renegotiate" \
3578 -s "write hello request" \
3579 -S "SSL - An unexpected message was received from our peer" \
3580 -S "failed"
3581
Hanno Becker6a243642017-10-12 15:18:45 +01003582requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003583run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003584 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003585 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003586 0 \
3587 -c "client hello, adding renegotiation extension" \
3588 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3589 -s "found renegotiation extension" \
3590 -s "server hello, secure renegotiation extension" \
3591 -c "found renegotiation extension" \
3592 -s "record counter limit reached: renegotiate" \
3593 -c "=> renegotiate" \
3594 -s "=> renegotiate" \
3595 -s "write hello request" \
3596 -S "SSL - An unexpected message was received from our peer" \
3597 -S "failed"
3598
Hanno Becker6a243642017-10-12 15:18:45 +01003599requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003600run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003601 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003602 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3603 0 \
3604 -C "client hello, adding renegotiation extension" \
3605 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3606 -S "found renegotiation extension" \
3607 -s "server hello, secure renegotiation extension" \
3608 -c "found renegotiation extension" \
3609 -S "record counter limit reached: renegotiate" \
3610 -C "=> renegotiate" \
3611 -S "=> renegotiate" \
3612 -S "write hello request" \
3613 -S "SSL - An unexpected message was received from our peer" \
3614 -S "failed"
3615
Hanno Becker6a243642017-10-12 15:18:45 +01003616requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003617run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003618 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003619 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003620 0 \
3621 -c "client hello, adding renegotiation extension" \
3622 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3623 -s "found renegotiation extension" \
3624 -s "server hello, secure renegotiation extension" \
3625 -c "found renegotiation extension" \
3626 -c "=> renegotiate" \
3627 -s "=> renegotiate" \
3628 -S "write hello request"
3629
Hanno Becker6a243642017-10-12 15:18:45 +01003630requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003631run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003632 "$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 +02003633 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003634 0 \
3635 -c "client hello, adding renegotiation extension" \
3636 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3637 -s "found renegotiation extension" \
3638 -s "server hello, secure renegotiation extension" \
3639 -c "found renegotiation extension" \
3640 -c "=> renegotiate" \
3641 -s "=> renegotiate" \
3642 -s "write hello request"
3643
Hanno Becker6a243642017-10-12 15:18:45 +01003644requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003645run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003646 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003647 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003648 0 \
3649 -c "client hello, adding renegotiation extension" \
3650 -c "found renegotiation extension" \
3651 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003652 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003653 -C "error" \
3654 -c "HTTP/1.0 200 [Oo][Kk]"
3655
Paul Bakker539d9722015-02-08 16:18:35 +01003656requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003657requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003658run_test "Renegotiation: gnutls server strict, client-initiated" \
3659 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003660 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003661 0 \
3662 -c "client hello, adding renegotiation extension" \
3663 -c "found renegotiation extension" \
3664 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003665 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003666 -C "error" \
3667 -c "HTTP/1.0 200 [Oo][Kk]"
3668
Paul Bakker539d9722015-02-08 16:18:35 +01003669requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003670requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003671run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3672 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3673 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
3674 1 \
3675 -c "client hello, adding renegotiation extension" \
3676 -C "found renegotiation extension" \
3677 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003678 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003679 -c "error" \
3680 -C "HTTP/1.0 200 [Oo][Kk]"
3681
Paul Bakker539d9722015-02-08 16:18:35 +01003682requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003683requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003684run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3685 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3686 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3687 allow_legacy=0" \
3688 1 \
3689 -c "client hello, adding renegotiation extension" \
3690 -C "found renegotiation extension" \
3691 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003692 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003693 -c "error" \
3694 -C "HTTP/1.0 200 [Oo][Kk]"
3695
Paul Bakker539d9722015-02-08 16:18:35 +01003696requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003697requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003698run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3699 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3700 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3701 allow_legacy=1" \
3702 0 \
3703 -c "client hello, adding renegotiation extension" \
3704 -C "found renegotiation extension" \
3705 -c "=> renegotiate" \
3706 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003707 -C "error" \
3708 -c "HTTP/1.0 200 [Oo][Kk]"
3709
Hanno Becker6a243642017-10-12 15:18:45 +01003710requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003711run_test "Renegotiation: DTLS, client-initiated" \
3712 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3713 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3714 0 \
3715 -c "client hello, adding renegotiation extension" \
3716 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3717 -s "found renegotiation extension" \
3718 -s "server hello, secure renegotiation extension" \
3719 -c "found renegotiation extension" \
3720 -c "=> renegotiate" \
3721 -s "=> renegotiate" \
3722 -S "write hello request"
3723
Hanno Becker6a243642017-10-12 15:18:45 +01003724requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003725run_test "Renegotiation: DTLS, server-initiated" \
3726 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003727 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3728 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003729 0 \
3730 -c "client hello, adding renegotiation extension" \
3731 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3732 -s "found renegotiation extension" \
3733 -s "server hello, secure renegotiation extension" \
3734 -c "found renegotiation extension" \
3735 -c "=> renegotiate" \
3736 -s "=> renegotiate" \
3737 -s "write hello request"
3738
Hanno Becker6a243642017-10-12 15:18:45 +01003739requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003740run_test "Renegotiation: DTLS, renego_period overflow" \
3741 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3742 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3743 0 \
3744 -c "client hello, adding renegotiation extension" \
3745 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3746 -s "found renegotiation extension" \
3747 -s "server hello, secure renegotiation extension" \
3748 -s "record counter limit reached: renegotiate" \
3749 -c "=> renegotiate" \
3750 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003751 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003752
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003753requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003754requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003755run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3756 "$G_SRV -u --mtu 4096" \
3757 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
3758 0 \
3759 -c "client hello, adding renegotiation extension" \
3760 -c "found renegotiation extension" \
3761 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003762 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003763 -C "error" \
3764 -s "Extra-header:"
3765
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003766# Test for the "secure renegotation" extension only (no actual renegotiation)
3767
Paul Bakker539d9722015-02-08 16:18:35 +01003768requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003769run_test "Renego ext: gnutls server strict, client default" \
3770 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
3771 "$P_CLI debug_level=3" \
3772 0 \
3773 -c "found renegotiation extension" \
3774 -C "error" \
3775 -c "HTTP/1.0 200 [Oo][Kk]"
3776
Paul Bakker539d9722015-02-08 16:18:35 +01003777requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003778run_test "Renego ext: gnutls server unsafe, client default" \
3779 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3780 "$P_CLI debug_level=3" \
3781 0 \
3782 -C "found renegotiation extension" \
3783 -C "error" \
3784 -c "HTTP/1.0 200 [Oo][Kk]"
3785
Paul Bakker539d9722015-02-08 16:18:35 +01003786requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003787run_test "Renego ext: gnutls server unsafe, client break legacy" \
3788 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3789 "$P_CLI debug_level=3 allow_legacy=-1" \
3790 1 \
3791 -C "found renegotiation extension" \
3792 -c "error" \
3793 -C "HTTP/1.0 200 [Oo][Kk]"
3794
Paul Bakker539d9722015-02-08 16:18:35 +01003795requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003796run_test "Renego ext: gnutls client strict, server default" \
3797 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003798 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003799 0 \
3800 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3801 -s "server hello, secure renegotiation extension"
3802
Paul Bakker539d9722015-02-08 16:18:35 +01003803requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003804run_test "Renego ext: gnutls client unsafe, server default" \
3805 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003806 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003807 0 \
3808 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3809 -S "server hello, secure renegotiation extension"
3810
Paul Bakker539d9722015-02-08 16:18:35 +01003811requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003812run_test "Renego ext: gnutls client unsafe, server break legacy" \
3813 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003814 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003815 1 \
3816 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3817 -S "server hello, secure renegotiation extension"
3818
Janos Follath0b242342016-02-17 10:11:21 +00003819# Tests for silently dropping trailing extra bytes in .der certificates
3820
3821requires_gnutls
3822run_test "DER format: no trailing bytes" \
3823 "$P_SRV crt_file=data_files/server5-der0.crt \
3824 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003825 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003826 0 \
3827 -c "Handshake was completed" \
3828
3829requires_gnutls
3830run_test "DER format: with a trailing zero byte" \
3831 "$P_SRV crt_file=data_files/server5-der1a.crt \
3832 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003833 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003834 0 \
3835 -c "Handshake was completed" \
3836
3837requires_gnutls
3838run_test "DER format: with a trailing random byte" \
3839 "$P_SRV crt_file=data_files/server5-der1b.crt \
3840 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003841 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003842 0 \
3843 -c "Handshake was completed" \
3844
3845requires_gnutls
3846run_test "DER format: with 2 trailing random bytes" \
3847 "$P_SRV crt_file=data_files/server5-der2.crt \
3848 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003849 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003850 0 \
3851 -c "Handshake was completed" \
3852
3853requires_gnutls
3854run_test "DER format: with 4 trailing random bytes" \
3855 "$P_SRV crt_file=data_files/server5-der4.crt \
3856 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003857 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003858 0 \
3859 -c "Handshake was completed" \
3860
3861requires_gnutls
3862run_test "DER format: with 8 trailing random bytes" \
3863 "$P_SRV crt_file=data_files/server5-der8.crt \
3864 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003865 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003866 0 \
3867 -c "Handshake was completed" \
3868
3869requires_gnutls
3870run_test "DER format: with 9 trailing random bytes" \
3871 "$P_SRV crt_file=data_files/server5-der9.crt \
3872 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003873 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003874 0 \
3875 -c "Handshake was completed" \
3876
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03003877# Tests for auth_mode, there are duplicated tests using ca callback for authentication
3878# When updating these tests, modify the matching authentication tests accordingly
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003880run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003881 "$P_SRV crt_file=data_files/server5-badsign.crt \
3882 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003883 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003884 1 \
3885 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003886 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003887 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003888 -c "X509 - Certificate verification failed"
3889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003890run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003891 "$P_SRV crt_file=data_files/server5-badsign.crt \
3892 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003893 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003894 0 \
3895 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003896 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003897 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003898 -C "X509 - Certificate verification failed"
3899
Hanno Beckere6706e62017-05-15 16:05:15 +01003900run_test "Authentication: server goodcert, client optional, no trusted CA" \
3901 "$P_SRV" \
3902 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3903 0 \
3904 -c "x509_verify_cert() returned" \
3905 -c "! The certificate is not correctly signed by the trusted CA" \
3906 -c "! Certificate verification flags"\
3907 -C "! mbedtls_ssl_handshake returned" \
3908 -C "X509 - Certificate verification failed" \
3909 -C "SSL - No CA Chain is set, but required to operate"
3910
3911run_test "Authentication: server goodcert, client required, no trusted CA" \
3912 "$P_SRV" \
3913 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3914 1 \
3915 -c "x509_verify_cert() returned" \
3916 -c "! The certificate is not correctly signed by the trusted CA" \
3917 -c "! Certificate verification flags"\
3918 -c "! mbedtls_ssl_handshake returned" \
3919 -c "SSL - No CA Chain is set, but required to operate"
3920
3921# The purpose of the next two tests is to test the client's behaviour when receiving a server
3922# certificate with an unsupported elliptic curve. This should usually not happen because
3923# the client informs the server about the supported curves - it does, though, in the
3924# corner case of a static ECDH suite, because the server doesn't check the curve on that
3925# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3926# different means to have the server ignoring the client's supported curve list.
3927
3928requires_config_enabled MBEDTLS_ECP_C
3929run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3930 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3931 crt_file=data_files/server5.ku-ka.crt" \
3932 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3933 1 \
3934 -c "bad certificate (EC key curve)"\
3935 -c "! Certificate verification flags"\
3936 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3937
3938requires_config_enabled MBEDTLS_ECP_C
3939run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3940 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3941 crt_file=data_files/server5.ku-ka.crt" \
3942 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3943 1 \
3944 -c "bad certificate (EC key curve)"\
3945 -c "! Certificate verification flags"\
3946 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3947
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003948run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003949 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003950 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003951 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003952 0 \
3953 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003954 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003955 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003956 -C "X509 - Certificate verification failed"
3957
Simon Butcher99000142016-10-13 17:21:01 +01003958run_test "Authentication: client SHA256, server required" \
3959 "$P_SRV auth_mode=required" \
3960 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3961 key_file=data_files/server6.key \
3962 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3963 0 \
3964 -c "Supported Signature Algorithm found: 4," \
3965 -c "Supported Signature Algorithm found: 5,"
3966
3967run_test "Authentication: client SHA384, server required" \
3968 "$P_SRV auth_mode=required" \
3969 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3970 key_file=data_files/server6.key \
3971 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3972 0 \
3973 -c "Supported Signature Algorithm found: 4," \
3974 -c "Supported Signature Algorithm found: 5,"
3975
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003976requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3977run_test "Authentication: client has no cert, server required (SSLv3)" \
3978 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3979 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3980 key_file=data_files/server5.key" \
3981 1 \
3982 -S "skip write certificate request" \
3983 -C "skip parse certificate request" \
3984 -c "got a certificate request" \
3985 -c "got no certificate to send" \
3986 -S "x509_verify_cert() returned" \
3987 -s "client has no certificate" \
3988 -s "! mbedtls_ssl_handshake returned" \
3989 -c "! mbedtls_ssl_handshake returned" \
3990 -s "No client certification received from the client, but required by the authentication mode"
3991
3992run_test "Authentication: client has no cert, server required (TLS)" \
3993 "$P_SRV debug_level=3 auth_mode=required" \
3994 "$P_CLI debug_level=3 crt_file=none \
3995 key_file=data_files/server5.key" \
3996 1 \
3997 -S "skip write certificate request" \
3998 -C "skip parse certificate request" \
3999 -c "got a certificate request" \
4000 -c "= write certificate$" \
4001 -C "skip write certificate$" \
4002 -S "x509_verify_cert() returned" \
4003 -s "client has no certificate" \
4004 -s "! mbedtls_ssl_handshake returned" \
4005 -c "! mbedtls_ssl_handshake returned" \
4006 -s "No client certification received from the client, but required by the authentication mode"
4007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004008run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004009 "$P_SRV debug_level=3 auth_mode=required" \
4010 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004011 key_file=data_files/server5.key" \
4012 1 \
4013 -S "skip write certificate request" \
4014 -C "skip parse certificate request" \
4015 -c "got a certificate request" \
4016 -C "skip write certificate" \
4017 -C "skip write certificate verify" \
4018 -S "skip parse certificate verify" \
4019 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004020 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004021 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02004022 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004023 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004024 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02004025# We don't check that the client receives the alert because it might
4026# detect that its write end of the connection is closed and abort
4027# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004028
Janos Follath89baba22017-04-10 14:34:35 +01004029run_test "Authentication: client cert not trusted, server required" \
4030 "$P_SRV debug_level=3 auth_mode=required" \
4031 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4032 key_file=data_files/server5.key" \
4033 1 \
4034 -S "skip write certificate request" \
4035 -C "skip parse certificate request" \
4036 -c "got a certificate request" \
4037 -C "skip write certificate" \
4038 -C "skip write certificate verify" \
4039 -S "skip parse certificate verify" \
4040 -s "x509_verify_cert() returned" \
4041 -s "! The certificate is not correctly signed by the trusted CA" \
4042 -s "! mbedtls_ssl_handshake returned" \
4043 -c "! mbedtls_ssl_handshake returned" \
4044 -s "X509 - Certificate verification failed"
4045
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004046run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004047 "$P_SRV debug_level=3 auth_mode=optional" \
4048 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004049 key_file=data_files/server5.key" \
4050 0 \
4051 -S "skip write certificate request" \
4052 -C "skip parse certificate request" \
4053 -c "got a certificate request" \
4054 -C "skip write certificate" \
4055 -C "skip write certificate verify" \
4056 -S "skip parse certificate verify" \
4057 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004058 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004059 -S "! mbedtls_ssl_handshake returned" \
4060 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004061 -S "X509 - Certificate verification failed"
4062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004063run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004064 "$P_SRV debug_level=3 auth_mode=none" \
4065 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004066 key_file=data_files/server5.key" \
4067 0 \
4068 -s "skip write certificate request" \
4069 -C "skip parse certificate request" \
4070 -c "got no certificate request" \
4071 -c "skip write certificate" \
4072 -c "skip write certificate verify" \
4073 -s "skip parse certificate verify" \
4074 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004075 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004076 -S "! mbedtls_ssl_handshake returned" \
4077 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004078 -S "X509 - Certificate verification failed"
4079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004080run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004081 "$P_SRV debug_level=3 auth_mode=optional" \
4082 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004083 0 \
4084 -S "skip write certificate request" \
4085 -C "skip parse certificate request" \
4086 -c "got a certificate request" \
4087 -C "skip write certificate$" \
4088 -C "got no certificate to send" \
4089 -S "SSLv3 client has no certificate" \
4090 -c "skip write certificate verify" \
4091 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004092 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004093 -S "! mbedtls_ssl_handshake returned" \
4094 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004095 -S "X509 - Certificate verification failed"
4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004097run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004098 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004099 "$O_CLI" \
4100 0 \
4101 -S "skip write certificate request" \
4102 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004103 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004104 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004105 -S "X509 - Certificate verification failed"
4106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004107run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004108 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004109 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004110 0 \
4111 -C "skip parse certificate request" \
4112 -c "got a certificate request" \
4113 -C "skip write certificate$" \
4114 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004115 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004116
Gilles Peskinefd8332e2017-05-03 16:25:07 +02004117run_test "Authentication: client no cert, openssl server required" \
4118 "$O_SRV -Verify 10" \
4119 "$P_CLI debug_level=3 crt_file=none key_file=none" \
4120 1 \
4121 -C "skip parse certificate request" \
4122 -c "got a certificate request" \
4123 -C "skip write certificate$" \
4124 -c "skip write certificate verify" \
4125 -c "! mbedtls_ssl_handshake returned"
4126
Janos Follathe2681a42016-03-07 15:57:05 +00004127requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004128run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004129 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004130 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004131 0 \
4132 -S "skip write certificate request" \
4133 -C "skip parse certificate request" \
4134 -c "got a certificate request" \
4135 -C "skip write certificate$" \
4136 -c "skip write certificate verify" \
4137 -c "got no certificate to send" \
4138 -s "SSLv3 client has no certificate" \
4139 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004140 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004141 -S "! mbedtls_ssl_handshake returned" \
4142 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004143 -S "X509 - Certificate verification failed"
4144
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02004145# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
4146# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004147
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004148MAX_IM_CA='8'
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02004149MAX_IM_CA_CONFIG=$( ../scripts/config.py get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004150
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004151if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01004152 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004153 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004154 printf "test value of ${MAX_IM_CA}. \n"
4155 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004156 printf "The tests assume this value and if it changes, the tests in this\n"
4157 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004158 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004159
4160 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004161fi
4162
Angus Grattonc4dd0732018-04-11 16:28:39 +10004163requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004164run_test "Authentication: server max_int chain, client default" \
4165 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4166 key_file=data_files/dir-maxpath/09.key" \
4167 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4168 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004169 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004170
Angus Grattonc4dd0732018-04-11 16:28:39 +10004171requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004172run_test "Authentication: server max_int+1 chain, client default" \
4173 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4174 key_file=data_files/dir-maxpath/10.key" \
4175 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4176 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004177 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004178
Angus Grattonc4dd0732018-04-11 16:28:39 +10004179requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004180run_test "Authentication: server max_int+1 chain, client optional" \
4181 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4182 key_file=data_files/dir-maxpath/10.key" \
4183 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4184 auth_mode=optional" \
4185 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004186 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004187
Angus Grattonc4dd0732018-04-11 16:28:39 +10004188requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004189run_test "Authentication: server max_int+1 chain, client none" \
4190 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4191 key_file=data_files/dir-maxpath/10.key" \
4192 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4193 auth_mode=none" \
4194 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004195 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004196
Angus Grattonc4dd0732018-04-11 16:28:39 +10004197requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004198run_test "Authentication: client max_int+1 chain, server default" \
4199 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4200 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4201 key_file=data_files/dir-maxpath/10.key" \
4202 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004203 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004204
Angus Grattonc4dd0732018-04-11 16:28:39 +10004205requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004206run_test "Authentication: client max_int+1 chain, server optional" \
4207 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4208 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4209 key_file=data_files/dir-maxpath/10.key" \
4210 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004211 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004212
Angus Grattonc4dd0732018-04-11 16:28:39 +10004213requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004214run_test "Authentication: client max_int+1 chain, server required" \
4215 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4216 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4217 key_file=data_files/dir-maxpath/10.key" \
4218 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004219 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004220
Angus Grattonc4dd0732018-04-11 16:28:39 +10004221requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004222run_test "Authentication: client max_int chain, server required" \
4223 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4224 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4225 key_file=data_files/dir-maxpath/09.key" \
4226 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004227 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004228
Janos Follath89baba22017-04-10 14:34:35 +01004229# Tests for CA list in CertificateRequest messages
4230
4231run_test "Authentication: send CA list in CertificateRequest (default)" \
4232 "$P_SRV debug_level=3 auth_mode=required" \
4233 "$P_CLI crt_file=data_files/server6.crt \
4234 key_file=data_files/server6.key" \
4235 0 \
4236 -s "requested DN"
4237
4238run_test "Authentication: do not send CA list in CertificateRequest" \
4239 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4240 "$P_CLI crt_file=data_files/server6.crt \
4241 key_file=data_files/server6.key" \
4242 0 \
4243 -S "requested DN"
4244
4245run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4246 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4247 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4248 key_file=data_files/server5.key" \
4249 1 \
4250 -S "requested DN" \
4251 -s "x509_verify_cert() returned" \
4252 -s "! The certificate is not correctly signed by the trusted CA" \
4253 -s "! mbedtls_ssl_handshake returned" \
4254 -c "! mbedtls_ssl_handshake returned" \
4255 -s "X509 - Certificate verification failed"
4256
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03004257# Tests for auth_mode, using CA callback, these are duplicated from the authentication tests
4258# When updating these tests, modify the matching authentication tests accordingly
Hanno Becker746aaf32019-03-28 15:25:23 +00004259
4260requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4261run_test "Authentication, CA callback: server badcert, client required" \
4262 "$P_SRV crt_file=data_files/server5-badsign.crt \
4263 key_file=data_files/server5.key" \
4264 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required" \
4265 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004266 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004267 -c "x509_verify_cert() returned" \
4268 -c "! The certificate is not correctly signed by the trusted CA" \
4269 -c "! mbedtls_ssl_handshake returned" \
4270 -c "X509 - Certificate verification failed"
4271
4272requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4273run_test "Authentication, CA callback: server badcert, client optional" \
4274 "$P_SRV crt_file=data_files/server5-badsign.crt \
4275 key_file=data_files/server5.key" \
4276 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional" \
4277 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004278 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004279 -c "x509_verify_cert() returned" \
4280 -c "! The certificate is not correctly signed by the trusted CA" \
4281 -C "! mbedtls_ssl_handshake returned" \
4282 -C "X509 - Certificate verification failed"
4283
4284# The purpose of the next two tests is to test the client's behaviour when receiving a server
4285# certificate with an unsupported elliptic curve. This should usually not happen because
4286# the client informs the server about the supported curves - it does, though, in the
4287# corner case of a static ECDH suite, because the server doesn't check the curve on that
4288# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
4289# different means to have the server ignoring the client's supported curve list.
4290
4291requires_config_enabled MBEDTLS_ECP_C
4292requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4293run_test "Authentication, CA callback: server ECDH p256v1, client required, p256v1 unsupported" \
4294 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4295 crt_file=data_files/server5.ku-ka.crt" \
4296 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required curves=secp521r1" \
4297 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004298 -c "use CA callback for X.509 CRT verification" \
4299 -c "bad certificate (EC key curve)" \
4300 -c "! Certificate verification flags" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004301 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
4302
4303requires_config_enabled MBEDTLS_ECP_C
4304requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4305run_test "Authentication, CA callback: server ECDH p256v1, client optional, p256v1 unsupported" \
4306 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4307 crt_file=data_files/server5.ku-ka.crt" \
4308 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional curves=secp521r1" \
4309 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004310 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004311 -c "bad certificate (EC key curve)"\
4312 -c "! Certificate verification flags"\
4313 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
4314
4315requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4316run_test "Authentication, CA callback: client SHA256, server required" \
4317 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4318 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4319 key_file=data_files/server6.key \
4320 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
4321 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004322 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004323 -c "Supported Signature Algorithm found: 4," \
4324 -c "Supported Signature Algorithm found: 5,"
4325
4326requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4327run_test "Authentication, CA callback: client SHA384, server required" \
4328 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4329 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4330 key_file=data_files/server6.key \
4331 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
4332 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004333 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004334 -c "Supported Signature Algorithm found: 4," \
4335 -c "Supported Signature Algorithm found: 5,"
4336
4337requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4338run_test "Authentication, CA callback: client badcert, server required" \
4339 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4340 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4341 key_file=data_files/server5.key" \
4342 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004343 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004344 -S "skip write certificate request" \
4345 -C "skip parse certificate request" \
4346 -c "got a certificate request" \
4347 -C "skip write certificate" \
4348 -C "skip write certificate verify" \
4349 -S "skip parse certificate verify" \
4350 -s "x509_verify_cert() returned" \
4351 -s "! The certificate is not correctly signed by the trusted CA" \
4352 -s "! mbedtls_ssl_handshake returned" \
4353 -s "send alert level=2 message=48" \
4354 -c "! mbedtls_ssl_handshake returned" \
4355 -s "X509 - Certificate verification failed"
4356# We don't check that the client receives the alert because it might
4357# detect that its write end of the connection is closed and abort
4358# before reading the alert message.
4359
4360requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4361run_test "Authentication, CA callback: client cert not trusted, server required" \
4362 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4363 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4364 key_file=data_files/server5.key" \
4365 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004366 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004367 -S "skip write certificate request" \
4368 -C "skip parse certificate request" \
4369 -c "got a certificate request" \
4370 -C "skip write certificate" \
4371 -C "skip write certificate verify" \
4372 -S "skip parse certificate verify" \
4373 -s "x509_verify_cert() returned" \
4374 -s "! The certificate is not correctly signed by the trusted CA" \
4375 -s "! mbedtls_ssl_handshake returned" \
4376 -c "! mbedtls_ssl_handshake returned" \
4377 -s "X509 - Certificate verification failed"
4378
4379requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4380run_test "Authentication, CA callback: client badcert, server optional" \
4381 "$P_SRV ca_callback=1 debug_level=3 auth_mode=optional" \
4382 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4383 key_file=data_files/server5.key" \
4384 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004385 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004386 -S "skip write certificate request" \
4387 -C "skip parse certificate request" \
4388 -c "got a certificate request" \
4389 -C "skip write certificate" \
4390 -C "skip write certificate verify" \
4391 -S "skip parse certificate verify" \
4392 -s "x509_verify_cert() returned" \
4393 -s "! The certificate is not correctly signed by the trusted CA" \
4394 -S "! mbedtls_ssl_handshake returned" \
4395 -C "! mbedtls_ssl_handshake returned" \
4396 -S "X509 - Certificate verification failed"
4397
4398requires_full_size_output_buffer
4399requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4400run_test "Authentication, CA callback: server max_int chain, client default" \
4401 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4402 key_file=data_files/dir-maxpath/09.key" \
4403 "$P_CLI ca_callback=1 debug_level=3 server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4404 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004405 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004406 -C "X509 - A fatal error occurred"
4407
4408requires_full_size_output_buffer
4409requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4410run_test "Authentication, CA callback: server max_int+1 chain, client default" \
4411 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4412 key_file=data_files/dir-maxpath/10.key" \
4413 "$P_CLI debug_level=3 ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4414 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004415 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004416 -c "X509 - A fatal error occurred"
4417
4418requires_full_size_output_buffer
4419requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4420run_test "Authentication, CA callback: server max_int+1 chain, client optional" \
4421 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4422 key_file=data_files/dir-maxpath/10.key" \
4423 "$P_CLI ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4424 debug_level=3 auth_mode=optional" \
4425 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004426 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004427 -c "X509 - A fatal error occurred"
4428
4429requires_full_size_output_buffer
4430requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4431run_test "Authentication, CA callback: client max_int+1 chain, server optional" \
4432 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4433 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4434 key_file=data_files/dir-maxpath/10.key" \
4435 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004436 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004437 -s "X509 - A fatal error occurred"
4438
4439requires_full_size_output_buffer
4440requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4441run_test "Authentication, CA callback: client max_int+1 chain, server required" \
4442 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4443 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4444 key_file=data_files/dir-maxpath/10.key" \
4445 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004446 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004447 -s "X509 - A fatal error occurred"
4448
4449requires_full_size_output_buffer
4450requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4451run_test "Authentication, CA callback: client max_int chain, server required" \
4452 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4453 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4454 key_file=data_files/dir-maxpath/09.key" \
4455 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004456 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004457 -S "X509 - A fatal error occurred"
4458
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004459# Tests for certificate selection based on SHA verson
4460
4461run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4462 "$P_SRV crt_file=data_files/server5.crt \
4463 key_file=data_files/server5.key \
4464 crt_file2=data_files/server5-sha1.crt \
4465 key_file2=data_files/server5.key" \
4466 "$P_CLI force_version=tls1_2" \
4467 0 \
4468 -c "signed using.*ECDSA with SHA256" \
4469 -C "signed using.*ECDSA with SHA1"
4470
4471run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4472 "$P_SRV crt_file=data_files/server5.crt \
4473 key_file=data_files/server5.key \
4474 crt_file2=data_files/server5-sha1.crt \
4475 key_file2=data_files/server5.key" \
4476 "$P_CLI force_version=tls1_1" \
4477 0 \
4478 -C "signed using.*ECDSA with SHA256" \
4479 -c "signed using.*ECDSA with SHA1"
4480
4481run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4482 "$P_SRV crt_file=data_files/server5.crt \
4483 key_file=data_files/server5.key \
4484 crt_file2=data_files/server5-sha1.crt \
4485 key_file2=data_files/server5.key" \
4486 "$P_CLI force_version=tls1" \
4487 0 \
4488 -C "signed using.*ECDSA with SHA256" \
4489 -c "signed using.*ECDSA with SHA1"
4490
4491run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4492 "$P_SRV crt_file=data_files/server5.crt \
4493 key_file=data_files/server5.key \
4494 crt_file2=data_files/server6.crt \
4495 key_file2=data_files/server6.key" \
4496 "$P_CLI force_version=tls1_1" \
4497 0 \
4498 -c "serial number.*09" \
4499 -c "signed using.*ECDSA with SHA256" \
4500 -C "signed using.*ECDSA with SHA1"
4501
4502run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4503 "$P_SRV crt_file=data_files/server6.crt \
4504 key_file=data_files/server6.key \
4505 crt_file2=data_files/server5.crt \
4506 key_file2=data_files/server5.key" \
4507 "$P_CLI force_version=tls1_1" \
4508 0 \
4509 -c "serial number.*0A" \
4510 -c "signed using.*ECDSA with SHA256" \
4511 -C "signed using.*ECDSA with SHA1"
4512
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004513# tests for SNI
4514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004515run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004516 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004517 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004518 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004519 0 \
4520 -S "parse ServerName extension" \
4521 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4522 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004524run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004525 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004526 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004527 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 +02004528 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004529 0 \
4530 -s "parse ServerName extension" \
4531 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4532 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004534run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004535 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004536 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004537 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 +02004538 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004539 0 \
4540 -s "parse ServerName extension" \
4541 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4542 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004544run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004545 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004546 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004547 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 +02004548 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004549 1 \
4550 -s "parse ServerName extension" \
4551 -s "ssl_sni_wrapper() returned" \
4552 -s "mbedtls_ssl_handshake returned" \
4553 -c "mbedtls_ssl_handshake returned" \
4554 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004555
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004556run_test "SNI: client auth no override: optional" \
4557 "$P_SRV debug_level=3 auth_mode=optional \
4558 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4559 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4560 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004561 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004562 -S "skip write certificate request" \
4563 -C "skip parse certificate request" \
4564 -c "got a certificate request" \
4565 -C "skip write certificate" \
4566 -C "skip write certificate verify" \
4567 -S "skip parse certificate verify"
4568
4569run_test "SNI: client auth override: none -> optional" \
4570 "$P_SRV debug_level=3 auth_mode=none \
4571 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4572 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4573 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004574 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004575 -S "skip write certificate request" \
4576 -C "skip parse certificate request" \
4577 -c "got a certificate request" \
4578 -C "skip write certificate" \
4579 -C "skip write certificate verify" \
4580 -S "skip parse certificate verify"
4581
4582run_test "SNI: client auth override: optional -> none" \
4583 "$P_SRV debug_level=3 auth_mode=optional \
4584 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4585 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4586 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004587 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004588 -s "skip write certificate request" \
4589 -C "skip parse certificate request" \
4590 -c "got no certificate request" \
4591 -c "skip write certificate" \
4592 -c "skip write certificate verify" \
4593 -s "skip parse certificate verify"
4594
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004595run_test "SNI: CA no override" \
4596 "$P_SRV debug_level=3 auth_mode=optional \
4597 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4598 ca_file=data_files/test-ca.crt \
4599 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4600 "$P_CLI debug_level=3 server_name=localhost \
4601 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4602 1 \
4603 -S "skip write certificate request" \
4604 -C "skip parse certificate request" \
4605 -c "got a certificate request" \
4606 -C "skip write certificate" \
4607 -C "skip write certificate verify" \
4608 -S "skip parse certificate verify" \
4609 -s "x509_verify_cert() returned" \
4610 -s "! The certificate is not correctly signed by the trusted CA" \
4611 -S "The certificate has been revoked (is on a CRL)"
4612
4613run_test "SNI: CA override" \
4614 "$P_SRV debug_level=3 auth_mode=optional \
4615 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4616 ca_file=data_files/test-ca.crt \
4617 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4618 "$P_CLI debug_level=3 server_name=localhost \
4619 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4620 0 \
4621 -S "skip write certificate request" \
4622 -C "skip parse certificate request" \
4623 -c "got a certificate request" \
4624 -C "skip write certificate" \
4625 -C "skip write certificate verify" \
4626 -S "skip parse certificate verify" \
4627 -S "x509_verify_cert() returned" \
4628 -S "! The certificate is not correctly signed by the trusted CA" \
4629 -S "The certificate has been revoked (is on a CRL)"
4630
4631run_test "SNI: CA override with CRL" \
4632 "$P_SRV debug_level=3 auth_mode=optional \
4633 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4634 ca_file=data_files/test-ca.crt \
4635 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4636 "$P_CLI debug_level=3 server_name=localhost \
4637 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4638 1 \
4639 -S "skip write certificate request" \
4640 -C "skip parse certificate request" \
4641 -c "got a certificate request" \
4642 -C "skip write certificate" \
4643 -C "skip write certificate verify" \
4644 -S "skip parse certificate verify" \
4645 -s "x509_verify_cert() returned" \
4646 -S "! The certificate is not correctly signed by the trusted CA" \
4647 -s "The certificate has been revoked (is on a CRL)"
4648
Andres AG1a834452016-12-07 10:01:30 +00004649# Tests for SNI and DTLS
4650
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004651run_test "SNI: DTLS, no SNI callback" \
4652 "$P_SRV debug_level=3 dtls=1 \
4653 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
4654 "$P_CLI server_name=localhost dtls=1" \
4655 0 \
4656 -S "parse ServerName extension" \
4657 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4658 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4659
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004660run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004661 "$P_SRV debug_level=3 dtls=1 \
4662 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4663 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4664 "$P_CLI server_name=localhost dtls=1" \
4665 0 \
4666 -s "parse ServerName extension" \
4667 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4668 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4669
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004670run_test "SNI: DTLS, matching cert 2" \
4671 "$P_SRV debug_level=3 dtls=1 \
4672 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4673 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4674 "$P_CLI server_name=polarssl.example dtls=1" \
4675 0 \
4676 -s "parse ServerName extension" \
4677 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4678 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4679
4680run_test "SNI: DTLS, no matching cert" \
4681 "$P_SRV debug_level=3 dtls=1 \
4682 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4683 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4684 "$P_CLI server_name=nonesuch.example dtls=1" \
4685 1 \
4686 -s "parse ServerName extension" \
4687 -s "ssl_sni_wrapper() returned" \
4688 -s "mbedtls_ssl_handshake returned" \
4689 -c "mbedtls_ssl_handshake returned" \
4690 -c "SSL - A fatal alert message was received from our peer"
4691
4692run_test "SNI: DTLS, client auth no override: optional" \
4693 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4694 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4695 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4696 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4697 0 \
4698 -S "skip write certificate request" \
4699 -C "skip parse certificate request" \
4700 -c "got a certificate request" \
4701 -C "skip write certificate" \
4702 -C "skip write certificate verify" \
4703 -S "skip parse certificate verify"
4704
4705run_test "SNI: DTLS, client auth override: none -> optional" \
4706 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4707 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4708 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4709 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4710 0 \
4711 -S "skip write certificate request" \
4712 -C "skip parse certificate request" \
4713 -c "got a certificate request" \
4714 -C "skip write certificate" \
4715 -C "skip write certificate verify" \
4716 -S "skip parse certificate verify"
4717
4718run_test "SNI: DTLS, client auth override: optional -> none" \
4719 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4720 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4721 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4722 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4723 0 \
4724 -s "skip write certificate request" \
4725 -C "skip parse certificate request" \
4726 -c "got no certificate request" \
4727 -c "skip write certificate" \
4728 -c "skip write certificate verify" \
4729 -s "skip parse certificate verify"
4730
4731run_test "SNI: DTLS, CA no override" \
4732 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4733 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4734 ca_file=data_files/test-ca.crt \
4735 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4736 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4737 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4738 1 \
4739 -S "skip write certificate request" \
4740 -C "skip parse certificate request" \
4741 -c "got a certificate request" \
4742 -C "skip write certificate" \
4743 -C "skip write certificate verify" \
4744 -S "skip parse certificate verify" \
4745 -s "x509_verify_cert() returned" \
4746 -s "! The certificate is not correctly signed by the trusted CA" \
4747 -S "The certificate has been revoked (is on a CRL)"
4748
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004749run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004750 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4751 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4752 ca_file=data_files/test-ca.crt \
4753 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4754 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4755 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4756 0 \
4757 -S "skip write certificate request" \
4758 -C "skip parse certificate request" \
4759 -c "got a certificate request" \
4760 -C "skip write certificate" \
4761 -C "skip write certificate verify" \
4762 -S "skip parse certificate verify" \
4763 -S "x509_verify_cert() returned" \
4764 -S "! The certificate is not correctly signed by the trusted CA" \
4765 -S "The certificate has been revoked (is on a CRL)"
4766
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004767run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004768 "$P_SRV debug_level=3 auth_mode=optional \
4769 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4770 ca_file=data_files/test-ca.crt \
4771 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4772 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4773 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4774 1 \
4775 -S "skip write certificate request" \
4776 -C "skip parse certificate request" \
4777 -c "got a certificate request" \
4778 -C "skip write certificate" \
4779 -C "skip write certificate verify" \
4780 -S "skip parse certificate verify" \
4781 -s "x509_verify_cert() returned" \
4782 -S "! The certificate is not correctly signed by the trusted CA" \
4783 -s "The certificate has been revoked (is on a CRL)"
4784
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004785# Tests for non-blocking I/O: exercise a variety of handshake flows
4786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004787run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004788 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4789 "$P_CLI nbio=2 tickets=0" \
4790 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004791 -S "mbedtls_ssl_handshake returned" \
4792 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004793 -c "Read from server: .* bytes read"
4794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004795run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004796 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4797 "$P_CLI nbio=2 tickets=0" \
4798 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004799 -S "mbedtls_ssl_handshake returned" \
4800 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004801 -c "Read from server: .* bytes read"
4802
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004803run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004804 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4805 "$P_CLI nbio=2 tickets=1" \
4806 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004807 -S "mbedtls_ssl_handshake returned" \
4808 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004809 -c "Read from server: .* bytes read"
4810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004811run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004812 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4813 "$P_CLI nbio=2 tickets=1" \
4814 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004815 -S "mbedtls_ssl_handshake returned" \
4816 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004817 -c "Read from server: .* bytes read"
4818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004819run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004820 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4821 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4822 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004823 -S "mbedtls_ssl_handshake returned" \
4824 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004825 -c "Read from server: .* bytes read"
4826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004827run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004828 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4829 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4830 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004831 -S "mbedtls_ssl_handshake returned" \
4832 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004833 -c "Read from server: .* bytes read"
4834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004835run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004836 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4837 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4838 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004839 -S "mbedtls_ssl_handshake returned" \
4840 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004841 -c "Read from server: .* bytes read"
4842
Hanno Becker00076712017-11-15 16:39:08 +00004843# Tests for event-driven I/O: exercise a variety of handshake flows
4844
4845run_test "Event-driven I/O: basic handshake" \
4846 "$P_SRV event=1 tickets=0 auth_mode=none" \
4847 "$P_CLI event=1 tickets=0" \
4848 0 \
4849 -S "mbedtls_ssl_handshake returned" \
4850 -C "mbedtls_ssl_handshake returned" \
4851 -c "Read from server: .* bytes read"
4852
4853run_test "Event-driven I/O: client auth" \
4854 "$P_SRV event=1 tickets=0 auth_mode=required" \
4855 "$P_CLI event=1 tickets=0" \
4856 0 \
4857 -S "mbedtls_ssl_handshake returned" \
4858 -C "mbedtls_ssl_handshake returned" \
4859 -c "Read from server: .* bytes read"
4860
4861run_test "Event-driven I/O: ticket" \
4862 "$P_SRV event=1 tickets=1 auth_mode=none" \
4863 "$P_CLI event=1 tickets=1" \
4864 0 \
4865 -S "mbedtls_ssl_handshake returned" \
4866 -C "mbedtls_ssl_handshake returned" \
4867 -c "Read from server: .* bytes read"
4868
4869run_test "Event-driven I/O: ticket + client auth" \
4870 "$P_SRV event=1 tickets=1 auth_mode=required" \
4871 "$P_CLI event=1 tickets=1" \
4872 0 \
4873 -S "mbedtls_ssl_handshake returned" \
4874 -C "mbedtls_ssl_handshake returned" \
4875 -c "Read from server: .* bytes read"
4876
4877run_test "Event-driven I/O: ticket + client auth + resume" \
4878 "$P_SRV event=1 tickets=1 auth_mode=required" \
4879 "$P_CLI event=1 tickets=1 reconnect=1" \
4880 0 \
4881 -S "mbedtls_ssl_handshake returned" \
4882 -C "mbedtls_ssl_handshake returned" \
4883 -c "Read from server: .* bytes read"
4884
4885run_test "Event-driven I/O: ticket + resume" \
4886 "$P_SRV event=1 tickets=1 auth_mode=none" \
4887 "$P_CLI event=1 tickets=1 reconnect=1" \
4888 0 \
4889 -S "mbedtls_ssl_handshake returned" \
4890 -C "mbedtls_ssl_handshake returned" \
4891 -c "Read from server: .* bytes read"
4892
4893run_test "Event-driven I/O: session-id resume" \
4894 "$P_SRV event=1 tickets=0 auth_mode=none" \
4895 "$P_CLI event=1 tickets=0 reconnect=1" \
4896 0 \
4897 -S "mbedtls_ssl_handshake returned" \
4898 -C "mbedtls_ssl_handshake returned" \
4899 -c "Read from server: .* bytes read"
4900
Hanno Becker6a33f592018-03-13 11:38:46 +00004901run_test "Event-driven I/O, DTLS: basic handshake" \
4902 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4903 "$P_CLI dtls=1 event=1 tickets=0" \
4904 0 \
4905 -c "Read from server: .* bytes read"
4906
4907run_test "Event-driven I/O, DTLS: client auth" \
4908 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4909 "$P_CLI dtls=1 event=1 tickets=0" \
4910 0 \
4911 -c "Read from server: .* bytes read"
4912
4913run_test "Event-driven I/O, DTLS: ticket" \
4914 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4915 "$P_CLI dtls=1 event=1 tickets=1" \
4916 0 \
4917 -c "Read from server: .* bytes read"
4918
4919run_test "Event-driven I/O, DTLS: ticket + client auth" \
4920 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4921 "$P_CLI dtls=1 event=1 tickets=1" \
4922 0 \
4923 -c "Read from server: .* bytes read"
4924
4925run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4926 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004927 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004928 0 \
4929 -c "Read from server: .* bytes read"
4930
4931run_test "Event-driven I/O, DTLS: ticket + resume" \
4932 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004933 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004934 0 \
4935 -c "Read from server: .* bytes read"
4936
4937run_test "Event-driven I/O, DTLS: session-id resume" \
4938 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004939 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004940 0 \
4941 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004942
4943# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4944# During session resumption, the client will send its ApplicationData record
4945# within the same datagram as the Finished messages. In this situation, the
4946# server MUST NOT idle on the underlying transport after handshake completion,
4947# because the ApplicationData request has already been queued internally.
4948run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004949 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004950 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004951 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004952 0 \
4953 -c "Read from server: .* bytes read"
4954
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004955# Tests for version negotiation
4956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004957run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004958 "$P_SRV" \
4959 "$P_CLI" \
4960 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004961 -S "mbedtls_ssl_handshake returned" \
4962 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004963 -s "Protocol is TLSv1.2" \
4964 -c "Protocol is TLSv1.2"
4965
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004966run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004967 "$P_SRV" \
4968 "$P_CLI max_version=tls1_1" \
4969 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004970 -S "mbedtls_ssl_handshake returned" \
4971 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004972 -s "Protocol is TLSv1.1" \
4973 -c "Protocol is TLSv1.1"
4974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004975run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004976 "$P_SRV max_version=tls1_1" \
4977 "$P_CLI" \
4978 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004979 -S "mbedtls_ssl_handshake returned" \
4980 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004981 -s "Protocol is TLSv1.1" \
4982 -c "Protocol is TLSv1.1"
4983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004984run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004985 "$P_SRV max_version=tls1_1" \
4986 "$P_CLI max_version=tls1_1" \
4987 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004988 -S "mbedtls_ssl_handshake returned" \
4989 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004990 -s "Protocol is TLSv1.1" \
4991 -c "Protocol is TLSv1.1"
4992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004993run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004994 "$P_SRV min_version=tls1_1" \
4995 "$P_CLI max_version=tls1_1" \
4996 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004997 -S "mbedtls_ssl_handshake returned" \
4998 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004999 -s "Protocol is TLSv1.1" \
5000 -c "Protocol is TLSv1.1"
5001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005002run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005003 "$P_SRV max_version=tls1_1" \
5004 "$P_CLI min_version=tls1_1" \
5005 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005006 -S "mbedtls_ssl_handshake returned" \
5007 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005008 -s "Protocol is TLSv1.1" \
5009 -c "Protocol is TLSv1.1"
5010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005011run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005012 "$P_SRV max_version=tls1_1" \
5013 "$P_CLI min_version=tls1_2" \
5014 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005015 -s "mbedtls_ssl_handshake returned" \
5016 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005017 -c "SSL - Handshake protocol not within min/max boundaries"
5018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005019run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005020 "$P_SRV min_version=tls1_2" \
5021 "$P_CLI max_version=tls1_1" \
5022 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005023 -s "mbedtls_ssl_handshake returned" \
5024 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005025 -s "SSL - Handshake protocol not within min/max boundaries"
5026
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005027# Tests for ALPN extension
5028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005029run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005030 "$P_SRV debug_level=3" \
5031 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005032 0 \
5033 -C "client hello, adding alpn extension" \
5034 -S "found alpn extension" \
5035 -C "got an alert message, type: \\[2:120]" \
5036 -S "server hello, adding alpn extension" \
5037 -C "found alpn extension " \
5038 -C "Application Layer Protocol is" \
5039 -S "Application Layer Protocol is"
5040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005041run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005042 "$P_SRV debug_level=3" \
5043 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005044 0 \
5045 -c "client hello, adding alpn extension" \
5046 -s "found alpn extension" \
5047 -C "got an alert message, type: \\[2:120]" \
5048 -S "server hello, adding alpn extension" \
5049 -C "found alpn extension " \
5050 -c "Application Layer Protocol is (none)" \
5051 -S "Application Layer Protocol is"
5052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005053run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005054 "$P_SRV debug_level=3 alpn=abc,1234" \
5055 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005056 0 \
5057 -C "client hello, adding alpn extension" \
5058 -S "found alpn extension" \
5059 -C "got an alert message, type: \\[2:120]" \
5060 -S "server hello, adding alpn extension" \
5061 -C "found alpn extension " \
5062 -C "Application Layer Protocol is" \
5063 -s "Application Layer Protocol is (none)"
5064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005065run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005066 "$P_SRV debug_level=3 alpn=abc,1234" \
5067 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005068 0 \
5069 -c "client hello, adding alpn extension" \
5070 -s "found alpn extension" \
5071 -C "got an alert message, type: \\[2:120]" \
5072 -s "server hello, adding alpn extension" \
5073 -c "found alpn extension" \
5074 -c "Application Layer Protocol is abc" \
5075 -s "Application Layer Protocol is abc"
5076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005077run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005078 "$P_SRV debug_level=3 alpn=abc,1234" \
5079 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005080 0 \
5081 -c "client hello, adding alpn extension" \
5082 -s "found alpn extension" \
5083 -C "got an alert message, type: \\[2:120]" \
5084 -s "server hello, adding alpn extension" \
5085 -c "found alpn extension" \
5086 -c "Application Layer Protocol is abc" \
5087 -s "Application Layer Protocol is abc"
5088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005089run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005090 "$P_SRV debug_level=3 alpn=abc,1234" \
5091 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005092 0 \
5093 -c "client hello, adding alpn extension" \
5094 -s "found alpn extension" \
5095 -C "got an alert message, type: \\[2:120]" \
5096 -s "server hello, adding alpn extension" \
5097 -c "found alpn extension" \
5098 -c "Application Layer Protocol is 1234" \
5099 -s "Application Layer Protocol is 1234"
5100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005101run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005102 "$P_SRV debug_level=3 alpn=abc,123" \
5103 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005104 1 \
5105 -c "client hello, adding alpn extension" \
5106 -s "found alpn extension" \
5107 -c "got an alert message, type: \\[2:120]" \
5108 -S "server hello, adding alpn extension" \
5109 -C "found alpn extension" \
5110 -C "Application Layer Protocol is 1234" \
5111 -S "Application Layer Protocol is 1234"
5112
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02005113
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005114# Tests for keyUsage in leaf certificates, part 1:
5115# server-side certificate/suite selection
5116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005117run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005118 "$P_SRV key_file=data_files/server2.key \
5119 crt_file=data_files/server2.ku-ds.crt" \
5120 "$P_CLI" \
5121 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02005122 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005123
5124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005125run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005126 "$P_SRV key_file=data_files/server2.key \
5127 crt_file=data_files/server2.ku-ke.crt" \
5128 "$P_CLI" \
5129 0 \
5130 -c "Ciphersuite is TLS-RSA-WITH-"
5131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005132run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005133 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005134 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005135 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005136 1 \
5137 -C "Ciphersuite is "
5138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005139run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005140 "$P_SRV key_file=data_files/server5.key \
5141 crt_file=data_files/server5.ku-ds.crt" \
5142 "$P_CLI" \
5143 0 \
5144 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
5145
5146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005147run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005148 "$P_SRV key_file=data_files/server5.key \
5149 crt_file=data_files/server5.ku-ka.crt" \
5150 "$P_CLI" \
5151 0 \
5152 -c "Ciphersuite is TLS-ECDH-"
5153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005154run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005155 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005156 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005157 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005158 1 \
5159 -C "Ciphersuite is "
5160
5161# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005162# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005164run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005165 "$O_SRV -key data_files/server2.key \
5166 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005167 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005168 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5169 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005170 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005171 -C "Processing of the Certificate handshake message failed" \
5172 -c "Ciphersuite is TLS-"
5173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005174run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005175 "$O_SRV -key data_files/server2.key \
5176 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005177 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005178 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5179 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005180 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005181 -C "Processing of the Certificate handshake message failed" \
5182 -c "Ciphersuite is TLS-"
5183
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005184run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005185 "$O_SRV -key data_files/server2.key \
5186 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005187 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005188 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5189 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005190 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005191 -C "Processing of the Certificate handshake message failed" \
5192 -c "Ciphersuite is TLS-"
5193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005194run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005195 "$O_SRV -key data_files/server2.key \
5196 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005197 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005198 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5199 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005200 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005201 -c "Processing of the Certificate handshake message failed" \
5202 -C "Ciphersuite is TLS-"
5203
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01005204run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
5205 "$O_SRV -key data_files/server2.key \
5206 -cert data_files/server2.ku-ke.crt" \
5207 "$P_CLI debug_level=1 auth_mode=optional \
5208 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5209 0 \
5210 -c "bad certificate (usage extensions)" \
5211 -C "Processing of the Certificate handshake message failed" \
5212 -c "Ciphersuite is TLS-" \
5213 -c "! Usage does not match the keyUsage extension"
5214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005215run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005216 "$O_SRV -key data_files/server2.key \
5217 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005218 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005219 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5220 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005221 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005222 -C "Processing of the Certificate handshake message failed" \
5223 -c "Ciphersuite is TLS-"
5224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005225run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005226 "$O_SRV -key data_files/server2.key \
5227 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005228 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005229 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5230 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005231 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005232 -c "Processing of the Certificate handshake message failed" \
5233 -C "Ciphersuite is TLS-"
5234
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01005235run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
5236 "$O_SRV -key data_files/server2.key \
5237 -cert data_files/server2.ku-ds.crt" \
5238 "$P_CLI debug_level=1 auth_mode=optional \
5239 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5240 0 \
5241 -c "bad certificate (usage extensions)" \
5242 -C "Processing of the Certificate handshake message failed" \
5243 -c "Ciphersuite is TLS-" \
5244 -c "! Usage does not match the keyUsage extension"
5245
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005246# Tests for keyUsage in leaf certificates, part 3:
5247# server-side checking of client cert
5248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005249run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005250 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005251 "$O_CLI -key data_files/server2.key \
5252 -cert data_files/server2.ku-ds.crt" \
5253 0 \
5254 -S "bad certificate (usage extensions)" \
5255 -S "Processing of the Certificate handshake message failed"
5256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005257run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005258 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005259 "$O_CLI -key data_files/server2.key \
5260 -cert data_files/server2.ku-ke.crt" \
5261 0 \
5262 -s "bad certificate (usage extensions)" \
5263 -S "Processing of the Certificate handshake message failed"
5264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005265run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005266 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005267 "$O_CLI -key data_files/server2.key \
5268 -cert data_files/server2.ku-ke.crt" \
5269 1 \
5270 -s "bad certificate (usage extensions)" \
5271 -s "Processing of the Certificate handshake message failed"
5272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005273run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005274 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005275 "$O_CLI -key data_files/server5.key \
5276 -cert data_files/server5.ku-ds.crt" \
5277 0 \
5278 -S "bad certificate (usage extensions)" \
5279 -S "Processing of the Certificate handshake message failed"
5280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005281run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005282 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005283 "$O_CLI -key data_files/server5.key \
5284 -cert data_files/server5.ku-ka.crt" \
5285 0 \
5286 -s "bad certificate (usage extensions)" \
5287 -S "Processing of the Certificate handshake message failed"
5288
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005289# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
5290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005291run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005292 "$P_SRV key_file=data_files/server5.key \
5293 crt_file=data_files/server5.eku-srv.crt" \
5294 "$P_CLI" \
5295 0
5296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005297run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005298 "$P_SRV key_file=data_files/server5.key \
5299 crt_file=data_files/server5.eku-srv.crt" \
5300 "$P_CLI" \
5301 0
5302
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005303run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005304 "$P_SRV key_file=data_files/server5.key \
5305 crt_file=data_files/server5.eku-cs_any.crt" \
5306 "$P_CLI" \
5307 0
5308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005309run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005310 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005311 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005312 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005313 1
5314
5315# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005317run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005318 "$O_SRV -key data_files/server5.key \
5319 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005320 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005321 0 \
5322 -C "bad certificate (usage extensions)" \
5323 -C "Processing of the Certificate handshake message failed" \
5324 -c "Ciphersuite is TLS-"
5325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005326run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005327 "$O_SRV -key data_files/server5.key \
5328 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005329 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005330 0 \
5331 -C "bad certificate (usage extensions)" \
5332 -C "Processing of the Certificate handshake message failed" \
5333 -c "Ciphersuite is TLS-"
5334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005335run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005336 "$O_SRV -key data_files/server5.key \
5337 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005338 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005339 0 \
5340 -C "bad certificate (usage extensions)" \
5341 -C "Processing of the Certificate handshake message failed" \
5342 -c "Ciphersuite is TLS-"
5343
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005344run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005345 "$O_SRV -key data_files/server5.key \
5346 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005347 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005348 1 \
5349 -c "bad certificate (usage extensions)" \
5350 -c "Processing of the Certificate handshake message failed" \
5351 -C "Ciphersuite is TLS-"
5352
5353# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005355run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005356 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005357 "$O_CLI -key data_files/server5.key \
5358 -cert data_files/server5.eku-cli.crt" \
5359 0 \
5360 -S "bad certificate (usage extensions)" \
5361 -S "Processing of the Certificate handshake message failed"
5362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005363run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005364 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005365 "$O_CLI -key data_files/server5.key \
5366 -cert data_files/server5.eku-srv_cli.crt" \
5367 0 \
5368 -S "bad certificate (usage extensions)" \
5369 -S "Processing of the Certificate handshake message failed"
5370
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005371run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005372 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005373 "$O_CLI -key data_files/server5.key \
5374 -cert data_files/server5.eku-cs_any.crt" \
5375 0 \
5376 -S "bad certificate (usage extensions)" \
5377 -S "Processing of the Certificate handshake message failed"
5378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005379run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005380 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005381 "$O_CLI -key data_files/server5.key \
5382 -cert data_files/server5.eku-cs.crt" \
5383 0 \
5384 -s "bad certificate (usage extensions)" \
5385 -S "Processing of the Certificate handshake message failed"
5386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005387run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005388 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005389 "$O_CLI -key data_files/server5.key \
5390 -cert data_files/server5.eku-cs.crt" \
5391 1 \
5392 -s "bad certificate (usage extensions)" \
5393 -s "Processing of the Certificate handshake message failed"
5394
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005395# Tests for DHM parameters loading
5396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005397run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005398 "$P_SRV" \
5399 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5400 debug_level=3" \
5401 0 \
5402 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005403 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005405run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005406 "$P_SRV dhm_file=data_files/dhparams.pem" \
5407 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5408 debug_level=3" \
5409 0 \
5410 -c "value of 'DHM: P ' (1024 bits)" \
5411 -c "value of 'DHM: G ' (2 bits)"
5412
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005413# Tests for DHM client-side size checking
5414
5415run_test "DHM size: server default, client default, OK" \
5416 "$P_SRV" \
5417 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5418 debug_level=1" \
5419 0 \
5420 -C "DHM prime too short:"
5421
5422run_test "DHM size: server default, client 2048, OK" \
5423 "$P_SRV" \
5424 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5425 debug_level=1 dhmlen=2048" \
5426 0 \
5427 -C "DHM prime too short:"
5428
5429run_test "DHM size: server 1024, client default, OK" \
5430 "$P_SRV dhm_file=data_files/dhparams.pem" \
5431 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5432 debug_level=1" \
5433 0 \
5434 -C "DHM prime too short:"
5435
5436run_test "DHM size: server 1000, client default, rejected" \
5437 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5438 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5439 debug_level=1" \
5440 1 \
5441 -c "DHM prime too short:"
5442
5443run_test "DHM size: server default, client 2049, rejected" \
5444 "$P_SRV" \
5445 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5446 debug_level=1 dhmlen=2049" \
5447 1 \
5448 -c "DHM prime too short:"
5449
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005450# Tests for PSK callback
5451
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005452run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005453 "$P_SRV psk=abc123 psk_identity=foo" \
5454 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5455 psk_identity=foo psk=abc123" \
5456 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005457 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005458 -S "SSL - Unknown identity received" \
5459 -S "SSL - Verification of the message MAC failed"
5460
Hanno Beckerf7027512018-10-23 15:27:39 +01005461requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5462run_test "PSK callback: opaque psk on client, no callback" \
5463 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5464 "$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 +00005465 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005466 0 \
5467 -c "skip PMS generation for opaque PSK"\
5468 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005469 -C "session hash for extended master secret"\
5470 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005471 -S "SSL - None of the common ciphersuites is usable" \
5472 -S "SSL - Unknown identity received" \
5473 -S "SSL - Verification of the message MAC failed"
5474
5475requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5476run_test "PSK callback: opaque psk on client, no callback, SHA-384" \
5477 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5478 "$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 +00005479 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005480 0 \
5481 -c "skip PMS generation for opaque PSK"\
5482 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005483 -C "session hash for extended master secret"\
5484 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005485 -S "SSL - None of the common ciphersuites is usable" \
5486 -S "SSL - Unknown identity received" \
5487 -S "SSL - Verification of the message MAC failed"
5488
5489requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5490run_test "PSK callback: opaque psk on client, no callback, EMS" \
5491 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5492 "$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 +00005493 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005494 0 \
5495 -c "skip PMS generation for opaque PSK"\
5496 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005497 -c "session hash for extended master secret"\
5498 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005499 -S "SSL - None of the common ciphersuites is usable" \
5500 -S "SSL - Unknown identity received" \
5501 -S "SSL - Verification of the message MAC failed"
5502
5503requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5504run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \
5505 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5506 "$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 +00005507 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005508 0 \
5509 -c "skip PMS generation for opaque PSK"\
5510 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005511 -c "session hash for extended master secret"\
5512 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005513 -S "SSL - None of the common ciphersuites is usable" \
5514 -S "SSL - Unknown identity received" \
5515 -S "SSL - Verification of the message MAC failed"
5516
Hanno Becker28c79dc2018-10-26 13:15:08 +01005517requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5518run_test "PSK callback: raw psk on client, static opaque on server, no callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005519 "$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 +01005520 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5521 psk_identity=foo psk=abc123" \
5522 0 \
5523 -C "skip PMS generation for opaque PSK"\
5524 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005525 -C "session hash for extended master secret"\
5526 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005527 -S "SSL - None of the common ciphersuites is usable" \
5528 -S "SSL - Unknown identity received" \
5529 -S "SSL - Verification of the message MAC failed"
5530
5531requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5532run_test "PSK callback: raw psk on client, static opaque on server, no callback, SHA-384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005533 "$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 +01005534 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5535 psk_identity=foo psk=abc123" \
5536 0 \
5537 -C "skip PMS generation for opaque PSK"\
5538 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005539 -C "session hash for extended master secret"\
5540 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005541 -S "SSL - None of the common ciphersuites is usable" \
5542 -S "SSL - Unknown identity received" \
5543 -S "SSL - Verification of the message MAC failed"
5544
5545requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5546run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005547 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005548 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5549 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5550 psk_identity=foo psk=abc123 extended_ms=1" \
5551 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005552 -c "session hash for extended master secret"\
5553 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005554 -C "skip PMS generation for opaque PSK"\
5555 -s "skip PMS generation for opaque PSK"\
5556 -S "SSL - None of the common ciphersuites is usable" \
5557 -S "SSL - Unknown identity received" \
5558 -S "SSL - Verification of the message MAC failed"
5559
5560requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5561run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS, SHA384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005562 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005563 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5564 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5565 psk_identity=foo psk=abc123 extended_ms=1" \
5566 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005567 -c "session hash for extended master secret"\
5568 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005569 -C "skip PMS generation for opaque PSK"\
5570 -s "skip PMS generation for opaque PSK"\
5571 -S "SSL - None of the common ciphersuites is usable" \
5572 -S "SSL - Unknown identity received" \
5573 -S "SSL - Verification of the message MAC failed"
5574
5575requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5576run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005577 "$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 +01005578 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5579 psk_identity=def psk=beef" \
5580 0 \
5581 -C "skip PMS generation for opaque PSK"\
5582 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005583 -C "session hash for extended master secret"\
5584 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005585 -S "SSL - None of the common ciphersuites is usable" \
5586 -S "SSL - Unknown identity received" \
5587 -S "SSL - Verification of the message MAC failed"
5588
5589requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5590run_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 +00005591 "$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 +01005592 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5593 psk_identity=def psk=beef" \
5594 0 \
5595 -C "skip PMS generation for opaque PSK"\
5596 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005597 -C "session hash for extended master secret"\
5598 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005599 -S "SSL - None of the common ciphersuites is usable" \
5600 -S "SSL - Unknown identity received" \
5601 -S "SSL - Verification of the message MAC failed"
5602
5603requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5604run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005605 "$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 +01005606 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5607 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5608 psk_identity=abc psk=dead extended_ms=1" \
5609 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005610 -c "session hash for extended master secret"\
5611 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005612 -C "skip PMS generation for opaque PSK"\
5613 -s "skip PMS generation for opaque PSK"\
5614 -S "SSL - None of the common ciphersuites is usable" \
5615 -S "SSL - Unknown identity received" \
5616 -S "SSL - Verification of the message MAC failed"
5617
5618requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5619run_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 +00005620 "$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 +01005621 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5622 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5623 psk_identity=abc psk=dead extended_ms=1" \
5624 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005625 -c "session hash for extended master secret"\
5626 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005627 -C "skip PMS generation for opaque PSK"\
5628 -s "skip PMS generation for opaque PSK"\
5629 -S "SSL - None of the common ciphersuites is usable" \
5630 -S "SSL - Unknown identity received" \
5631 -S "SSL - Verification of the message MAC failed"
5632
5633requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5634run_test "PSK callback: raw psk on client, mismatching static raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005635 "$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 +01005636 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5637 psk_identity=def psk=beef" \
5638 0 \
5639 -C "skip PMS generation for opaque PSK"\
5640 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005641 -C "session hash for extended master secret"\
5642 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005643 -S "SSL - None of the common ciphersuites is usable" \
5644 -S "SSL - Unknown identity received" \
5645 -S "SSL - Verification of the message MAC failed"
5646
5647requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5648run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005649 "$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 +01005650 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5651 psk_identity=def psk=beef" \
5652 0 \
5653 -C "skip PMS generation for opaque PSK"\
5654 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005655 -C "session hash for extended master secret"\
5656 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005657 -S "SSL - None of the common ciphersuites is usable" \
5658 -S "SSL - Unknown identity received" \
5659 -S "SSL - Verification of the message MAC failed"
5660
5661requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5662run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, raw PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005663 "$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 +01005664 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5665 psk_identity=def psk=beef" \
5666 0 \
5667 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005668 -C "session hash for extended master secret"\
5669 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005670 -S "SSL - None of the common ciphersuites is usable" \
5671 -S "SSL - Unknown identity received" \
5672 -S "SSL - Verification of the message MAC failed"
5673
5674requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5675run_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 +00005676 "$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 +01005677 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5678 psk_identity=def psk=beef" \
5679 0 \
5680 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005681 -C "session hash for extended master secret"\
5682 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005683 -S "SSL - None of the common ciphersuites is usable" \
5684 -S "SSL - Unknown identity received" \
5685 -S "SSL - Verification of the message MAC failed"
5686
5687requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5688run_test "PSK callback: raw psk on client, matching opaque PSK on server, wrong opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005689 "$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 +01005690 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5691 psk_identity=def psk=beef" \
5692 1 \
5693 -s "SSL - Verification of the message MAC failed"
5694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005695run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005696 "$P_SRV" \
5697 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5698 psk_identity=foo psk=abc123" \
5699 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005700 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005701 -S "SSL - Unknown identity received" \
5702 -S "SSL - Verification of the message MAC failed"
5703
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005704run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005705 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5706 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5707 psk_identity=foo psk=abc123" \
5708 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005709 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005710 -s "SSL - Unknown identity received" \
5711 -S "SSL - Verification of the message MAC failed"
5712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005713run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005714 "$P_SRV psk_list=abc,dead,def,beef" \
5715 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5716 psk_identity=abc psk=dead" \
5717 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005718 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005719 -S "SSL - Unknown identity received" \
5720 -S "SSL - Verification of the message MAC failed"
5721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005722run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005723 "$P_SRV psk_list=abc,dead,def,beef" \
5724 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5725 psk_identity=def psk=beef" \
5726 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005727 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005728 -S "SSL - Unknown identity received" \
5729 -S "SSL - Verification of the message MAC failed"
5730
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005731run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005732 "$P_SRV psk_list=abc,dead,def,beef" \
5733 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5734 psk_identity=ghi psk=beef" \
5735 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005736 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005737 -s "SSL - Unknown identity received" \
5738 -S "SSL - Verification of the message MAC failed"
5739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005740run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005741 "$P_SRV psk_list=abc,dead,def,beef" \
5742 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5743 psk_identity=abc psk=beef" \
5744 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005745 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005746 -S "SSL - Unknown identity received" \
5747 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005748
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005749# Tests for EC J-PAKE
5750
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005751requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005752run_test "ECJPAKE: client not configured" \
5753 "$P_SRV debug_level=3" \
5754 "$P_CLI debug_level=3" \
5755 0 \
5756 -C "add ciphersuite: c0ff" \
5757 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005758 -S "found ecjpake kkpp extension" \
5759 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005760 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005761 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005762 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005763 -S "None of the common ciphersuites is usable"
5764
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005765requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005766run_test "ECJPAKE: server not configured" \
5767 "$P_SRV debug_level=3" \
5768 "$P_CLI debug_level=3 ecjpake_pw=bla \
5769 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5770 1 \
5771 -c "add ciphersuite: c0ff" \
5772 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005773 -s "found ecjpake kkpp extension" \
5774 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005775 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005776 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005777 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005778 -s "None of the common ciphersuites is usable"
5779
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005780requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005781run_test "ECJPAKE: working, TLS" \
5782 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5783 "$P_CLI debug_level=3 ecjpake_pw=bla \
5784 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005785 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005786 -c "add ciphersuite: c0ff" \
5787 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005788 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005789 -s "found ecjpake kkpp extension" \
5790 -S "skip ecjpake kkpp extension" \
5791 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005792 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005793 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005794 -S "None of the common ciphersuites is usable" \
5795 -S "SSL - Verification of the message MAC failed"
5796
Janos Follath74537a62016-09-02 13:45:28 +01005797server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005798requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005799run_test "ECJPAKE: password mismatch, TLS" \
5800 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5801 "$P_CLI debug_level=3 ecjpake_pw=bad \
5802 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5803 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005804 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005805 -s "SSL - Verification of the message MAC failed"
5806
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005807requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005808run_test "ECJPAKE: working, DTLS" \
5809 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5810 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5811 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5812 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005813 -c "re-using cached ecjpake parameters" \
5814 -S "SSL - Verification of the message MAC failed"
5815
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005816requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005817run_test "ECJPAKE: working, DTLS, no cookie" \
5818 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5819 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5820 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5821 0 \
5822 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005823 -S "SSL - Verification of the message MAC failed"
5824
Janos Follath74537a62016-09-02 13:45:28 +01005825server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005826requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005827run_test "ECJPAKE: password mismatch, DTLS" \
5828 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5829 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5830 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5831 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005832 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005833 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005834
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005835# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005836requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005837run_test "ECJPAKE: working, DTLS, nolog" \
5838 "$P_SRV dtls=1 ecjpake_pw=bla" \
5839 "$P_CLI dtls=1 ecjpake_pw=bla \
5840 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5841 0
5842
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005843# Tests for ciphersuites per version
5844
Janos Follathe2681a42016-03-07 15:57:05 +00005845requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005846requires_config_enabled MBEDTLS_CAMELLIA_C
5847requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005848run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005849 "$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 +02005850 "$P_CLI force_version=ssl3" \
5851 0 \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005852 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005853
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005854requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5855requires_config_enabled MBEDTLS_CAMELLIA_C
5856requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005857run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005858 "$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 +01005859 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005860 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005861 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005862
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005863requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5864requires_config_enabled MBEDTLS_CAMELLIA_C
5865requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005866run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005867 "$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 +02005868 "$P_CLI force_version=tls1_1" \
5869 0 \
5870 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5871
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005872requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5873requires_config_enabled MBEDTLS_CAMELLIA_C
5874requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005875run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005876 "$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 +02005877 "$P_CLI force_version=tls1_2" \
5878 0 \
5879 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5880
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005881# Test for ClientHello without extensions
5882
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005883requires_gnutls
Manuel Pégourié-Gonnardbc4da292020-01-30 12:45:14 +01005884run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard77cbeff2020-01-30 10:58:57 +01005885 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005886 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005887 0 \
5888 -s "dumping 'client hello extensions' (0 bytes)"
5889
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005890# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005891
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005892run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005893 "$P_SRV" \
5894 "$P_CLI request_size=100" \
5895 0 \
5896 -s "Read from client: 100 bytes read$"
5897
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005898run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005899 "$P_SRV" \
5900 "$P_CLI request_size=500" \
5901 0 \
5902 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005903
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005904# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005905
Janos Follathe2681a42016-03-07 15:57:05 +00005906requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005907run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005908 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005909 "$P_CLI request_size=1 force_version=ssl3 \
5910 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5911 0 \
5912 -s "Read from client: 1 bytes read"
5913
Janos Follathe2681a42016-03-07 15:57:05 +00005914requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005915run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005916 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005917 "$P_CLI request_size=1 force_version=ssl3 \
5918 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5919 0 \
5920 -s "Read from client: 1 bytes read"
5921
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005922run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005923 "$P_SRV" \
5924 "$P_CLI request_size=1 force_version=tls1 \
5925 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5926 0 \
5927 -s "Read from client: 1 bytes read"
5928
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005929run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005930 "$P_SRV" \
5931 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5932 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5933 0 \
5934 -s "Read from client: 1 bytes read"
5935
Hanno Becker32c55012017-11-10 08:42:54 +00005936requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005937run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005938 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005939 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005940 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005941 0 \
5942 -s "Read from client: 1 bytes read"
5943
Hanno Becker32c55012017-11-10 08:42:54 +00005944requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005945run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005946 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005947 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005948 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005949 0 \
5950 -s "Read from client: 1 bytes read"
5951
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005952run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005953 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005954 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005955 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5956 0 \
5957 -s "Read from client: 1 bytes read"
5958
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005959run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005960 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5961 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005962 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005963 0 \
5964 -s "Read from client: 1 bytes read"
5965
5966requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005967run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005968 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005969 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005970 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005971 0 \
5972 -s "Read from client: 1 bytes read"
5973
Hanno Becker8501f982017-11-10 08:59:04 +00005974requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005975run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005976 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5977 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5978 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005979 0 \
5980 -s "Read from client: 1 bytes read"
5981
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005982run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005983 "$P_SRV" \
5984 "$P_CLI request_size=1 force_version=tls1_1 \
5985 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5986 0 \
5987 -s "Read from client: 1 bytes read"
5988
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005989run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005990 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005991 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005992 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005993 0 \
5994 -s "Read from client: 1 bytes read"
5995
5996requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005997run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005998 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005999 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006000 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006001 0 \
6002 -s "Read from client: 1 bytes read"
6003
6004requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006005run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006006 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006007 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006008 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006009 0 \
6010 -s "Read from client: 1 bytes read"
6011
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006012run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006013 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006014 "$P_CLI request_size=1 force_version=tls1_1 \
6015 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6016 0 \
6017 -s "Read from client: 1 bytes read"
6018
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006019run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00006020 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006021 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006022 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006023 0 \
6024 -s "Read from client: 1 bytes read"
6025
Hanno Becker8501f982017-11-10 08:59:04 +00006026requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006027run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006028 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006029 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006030 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006031 0 \
6032 -s "Read from client: 1 bytes read"
6033
Hanno Becker32c55012017-11-10 08:42:54 +00006034requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006035run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006036 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006037 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006038 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006039 0 \
6040 -s "Read from client: 1 bytes read"
6041
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006042run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006043 "$P_SRV" \
6044 "$P_CLI request_size=1 force_version=tls1_2 \
6045 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6046 0 \
6047 -s "Read from client: 1 bytes read"
6048
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006049run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006050 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00006051 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006052 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006053 0 \
6054 -s "Read from client: 1 bytes read"
6055
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006056run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006057 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006058 "$P_CLI request_size=1 force_version=tls1_2 \
6059 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006060 0 \
6061 -s "Read from client: 1 bytes read"
6062
Hanno Becker32c55012017-11-10 08:42:54 +00006063requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006064run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006065 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006066 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006067 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006068 0 \
6069 -s "Read from client: 1 bytes read"
6070
Hanno Becker8501f982017-11-10 08:59:04 +00006071requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006072run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006073 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006074 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006075 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006076 0 \
6077 -s "Read from client: 1 bytes read"
6078
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006079run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006080 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006081 "$P_CLI request_size=1 force_version=tls1_2 \
6082 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6083 0 \
6084 -s "Read from client: 1 bytes read"
6085
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006086run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006087 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006088 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006089 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00006090 0 \
6091 -s "Read from client: 1 bytes read"
6092
Hanno Becker32c55012017-11-10 08:42:54 +00006093requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006094run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006095 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006096 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006097 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006098 0 \
6099 -s "Read from client: 1 bytes read"
6100
Hanno Becker8501f982017-11-10 08:59:04 +00006101requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006102run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006103 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006104 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006105 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006106 0 \
6107 -s "Read from client: 1 bytes read"
6108
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006109run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006110 "$P_SRV" \
6111 "$P_CLI request_size=1 force_version=tls1_2 \
6112 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6113 0 \
6114 -s "Read from client: 1 bytes read"
6115
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006116run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006117 "$P_SRV" \
6118 "$P_CLI request_size=1 force_version=tls1_2 \
6119 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6120 0 \
6121 -s "Read from client: 1 bytes read"
6122
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006123# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00006124
6125requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006126run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006127 "$P_SRV dtls=1 force_version=dtls1" \
6128 "$P_CLI dtls=1 request_size=1 \
6129 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6130 0 \
6131 -s "Read from client: 1 bytes read"
6132
6133requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006134run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00006135 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
6136 "$P_CLI dtls=1 request_size=1 \
6137 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6138 0 \
6139 -s "Read from client: 1 bytes read"
6140
6141requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6142requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006143run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006144 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
6145 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00006146 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6147 0 \
6148 -s "Read from client: 1 bytes read"
6149
6150requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6151requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006152run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006153 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006154 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006155 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00006156 0 \
6157 -s "Read from client: 1 bytes read"
6158
6159requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006160run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00006161 "$P_SRV dtls=1 force_version=dtls1_2" \
6162 "$P_CLI dtls=1 request_size=1 \
6163 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6164 0 \
6165 -s "Read from client: 1 bytes read"
6166
6167requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006168run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006169 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006170 "$P_CLI dtls=1 request_size=1 \
6171 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6172 0 \
6173 -s "Read from client: 1 bytes read"
6174
6175requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6176requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006177run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006178 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00006179 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006180 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00006181 0 \
6182 -s "Read from client: 1 bytes read"
6183
6184requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6185requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006186run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006187 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006188 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006189 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00006190 0 \
6191 -s "Read from client: 1 bytes read"
6192
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006193# Tests for small server packets
6194
6195requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6196run_test "Small server packet SSLv3 BlockCipher" \
6197 "$P_SRV response_size=1 min_version=ssl3" \
6198 "$P_CLI force_version=ssl3 \
6199 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6200 0 \
6201 -c "Read from server: 1 bytes read"
6202
6203requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6204run_test "Small server packet SSLv3 StreamCipher" \
6205 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6206 "$P_CLI force_version=ssl3 \
6207 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6208 0 \
6209 -c "Read from server: 1 bytes read"
6210
6211run_test "Small server packet TLS 1.0 BlockCipher" \
6212 "$P_SRV response_size=1" \
6213 "$P_CLI force_version=tls1 \
6214 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6215 0 \
6216 -c "Read from server: 1 bytes read"
6217
6218run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
6219 "$P_SRV response_size=1" \
6220 "$P_CLI force_version=tls1 etm=0 \
6221 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6222 0 \
6223 -c "Read from server: 1 bytes read"
6224
6225requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6226run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
6227 "$P_SRV response_size=1 trunc_hmac=1" \
6228 "$P_CLI force_version=tls1 \
6229 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6230 0 \
6231 -c "Read from server: 1 bytes read"
6232
6233requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6234run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
6235 "$P_SRV response_size=1 trunc_hmac=1" \
6236 "$P_CLI force_version=tls1 \
6237 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6238 0 \
6239 -c "Read from server: 1 bytes read"
6240
6241run_test "Small server packet TLS 1.0 StreamCipher" \
6242 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6243 "$P_CLI force_version=tls1 \
6244 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6245 0 \
6246 -c "Read from server: 1 bytes read"
6247
6248run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
6249 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6250 "$P_CLI force_version=tls1 \
6251 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6252 0 \
6253 -c "Read from server: 1 bytes read"
6254
6255requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6256run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
6257 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6258 "$P_CLI force_version=tls1 \
6259 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6260 0 \
6261 -c "Read from server: 1 bytes read"
6262
6263requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6264run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6265 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6266 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6267 trunc_hmac=1 etm=0" \
6268 0 \
6269 -c "Read from server: 1 bytes read"
6270
6271run_test "Small server packet TLS 1.1 BlockCipher" \
6272 "$P_SRV response_size=1" \
6273 "$P_CLI force_version=tls1_1 \
6274 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6275 0 \
6276 -c "Read from server: 1 bytes read"
6277
6278run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
6279 "$P_SRV response_size=1" \
6280 "$P_CLI force_version=tls1_1 \
6281 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
6282 0 \
6283 -c "Read from server: 1 bytes read"
6284
6285requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6286run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
6287 "$P_SRV response_size=1 trunc_hmac=1" \
6288 "$P_CLI force_version=tls1_1 \
6289 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6290 0 \
6291 -c "Read from server: 1 bytes read"
6292
6293requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6294run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6295 "$P_SRV response_size=1 trunc_hmac=1" \
6296 "$P_CLI force_version=tls1_1 \
6297 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6298 0 \
6299 -c "Read from server: 1 bytes read"
6300
6301run_test "Small server packet TLS 1.1 StreamCipher" \
6302 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6303 "$P_CLI force_version=tls1_1 \
6304 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6305 0 \
6306 -c "Read from server: 1 bytes read"
6307
6308run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
6309 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6310 "$P_CLI force_version=tls1_1 \
6311 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6312 0 \
6313 -c "Read from server: 1 bytes read"
6314
6315requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6316run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
6317 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6318 "$P_CLI force_version=tls1_1 \
6319 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6320 0 \
6321 -c "Read from server: 1 bytes read"
6322
6323requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6324run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6325 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6326 "$P_CLI force_version=tls1_1 \
6327 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6328 0 \
6329 -c "Read from server: 1 bytes read"
6330
6331run_test "Small server packet TLS 1.2 BlockCipher" \
6332 "$P_SRV response_size=1" \
6333 "$P_CLI force_version=tls1_2 \
6334 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6335 0 \
6336 -c "Read from server: 1 bytes read"
6337
6338run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
6339 "$P_SRV response_size=1" \
6340 "$P_CLI force_version=tls1_2 \
6341 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
6342 0 \
6343 -c "Read from server: 1 bytes read"
6344
6345run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
6346 "$P_SRV response_size=1" \
6347 "$P_CLI force_version=tls1_2 \
6348 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6349 0 \
6350 -c "Read from server: 1 bytes read"
6351
6352requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6353run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
6354 "$P_SRV response_size=1 trunc_hmac=1" \
6355 "$P_CLI force_version=tls1_2 \
6356 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6357 0 \
6358 -c "Read from server: 1 bytes read"
6359
6360requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6361run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6362 "$P_SRV response_size=1 trunc_hmac=1" \
6363 "$P_CLI force_version=tls1_2 \
6364 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6365 0 \
6366 -c "Read from server: 1 bytes read"
6367
6368run_test "Small server packet TLS 1.2 StreamCipher" \
6369 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6370 "$P_CLI force_version=tls1_2 \
6371 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6372 0 \
6373 -c "Read from server: 1 bytes read"
6374
6375run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
6376 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6377 "$P_CLI force_version=tls1_2 \
6378 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6379 0 \
6380 -c "Read from server: 1 bytes read"
6381
6382requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6383run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
6384 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6385 "$P_CLI force_version=tls1_2 \
6386 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6387 0 \
6388 -c "Read from server: 1 bytes read"
6389
6390requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6391run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6392 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6393 "$P_CLI force_version=tls1_2 \
6394 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6395 0 \
6396 -c "Read from server: 1 bytes read"
6397
6398run_test "Small server packet TLS 1.2 AEAD" \
6399 "$P_SRV response_size=1" \
6400 "$P_CLI force_version=tls1_2 \
6401 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6402 0 \
6403 -c "Read from server: 1 bytes read"
6404
6405run_test "Small server packet TLS 1.2 AEAD shorter tag" \
6406 "$P_SRV response_size=1" \
6407 "$P_CLI force_version=tls1_2 \
6408 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6409 0 \
6410 -c "Read from server: 1 bytes read"
6411
6412# Tests for small server packets in DTLS
6413
6414requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6415run_test "Small server packet DTLS 1.0" \
6416 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
6417 "$P_CLI dtls=1 \
6418 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6419 0 \
6420 -c "Read from server: 1 bytes read"
6421
6422requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6423run_test "Small server packet DTLS 1.0, without EtM" \
6424 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
6425 "$P_CLI dtls=1 \
6426 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6427 0 \
6428 -c "Read from server: 1 bytes read"
6429
6430requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6431requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6432run_test "Small server packet DTLS 1.0, truncated hmac" \
6433 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
6434 "$P_CLI dtls=1 trunc_hmac=1 \
6435 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6436 0 \
6437 -c "Read from server: 1 bytes read"
6438
6439requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6440requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6441run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
6442 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
6443 "$P_CLI dtls=1 \
6444 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
6445 0 \
6446 -c "Read from server: 1 bytes read"
6447
6448requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6449run_test "Small server packet DTLS 1.2" \
6450 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
6451 "$P_CLI dtls=1 \
6452 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6453 0 \
6454 -c "Read from server: 1 bytes read"
6455
6456requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6457run_test "Small server packet DTLS 1.2, without EtM" \
6458 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
6459 "$P_CLI dtls=1 \
6460 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6461 0 \
6462 -c "Read from server: 1 bytes read"
6463
6464requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6465requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6466run_test "Small server packet DTLS 1.2, truncated hmac" \
6467 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
6468 "$P_CLI dtls=1 \
6469 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6470 0 \
6471 -c "Read from server: 1 bytes read"
6472
6473requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6474requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6475run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
6476 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
6477 "$P_CLI dtls=1 \
6478 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
6479 0 \
6480 -c "Read from server: 1 bytes read"
6481
Janos Follath00efff72016-05-06 13:48:23 +01006482# A test for extensions in SSLv3
6483
6484requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6485run_test "SSLv3 with extensions, server side" \
6486 "$P_SRV min_version=ssl3 debug_level=3" \
6487 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
6488 0 \
6489 -S "dumping 'client hello extensions'" \
6490 -S "server hello, total extension length:"
6491
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006492# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006493
Angus Grattonc4dd0732018-04-11 16:28:39 +10006494# How many fragments do we expect to write $1 bytes?
6495fragments_for_write() {
6496 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
6497}
6498
Janos Follathe2681a42016-03-07 15:57:05 +00006499requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006500run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01006501 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006502 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006503 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6504 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006505 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6506 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006507
Janos Follathe2681a42016-03-07 15:57:05 +00006508requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006509run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006510 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006511 "$P_CLI request_size=16384 force_version=ssl3 \
6512 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6513 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006514 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6515 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006516
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006517run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006518 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006519 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006520 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6521 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006522 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6523 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006524
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006525run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006526 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006527 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
6528 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6529 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006530 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006531
Hanno Becker32c55012017-11-10 08:42:54 +00006532requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006533run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006534 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006535 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006536 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006537 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006538 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6539 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006540
Hanno Becker32c55012017-11-10 08:42:54 +00006541requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006542run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006543 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006544 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006545 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006546 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006547 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006548
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006549run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006550 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006551 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006552 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6553 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006554 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006555
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006556run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006557 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6558 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006559 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006560 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006561 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006562
6563requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006564run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006565 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006566 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006567 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006568 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006569 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006570
Hanno Becker278fc7a2017-11-10 09:16:28 +00006571requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006572run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006573 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006574 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006575 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006576 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006577 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6578 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006579
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006580run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006581 "$P_SRV" \
6582 "$P_CLI request_size=16384 force_version=tls1_1 \
6583 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6584 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006585 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6586 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006587
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006588run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006589 "$P_SRV" \
6590 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6591 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006592 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006593 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006594
Hanno Becker32c55012017-11-10 08:42:54 +00006595requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006596run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006597 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006598 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006599 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006600 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006601 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006602
Hanno Becker32c55012017-11-10 08:42:54 +00006603requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006604run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006605 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006606 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006607 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006608 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006609 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006610
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006611run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006612 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6613 "$P_CLI request_size=16384 force_version=tls1_1 \
6614 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6615 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006616 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6617 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006618
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006619run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006620 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006621 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006622 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006623 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006624 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6625 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006626
Hanno Becker278fc7a2017-11-10 09:16:28 +00006627requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006628run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006629 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006630 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006631 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006632 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006633 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006634
Hanno Becker278fc7a2017-11-10 09:16:28 +00006635requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006636run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006637 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006638 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006639 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006640 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006641 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6642 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006643
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006644run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006645 "$P_SRV" \
6646 "$P_CLI request_size=16384 force_version=tls1_2 \
6647 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6648 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006649 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6650 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006651
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006652run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006653 "$P_SRV" \
6654 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6655 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6656 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006657 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006658
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006659run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006660 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006661 "$P_CLI request_size=16384 force_version=tls1_2 \
6662 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006663 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006664 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6665 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006666
Hanno Becker32c55012017-11-10 08:42:54 +00006667requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006668run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006669 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006670 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006671 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006672 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006673 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006674
Hanno Becker278fc7a2017-11-10 09:16:28 +00006675requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006676run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006677 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006678 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006679 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006680 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006681 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6682 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006683
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006684run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006685 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006686 "$P_CLI request_size=16384 force_version=tls1_2 \
6687 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6688 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006689 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6690 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006691
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006692run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006693 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006694 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006695 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6696 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006697 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006698
Hanno Becker32c55012017-11-10 08:42:54 +00006699requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006700run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006701 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006702 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006703 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006704 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006705 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006706
Hanno Becker278fc7a2017-11-10 09:16:28 +00006707requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006708run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006709 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006710 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006711 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006712 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006713 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6714 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006715
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006716run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006717 "$P_SRV" \
6718 "$P_CLI request_size=16384 force_version=tls1_2 \
6719 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6720 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006721 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6722 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006723
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006724run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006725 "$P_SRV" \
6726 "$P_CLI request_size=16384 force_version=tls1_2 \
6727 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6728 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006729 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6730 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006731
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006732# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006733requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6734run_test "Large server packet SSLv3 StreamCipher" \
6735 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6736 "$P_CLI force_version=ssl3 \
6737 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6738 0 \
6739 -c "Read from server: 16384 bytes read"
6740
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006741# Checking next 4 tests logs for 1n-1 split against BEAST too
6742requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6743run_test "Large server packet SSLv3 BlockCipher" \
6744 "$P_SRV response_size=16384 min_version=ssl3" \
6745 "$P_CLI force_version=ssl3 recsplit=0 \
6746 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6747 0 \
6748 -c "Read from server: 1 bytes read"\
6749 -c "16383 bytes read"\
6750 -C "Read from server: 16384 bytes read"
6751
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006752run_test "Large server packet TLS 1.0 BlockCipher" \
6753 "$P_SRV response_size=16384" \
6754 "$P_CLI force_version=tls1 recsplit=0 \
6755 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6756 0 \
6757 -c "Read from server: 1 bytes read"\
6758 -c "16383 bytes read"\
6759 -C "Read from server: 16384 bytes read"
6760
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006761run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6762 "$P_SRV response_size=16384" \
6763 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6764 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6765 0 \
6766 -c "Read from server: 1 bytes read"\
6767 -c "16383 bytes read"\
6768 -C "Read from server: 16384 bytes read"
6769
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006770requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6771run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6772 "$P_SRV response_size=16384" \
6773 "$P_CLI force_version=tls1 recsplit=0 \
6774 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6775 trunc_hmac=1" \
6776 0 \
6777 -c "Read from server: 1 bytes read"\
6778 -c "16383 bytes read"\
6779 -C "Read from server: 16384 bytes read"
6780
6781requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6782run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6783 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6784 "$P_CLI force_version=tls1 \
6785 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6786 trunc_hmac=1" \
6787 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006788 -s "16384 bytes written in 1 fragments" \
6789 -c "Read from server: 16384 bytes read"
6790
6791run_test "Large server packet TLS 1.0 StreamCipher" \
6792 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6793 "$P_CLI force_version=tls1 \
6794 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6795 0 \
6796 -s "16384 bytes written in 1 fragments" \
6797 -c "Read from server: 16384 bytes read"
6798
6799run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6800 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6801 "$P_CLI force_version=tls1 \
6802 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6803 0 \
6804 -s "16384 bytes written in 1 fragments" \
6805 -c "Read from server: 16384 bytes read"
6806
6807requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6808run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6809 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6810 "$P_CLI force_version=tls1 \
6811 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6812 0 \
6813 -s "16384 bytes written in 1 fragments" \
6814 -c "Read from server: 16384 bytes read"
6815
6816requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6817run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6818 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6819 "$P_CLI force_version=tls1 \
6820 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6821 0 \
6822 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006823 -c "Read from server: 16384 bytes read"
6824
6825run_test "Large server packet TLS 1.1 BlockCipher" \
6826 "$P_SRV response_size=16384" \
6827 "$P_CLI force_version=tls1_1 \
6828 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6829 0 \
6830 -c "Read from server: 16384 bytes read"
6831
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006832run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6833 "$P_SRV response_size=16384" \
6834 "$P_CLI force_version=tls1_1 etm=0 \
6835 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006836 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006837 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006838 -c "Read from server: 16384 bytes read"
6839
6840requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6841run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6842 "$P_SRV response_size=16384" \
6843 "$P_CLI force_version=tls1_1 \
6844 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6845 trunc_hmac=1" \
6846 0 \
6847 -c "Read from server: 16384 bytes read"
6848
6849requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006850run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6851 "$P_SRV response_size=16384 trunc_hmac=1" \
6852 "$P_CLI force_version=tls1_1 \
6853 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6854 0 \
6855 -s "16384 bytes written in 1 fragments" \
6856 -c "Read from server: 16384 bytes read"
6857
6858run_test "Large server packet TLS 1.1 StreamCipher" \
6859 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6860 "$P_CLI force_version=tls1_1 \
6861 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6862 0 \
6863 -c "Read from server: 16384 bytes read"
6864
6865run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6866 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6867 "$P_CLI force_version=tls1_1 \
6868 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6869 0 \
6870 -s "16384 bytes written in 1 fragments" \
6871 -c "Read from server: 16384 bytes read"
6872
6873requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006874run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6875 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6876 "$P_CLI force_version=tls1_1 \
6877 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6878 trunc_hmac=1" \
6879 0 \
6880 -c "Read from server: 16384 bytes read"
6881
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006882run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6883 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6884 "$P_CLI force_version=tls1_1 \
6885 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6886 0 \
6887 -s "16384 bytes written in 1 fragments" \
6888 -c "Read from server: 16384 bytes read"
6889
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006890run_test "Large server packet TLS 1.2 BlockCipher" \
6891 "$P_SRV response_size=16384" \
6892 "$P_CLI force_version=tls1_2 \
6893 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6894 0 \
6895 -c "Read from server: 16384 bytes read"
6896
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006897run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6898 "$P_SRV response_size=16384" \
6899 "$P_CLI force_version=tls1_2 etm=0 \
6900 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6901 0 \
6902 -s "16384 bytes written in 1 fragments" \
6903 -c "Read from server: 16384 bytes read"
6904
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006905run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6906 "$P_SRV response_size=16384" \
6907 "$P_CLI force_version=tls1_2 \
6908 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6909 0 \
6910 -c "Read from server: 16384 bytes read"
6911
6912requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6913run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6914 "$P_SRV response_size=16384" \
6915 "$P_CLI force_version=tls1_2 \
6916 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6917 trunc_hmac=1" \
6918 0 \
6919 -c "Read from server: 16384 bytes read"
6920
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006921run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6922 "$P_SRV response_size=16384 trunc_hmac=1" \
6923 "$P_CLI force_version=tls1_2 \
6924 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6925 0 \
6926 -s "16384 bytes written in 1 fragments" \
6927 -c "Read from server: 16384 bytes read"
6928
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006929run_test "Large server packet TLS 1.2 StreamCipher" \
6930 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6931 "$P_CLI force_version=tls1_2 \
6932 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6933 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006934 -s "16384 bytes written in 1 fragments" \
6935 -c "Read from server: 16384 bytes read"
6936
6937run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6938 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6939 "$P_CLI force_version=tls1_2 \
6940 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6941 0 \
6942 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006943 -c "Read from server: 16384 bytes read"
6944
6945requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6946run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6947 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6948 "$P_CLI force_version=tls1_2 \
6949 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6950 trunc_hmac=1" \
6951 0 \
6952 -c "Read from server: 16384 bytes read"
6953
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006954requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6955run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6956 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6957 "$P_CLI force_version=tls1_2 \
6958 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6959 0 \
6960 -s "16384 bytes written in 1 fragments" \
6961 -c "Read from server: 16384 bytes read"
6962
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006963run_test "Large server packet TLS 1.2 AEAD" \
6964 "$P_SRV response_size=16384" \
6965 "$P_CLI force_version=tls1_2 \
6966 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6967 0 \
6968 -c "Read from server: 16384 bytes read"
6969
6970run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6971 "$P_SRV response_size=16384" \
6972 "$P_CLI force_version=tls1_2 \
6973 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6974 0 \
6975 -c "Read from server: 16384 bytes read"
6976
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006977# Tests for restartable ECC
6978
6979requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6980run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006981 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006982 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006983 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006984 debug_level=1" \
6985 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006986 -C "x509_verify_cert.*4b00" \
6987 -C "mbedtls_pk_verify.*4b00" \
6988 -C "mbedtls_ecdh_make_public.*4b00" \
6989 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006990
6991requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6992run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006993 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006994 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006995 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006996 debug_level=1 ec_max_ops=0" \
6997 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006998 -C "x509_verify_cert.*4b00" \
6999 -C "mbedtls_pk_verify.*4b00" \
7000 -C "mbedtls_ecdh_make_public.*4b00" \
7001 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007002
7003requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7004run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007005 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007006 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007007 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007008 debug_level=1 ec_max_ops=65535" \
7009 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007010 -C "x509_verify_cert.*4b00" \
7011 -C "mbedtls_pk_verify.*4b00" \
7012 -C "mbedtls_ecdh_make_public.*4b00" \
7013 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007014
7015requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7016run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007017 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007018 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007019 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007020 debug_level=1 ec_max_ops=1000" \
7021 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007022 -c "x509_verify_cert.*4b00" \
7023 -c "mbedtls_pk_verify.*4b00" \
7024 -c "mbedtls_ecdh_make_public.*4b00" \
7025 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007026
7027requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007028run_test "EC restart: TLS, max_ops=1000, badsign" \
7029 "$P_SRV auth_mode=required \
7030 crt_file=data_files/server5-badsign.crt \
7031 key_file=data_files/server5.key" \
7032 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7033 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7034 debug_level=1 ec_max_ops=1000" \
7035 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007036 -c "x509_verify_cert.*4b00" \
7037 -C "mbedtls_pk_verify.*4b00" \
7038 -C "mbedtls_ecdh_make_public.*4b00" \
7039 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007040 -c "! The certificate is not correctly signed by the trusted CA" \
7041 -c "! mbedtls_ssl_handshake returned" \
7042 -c "X509 - Certificate verification failed"
7043
7044requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7045run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
7046 "$P_SRV auth_mode=required \
7047 crt_file=data_files/server5-badsign.crt \
7048 key_file=data_files/server5.key" \
7049 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7050 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7051 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
7052 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007053 -c "x509_verify_cert.*4b00" \
7054 -c "mbedtls_pk_verify.*4b00" \
7055 -c "mbedtls_ecdh_make_public.*4b00" \
7056 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007057 -c "! The certificate is not correctly signed by the trusted CA" \
7058 -C "! mbedtls_ssl_handshake returned" \
7059 -C "X509 - Certificate verification failed"
7060
7061requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7062run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
7063 "$P_SRV auth_mode=required \
7064 crt_file=data_files/server5-badsign.crt \
7065 key_file=data_files/server5.key" \
7066 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7067 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7068 debug_level=1 ec_max_ops=1000 auth_mode=none" \
7069 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007070 -C "x509_verify_cert.*4b00" \
7071 -c "mbedtls_pk_verify.*4b00" \
7072 -c "mbedtls_ecdh_make_public.*4b00" \
7073 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007074 -C "! The certificate is not correctly signed by the trusted CA" \
7075 -C "! mbedtls_ssl_handshake returned" \
7076 -C "X509 - Certificate verification failed"
7077
7078requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007079run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007080 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007081 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007082 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007083 dtls=1 debug_level=1 ec_max_ops=1000" \
7084 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007085 -c "x509_verify_cert.*4b00" \
7086 -c "mbedtls_pk_verify.*4b00" \
7087 -c "mbedtls_ecdh_make_public.*4b00" \
7088 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007089
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007090requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7091run_test "EC restart: TLS, max_ops=1000 no client auth" \
7092 "$P_SRV" \
7093 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7094 debug_level=1 ec_max_ops=1000" \
7095 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007096 -c "x509_verify_cert.*4b00" \
7097 -c "mbedtls_pk_verify.*4b00" \
7098 -c "mbedtls_ecdh_make_public.*4b00" \
7099 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007100
7101requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7102run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
7103 "$P_SRV psk=abc123" \
7104 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
7105 psk=abc123 debug_level=1 ec_max_ops=1000" \
7106 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007107 -C "x509_verify_cert.*4b00" \
7108 -C "mbedtls_pk_verify.*4b00" \
7109 -C "mbedtls_ecdh_make_public.*4b00" \
7110 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007111
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007112# Tests of asynchronous private key support in SSL
7113
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007114requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007115run_test "SSL async private: sign, delay=0" \
7116 "$P_SRV \
7117 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007118 "$P_CLI" \
7119 0 \
7120 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007121 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007122
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007123requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007124run_test "SSL async private: sign, delay=1" \
7125 "$P_SRV \
7126 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007127 "$P_CLI" \
7128 0 \
7129 -s "Async sign callback: using key slot " \
7130 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007131 -s "Async resume (slot [0-9]): sign done, status=0"
7132
Gilles Peskine12d0cc12018-04-26 15:06:56 +02007133requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7134run_test "SSL async private: sign, delay=2" \
7135 "$P_SRV \
7136 async_operations=s async_private_delay1=2 async_private_delay2=2" \
7137 "$P_CLI" \
7138 0 \
7139 -s "Async sign callback: using key slot " \
7140 -U "Async sign callback: using key slot " \
7141 -s "Async resume (slot [0-9]): call 1 more times." \
7142 -s "Async resume (slot [0-9]): call 0 more times." \
7143 -s "Async resume (slot [0-9]): sign done, status=0"
7144
Gilles Peskined3268832018-04-26 06:23:59 +02007145# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
7146# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
7147requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7148requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7149run_test "SSL async private: sign, RSA, TLS 1.1" \
7150 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
7151 async_operations=s async_private_delay1=0 async_private_delay2=0" \
7152 "$P_CLI force_version=tls1_1" \
7153 0 \
7154 -s "Async sign callback: using key slot " \
7155 -s "Async resume (slot [0-9]): sign done, status=0"
7156
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007157requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02007158run_test "SSL async private: sign, SNI" \
7159 "$P_SRV debug_level=3 \
7160 async_operations=s async_private_delay1=0 async_private_delay2=0 \
7161 crt_file=data_files/server5.crt key_file=data_files/server5.key \
7162 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
7163 "$P_CLI server_name=polarssl.example" \
7164 0 \
7165 -s "Async sign callback: using key slot " \
7166 -s "Async resume (slot [0-9]): sign done, status=0" \
7167 -s "parse ServerName extension" \
7168 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
7169 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
7170
7171requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007172run_test "SSL async private: decrypt, delay=0" \
7173 "$P_SRV \
7174 async_operations=d async_private_delay1=0 async_private_delay2=0" \
7175 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7176 0 \
7177 -s "Async decrypt callback: using key slot " \
7178 -s "Async resume (slot [0-9]): decrypt done, status=0"
7179
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007180requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007181run_test "SSL async private: decrypt, delay=1" \
7182 "$P_SRV \
7183 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7184 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7185 0 \
7186 -s "Async decrypt callback: using key slot " \
7187 -s "Async resume (slot [0-9]): call 0 more times." \
7188 -s "Async resume (slot [0-9]): decrypt done, status=0"
7189
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007190requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007191run_test "SSL async private: decrypt RSA-PSK, delay=0" \
7192 "$P_SRV psk=abc123 \
7193 async_operations=d async_private_delay1=0 async_private_delay2=0" \
7194 "$P_CLI psk=abc123 \
7195 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
7196 0 \
7197 -s "Async decrypt callback: using key slot " \
7198 -s "Async resume (slot [0-9]): decrypt done, status=0"
7199
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007200requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007201run_test "SSL async private: decrypt RSA-PSK, delay=1" \
7202 "$P_SRV psk=abc123 \
7203 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7204 "$P_CLI psk=abc123 \
7205 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
7206 0 \
7207 -s "Async decrypt callback: using key slot " \
7208 -s "Async resume (slot [0-9]): call 0 more times." \
7209 -s "Async resume (slot [0-9]): decrypt done, status=0"
7210
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007211requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007212run_test "SSL async private: sign callback not present" \
7213 "$P_SRV \
7214 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7215 "$P_CLI; [ \$? -eq 1 ] &&
7216 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7217 0 \
7218 -S "Async sign callback" \
7219 -s "! mbedtls_ssl_handshake returned" \
7220 -s "The own private key or pre-shared key is not set, but needed" \
7221 -s "Async resume (slot [0-9]): decrypt done, status=0" \
7222 -s "Successful connection"
7223
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007224requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007225run_test "SSL async private: decrypt callback not present" \
7226 "$P_SRV debug_level=1 \
7227 async_operations=s async_private_delay1=1 async_private_delay2=1" \
7228 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
7229 [ \$? -eq 1 ] && $P_CLI" \
7230 0 \
7231 -S "Async decrypt callback" \
7232 -s "! mbedtls_ssl_handshake returned" \
7233 -s "got no RSA private key" \
7234 -s "Async resume (slot [0-9]): sign done, status=0" \
7235 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007236
7237# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007238requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007239run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007240 "$P_SRV \
7241 async_operations=s async_private_delay1=1 \
7242 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7243 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007244 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7245 0 \
7246 -s "Async sign callback: using key slot 0," \
7247 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007248 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007249
7250# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007251requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007252run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007253 "$P_SRV \
7254 async_operations=s async_private_delay2=1 \
7255 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7256 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007257 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7258 0 \
7259 -s "Async sign callback: using key slot 0," \
7260 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007261 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007262
7263# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007264requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02007265run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007266 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02007267 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007268 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7269 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007270 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7271 0 \
7272 -s "Async sign callback: using key slot 1," \
7273 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007274 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007275
7276# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007277requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007278run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007279 "$P_SRV \
7280 async_operations=s async_private_delay1=1 \
7281 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7282 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007283 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7284 0 \
7285 -s "Async sign callback: no key matches this certificate."
7286
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007287requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007288run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007289 "$P_SRV \
7290 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7291 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007292 "$P_CLI" \
7293 1 \
7294 -s "Async sign callback: injected error" \
7295 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02007296 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007297 -s "! mbedtls_ssl_handshake returned"
7298
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007299requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007300run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007301 "$P_SRV \
7302 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7303 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007304 "$P_CLI" \
7305 1 \
7306 -s "Async sign callback: using key slot " \
7307 -S "Async resume" \
7308 -s "Async cancel"
7309
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007310requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007311run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007312 "$P_SRV \
7313 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7314 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007315 "$P_CLI" \
7316 1 \
7317 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007318 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02007319 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007320 -s "! mbedtls_ssl_handshake returned"
7321
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007322requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007323run_test "SSL async private: decrypt, error in start" \
7324 "$P_SRV \
7325 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7326 async_private_error=1" \
7327 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7328 1 \
7329 -s "Async decrypt callback: injected error" \
7330 -S "Async resume" \
7331 -S "Async cancel" \
7332 -s "! mbedtls_ssl_handshake returned"
7333
7334requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7335run_test "SSL async private: decrypt, cancel after start" \
7336 "$P_SRV \
7337 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7338 async_private_error=2" \
7339 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7340 1 \
7341 -s "Async decrypt callback: using key slot " \
7342 -S "Async resume" \
7343 -s "Async cancel"
7344
7345requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7346run_test "SSL async private: decrypt, error in resume" \
7347 "$P_SRV \
7348 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7349 async_private_error=3" \
7350 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7351 1 \
7352 -s "Async decrypt callback: using key slot " \
7353 -s "Async resume callback: decrypt done but injected error" \
7354 -S "Async cancel" \
7355 -s "! mbedtls_ssl_handshake returned"
7356
7357requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007358run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007359 "$P_SRV \
7360 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7361 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007362 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
7363 0 \
7364 -s "Async cancel" \
7365 -s "! mbedtls_ssl_handshake returned" \
7366 -s "Async resume" \
7367 -s "Successful connection"
7368
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007369requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007370run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007371 "$P_SRV \
7372 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7373 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007374 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
7375 0 \
7376 -s "! mbedtls_ssl_handshake returned" \
7377 -s "Async resume" \
7378 -s "Successful connection"
7379
7380# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007381requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007382run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007383 "$P_SRV \
7384 async_operations=s async_private_delay1=1 async_private_error=-2 \
7385 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7386 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007387 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
7388 [ \$? -eq 1 ] &&
7389 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7390 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02007391 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007392 -S "Async resume" \
7393 -s "Async cancel" \
7394 -s "! mbedtls_ssl_handshake returned" \
7395 -s "Async sign callback: no key matches this certificate." \
7396 -s "Successful connection"
7397
7398# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007399requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007400run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007401 "$P_SRV \
7402 async_operations=s async_private_delay1=1 async_private_error=-3 \
7403 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7404 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007405 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
7406 [ \$? -eq 1 ] &&
7407 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7408 0 \
7409 -s "Async resume" \
7410 -s "! mbedtls_ssl_handshake returned" \
7411 -s "Async sign callback: no key matches this certificate." \
7412 -s "Successful connection"
7413
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007414requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007415requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007416run_test "SSL async private: renegotiation: client-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007417 "$P_SRV \
7418 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007419 exchanges=2 renegotiation=1" \
7420 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
7421 0 \
7422 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007423 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007424
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007425requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007426requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007427run_test "SSL async private: renegotiation: server-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007428 "$P_SRV \
7429 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007430 exchanges=2 renegotiation=1 renegotiate=1" \
7431 "$P_CLI exchanges=2 renegotiation=1" \
7432 0 \
7433 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007434 -s "Async resume (slot [0-9]): sign done, status=0"
7435
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007436requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007437requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007438run_test "SSL async private: renegotiation: client-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007439 "$P_SRV \
7440 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7441 exchanges=2 renegotiation=1" \
7442 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
7443 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7444 0 \
7445 -s "Async decrypt callback: using key slot " \
7446 -s "Async resume (slot [0-9]): decrypt done, status=0"
7447
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007448requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007449requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007450run_test "SSL async private: renegotiation: server-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007451 "$P_SRV \
7452 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7453 exchanges=2 renegotiation=1 renegotiate=1" \
7454 "$P_CLI exchanges=2 renegotiation=1 \
7455 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7456 0 \
7457 -s "Async decrypt callback: using key slot " \
7458 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007459
Ron Eldor58093c82018-06-28 13:22:05 +03007460# Tests for ECC extensions (rfc 4492)
7461
Ron Eldor643df7c2018-06-28 16:17:00 +03007462requires_config_enabled MBEDTLS_AES_C
7463requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7464requires_config_enabled MBEDTLS_SHA256_C
7465requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007466run_test "Force a non ECC ciphersuite in the client side" \
7467 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03007468 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03007469 0 \
7470 -C "client hello, adding supported_elliptic_curves extension" \
7471 -C "client hello, adding supported_point_formats extension" \
7472 -S "found supported elliptic curves extension" \
7473 -S "found supported point formats extension"
7474
Ron Eldor643df7c2018-06-28 16:17:00 +03007475requires_config_enabled MBEDTLS_AES_C
7476requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7477requires_config_enabled MBEDTLS_SHA256_C
7478requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007479run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03007480 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03007481 "$P_CLI debug_level=3" \
7482 0 \
7483 -C "found supported_point_formats extension" \
7484 -S "server hello, supported_point_formats extension"
7485
Ron Eldor643df7c2018-06-28 16:17:00 +03007486requires_config_enabled MBEDTLS_AES_C
7487requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7488requires_config_enabled MBEDTLS_SHA256_C
7489requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007490run_test "Force an ECC ciphersuite in the client side" \
7491 "$P_SRV debug_level=3" \
7492 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7493 0 \
7494 -c "client hello, adding supported_elliptic_curves extension" \
7495 -c "client hello, adding supported_point_formats extension" \
7496 -s "found supported elliptic curves extension" \
7497 -s "found supported point formats extension"
7498
Ron Eldor643df7c2018-06-28 16:17:00 +03007499requires_config_enabled MBEDTLS_AES_C
7500requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7501requires_config_enabled MBEDTLS_SHA256_C
7502requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007503run_test "Force an ECC ciphersuite in the server side" \
7504 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7505 "$P_CLI debug_level=3" \
7506 0 \
7507 -c "found supported_point_formats extension" \
7508 -s "server hello, supported_point_formats extension"
7509
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007510# Tests for DTLS HelloVerifyRequest
7511
7512run_test "DTLS cookie: enabled" \
7513 "$P_SRV dtls=1 debug_level=2" \
7514 "$P_CLI dtls=1 debug_level=2" \
7515 0 \
7516 -s "cookie verification failed" \
7517 -s "cookie verification passed" \
7518 -S "cookie verification skipped" \
7519 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007520 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007521 -S "SSL - The requested feature is not available"
7522
7523run_test "DTLS cookie: disabled" \
7524 "$P_SRV dtls=1 debug_level=2 cookies=0" \
7525 "$P_CLI dtls=1 debug_level=2" \
7526 0 \
7527 -S "cookie verification failed" \
7528 -S "cookie verification passed" \
7529 -s "cookie verification skipped" \
7530 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007531 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007532 -S "SSL - The requested feature is not available"
7533
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007534run_test "DTLS cookie: default (failing)" \
7535 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
7536 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
7537 1 \
7538 -s "cookie verification failed" \
7539 -S "cookie verification passed" \
7540 -S "cookie verification skipped" \
7541 -C "received hello verify request" \
7542 -S "hello verification requested" \
7543 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007544
7545requires_ipv6
7546run_test "DTLS cookie: enabled, IPv6" \
7547 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
7548 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
7549 0 \
7550 -s "cookie verification failed" \
7551 -s "cookie verification passed" \
7552 -S "cookie verification skipped" \
7553 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007554 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007555 -S "SSL - The requested feature is not available"
7556
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007557run_test "DTLS cookie: enabled, nbio" \
7558 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7559 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7560 0 \
7561 -s "cookie verification failed" \
7562 -s "cookie verification passed" \
7563 -S "cookie verification skipped" \
7564 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007565 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007566 -S "SSL - The requested feature is not available"
7567
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007568# Tests for client reconnecting from the same port with DTLS
7569
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007570not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007571run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007572 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7573 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007574 0 \
7575 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007576 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007577 -S "Client initiated reconnection from same port"
7578
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007579not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007580run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007581 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7582 "$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 +02007583 0 \
7584 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007585 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007586 -s "Client initiated reconnection from same port"
7587
Paul Bakker362689d2016-05-13 10:33:25 +01007588not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
7589run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007590 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7591 "$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 +02007592 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007593 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007594 -s "Client initiated reconnection from same port"
7595
Paul Bakker362689d2016-05-13 10:33:25 +01007596only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
7597run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7598 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7599 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7600 0 \
7601 -S "The operation timed out" \
7602 -s "Client initiated reconnection from same port"
7603
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007604run_test "DTLS client reconnect from same port: no cookies" \
7605 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007606 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7607 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007608 -s "The operation timed out" \
7609 -S "Client initiated reconnection from same port"
7610
Manuel Pégourié-Gonnardbaad2de2020-03-13 11:11:02 +01007611run_test "DTLS client reconnect from same port: attacker-injected" \
7612 -p "$P_PXY inject_clihlo=1" \
7613 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
7614 "$P_CLI dtls=1 exchanges=2" \
7615 0 \
7616 -s "possible client reconnect from the same port" \
7617 -S "Client initiated reconnection from same port"
7618
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007619# Tests for various cases of client authentication with DTLS
7620# (focused on handshake flows and message parsing)
7621
7622run_test "DTLS client auth: required" \
7623 "$P_SRV dtls=1 auth_mode=required" \
7624 "$P_CLI dtls=1" \
7625 0 \
7626 -s "Verifying peer X.509 certificate... ok"
7627
7628run_test "DTLS client auth: optional, client has no cert" \
7629 "$P_SRV dtls=1 auth_mode=optional" \
7630 "$P_CLI dtls=1 crt_file=none key_file=none" \
7631 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007632 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007633
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007634run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007635 "$P_SRV dtls=1 auth_mode=none" \
7636 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7637 0 \
7638 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007639 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007640
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007641run_test "DTLS wrong PSK: badmac alert" \
7642 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7643 "$P_CLI dtls=1 psk=abc124" \
7644 1 \
7645 -s "SSL - Verification of the message MAC failed" \
7646 -c "SSL - A fatal alert message was received from our peer"
7647
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007648# Tests for receiving fragmented handshake messages with DTLS
7649
7650requires_gnutls
7651run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7652 "$G_SRV -u --mtu 2048 -a" \
7653 "$P_CLI dtls=1 debug_level=2" \
7654 0 \
7655 -C "found fragmented DTLS handshake message" \
7656 -C "error"
7657
7658requires_gnutls
7659run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7660 "$G_SRV -u --mtu 512" \
7661 "$P_CLI dtls=1 debug_level=2" \
7662 0 \
7663 -c "found fragmented DTLS handshake message" \
7664 -C "error"
7665
7666requires_gnutls
7667run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7668 "$G_SRV -u --mtu 128" \
7669 "$P_CLI dtls=1 debug_level=2" \
7670 0 \
7671 -c "found fragmented DTLS handshake message" \
7672 -C "error"
7673
7674requires_gnutls
7675run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7676 "$G_SRV -u --mtu 128" \
7677 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7678 0 \
7679 -c "found fragmented DTLS handshake message" \
7680 -C "error"
7681
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007682requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007683requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007684run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7685 "$G_SRV -u --mtu 256" \
7686 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
7687 0 \
7688 -c "found fragmented DTLS handshake message" \
7689 -c "client hello, adding renegotiation extension" \
7690 -c "found renegotiation extension" \
7691 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007692 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007693 -C "error" \
7694 -s "Extra-header:"
7695
7696requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007697requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007698run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7699 "$G_SRV -u --mtu 256" \
7700 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
7701 0 \
7702 -c "found fragmented DTLS handshake message" \
7703 -c "client hello, adding renegotiation extension" \
7704 -c "found renegotiation extension" \
7705 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007706 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007707 -C "error" \
7708 -s "Extra-header:"
7709
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007710run_test "DTLS reassembly: no fragmentation (openssl server)" \
7711 "$O_SRV -dtls1 -mtu 2048" \
7712 "$P_CLI dtls=1 debug_level=2" \
7713 0 \
7714 -C "found fragmented DTLS handshake message" \
7715 -C "error"
7716
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007717run_test "DTLS reassembly: some fragmentation (openssl server)" \
7718 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007719 "$P_CLI dtls=1 debug_level=2" \
7720 0 \
7721 -c "found fragmented DTLS handshake message" \
7722 -C "error"
7723
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007724run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007725 "$O_SRV -dtls1 -mtu 256" \
7726 "$P_CLI dtls=1 debug_level=2" \
7727 0 \
7728 -c "found fragmented DTLS handshake message" \
7729 -C "error"
7730
7731run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7732 "$O_SRV -dtls1 -mtu 256" \
7733 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7734 0 \
7735 -c "found fragmented DTLS handshake message" \
7736 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007737
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007738# Tests for sending fragmented handshake messages with DTLS
7739#
7740# Use client auth when we need the client to send large messages,
7741# and use large cert chains on both sides too (the long chains we have all use
7742# both RSA and ECDSA, but ideally we should have long chains with either).
7743# Sizes reached (UDP payload):
7744# - 2037B for server certificate
7745# - 1542B for client certificate
7746# - 1013B for newsessionticket
7747# - all others below 512B
7748# All those tests assume MAX_CONTENT_LEN is at least 2048
7749
7750requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7751requires_config_enabled MBEDTLS_RSA_C
7752requires_config_enabled MBEDTLS_ECDSA_C
7753requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7754run_test "DTLS fragmenting: none (for reference)" \
7755 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7756 crt_file=data_files/server7_int-ca.crt \
7757 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007758 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007759 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007760 "$P_CLI dtls=1 debug_level=2 \
7761 crt_file=data_files/server8_int-ca2.crt \
7762 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007763 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007764 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007765 0 \
7766 -S "found fragmented DTLS handshake message" \
7767 -C "found fragmented DTLS handshake message" \
7768 -C "error"
7769
7770requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7771requires_config_enabled MBEDTLS_RSA_C
7772requires_config_enabled MBEDTLS_ECDSA_C
7773requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007774run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007775 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7776 crt_file=data_files/server7_int-ca.crt \
7777 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007778 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007779 max_frag_len=1024" \
7780 "$P_CLI dtls=1 debug_level=2 \
7781 crt_file=data_files/server8_int-ca2.crt \
7782 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007783 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007784 max_frag_len=2048" \
7785 0 \
7786 -S "found fragmented DTLS handshake message" \
7787 -c "found fragmented DTLS handshake message" \
7788 -C "error"
7789
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007790# With the MFL extension, the server has no way of forcing
7791# the client to not exceed a certain MTU; hence, the following
7792# test can't be replicated with an MTU proxy such as the one
7793# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007794requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7795requires_config_enabled MBEDTLS_RSA_C
7796requires_config_enabled MBEDTLS_ECDSA_C
7797requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007798run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007799 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7800 crt_file=data_files/server7_int-ca.crt \
7801 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007802 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007803 max_frag_len=512" \
7804 "$P_CLI dtls=1 debug_level=2 \
7805 crt_file=data_files/server8_int-ca2.crt \
7806 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007807 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007808 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007809 0 \
7810 -S "found fragmented DTLS handshake message" \
7811 -c "found fragmented DTLS handshake message" \
7812 -C "error"
7813
7814requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7815requires_config_enabled MBEDTLS_RSA_C
7816requires_config_enabled MBEDTLS_ECDSA_C
7817requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007818run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007819 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7820 crt_file=data_files/server7_int-ca.crt \
7821 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007822 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007823 max_frag_len=2048" \
7824 "$P_CLI dtls=1 debug_level=2 \
7825 crt_file=data_files/server8_int-ca2.crt \
7826 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007827 hs_timeout=2500-60000 \
7828 max_frag_len=1024" \
7829 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007830 -S "found fragmented DTLS handshake message" \
7831 -c "found fragmented DTLS handshake message" \
7832 -C "error"
7833
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007834# While not required by the standard defining the MFL extension
7835# (according to which it only applies to records, not to datagrams),
7836# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7837# as otherwise there wouldn't be any means to communicate MTU restrictions
7838# to the peer.
7839# The next test checks that no datagrams significantly larger than the
7840# negotiated MFL are sent.
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: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007846 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007847 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7848 crt_file=data_files/server7_int-ca.crt \
7849 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007850 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007851 max_frag_len=2048" \
7852 "$P_CLI dtls=1 debug_level=2 \
7853 crt_file=data_files/server8_int-ca2.crt \
7854 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007855 hs_timeout=2500-60000 \
7856 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007857 0 \
7858 -S "found fragmented DTLS handshake message" \
7859 -c "found fragmented DTLS handshake message" \
7860 -C "error"
7861
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007862requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7863requires_config_enabled MBEDTLS_RSA_C
7864requires_config_enabled MBEDTLS_ECDSA_C
7865requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007866run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007867 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7868 crt_file=data_files/server7_int-ca.crt \
7869 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007870 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007871 max_frag_len=2048" \
7872 "$P_CLI dtls=1 debug_level=2 \
7873 crt_file=data_files/server8_int-ca2.crt \
7874 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007875 hs_timeout=2500-60000 \
7876 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007877 0 \
7878 -s "found fragmented DTLS handshake message" \
7879 -c "found fragmented DTLS handshake message" \
7880 -C "error"
7881
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007882# While not required by the standard defining the MFL extension
7883# (according to which it only applies to records, not to datagrams),
7884# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7885# as otherwise there wouldn't be any means to communicate MTU restrictions
7886# to the peer.
7887# The next test checks that no datagrams significantly larger than the
7888# negotiated MFL are sent.
7889requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7890requires_config_enabled MBEDTLS_RSA_C
7891requires_config_enabled MBEDTLS_ECDSA_C
7892requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7893run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007894 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007895 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7896 crt_file=data_files/server7_int-ca.crt \
7897 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007898 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007899 max_frag_len=2048" \
7900 "$P_CLI dtls=1 debug_level=2 \
7901 crt_file=data_files/server8_int-ca2.crt \
7902 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007903 hs_timeout=2500-60000 \
7904 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007905 0 \
7906 -s "found fragmented DTLS handshake message" \
7907 -c "found fragmented DTLS handshake message" \
7908 -C "error"
7909
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007910requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7911requires_config_enabled MBEDTLS_RSA_C
7912requires_config_enabled MBEDTLS_ECDSA_C
7913run_test "DTLS fragmenting: none (for reference) (MTU)" \
7914 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7915 crt_file=data_files/server7_int-ca.crt \
7916 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007917 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007918 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007919 "$P_CLI dtls=1 debug_level=2 \
7920 crt_file=data_files/server8_int-ca2.crt \
7921 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007922 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007923 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007924 0 \
7925 -S "found fragmented DTLS handshake message" \
7926 -C "found fragmented DTLS handshake message" \
7927 -C "error"
7928
7929requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7930requires_config_enabled MBEDTLS_RSA_C
7931requires_config_enabled MBEDTLS_ECDSA_C
7932run_test "DTLS fragmenting: client (MTU)" \
7933 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7934 crt_file=data_files/server7_int-ca.crt \
7935 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007936 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007937 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007938 "$P_CLI dtls=1 debug_level=2 \
7939 crt_file=data_files/server8_int-ca2.crt \
7940 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007941 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007942 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007943 0 \
7944 -s "found fragmented DTLS handshake message" \
7945 -C "found fragmented DTLS handshake message" \
7946 -C "error"
7947
7948requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7949requires_config_enabled MBEDTLS_RSA_C
7950requires_config_enabled MBEDTLS_ECDSA_C
7951run_test "DTLS fragmenting: server (MTU)" \
7952 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7953 crt_file=data_files/server7_int-ca.crt \
7954 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007955 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007956 mtu=512" \
7957 "$P_CLI dtls=1 debug_level=2 \
7958 crt_file=data_files/server8_int-ca2.crt \
7959 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007960 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007961 mtu=2048" \
7962 0 \
7963 -S "found fragmented DTLS handshake message" \
7964 -c "found fragmented DTLS handshake message" \
7965 -C "error"
7966
7967requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7968requires_config_enabled MBEDTLS_RSA_C
7969requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007970run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007971 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007972 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7973 crt_file=data_files/server7_int-ca.crt \
7974 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007975 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007976 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007977 "$P_CLI dtls=1 debug_level=2 \
7978 crt_file=data_files/server8_int-ca2.crt \
7979 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007980 hs_timeout=2500-60000 \
7981 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007982 0 \
7983 -s "found fragmented DTLS handshake message" \
7984 -c "found fragmented DTLS handshake message" \
7985 -C "error"
7986
Andrzej Kurek77826052018-10-11 07:34:08 -04007987# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007988requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7989requires_config_enabled MBEDTLS_RSA_C
7990requires_config_enabled MBEDTLS_ECDSA_C
7991requires_config_enabled MBEDTLS_SHA256_C
7992requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7993requires_config_enabled MBEDTLS_AES_C
7994requires_config_enabled MBEDTLS_GCM_C
7995run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007996 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007997 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7998 crt_file=data_files/server7_int-ca.crt \
7999 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008000 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00008001 mtu=512" \
8002 "$P_CLI dtls=1 debug_level=2 \
8003 crt_file=data_files/server8_int-ca2.crt \
8004 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008005 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8006 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008007 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008008 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008009 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008010 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008011 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008012
Andrzej Kurek7311c782018-10-11 06:49:41 -04008013# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04008014# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008015# The ratio of max/min timeout should ideally equal 4 to accept two
8016# retransmissions, but in some cases (like both the server and client using
8017# fragmentation and auto-reduction) an extra retransmission might occur,
8018# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01008019not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008020requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8021requires_config_enabled MBEDTLS_RSA_C
8022requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008023requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8024requires_config_enabled MBEDTLS_AES_C
8025requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02008026run_test "DTLS fragmenting: proxy MTU: auto-reduction (not valgrind)" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008027 -p "$P_PXY mtu=508" \
8028 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8029 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008030 key_file=data_files/server7.key \
8031 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008032 "$P_CLI dtls=1 debug_level=2 \
8033 crt_file=data_files/server8_int-ca2.crt \
8034 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008035 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8036 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008037 0 \
8038 -s "found fragmented DTLS handshake message" \
8039 -c "found fragmented DTLS handshake message" \
8040 -C "error"
8041
Andrzej Kurek77826052018-10-11 07:34:08 -04008042# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01008043only_with_valgrind
8044requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8045requires_config_enabled MBEDTLS_RSA_C
8046requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008047requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8048requires_config_enabled MBEDTLS_AES_C
8049requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02008050run_test "DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)" \
Hanno Becker108992e2018-08-29 17:04:18 +01008051 -p "$P_PXY mtu=508" \
8052 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8053 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008054 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01008055 hs_timeout=250-10000" \
8056 "$P_CLI dtls=1 debug_level=2 \
8057 crt_file=data_files/server8_int-ca2.crt \
8058 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008059 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01008060 hs_timeout=250-10000" \
8061 0 \
8062 -s "found fragmented DTLS handshake message" \
8063 -c "found fragmented DTLS handshake message" \
8064 -C "error"
8065
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008066# 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 +02008067# OTOH the client might resend if the server is to slow to reset after sending
8068# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008069not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008070requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8071requires_config_enabled MBEDTLS_RSA_C
8072requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008073run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008074 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008075 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8076 crt_file=data_files/server7_int-ca.crt \
8077 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008078 hs_timeout=10000-60000 \
8079 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008080 "$P_CLI dtls=1 debug_level=2 \
8081 crt_file=data_files/server8_int-ca2.crt \
8082 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008083 hs_timeout=10000-60000 \
8084 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008085 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008086 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008087 -s "found fragmented DTLS handshake message" \
8088 -c "found fragmented DTLS handshake message" \
8089 -C "error"
8090
Andrzej Kurek77826052018-10-11 07:34:08 -04008091# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008092# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
8093# OTOH the client might resend if the server is to slow to reset after sending
8094# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008095not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008096requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8097requires_config_enabled MBEDTLS_RSA_C
8098requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008099requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8100requires_config_enabled MBEDTLS_AES_C
8101requires_config_enabled MBEDTLS_GCM_C
8102run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008103 -p "$P_PXY mtu=512" \
8104 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8105 crt_file=data_files/server7_int-ca.crt \
8106 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008107 hs_timeout=10000-60000 \
8108 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008109 "$P_CLI dtls=1 debug_level=2 \
8110 crt_file=data_files/server8_int-ca2.crt \
8111 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008112 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8113 hs_timeout=10000-60000 \
8114 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008115 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008116 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008117 -s "found fragmented DTLS handshake message" \
8118 -c "found fragmented DTLS handshake message" \
8119 -C "error"
8120
Andrzej Kurek7311c782018-10-11 06:49:41 -04008121not_with_valgrind # spurious autoreduction due to timeout
8122requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8123requires_config_enabled MBEDTLS_RSA_C
8124requires_config_enabled MBEDTLS_ECDSA_C
8125run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008126 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008127 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8128 crt_file=data_files/server7_int-ca.crt \
8129 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008130 hs_timeout=10000-60000 \
8131 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008132 "$P_CLI dtls=1 debug_level=2 \
8133 crt_file=data_files/server8_int-ca2.crt \
8134 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008135 hs_timeout=10000-60000 \
8136 mtu=1024 nbio=2" \
8137 0 \
8138 -S "autoreduction" \
8139 -s "found fragmented DTLS handshake message" \
8140 -c "found fragmented DTLS handshake message" \
8141 -C "error"
8142
Andrzej Kurek77826052018-10-11 07:34:08 -04008143# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008144not_with_valgrind # spurious autoreduction due to timeout
8145requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8146requires_config_enabled MBEDTLS_RSA_C
8147requires_config_enabled MBEDTLS_ECDSA_C
8148requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8149requires_config_enabled MBEDTLS_AES_C
8150requires_config_enabled MBEDTLS_GCM_C
8151run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
8152 -p "$P_PXY mtu=512" \
8153 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8154 crt_file=data_files/server7_int-ca.crt \
8155 key_file=data_files/server7.key \
8156 hs_timeout=10000-60000 \
8157 mtu=512 nbio=2" \
8158 "$P_CLI dtls=1 debug_level=2 \
8159 crt_file=data_files/server8_int-ca2.crt \
8160 key_file=data_files/server8.key \
8161 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8162 hs_timeout=10000-60000 \
8163 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008164 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008165 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008166 -s "found fragmented DTLS handshake message" \
8167 -c "found fragmented DTLS handshake message" \
8168 -C "error"
8169
Andrzej Kurek77826052018-10-11 07:34:08 -04008170# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01008171# This ensures things still work after session_reset().
8172# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008173# Since we don't support reading fragmented ClientHello yet,
8174# up the MTU to 1450 (larger than ClientHello with session ticket,
8175# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008176# An autoreduction on the client-side might happen if the server is
8177# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02008178# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008179# resumed listening, which would result in a spurious autoreduction.
8180not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008181requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8182requires_config_enabled MBEDTLS_RSA_C
8183requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008184requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8185requires_config_enabled MBEDTLS_AES_C
8186requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008187run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
8188 -p "$P_PXY mtu=1450" \
8189 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8190 crt_file=data_files/server7_int-ca.crt \
8191 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008192 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008193 mtu=1450" \
8194 "$P_CLI dtls=1 debug_level=2 \
8195 crt_file=data_files/server8_int-ca2.crt \
8196 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008197 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008198 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01008199 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008200 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008201 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008202 -s "found fragmented DTLS handshake message" \
8203 -c "found fragmented DTLS handshake message" \
8204 -C "error"
8205
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008206# An autoreduction on the client-side might happen if the server is
8207# slow to reset, therefore omitting '-C "autoreduction"' below.
8208not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008209requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8210requires_config_enabled MBEDTLS_RSA_C
8211requires_config_enabled MBEDTLS_ECDSA_C
8212requires_config_enabled MBEDTLS_SHA256_C
8213requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8214requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8215requires_config_enabled MBEDTLS_CHACHAPOLY_C
8216run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
8217 -p "$P_PXY mtu=512" \
8218 "$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 \
8221 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008222 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008223 mtu=512" \
8224 "$P_CLI dtls=1 debug_level=2 \
8225 crt_file=data_files/server8_int-ca2.crt \
8226 key_file=data_files/server8.key \
8227 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008228 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008229 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008230 mtu=512" \
8231 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008232 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008233 -s "found fragmented DTLS handshake message" \
8234 -c "found fragmented DTLS handshake message" \
8235 -C "error"
8236
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008237# An autoreduction on the client-side might happen if the server is
8238# slow to reset, therefore omitting '-C "autoreduction"' below.
8239not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008240requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8241requires_config_enabled MBEDTLS_RSA_C
8242requires_config_enabled MBEDTLS_ECDSA_C
8243requires_config_enabled MBEDTLS_SHA256_C
8244requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8245requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8246requires_config_enabled MBEDTLS_AES_C
8247requires_config_enabled MBEDTLS_GCM_C
8248run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
8249 -p "$P_PXY mtu=512" \
8250 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8251 crt_file=data_files/server7_int-ca.crt \
8252 key_file=data_files/server7.key \
8253 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008254 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008255 mtu=512" \
8256 "$P_CLI dtls=1 debug_level=2 \
8257 crt_file=data_files/server8_int-ca2.crt \
8258 key_file=data_files/server8.key \
8259 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008260 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008261 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008262 mtu=512" \
8263 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008264 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008265 -s "found fragmented DTLS handshake message" \
8266 -c "found fragmented DTLS handshake message" \
8267 -C "error"
8268
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008269# An autoreduction on the client-side might happen if the server is
8270# slow to reset, therefore omitting '-C "autoreduction"' below.
8271not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008272requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8273requires_config_enabled MBEDTLS_RSA_C
8274requires_config_enabled MBEDTLS_ECDSA_C
8275requires_config_enabled MBEDTLS_SHA256_C
8276requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8277requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8278requires_config_enabled MBEDTLS_AES_C
8279requires_config_enabled MBEDTLS_CCM_C
8280run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008281 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008282 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8283 crt_file=data_files/server7_int-ca.crt \
8284 key_file=data_files/server7.key \
8285 exchanges=2 renegotiation=1 \
8286 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008287 hs_timeout=10000-60000 \
8288 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008289 "$P_CLI dtls=1 debug_level=2 \
8290 crt_file=data_files/server8_int-ca2.crt \
8291 key_file=data_files/server8.key \
8292 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008293 hs_timeout=10000-60000 \
8294 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008295 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008296 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008297 -s "found fragmented DTLS handshake message" \
8298 -c "found fragmented DTLS handshake message" \
8299 -C "error"
8300
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008301# An autoreduction on the client-side might happen if the server is
8302# slow to reset, therefore omitting '-C "autoreduction"' below.
8303not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008304requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8305requires_config_enabled MBEDTLS_RSA_C
8306requires_config_enabled MBEDTLS_ECDSA_C
8307requires_config_enabled MBEDTLS_SHA256_C
8308requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8309requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8310requires_config_enabled MBEDTLS_AES_C
8311requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
8312requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
8313run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008314 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008315 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8316 crt_file=data_files/server7_int-ca.crt \
8317 key_file=data_files/server7.key \
8318 exchanges=2 renegotiation=1 \
8319 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008320 hs_timeout=10000-60000 \
8321 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008322 "$P_CLI dtls=1 debug_level=2 \
8323 crt_file=data_files/server8_int-ca2.crt \
8324 key_file=data_files/server8.key \
8325 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008326 hs_timeout=10000-60000 \
8327 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008328 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008329 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008330 -s "found fragmented DTLS handshake message" \
8331 -c "found fragmented DTLS handshake message" \
8332 -C "error"
8333
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008334# An autoreduction on the client-side might happen if the server is
8335# slow to reset, therefore omitting '-C "autoreduction"' below.
8336not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008337requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8338requires_config_enabled MBEDTLS_RSA_C
8339requires_config_enabled MBEDTLS_ECDSA_C
8340requires_config_enabled MBEDTLS_SHA256_C
8341requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8342requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8343requires_config_enabled MBEDTLS_AES_C
8344requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
8345run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008346 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008347 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8348 crt_file=data_files/server7_int-ca.crt \
8349 key_file=data_files/server7.key \
8350 exchanges=2 renegotiation=1 \
8351 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008352 hs_timeout=10000-60000 \
8353 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008354 "$P_CLI dtls=1 debug_level=2 \
8355 crt_file=data_files/server8_int-ca2.crt \
8356 key_file=data_files/server8.key \
8357 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008358 hs_timeout=10000-60000 \
8359 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008360 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008361 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008362 -s "found fragmented DTLS handshake message" \
8363 -c "found fragmented DTLS handshake message" \
8364 -C "error"
8365
Andrzej Kurek77826052018-10-11 07:34:08 -04008366# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008367requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8368requires_config_enabled MBEDTLS_RSA_C
8369requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008370requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8371requires_config_enabled MBEDTLS_AES_C
8372requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008373client_needs_more_time 2
8374run_test "DTLS fragmenting: proxy MTU + 3d" \
8375 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008376 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008377 crt_file=data_files/server7_int-ca.crt \
8378 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008379 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008380 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008381 crt_file=data_files/server8_int-ca2.crt \
8382 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008383 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008384 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008385 0 \
8386 -s "found fragmented DTLS handshake message" \
8387 -c "found fragmented DTLS handshake message" \
8388 -C "error"
8389
Andrzej Kurek77826052018-10-11 07:34:08 -04008390# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008391requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8392requires_config_enabled MBEDTLS_RSA_C
8393requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008394requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8395requires_config_enabled MBEDTLS_AES_C
8396requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008397client_needs_more_time 2
8398run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
8399 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
8400 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8401 crt_file=data_files/server7_int-ca.crt \
8402 key_file=data_files/server7.key \
8403 hs_timeout=250-10000 mtu=512 nbio=2" \
8404 "$P_CLI dtls=1 debug_level=2 \
8405 crt_file=data_files/server8_int-ca2.crt \
8406 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008407 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008408 hs_timeout=250-10000 mtu=512 nbio=2" \
8409 0 \
8410 -s "found fragmented DTLS handshake message" \
8411 -c "found fragmented DTLS handshake message" \
8412 -C "error"
8413
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008414# interop tests for DTLS fragmentating with reliable connection
8415#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008416# here and below we just want to test that the we fragment in a way that
8417# pleases other implementations, so we don't need the peer to fragment
8418requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8419requires_config_enabled MBEDTLS_RSA_C
8420requires_config_enabled MBEDTLS_ECDSA_C
8421requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008422requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008423run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
8424 "$G_SRV -u" \
8425 "$P_CLI dtls=1 debug_level=2 \
8426 crt_file=data_files/server8_int-ca2.crt \
8427 key_file=data_files/server8.key \
8428 mtu=512 force_version=dtls1_2" \
8429 0 \
8430 -c "fragmenting handshake message" \
8431 -C "error"
8432
8433requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8434requires_config_enabled MBEDTLS_RSA_C
8435requires_config_enabled MBEDTLS_ECDSA_C
8436requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008437requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008438run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
8439 "$G_SRV -u" \
8440 "$P_CLI dtls=1 debug_level=2 \
8441 crt_file=data_files/server8_int-ca2.crt \
8442 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008443 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008444 0 \
8445 -c "fragmenting handshake message" \
8446 -C "error"
8447
Hanno Beckerb9a00862018-08-28 10:20:22 +01008448# We use --insecure for the GnuTLS client because it expects
8449# the hostname / IP it connects to to be the name used in the
8450# certificate obtained from the server. Here, however, it
8451# connects to 127.0.0.1 while our test certificates use 'localhost'
8452# as the server name in the certificate. This will make the
8453# certifiate validation fail, but passing --insecure makes
8454# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008455requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8456requires_config_enabled MBEDTLS_RSA_C
8457requires_config_enabled MBEDTLS_ECDSA_C
8458requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008459requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008460requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008461run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008462 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008463 crt_file=data_files/server7_int-ca.crt \
8464 key_file=data_files/server7.key \
8465 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008466 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008467 0 \
8468 -s "fragmenting handshake message"
8469
Hanno Beckerb9a00862018-08-28 10:20:22 +01008470# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008471requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8472requires_config_enabled MBEDTLS_RSA_C
8473requires_config_enabled MBEDTLS_ECDSA_C
8474requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008475requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008476requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008477run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008478 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008479 crt_file=data_files/server7_int-ca.crt \
8480 key_file=data_files/server7.key \
8481 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008482 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008483 0 \
8484 -s "fragmenting handshake message"
8485
8486requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8487requires_config_enabled MBEDTLS_RSA_C
8488requires_config_enabled MBEDTLS_ECDSA_C
8489requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8490run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
8491 "$O_SRV -dtls1_2 -verify 10" \
8492 "$P_CLI dtls=1 debug_level=2 \
8493 crt_file=data_files/server8_int-ca2.crt \
8494 key_file=data_files/server8.key \
8495 mtu=512 force_version=dtls1_2" \
8496 0 \
8497 -c "fragmenting handshake message" \
8498 -C "error"
8499
8500requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8501requires_config_enabled MBEDTLS_RSA_C
8502requires_config_enabled MBEDTLS_ECDSA_C
8503requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8504run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
8505 "$O_SRV -dtls1 -verify 10" \
8506 "$P_CLI dtls=1 debug_level=2 \
8507 crt_file=data_files/server8_int-ca2.crt \
8508 key_file=data_files/server8.key \
8509 mtu=512 force_version=dtls1" \
8510 0 \
8511 -c "fragmenting handshake message" \
8512 -C "error"
8513
8514requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8515requires_config_enabled MBEDTLS_RSA_C
8516requires_config_enabled MBEDTLS_ECDSA_C
8517requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8518run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
8519 "$P_SRV dtls=1 debug_level=2 \
8520 crt_file=data_files/server7_int-ca.crt \
8521 key_file=data_files/server7.key \
8522 mtu=512 force_version=dtls1_2" \
8523 "$O_CLI -dtls1_2" \
8524 0 \
8525 -s "fragmenting handshake message"
8526
8527requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8528requires_config_enabled MBEDTLS_RSA_C
8529requires_config_enabled MBEDTLS_ECDSA_C
8530requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8531run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8532 "$P_SRV dtls=1 debug_level=2 \
8533 crt_file=data_files/server7_int-ca.crt \
8534 key_file=data_files/server7.key \
8535 mtu=512 force_version=dtls1" \
8536 "$O_CLI -dtls1" \
8537 0 \
8538 -s "fragmenting handshake message"
8539
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008540# interop tests for DTLS fragmentating with unreliable connection
8541#
8542# again we just want to test that the we fragment in a way that
8543# pleases other implementations, so we don't need the peer to fragment
8544requires_gnutls_next
8545requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8546requires_config_enabled MBEDTLS_RSA_C
8547requires_config_enabled MBEDTLS_ECDSA_C
8548requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008549client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008550run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8551 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8552 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008553 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008554 crt_file=data_files/server8_int-ca2.crt \
8555 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008556 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008557 0 \
8558 -c "fragmenting handshake message" \
8559 -C "error"
8560
8561requires_gnutls_next
8562requires_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é-Gonnard02f3a8a2018-08-20 10:49:28 +02008566client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008567run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8568 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8569 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008570 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008571 crt_file=data_files/server8_int-ca2.crt \
8572 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008573 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008574 0 \
8575 -c "fragmenting handshake message" \
8576 -C "error"
8577
k-stachowiak17a38d32019-02-18 15:29:56 +01008578requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008579requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8580requires_config_enabled MBEDTLS_RSA_C
8581requires_config_enabled MBEDTLS_ECDSA_C
8582requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8583client_needs_more_time 4
8584run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8585 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8586 "$P_SRV dtls=1 debug_level=2 \
8587 crt_file=data_files/server7_int-ca.crt \
8588 key_file=data_files/server7.key \
8589 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008590 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008591 0 \
8592 -s "fragmenting handshake message"
8593
k-stachowiak17a38d32019-02-18 15:29:56 +01008594requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008595requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8596requires_config_enabled MBEDTLS_RSA_C
8597requires_config_enabled MBEDTLS_ECDSA_C
8598requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8599client_needs_more_time 4
8600run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8601 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8602 "$P_SRV dtls=1 debug_level=2 \
8603 crt_file=data_files/server7_int-ca.crt \
8604 key_file=data_files/server7.key \
8605 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008606 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008607 0 \
8608 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008609
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008610## Interop test with OpenSSL might trigger a bug in recent versions (including
8611## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008612## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008613## They should be re-enabled once a fixed version of OpenSSL is available
8614## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008615skip_next_test
8616requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8617requires_config_enabled MBEDTLS_RSA_C
8618requires_config_enabled MBEDTLS_ECDSA_C
8619requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8620client_needs_more_time 4
8621run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8622 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8623 "$O_SRV -dtls1_2 -verify 10" \
8624 "$P_CLI dtls=1 debug_level=2 \
8625 crt_file=data_files/server8_int-ca2.crt \
8626 key_file=data_files/server8.key \
8627 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8628 0 \
8629 -c "fragmenting handshake message" \
8630 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008631
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008632skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008633requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8634requires_config_enabled MBEDTLS_RSA_C
8635requires_config_enabled MBEDTLS_ECDSA_C
8636requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008637client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008638run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8639 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008640 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008641 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008642 crt_file=data_files/server8_int-ca2.crt \
8643 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008644 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008645 0 \
8646 -c "fragmenting handshake message" \
8647 -C "error"
8648
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008649skip_next_test
8650requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8651requires_config_enabled MBEDTLS_RSA_C
8652requires_config_enabled MBEDTLS_ECDSA_C
8653requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8654client_needs_more_time 4
8655run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8656 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8657 "$P_SRV dtls=1 debug_level=2 \
8658 crt_file=data_files/server7_int-ca.crt \
8659 key_file=data_files/server7.key \
8660 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8661 "$O_CLI -dtls1_2" \
8662 0 \
8663 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008664
8665# -nbio is added to prevent s_client from blocking in case of duplicated
8666# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008667skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008668requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8669requires_config_enabled MBEDTLS_RSA_C
8670requires_config_enabled MBEDTLS_ECDSA_C
8671requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008672client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008673run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8674 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008675 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008676 crt_file=data_files/server7_int-ca.crt \
8677 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008678 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008679 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008680 0 \
8681 -s "fragmenting handshake message"
8682
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008683# Tests for specific things with "unreliable" UDP connection
8684
8685not_with_valgrind # spurious resend due to timeout
8686run_test "DTLS proxy: reference" \
8687 -p "$P_PXY" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008688 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
8689 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008690 0 \
8691 -C "replayed record" \
8692 -S "replayed record" \
Hanno Beckerb2a86c32019-07-19 15:43:09 +01008693 -C "Buffer record from epoch" \
8694 -S "Buffer record from epoch" \
8695 -C "ssl_buffer_message" \
8696 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008697 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008698 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008699 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008700 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008701 -c "HTTP/1.0 200 OK"
8702
8703not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008704run_test "DTLS proxy: duplicate every packet" \
8705 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008706 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
8707 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008708 0 \
8709 -c "replayed record" \
8710 -s "replayed record" \
8711 -c "record from another epoch" \
8712 -s "record from another epoch" \
8713 -S "resend" \
8714 -s "Extra-header:" \
8715 -c "HTTP/1.0 200 OK"
8716
8717run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8718 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008719 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8720 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008721 0 \
8722 -c "replayed record" \
8723 -S "replayed record" \
8724 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008725 -s "record from another epoch" \
8726 -c "resend" \
8727 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008728 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008729 -c "HTTP/1.0 200 OK"
8730
8731run_test "DTLS proxy: multiple records in same datagram" \
8732 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008733 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8734 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008735 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008736 -c "next record in same datagram" \
8737 -s "next record in same datagram"
8738
8739run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8740 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008741 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8742 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008743 0 \
8744 -c "next record in same datagram" \
8745 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008746
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008747run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8748 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008749 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8750 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008751 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008752 -c "discarding invalid record (mac)" \
8753 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008754 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008755 -c "HTTP/1.0 200 OK" \
8756 -S "too many records with bad MAC" \
8757 -S "Verification of the message MAC failed"
8758
8759run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8760 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008761 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8762 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008763 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008764 -C "discarding invalid record (mac)" \
8765 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008766 -S "Extra-header:" \
8767 -C "HTTP/1.0 200 OK" \
8768 -s "too many records with bad MAC" \
8769 -s "Verification of the message MAC failed"
8770
8771run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8772 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008773 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8774 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008775 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008776 -c "discarding invalid record (mac)" \
8777 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008778 -s "Extra-header:" \
8779 -c "HTTP/1.0 200 OK" \
8780 -S "too many records with bad MAC" \
8781 -S "Verification of the message MAC failed"
8782
8783run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8784 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008785 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8786 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008787 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008788 -c "discarding invalid record (mac)" \
8789 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008790 -s "Extra-header:" \
8791 -c "HTTP/1.0 200 OK" \
8792 -s "too many records with bad MAC" \
8793 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008794
8795run_test "DTLS proxy: delay ChangeCipherSpec" \
8796 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008797 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8798 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008799 0 \
8800 -c "record from another epoch" \
8801 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008802 -s "Extra-header:" \
8803 -c "HTTP/1.0 200 OK"
8804
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008805# Tests for reordering support with DTLS
8806
Hanno Becker56cdfd12018-08-17 13:42:15 +01008807run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8808 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008809 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8810 hs_timeout=2500-60000" \
8811 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8812 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008813 0 \
8814 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008815 -c "Next handshake message has been buffered - load"\
8816 -S "Buffering HS message" \
8817 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008818 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008819 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008820 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008821 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008822
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008823run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8824 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008825 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8826 hs_timeout=2500-60000" \
8827 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8828 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008829 0 \
8830 -c "Buffering HS message" \
8831 -c "found fragmented DTLS handshake message"\
8832 -c "Next handshake message 1 not or only partially bufffered" \
8833 -c "Next handshake message has been buffered - load"\
8834 -S "Buffering HS message" \
8835 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008836 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008837 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008838 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008839 -S "Remember CCS message"
8840
Hanno Beckera1adcca2018-08-24 14:41:07 +01008841# The client buffers the ServerKeyExchange before receiving the fragmented
8842# Certificate message; at the time of writing, together these are aroudn 1200b
8843# in size, so that the bound below ensures that the certificate can be reassembled
8844# while keeping the ServerKeyExchange.
8845requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8846run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008847 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008848 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8849 hs_timeout=2500-60000" \
8850 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8851 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008852 0 \
8853 -c "Buffering HS message" \
8854 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008855 -C "attempt to make space by freeing buffered messages" \
8856 -S "Buffering HS message" \
8857 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008858 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008859 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008860 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008861 -S "Remember CCS message"
8862
8863# The size constraints ensure that the delayed certificate message can't
8864# be reassembled while keeping the ServerKeyExchange message, but it can
8865# when dropping it first.
8866requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8867requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8868run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8869 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008870 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8871 hs_timeout=2500-60000" \
8872 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8873 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008874 0 \
8875 -c "Buffering HS message" \
8876 -c "attempt to make space by freeing buffered future messages" \
8877 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008878 -S "Buffering HS message" \
8879 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008880 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008881 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008882 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008883 -S "Remember CCS message"
8884
Hanno Becker56cdfd12018-08-17 13:42:15 +01008885run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8886 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008887 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8888 hs_timeout=2500-60000" \
8889 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8890 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008891 0 \
8892 -C "Buffering HS message" \
8893 -C "Next handshake message has been buffered - load"\
8894 -s "Buffering HS message" \
8895 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008896 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008897 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008898 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008899 -S "Remember CCS message"
8900
8901run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8902 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008903 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8904 hs_timeout=2500-60000" \
8905 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8906 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008907 0 \
8908 -C "Buffering HS message" \
8909 -C "Next handshake message has been buffered - load"\
8910 -S "Buffering HS message" \
8911 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008912 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008913 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008914 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008915 -S "Remember CCS message"
8916
8917run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8918 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008919 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8920 hs_timeout=2500-60000" \
8921 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8922 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008923 0 \
8924 -C "Buffering HS message" \
8925 -C "Next handshake message has been buffered - load"\
8926 -S "Buffering HS message" \
8927 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008928 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008929 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008930 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008931 -s "Remember CCS message"
8932
Hanno Beckera1adcca2018-08-24 14:41:07 +01008933run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008934 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008935 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8936 hs_timeout=2500-60000" \
8937 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8938 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008939 0 \
8940 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008941 -s "Found buffered record from current epoch - load" \
8942 -c "Buffer record from epoch 1" \
8943 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008944
Hanno Beckera1adcca2018-08-24 14:41:07 +01008945# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8946# from the server are delayed, so that the encrypted Finished message
8947# is received and buffered. When the fragmented NewSessionTicket comes
8948# in afterwards, the encrypted Finished message must be freed in order
8949# to make space for the NewSessionTicket to be reassembled.
8950# This works only in very particular circumstances:
8951# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8952# of the NewSessionTicket, but small enough to also allow buffering of
8953# the encrypted Finished message.
8954# - The MTU setting on the server must be so small that the NewSessionTicket
8955# needs to be fragmented.
8956# - All messages sent by the server must be small enough to be either sent
8957# without fragmentation or be reassembled within the bounds of
8958# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8959# handshake, omitting CRTs.
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02008960requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8961requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008962run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8963 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02008964 "$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 +01008965 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8966 0 \
8967 -s "Buffer record from epoch 1" \
8968 -s "Found buffered record from current epoch - load" \
8969 -c "Buffer record from epoch 1" \
8970 -C "Found buffered record from current epoch - load" \
8971 -c "Enough space available after freeing future epoch record"
8972
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008973# Tests for "randomly unreliable connection": try a variety of flows and peers
8974
8975client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008976run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8977 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008978 "$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 +02008979 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008980 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008981 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8982 0 \
8983 -s "Extra-header:" \
8984 -c "HTTP/1.0 200 OK"
8985
Janos Follath74537a62016-09-02 13:45:28 +01008986client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008987run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8988 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008989 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8990 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008991 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8992 0 \
8993 -s "Extra-header:" \
8994 -c "HTTP/1.0 200 OK"
8995
Janos Follath74537a62016-09-02 13:45:28 +01008996client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008997run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8998 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008999 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
9000 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009001 0 \
9002 -s "Extra-header:" \
9003 -c "HTTP/1.0 200 OK"
9004
Janos Follath74537a62016-09-02 13:45:28 +01009005client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009006run_test "DTLS proxy: 3d, FS, client auth" \
9007 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009008 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
9009 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009010 0 \
9011 -s "Extra-header:" \
9012 -c "HTTP/1.0 200 OK"
9013
Janos Follath74537a62016-09-02 13:45:28 +01009014client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009015run_test "DTLS proxy: 3d, FS, ticket" \
9016 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009017 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
9018 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009019 0 \
9020 -s "Extra-header:" \
9021 -c "HTTP/1.0 200 OK"
9022
Janos Follath74537a62016-09-02 13:45:28 +01009023client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009024run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
9025 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009026 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
9027 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02009028 0 \
9029 -s "Extra-header:" \
9030 -c "HTTP/1.0 200 OK"
9031
Janos Follath74537a62016-09-02 13:45:28 +01009032client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009033run_test "DTLS proxy: 3d, max handshake, nbio" \
9034 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009035 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009036 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009037 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009038 0 \
9039 -s "Extra-header:" \
9040 -c "HTTP/1.0 200 OK"
9041
Janos Follath74537a62016-09-02 13:45:28 +01009042client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02009043run_test "DTLS proxy: 3d, min handshake, resumption" \
9044 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009045 "$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 +02009046 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009047 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01009048 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02009049 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9050 0 \
9051 -s "a session has been resumed" \
9052 -c "a session has been resumed" \
9053 -s "Extra-header:" \
9054 -c "HTTP/1.0 200 OK"
9055
Janos Follath74537a62016-09-02 13:45:28 +01009056client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02009057run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
9058 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009059 "$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 +02009060 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009061 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01009062 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02009063 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
9064 0 \
9065 -s "a session has been resumed" \
9066 -c "a session has been resumed" \
9067 -s "Extra-header:" \
9068 -c "HTTP/1.0 200 OK"
9069
Janos Follath74537a62016-09-02 13:45:28 +01009070client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009071requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009072run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02009073 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009074 "$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 +02009075 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009076 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009077 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02009078 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9079 0 \
9080 -c "=> renegotiate" \
9081 -s "=> renegotiate" \
9082 -s "Extra-header:" \
9083 -c "HTTP/1.0 200 OK"
9084
Janos Follath74537a62016-09-02 13:45:28 +01009085client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009086requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009087run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
9088 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009089 "$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 +02009090 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009091 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009092 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009093 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9094 0 \
9095 -c "=> renegotiate" \
9096 -s "=> renegotiate" \
9097 -s "Extra-header:" \
9098 -c "HTTP/1.0 200 OK"
9099
Janos Follath74537a62016-09-02 13:45:28 +01009100client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009101requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009102run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009103 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009104 "$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 +02009105 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009106 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009107 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009108 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009109 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9110 0 \
9111 -c "=> renegotiate" \
9112 -s "=> renegotiate" \
9113 -s "Extra-header:" \
9114 -c "HTTP/1.0 200 OK"
9115
Janos Follath74537a62016-09-02 13:45:28 +01009116client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009117requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009118run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009119 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009120 "$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 +02009121 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009122 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009123 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009124 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009125 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9126 0 \
9127 -c "=> renegotiate" \
9128 -s "=> renegotiate" \
9129 -s "Extra-header:" \
9130 -c "HTTP/1.0 200 OK"
9131
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009132## Interop tests with OpenSSL might trigger a bug in recent versions (including
9133## all versions installed on the CI machines), reported here:
9134## Bug report: https://github.com/openssl/openssl/issues/6902
9135## They should be re-enabled once a fixed version of OpenSSL is available
9136## (this should happen in some 1.1.1_ release according to the ticket).
9137skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01009138client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009139not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009140run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009141 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9142 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009143 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009144 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009145 -c "HTTP/1.0 200 OK"
9146
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009147skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01009148client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009149not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009150run_test "DTLS proxy: 3d, openssl server, fragmentation" \
9151 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9152 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009153 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009154 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009155 -c "HTTP/1.0 200 OK"
9156
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009157skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01009158client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009159not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009160run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
9161 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9162 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009163 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009164 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009165 -c "HTTP/1.0 200 OK"
9166
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00009167requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01009168client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009169not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009170run_test "DTLS proxy: 3d, gnutls server" \
9171 -p "$P_PXY drop=5 delay=5 duplicate=5" \
9172 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009173 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009174 0 \
9175 -s "Extra-header:" \
9176 -c "Extra-header:"
9177
k-stachowiak17a38d32019-02-18 15:29:56 +01009178requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01009179client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009180not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009181run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
9182 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01009183 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009184 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009185 0 \
9186 -s "Extra-header:" \
9187 -c "Extra-header:"
9188
k-stachowiak17a38d32019-02-18 15:29:56 +01009189requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01009190client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009191not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009192run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
9193 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01009194 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009195 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009196 0 \
9197 -s "Extra-header:" \
9198 -c "Extra-header:"
9199
Ron Eldorf75e2522019-05-14 20:38:49 +03009200requires_config_enabled MBEDTLS_SSL_EXPORT_KEYS
9201run_test "export keys functionality" \
9202 "$P_SRV eap_tls=1 debug_level=3" \
9203 "$P_CLI eap_tls=1 debug_level=3" \
9204 0 \
9205 -s "exported maclen is " \
9206 -s "exported keylen is " \
9207 -s "exported ivlen is " \
9208 -c "exported maclen is " \
9209 -c "exported keylen is " \
Ron Eldor65d8c262019-06-04 13:05:36 +03009210 -c "exported ivlen is " \
9211 -c "EAP-TLS key material is:"\
9212 -s "EAP-TLS key material is:"\
9213 -c "EAP-TLS IV is:" \
9214 -s "EAP-TLS IV is:"
Ron Eldorf75e2522019-05-14 20:38:49 +03009215
Piotr Nowicki0937ed22019-11-26 16:32:40 +01009216# Test heap memory usage after handshake
9217requires_config_enabled MBEDTLS_MEMORY_DEBUG
9218requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C
9219requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
9220run_tests_memory_after_hanshake
9221
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01009222# Final report
9223
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009224echo "------------------------------------------------------------------------"
9225
9226if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01009227 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009228else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01009229 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009230fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02009231PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02009232echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009233
9234exit $FAILS