blob: 483a264b112dddd4bfef98a175770c96095dba66 [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#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# Copyright (c) 2016, ARM Limited, All Rights Reserved
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#
20# This file is part of Mbed TLS (https://tls.mbed.org)
Simon Butcher58eddef2016-05-19 23:43:11 +010021#
22# Purpose
23#
24# Executes tests to prove various TLS/SSL options and extensions.
25#
26# The goal is not to cover every ciphersuite/version, but instead to cover
27# specific options (max fragment length, truncated hmac, etc) or procedures
28# (session resumption from cache or ticket, renego, etc).
29#
30# The tests assume a build with default options, with exceptions expressed
31# with a dependency. The tests focus on functionality and do not consider
32# performance.
33#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010034
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010035set -u
36
Jaeden Amero6e70eb22019-07-03 13:51:04 +010037# Limit the size of each log to 10 GiB, in case of failures with this script
38# where it may output seemingly unlimited length error logs.
39ulimit -f 20971520
40
Gilles Peskine560280b2019-09-16 15:17:38 +020041ORIGINAL_PWD=$PWD
42if ! cd "$(dirname "$0")"; then
43 exit 125
Angus Grattonc4dd0732018-04-11 16:28:39 +100044fi
45
Antonin Décimo36e89b52019-01-23 15:24:37 +010046# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010047: ${P_SRV:=../programs/ssl/ssl_server2}
48: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020049: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010050: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020051: ${GNUTLS_CLI:=gnutls-cli}
52: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020053: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010054
Gilles Peskine560280b2019-09-16 15:17:38 +020055guess_config_name() {
56 if git diff --quiet ../include/mbedtls/config.h 2>/dev/null; then
57 echo "default"
58 else
59 echo "unknown"
60 fi
61}
62: ${MBEDTLS_TEST_OUTCOME_FILE=}
63: ${MBEDTLS_TEST_CONFIGURATION:="$(guess_config_name)"}
64: ${MBEDTLS_TEST_PLATFORM:="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"}
65
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020066O_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 +010067O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020068G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010069G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020070TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010071
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020072# alternative versions of OpenSSL and GnuTLS (no default path)
73
74if [ -n "${OPENSSL_LEGACY:-}" ]; then
75 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
76 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
77else
78 O_LEGACY_SRV=false
79 O_LEGACY_CLI=false
80fi
81
Hanno Becker58e9dc32018-08-17 15:53:21 +010082if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020083 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
84else
85 G_NEXT_SRV=false
86fi
87
Hanno Becker58e9dc32018-08-17 15:53:21 +010088if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020089 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
90else
91 G_NEXT_CLI=false
92fi
93
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010094TESTS=0
95FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020096SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010097
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000098CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020099
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100100MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100101FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200102EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100103
Paul Bakkere20310a2016-05-10 11:18:17 +0100104SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +0100105RUN_TEST_NUMBER=''
106
Paul Bakkeracaac852016-05-10 11:47:13 +0100107PRESERVE_LOGS=0
108
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200109# Pick a "unique" server port in the range 10000-19999, and a proxy
110# port which is this plus 10000. Each port number may be independently
111# overridden by a command line option.
112SRV_PORT=$(($$ % 10000 + 10000))
113PXY_PORT=$((SRV_PORT + 10000))
114
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100115print_usage() {
116 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100117 printf " -h|--help\tPrint this help.\n"
118 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200119 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
120 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100121 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100122 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100123 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskine560280b2019-09-16 15:17:38 +0200124 printf " --outcome-file\tFile where test outcomes are written\n"
125 printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n"
126 printf " --port \tTCP/UDP port (default: randomish 1xxxx)\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200127 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Gilles Peskine560280b2019-09-16 15:17:38 +0200128 printf " --seed \tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100129}
130
131get_options() {
132 while [ $# -gt 0 ]; do
133 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100134 -f|--filter)
135 shift; FILTER=$1
136 ;;
137 -e|--exclude)
138 shift; EXCLUDE=$1
139 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100140 -m|--memcheck)
141 MEMCHECK=1
142 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100143 -n|--number)
144 shift; RUN_TEST_NUMBER=$1
145 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100146 -s|--show-numbers)
147 SHOW_TEST_NUMBER=1
148 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100149 -p|--preserve-logs)
150 PRESERVE_LOGS=1
151 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200152 --port)
153 shift; SRV_PORT=$1
154 ;;
155 --proxy-port)
156 shift; PXY_PORT=$1
157 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100158 --seed)
159 shift; SEED="$1"
160 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100161 -h|--help)
162 print_usage
163 exit 0
164 ;;
165 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200166 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100167 print_usage
168 exit 1
169 ;;
170 esac
171 shift
172 done
173}
174
Gilles Peskine560280b2019-09-16 15:17:38 +0200175# Make the outcome file path relative to the original directory, not
176# to .../tests
177case "$MBEDTLS_TEST_OUTCOME_FILE" in
178 [!/]*)
179 MBEDTLS_TEST_OUTCOME_FILE="$ORIGINAL_PWD/$MBEDTLS_TEST_OUTCOME_FILE"
180 ;;
181esac
182
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100183# Skip next test; use this macro to skip tests which are legitimate
184# in theory and expected to be re-introduced at some point, but
185# aren't expected to succeed at the moment due to problems outside
186# our control (such as bugs in other TLS implementations).
187skip_next_test() {
188 SKIP_NEXT="YES"
189}
190
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100191# skip next test if the flag is not enabled in config.h
192requires_config_enabled() {
193 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
194 SKIP_NEXT="YES"
195 fi
196}
197
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200198# skip next test if the flag is enabled in config.h
199requires_config_disabled() {
200 if grep "^#define $1" $CONFIG_H > /dev/null; then
201 SKIP_NEXT="YES"
202 fi
203}
204
Hanno Becker7c48dd12018-08-28 16:09:22 +0100205get_config_value_or_default() {
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100206 # This function uses the query_config command line option to query the
207 # required Mbed TLS compile time configuration from the ssl_server2
208 # program. The command will always return a success value if the
209 # configuration is defined and the value will be printed to stdout.
210 #
211 # Note that if the configuration is not defined or is defined to nothing,
212 # the output of this function will be an empty string.
213 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100214}
215
216requires_config_value_at_least() {
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100217 VAL="$( get_config_value_or_default "$1" )"
218 if [ -z "$VAL" ]; then
219 # Should never happen
220 echo "Mbed TLS configuration $1 is not defined"
221 exit 1
222 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100223 SKIP_NEXT="YES"
224 fi
225}
226
227requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100228 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100229 if [ -z "$VAL" ]; then
230 # Should never happen
231 echo "Mbed TLS configuration $1 is not defined"
232 exit 1
233 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100234 SKIP_NEXT="YES"
235 fi
236}
237
Hanno Becker9d76d562018-11-16 17:27:29 +0000238requires_ciphersuite_enabled() {
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100239 if [ -z "$($P_CLI --help 2>/dev/null | grep $1)" ]; then
Hanno Becker9d76d562018-11-16 17:27:29 +0000240 SKIP_NEXT="YES"
241 fi
242}
243
Gilles Peskine0d721652020-06-26 23:35:53 +0200244# maybe_requires_ciphersuite_enabled CMD [RUN_TEST_OPTION...]
245# If CMD (call to a TLS client or server program) requires a specific
246# ciphersuite, arrange to only run the test case if this ciphersuite is
247# enabled. As an exception, do run the test case if it expects a ciphersuite
248# mismatch.
249maybe_requires_ciphersuite_enabled() {
250 case "$1" in
251 *\ force_ciphersuite=*) :;;
252 *) return;; # No specific required ciphersuite
253 esac
254 ciphersuite="${1##*\ force_ciphersuite=}"
255 ciphersuite="${ciphersuite%%[!-0-9A-Z_a-z]*}"
256 shift
257
258 case "$*" in
259 *"-s SSL - The server has no ciphersuites in common"*)
260 # This test case expects a ciphersuite mismatch, so it doesn't
261 # require the ciphersuite to be enabled.
262 ;;
263 *)
264 requires_ciphersuite_enabled "$ciphersuite"
265 ;;
266 esac
267
268 unset ciphersuite
269}
270
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200271# skip next test if OpenSSL doesn't support FALLBACK_SCSV
272requires_openssl_with_fallback_scsv() {
273 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
274 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
275 then
276 OPENSSL_HAS_FBSCSV="YES"
277 else
278 OPENSSL_HAS_FBSCSV="NO"
279 fi
280 fi
281 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
282 SKIP_NEXT="YES"
283 fi
284}
285
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200286# skip next test if GnuTLS isn't available
287requires_gnutls() {
288 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200289 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200290 GNUTLS_AVAILABLE="YES"
291 else
292 GNUTLS_AVAILABLE="NO"
293 fi
294 fi
295 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
296 SKIP_NEXT="YES"
297 fi
298}
299
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200300# skip next test if GnuTLS-next isn't available
301requires_gnutls_next() {
302 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
303 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
304 GNUTLS_NEXT_AVAILABLE="YES"
305 else
306 GNUTLS_NEXT_AVAILABLE="NO"
307 fi
308 fi
309 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
310 SKIP_NEXT="YES"
311 fi
312}
313
314# skip next test if OpenSSL-legacy isn't available
315requires_openssl_legacy() {
316 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
317 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
318 OPENSSL_LEGACY_AVAILABLE="YES"
319 else
320 OPENSSL_LEGACY_AVAILABLE="NO"
321 fi
322 fi
323 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
324 SKIP_NEXT="YES"
325 fi
326}
327
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200328# skip next test if IPv6 isn't available on this host
329requires_ipv6() {
330 if [ -z "${HAS_IPV6:-}" ]; then
331 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
332 SRV_PID=$!
333 sleep 1
334 kill $SRV_PID >/dev/null 2>&1
335 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
336 HAS_IPV6="NO"
337 else
338 HAS_IPV6="YES"
339 fi
340 rm -r $SRV_OUT
341 fi
342
343 if [ "$HAS_IPV6" = "NO" ]; then
344 SKIP_NEXT="YES"
345 fi
346}
347
Andrzej Kurekb4593462018-10-11 08:43:30 -0400348# skip next test if it's i686 or uname is not available
349requires_not_i686() {
350 if [ -z "${IS_I686:-}" ]; then
351 IS_I686="YES"
352 if which "uname" >/dev/null 2>&1; then
353 if [ -z "$(uname -a | grep i686)" ]; then
354 IS_I686="NO"
355 fi
356 fi
357 fi
358 if [ "$IS_I686" = "YES" ]; then
359 SKIP_NEXT="YES"
360 fi
361}
362
Angus Grattonc4dd0732018-04-11 16:28:39 +1000363# Calculate the input & output maximum content lengths set in the config
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200364MAX_CONTENT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
365MAX_IN_LEN=$( ../scripts/config.py get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
366MAX_OUT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
Angus Grattonc4dd0732018-04-11 16:28:39 +1000367
368if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
369 MAX_CONTENT_LEN="$MAX_IN_LEN"
370fi
371if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
372 MAX_CONTENT_LEN="$MAX_OUT_LEN"
373fi
374
375# skip the next test if the SSL output buffer is less than 16KB
376requires_full_size_output_buffer() {
377 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
378 SKIP_NEXT="YES"
379 fi
380}
381
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200382# skip the next test if valgrind is in use
383not_with_valgrind() {
384 if [ "$MEMCHECK" -gt 0 ]; then
385 SKIP_NEXT="YES"
386 fi
387}
388
Paul Bakker362689d2016-05-13 10:33:25 +0100389# skip the next test if valgrind is NOT in use
390only_with_valgrind() {
391 if [ "$MEMCHECK" -eq 0 ]; then
392 SKIP_NEXT="YES"
393 fi
394}
395
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200396# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100397client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200398 CLI_DELAY_FACTOR=$1
399}
400
Janos Follath74537a62016-09-02 13:45:28 +0100401# wait for the given seconds after the client finished in the next test
402server_needs_more_time() {
403 SRV_DELAY_SECONDS=$1
404}
405
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100406# print_name <name>
407print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100408 TESTS=$(( $TESTS + 1 ))
409 LINE=""
410
411 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
412 LINE="$TESTS "
413 fi
414
415 LINE="$LINE$1"
416 printf "$LINE "
417 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100418 for i in `seq 1 $LEN`; do printf '.'; done
419 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100420
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100421}
422
Gilles Peskine560280b2019-09-16 15:17:38 +0200423# record_outcome <outcome> [<failure-reason>]
424# The test name must be in $NAME.
425record_outcome() {
426 echo "$1"
427 if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ]; then
428 printf '%s;%s;%s;%s;%s;%s\n' \
429 "$MBEDTLS_TEST_PLATFORM" "$MBEDTLS_TEST_CONFIGURATION" \
430 "ssl-opt" "$NAME" \
431 "$1" "${2-}" \
432 >>"$MBEDTLS_TEST_OUTCOME_FILE"
433 fi
434}
435
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100436# fail <message>
437fail() {
Gilles Peskine560280b2019-09-16 15:17:38 +0200438 record_outcome "FAIL" "$1"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100439 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100440
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200441 mv $SRV_OUT o-srv-${TESTS}.log
442 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200443 if [ -n "$PXY_CMD" ]; then
444 mv $PXY_OUT o-pxy-${TESTS}.log
445 fi
446 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100447
Manuel Pégourié-Gonnard3f3302f2020-06-08 11:49:05 +0200448 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200449 echo " ! server output:"
450 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200451 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200452 echo " ! client output:"
453 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200454 if [ -n "$PXY_CMD" ]; then
455 echo " ! ========================================================"
456 echo " ! proxy output:"
457 cat o-pxy-${TESTS}.log
458 fi
459 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200460 fi
461
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200462 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100463}
464
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100465# is_polar <cmd_line>
466is_polar() {
467 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
468}
469
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200470# openssl s_server doesn't have -www with DTLS
471check_osrv_dtls() {
472 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
473 NEEDS_INPUT=1
474 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
475 else
476 NEEDS_INPUT=0
477 fi
478}
479
480# provide input to commands that need it
481provide_input() {
482 if [ $NEEDS_INPUT -eq 0 ]; then
483 return
484 fi
485
486 while true; do
487 echo "HTTP/1.0 200 OK"
488 sleep 1
489 done
490}
491
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100492# has_mem_err <log_file_name>
493has_mem_err() {
494 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
495 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
496 then
497 return 1 # false: does not have errors
498 else
499 return 0 # true: has errors
500 fi
501}
502
Unknownd364f4c2019-09-02 10:42:57 -0400503# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100504if type lsof >/dev/null 2>/dev/null; then
Unknownd364f4c2019-09-02 10:42:57 -0400505 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100506 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200507 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100508 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200509 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100510 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200511 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100512 # Make a tight loop, server normally takes less than 1s to start.
513 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
514 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknownd364f4c2019-09-02 10:42:57 -0400515 echo "$3 START TIMEOUT"
516 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100517 break
518 fi
519 # Linux and *BSD support decimal arguments to sleep. On other
520 # OSes this may be a tight loop.
521 sleep 0.1 2>/dev/null || true
522 done
523 }
524else
Unknownd364f4c2019-09-02 10:42:57 -0400525 echo "Warning: lsof not available, wait_app_start = sleep"
526 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200527 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100528 }
529fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200530
Unknownd364f4c2019-09-02 10:42:57 -0400531# Wait for server process $2 to be listening on port $1.
532wait_server_start() {
533 wait_app_start $1 $2 "SERVER" $SRV_OUT
534}
535
536# Wait for proxy process $2 to be listening on port $1.
537wait_proxy_start() {
538 wait_app_start $1 $2 "PROXY" $PXY_OUT
539}
540
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100541# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100542# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100543# acceptable bounds
544check_server_hello_time() {
545 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100546 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100547 # Get the Unix timestamp for now
548 CUR_TIME=$(date +'%s')
549 THRESHOLD_IN_SECS=300
550
551 # Check if the ServerHello time was printed
552 if [ -z "$SERVER_HELLO_TIME" ]; then
553 return 1
554 fi
555
556 # Check the time in ServerHello is within acceptable bounds
557 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
558 # The time in ServerHello is at least 5 minutes before now
559 return 1
560 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100561 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100562 return 1
563 else
564 return 0
565 fi
566}
567
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100568# Get handshake memory usage from server or client output and put it into the variable specified by the first argument
569handshake_memory_get() {
570 OUTPUT_VARIABLE="$1"
571 OUTPUT_FILE="$2"
572
573 # Get memory usage from a pattern like "Heap memory usage after handshake: 23112 bytes. Peak memory usage was 33112"
574 MEM_USAGE=$(sed -n 's/.*Heap memory usage after handshake: //p' < "$OUTPUT_FILE" | grep -o "[0-9]*" | head -1)
575
576 # Check if memory usage was read
577 if [ -z "$MEM_USAGE" ]; then
578 echo "Error: Can not read the value of handshake memory usage"
579 return 1
580 else
581 eval "$OUTPUT_VARIABLE=$MEM_USAGE"
582 return 0
583 fi
584}
585
586# Get handshake memory usage from server or client output and check if this value
587# is not higher than the maximum given by the first argument
588handshake_memory_check() {
589 MAX_MEMORY="$1"
590 OUTPUT_FILE="$2"
591
592 # Get memory usage
593 if ! handshake_memory_get "MEMORY_USAGE" "$OUTPUT_FILE"; then
594 return 1
595 fi
596
597 # Check if memory usage is below max value
598 if [ "$MEMORY_USAGE" -gt "$MAX_MEMORY" ]; then
599 echo "\nFailed: Handshake memory usage was $MEMORY_USAGE bytes," \
600 "but should be below $MAX_MEMORY bytes"
601 return 1
602 else
603 return 0
604 fi
605}
606
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200607# wait for client to terminate and set CLI_EXIT
608# must be called right after starting the client
609wait_client_done() {
610 CLI_PID=$!
611
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200612 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
613 CLI_DELAY_FACTOR=1
614
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200615 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200616 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200617
618 wait $CLI_PID
619 CLI_EXIT=$?
620
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200621 kill $DOG_PID >/dev/null 2>&1
622 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200623
624 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100625
626 sleep $SRV_DELAY_SECONDS
627 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200628}
629
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200630# check if the given command uses dtls and sets global variable DTLS
631detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200632 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200633 DTLS=1
634 else
635 DTLS=0
636 fi
637}
638
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200639# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100640# Options: -s pattern pattern that must be present in server output
641# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100642# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100643# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100644# -S pattern pattern that must be absent in server output
645# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100646# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100647# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100648run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100649 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200650 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100651
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100652 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
653 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200654 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200655 # There was no request to run the test, so don't record its outcome.
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100656 return
657 fi
658
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100659 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100660
Paul Bakkerb7584a52016-05-10 10:50:43 +0100661 # Do we only run numbered tests?
662 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
663 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
664 else
665 SKIP_NEXT="YES"
666 fi
667
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200668 # does this test use a proxy?
669 if [ "X$1" = "X-p" ]; then
670 PXY_CMD="$2"
671 shift 2
672 else
673 PXY_CMD=""
674 fi
675
676 # get commands and client output
677 SRV_CMD="$1"
678 CLI_CMD="$2"
679 CLI_EXPECT="$3"
680 shift 3
681
Hanno Becker91e72c32019-05-10 14:38:42 +0100682 # Check if test uses files
683 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
684 if [ ! -z "$TEST_USES_FILES" ]; then
685 requires_config_enabled MBEDTLS_FS_IO
686 fi
687
Gilles Peskine0d721652020-06-26 23:35:53 +0200688 # If the client or serve requires a ciphersuite, check that it's enabled.
689 maybe_requires_ciphersuite_enabled "$SRV_CMD" "$@"
690 maybe_requires_ciphersuite_enabled "$CLI_CMD" "$@"
Hanno Becker9d76d562018-11-16 17:27:29 +0000691
692 # should we skip?
693 if [ "X$SKIP_NEXT" = "XYES" ]; then
694 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200695 record_outcome "SKIP"
Hanno Becker9d76d562018-11-16 17:27:29 +0000696 SKIPS=$(( $SKIPS + 1 ))
697 return
698 fi
699
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200700 # update DTLS variable
701 detect_dtls "$SRV_CMD"
702
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200703 # if the test uses DTLS but no custom proxy, add a simple proxy
704 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard70fce982020-06-25 09:54:46 +0200705 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200706 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard8779e9a2020-07-16 10:19:32 +0200707 case " $SRV_CMD " in
708 *' server_addr=::1 '*)
709 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
710 esac
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200711 fi
712
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100713 # fix client port
714 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200715 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
716 else
717 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
718 fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200719
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100720 # prepend valgrind to our commands if active
721 if [ "$MEMCHECK" -gt 0 ]; then
722 if is_polar "$SRV_CMD"; then
723 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
724 fi
725 if is_polar "$CLI_CMD"; then
726 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
727 fi
728 fi
729
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200730 TIMES_LEFT=2
731 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200732 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200733
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200734 # run the commands
735 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda3b994f2020-07-27 09:45:32 +0200736 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200737 $PXY_CMD >> $PXY_OUT 2>&1 &
738 PXY_PID=$!
Unknownd364f4c2019-09-02 10:42:57 -0400739 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200740 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200741
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200742 check_osrv_dtls
Manuel Pégourié-Gonnardd06125c2020-06-08 12:06:21 +0200743 printf "# $NAME\n$SRV_CMD\n" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200744 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
745 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100746 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200747
Manuel Pégourié-Gonnardd06125c2020-06-08 12:06:21 +0200748 printf "# $NAME\n$CLI_CMD\n" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200749 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
750 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100751
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100752 sleep 0.05
753
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200754 # terminate the server (and the proxy)
755 kill $SRV_PID
756 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100757
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200758 if [ -n "$PXY_CMD" ]; then
759 kill $PXY_PID >/dev/null 2>&1
760 wait $PXY_PID
761 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100762
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200763 # retry only on timeouts
764 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
765 printf "RETRY "
766 else
767 TIMES_LEFT=0
768 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200769 done
770
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100771 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200772 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100773 # expected client exit to incorrectly succeed in case of catastrophic
774 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100775 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200776 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100777 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100778 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100779 return
780 fi
781 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100782 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200783 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100784 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100785 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100786 return
787 fi
788 fi
789
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100790 # check server exit code
791 if [ $? != 0 ]; then
792 fail "server fail"
793 return
794 fi
795
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100796 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100797 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
798 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100799 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200800 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100801 return
802 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100803
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100804 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200805 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100806 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100807 while [ $# -gt 0 ]
808 do
809 case $1 in
810 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100811 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 +0100812 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100813 return
814 fi
815 ;;
816
817 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100818 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 +0100819 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100820 return
821 fi
822 ;;
823
824 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100825 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 +0100826 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100827 return
828 fi
829 ;;
830
831 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100832 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 +0100833 fail "pattern '$2' MUST NOT be present in the Client output"
834 return
835 fi
836 ;;
837
838 # The filtering in the following two options (-u and -U) do the following
839 # - ignore valgrind output
Antonin Décimo36e89b52019-01-23 15:24:37 +0100840 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100841 # - keep one of each non-unique line
842 # - count how many lines remain
843 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
844 # if there were no duplicates.
845 "-U")
846 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
847 fail "lines following pattern '$2' must be unique in Server output"
848 return
849 fi
850 ;;
851
852 "-u")
853 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
854 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100855 return
856 fi
857 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100858 "-F")
859 if ! $2 "$SRV_OUT"; then
860 fail "function call to '$2' failed on Server output"
861 return
862 fi
863 ;;
864 "-f")
865 if ! $2 "$CLI_OUT"; then
866 fail "function call to '$2' failed on Client output"
867 return
868 fi
869 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100870
871 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200872 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100873 exit 1
874 esac
875 shift 2
876 done
877
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100878 # check valgrind's results
879 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200880 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100881 fail "Server has memory errors"
882 return
883 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200884 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100885 fail "Client has memory errors"
886 return
887 fi
888 fi
889
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100890 # if we're here, everything is ok
Gilles Peskine560280b2019-09-16 15:17:38 +0200891 record_outcome "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100892 if [ "$PRESERVE_LOGS" -gt 0 ]; then
893 mv $SRV_OUT o-srv-${TESTS}.log
894 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100895 if [ -n "$PXY_CMD" ]; then
896 mv $PXY_OUT o-pxy-${TESTS}.log
897 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100898 fi
899
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200900 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100901}
902
Hanno Becker9b5853c2018-11-16 17:28:40 +0000903run_test_psa() {
904 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
Hanno Beckere9420c22018-11-20 11:37:34 +0000905 run_test "PSA-supported ciphersuite: $1" \
Hanno Becker4c8c7aa2019-04-10 09:25:41 +0100906 "$P_SRV debug_level=3 force_version=tls1_2" \
907 "$P_CLI debug_level=3 force_version=tls1_2 force_ciphersuite=$1" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000908 0 \
909 -c "Successfully setup PSA-based decryption cipher context" \
910 -c "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500911 -c "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500912 -c "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000913 -s "Successfully setup PSA-based decryption cipher context" \
914 -s "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500915 -s "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500916 -s "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000917 -C "Failed to setup PSA-based cipher context"\
918 -S "Failed to setup PSA-based cipher context"\
919 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000920 -c "Perform PSA-based ECDH computation."\
Andrzej Kureke85414e2019-01-15 05:23:59 -0500921 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000922 -S "error" \
923 -C "error"
924}
925
Hanno Becker354e2482019-01-08 11:40:25 +0000926run_test_psa_force_curve() {
927 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
928 run_test "PSA - ECDH with $1" \
929 "$P_SRV debug_level=4 force_version=tls1_2" \
930 "$P_CLI debug_level=4 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=$1" \
931 0 \
Hanno Becker28f78442019-02-18 16:47:50 +0000932 -c "Successfully setup PSA-based decryption cipher context" \
933 -c "Successfully setup PSA-based encryption cipher context" \
934 -c "PSA calc verify" \
935 -c "calc PSA finished" \
936 -s "Successfully setup PSA-based decryption cipher context" \
937 -s "Successfully setup PSA-based encryption cipher context" \
938 -s "PSA calc verify" \
939 -s "calc PSA finished" \
940 -C "Failed to setup PSA-based cipher context"\
941 -S "Failed to setup PSA-based cipher context"\
Hanno Becker354e2482019-01-08 11:40:25 +0000942 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000943 -c "Perform PSA-based ECDH computation."\
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100944 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200945 -S "error" \
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200946 -C "error"
947}
948
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100949# Test that the server's memory usage after a handshake is reduced when a client specifies
950# a maximum fragment length.
951# first argument ($1) is MFL for SSL client
952# second argument ($2) is memory usage for SSL client with default MFL (16k)
953run_test_memory_after_hanshake_with_mfl()
954{
955 # The test passes if the difference is around 2*(16k-MFL)
956 local MEMORY_USAGE_LIMIT="$(( $2 - ( 2 * ( 16384 - $1 )) ))"
957
958 # Leave some margin for robustness
959 MEMORY_USAGE_LIMIT="$(( ( MEMORY_USAGE_LIMIT * 110 ) / 100 ))"
960
961 run_test "Handshake memory usage (MFL $1)" \
962 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
963 "$P_CLI debug_level=3 force_version=tls1_2 \
964 crt_file=data_files/server5.crt key_file=data_files/server5.key \
965 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM max_frag_len=$1" \
966 0 \
967 -F "handshake_memory_check $MEMORY_USAGE_LIMIT"
968}
969
970
971# Test that the server's memory usage after a handshake is reduced when a client specifies
972# different values of Maximum Fragment Length: default (16k), 4k, 2k, 1k and 512 bytes
973run_tests_memory_after_hanshake()
974{
975 # all tests in this sequence requires the same configuration (see requires_config_enabled())
976 SKIP_THIS_TESTS="$SKIP_NEXT"
977
978 # first test with default MFU is to get reference memory usage
979 MEMORY_USAGE_MFL_16K=0
980 run_test "Handshake memory usage initial (MFL 16384 - default)" \
981 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
982 "$P_CLI debug_level=3 force_version=tls1_2 \
983 crt_file=data_files/server5.crt key_file=data_files/server5.key \
984 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM" \
985 0 \
986 -F "handshake_memory_get MEMORY_USAGE_MFL_16K"
987
988 SKIP_NEXT="$SKIP_THIS_TESTS"
989 run_test_memory_after_hanshake_with_mfl 4096 "$MEMORY_USAGE_MFL_16K"
990
991 SKIP_NEXT="$SKIP_THIS_TESTS"
992 run_test_memory_after_hanshake_with_mfl 2048 "$MEMORY_USAGE_MFL_16K"
993
994 SKIP_NEXT="$SKIP_THIS_TESTS"
995 run_test_memory_after_hanshake_with_mfl 1024 "$MEMORY_USAGE_MFL_16K"
996
997 SKIP_NEXT="$SKIP_THIS_TESTS"
998 run_test_memory_after_hanshake_with_mfl 512 "$MEMORY_USAGE_MFL_16K"
999}
1000
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001001cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001002 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Piotr Nowicki3de298f2020-04-16 14:35:19 +02001003 rm -f context_srv.txt
1004 rm -f context_cli.txt
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +02001005 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
1006 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
1007 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
1008 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001009 exit 1
1010}
1011
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +01001012#
1013# MAIN
1014#
1015
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +01001016get_options "$@"
1017
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001018# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +01001019P_SRV_BIN="${P_SRV%%[ ]*}"
1020P_CLI_BIN="${P_CLI%%[ ]*}"
1021P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +01001022if [ ! -x "$P_SRV_BIN" ]; then
1023 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001024 exit 1
1025fi
Hanno Becker17c04932017-10-10 14:44:53 +01001026if [ ! -x "$P_CLI_BIN" ]; then
1027 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001028 exit 1
1029fi
Hanno Becker17c04932017-10-10 14:44:53 +01001030if [ ! -x "$P_PXY_BIN" ]; then
1031 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001032 exit 1
1033fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +01001034if [ "$MEMCHECK" -gt 0 ]; then
1035 if which valgrind >/dev/null 2>&1; then :; else
1036 echo "Memcheck not possible. Valgrind not found"
1037 exit 1
1038 fi
1039fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001040if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1041 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001042 exit 1
1043fi
1044
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001045# used by watchdog
1046MAIN_PID="$$"
1047
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001048# We use somewhat arbitrary delays for tests:
1049# - how long do we wait for the server to start (when lsof not available)?
1050# - how long do we allow for the client to finish?
1051# (not to check performance, just to avoid waiting indefinitely)
1052# Things are slower with valgrind, so give extra time here.
1053#
1054# Note: without lsof, there is a trade-off between the running time of this
1055# script and the risk of spurious errors because we didn't wait long enough.
1056# The watchdog delay on the other hand doesn't affect normal running time of
1057# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001058if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001059 START_DELAY=6
1060 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001061else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001062 START_DELAY=2
1063 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001064fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001065
1066# some particular tests need more time:
1067# - for the client, we multiply the usual watchdog limit by a factor
1068# - for the server, we sleep for a number of seconds after the client exits
1069# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001070CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001071SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001072
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001073# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001074# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001075P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1076P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001077P_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 +02001078O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001079O_CLI="$O_CLI -connect localhost:+SRV_PORT"
1080G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001081G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001082
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001083if [ -n "${OPENSSL_LEGACY:-}" ]; then
1084 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1085 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1086fi
1087
Hanno Becker58e9dc32018-08-17 15:53:21 +01001088if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001089 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1090fi
1091
Hanno Becker58e9dc32018-08-17 15:53:21 +01001092if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001093 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001094fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001095
Gilles Peskine62469d92017-05-10 10:13:59 +02001096# Allow SHA-1, because many of our test certificates use it
1097P_SRV="$P_SRV allow_sha1=1"
1098P_CLI="$P_CLI allow_sha1=1"
1099
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001100# Also pick a unique name for intermediate files
1101SRV_OUT="srv_out.$$"
1102CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001103PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001104SESSION="session.$$"
1105
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001106SKIP_NEXT="NO"
1107
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001108trap cleanup INT TERM HUP
1109
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001110# Basic test
1111
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001112# Checks that:
1113# - things work with all ciphersuites active (used with config-full in all.sh)
1114# - the expected (highest security) parameters are selected
1115# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001116run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001117 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001118 "$P_CLI" \
1119 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001120 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001121 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001122 -s "client hello v3, signature_algorithm ext: 6" \
1123 -s "ECDHE curve: secp521r1" \
1124 -S "error" \
1125 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001126
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001127run_test "Default, DTLS" \
1128 "$P_SRV dtls=1" \
1129 "$P_CLI dtls=1" \
1130 0 \
1131 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001132 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001133
Manuel Pégourié-Gonnard342d2ca2020-01-02 11:58:00 +01001134requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1135run_test "Default (compression enabled)" \
1136 "$P_SRV debug_level=3" \
1137 "$P_CLI debug_level=3" \
1138 0 \
1139 -s "Allocating compression buffer" \
1140 -c "Allocating compression buffer" \
1141 -s "Record expansion is unknown (compression)" \
1142 -c "Record expansion is unknown (compression)" \
1143 -S "error" \
1144 -C "error"
1145
Hanno Becker746aaf32019-03-28 15:25:23 +00001146requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1147run_test "CA callback on client" \
1148 "$P_SRV debug_level=3" \
1149 "$P_CLI ca_callback=1 debug_level=3 " \
1150 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001151 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001152 -S "error" \
1153 -C "error"
1154
1155requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1156requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1157requires_config_enabled MBEDTLS_ECDSA_C
1158requires_config_enabled MBEDTLS_SHA256_C
1159run_test "CA callback on server" \
1160 "$P_SRV auth_mode=required" \
1161 "$P_CLI ca_callback=1 debug_level=3 crt_file=data_files/server5.crt \
1162 key_file=data_files/server5.key" \
1163 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001164 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001165 -s "Verifying peer X.509 certificate... ok" \
1166 -S "error" \
1167 -C "error"
1168
Manuel Pégourié-Gonnardcfdf8f42018-11-08 09:52:25 +01001169# Test using an opaque private key for client authentication
1170requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
1171requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1172requires_config_enabled MBEDTLS_ECDSA_C
1173requires_config_enabled MBEDTLS_SHA256_C
1174run_test "Opaque key for client authentication" \
1175 "$P_SRV auth_mode=required" \
1176 "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \
1177 key_file=data_files/server5.key" \
1178 0 \
1179 -c "key type: Opaque" \
1180 -s "Verifying peer X.509 certificate... ok" \
1181 -S "error" \
1182 -C "error"
1183
Hanno Becker9b5853c2018-11-16 17:28:40 +00001184# Test ciphersuites which we expect to be fully supported by PSA Crypto
1185# and check that we don't fall back to Mbed TLS' internal crypto primitives.
1186run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM
1187run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
1188run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM
1189run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8
1190run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
1191run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384
1192run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA
1193run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
1194run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384
1195
Hanno Becker354e2482019-01-08 11:40:25 +00001196requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1197run_test_psa_force_curve "secp521r1"
1198requires_config_enabled MBEDTLS_ECP_DP_BP512R1_ENABLED
1199run_test_psa_force_curve "brainpoolP512r1"
1200requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
1201run_test_psa_force_curve "secp384r1"
1202requires_config_enabled MBEDTLS_ECP_DP_BP384R1_ENABLED
1203run_test_psa_force_curve "brainpoolP384r1"
1204requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED
1205run_test_psa_force_curve "secp256r1"
1206requires_config_enabled MBEDTLS_ECP_DP_SECP256K1_ENABLED
1207run_test_psa_force_curve "secp256k1"
1208requires_config_enabled MBEDTLS_ECP_DP_BP256R1_ENABLED
1209run_test_psa_force_curve "brainpoolP256r1"
1210requires_config_enabled MBEDTLS_ECP_DP_SECP224R1_ENABLED
1211run_test_psa_force_curve "secp224r1"
1212requires_config_enabled MBEDTLS_ECP_DP_SECP224K1_ENABLED
1213run_test_psa_force_curve "secp224k1"
1214requires_config_enabled MBEDTLS_ECP_DP_SECP192R1_ENABLED
1215run_test_psa_force_curve "secp192r1"
1216requires_config_enabled MBEDTLS_ECP_DP_SECP192K1_ENABLED
1217run_test_psa_force_curve "secp192k1"
1218
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001219# Test current time in ServerHello
1220requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001221run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001222 "$P_SRV debug_level=3" \
1223 "$P_CLI debug_level=3" \
1224 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001225 -f "check_server_hello_time" \
1226 -F "check_server_hello_time"
1227
Simon Butcher8e004102016-10-14 00:48:33 +01001228# Test for uniqueness of IVs in AEAD ciphersuites
1229run_test "Unique IV in GCM" \
1230 "$P_SRV exchanges=20 debug_level=4" \
1231 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1232 0 \
1233 -u "IV used" \
1234 -U "IV used"
1235
Janos Follathee11be62019-04-04 12:03:30 +01001236# Tests for certificate verification callback
1237run_test "Configuration-specific CRT verification callback" \
1238 "$P_SRV debug_level=3" \
1239 "$P_CLI context_crt_cb=0 debug_level=3" \
1240 0 \
Janos Follathee11be62019-04-04 12:03:30 +01001241 -S "error" \
1242 -c "Verify requested for " \
1243 -c "Use configuration-specific verification callback" \
1244 -C "Use context-specific verification callback" \
1245 -C "error"
1246
Hanno Beckerefb440a2019-04-03 13:04:33 +01001247run_test "Context-specific CRT verification callback" \
1248 "$P_SRV debug_level=3" \
1249 "$P_CLI context_crt_cb=1 debug_level=3" \
1250 0 \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001251 -S "error" \
Janos Follathee11be62019-04-04 12:03:30 +01001252 -c "Verify requested for " \
1253 -c "Use context-specific verification callback" \
1254 -C "Use configuration-specific verification callback" \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001255 -C "error"
1256
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001257# Tests for rc4 option
1258
Simon Butchera410af52016-05-19 22:12:18 +01001259requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001260run_test "RC4: server disabled, client enabled" \
1261 "$P_SRV" \
1262 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1263 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001264 -s "SSL - The server has no ciphersuites in common"
1265
Simon Butchera410af52016-05-19 22:12:18 +01001266requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001267run_test "RC4: server half, client enabled" \
1268 "$P_SRV arc4=1" \
1269 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1270 1 \
1271 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001272
1273run_test "RC4: server enabled, client disabled" \
1274 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1275 "$P_CLI" \
1276 1 \
1277 -s "SSL - The server has no ciphersuites in common"
1278
1279run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001280 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001281 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1282 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001283 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001284 -S "SSL - The server has no ciphersuites in common"
1285
Hanno Beckerd26bb202018-08-17 09:54:10 +01001286# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1287
1288requires_gnutls
1289requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1290run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1291 "$G_SRV"\
1292 "$P_CLI force_version=tls1_1" \
1293 0
1294
1295requires_gnutls
1296requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1297run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1298 "$G_SRV"\
1299 "$P_CLI force_version=tls1" \
1300 0
1301
Gilles Peskinebc70a182017-05-09 15:59:24 +02001302# Tests for SHA-1 support
1303
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001304requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001305run_test "SHA-1 forbidden by default in server certificate" \
1306 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1307 "$P_CLI debug_level=2 allow_sha1=0" \
1308 1 \
1309 -c "The certificate is signed with an unacceptable hash"
1310
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001311requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02001312run_test "SHA-1 allowed by default in server certificate" \
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001313 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1314 "$P_CLI debug_level=2 allow_sha1=0" \
1315 0
1316
Gilles Peskinebc70a182017-05-09 15:59:24 +02001317run_test "SHA-1 explicitly allowed in server certificate" \
1318 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1319 "$P_CLI allow_sha1=1" \
1320 0
1321
1322run_test "SHA-256 allowed by default in server certificate" \
1323 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1324 "$P_CLI allow_sha1=0" \
1325 0
1326
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001327requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001328run_test "SHA-1 forbidden by default in client certificate" \
1329 "$P_SRV auth_mode=required allow_sha1=0" \
1330 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1331 1 \
1332 -s "The certificate is signed with an unacceptable hash"
1333
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001334requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02001335run_test "SHA-1 allowed by default in client certificate" \
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001336 "$P_SRV auth_mode=required allow_sha1=0" \
1337 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1338 0
1339
Gilles Peskinebc70a182017-05-09 15:59:24 +02001340run_test "SHA-1 explicitly allowed in client certificate" \
1341 "$P_SRV auth_mode=required allow_sha1=1" \
1342 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1343 0
1344
1345run_test "SHA-256 allowed by default in client certificate" \
1346 "$P_SRV auth_mode=required allow_sha1=0" \
1347 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1348 0
1349
Hanno Becker7ae8a762018-08-14 15:43:35 +01001350# Tests for datagram packing
1351run_test "DTLS: multiple records in same datagram, client and server" \
1352 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1353 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1354 0 \
1355 -c "next record in same datagram" \
1356 -s "next record in same datagram"
1357
1358run_test "DTLS: multiple records in same datagram, client only" \
1359 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1360 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1361 0 \
1362 -s "next record in same datagram" \
1363 -C "next record in same datagram"
1364
1365run_test "DTLS: multiple records in same datagram, server only" \
1366 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1367 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1368 0 \
1369 -S "next record in same datagram" \
1370 -c "next record in same datagram"
1371
1372run_test "DTLS: multiple records in same datagram, neither client nor server" \
1373 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1374 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1375 0 \
1376 -S "next record in same datagram" \
1377 -C "next record in same datagram"
1378
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001379# Tests for Truncated HMAC extension
1380
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001381run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001382 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001383 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001384 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001385 -s "dumping 'expected mac' (20 bytes)" \
1386 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001387
Hanno Becker32c55012017-11-10 08:42:54 +00001388requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001389run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001390 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001391 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001392 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001393 -s "dumping 'expected mac' (20 bytes)" \
1394 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001395
Hanno Becker32c55012017-11-10 08:42:54 +00001396requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001397run_test "Truncated HMAC: client enabled, server default" \
1398 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001399 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001400 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001401 -s "dumping 'expected mac' (20 bytes)" \
1402 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001403
Hanno Becker32c55012017-11-10 08:42:54 +00001404requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001405run_test "Truncated HMAC: client enabled, server disabled" \
1406 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001407 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001408 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001409 -s "dumping 'expected mac' (20 bytes)" \
1410 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001411
Hanno Becker32c55012017-11-10 08:42:54 +00001412requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001413run_test "Truncated HMAC: client disabled, server enabled" \
1414 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001415 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001416 0 \
1417 -s "dumping 'expected mac' (20 bytes)" \
1418 -S "dumping 'expected mac' (10 bytes)"
1419
1420requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001421run_test "Truncated HMAC: client enabled, server enabled" \
1422 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001423 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001424 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001425 -S "dumping 'expected mac' (20 bytes)" \
1426 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001427
Hanno Becker4c4f4102017-11-10 09:16:05 +00001428run_test "Truncated HMAC, DTLS: client default, server default" \
1429 "$P_SRV dtls=1 debug_level=4" \
1430 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1431 0 \
1432 -s "dumping 'expected mac' (20 bytes)" \
1433 -S "dumping 'expected mac' (10 bytes)"
1434
1435requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1436run_test "Truncated HMAC, DTLS: client disabled, server default" \
1437 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001438 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001439 0 \
1440 -s "dumping 'expected mac' (20 bytes)" \
1441 -S "dumping 'expected mac' (10 bytes)"
1442
1443requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1444run_test "Truncated HMAC, DTLS: client enabled, server default" \
1445 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001446 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001447 0 \
1448 -s "dumping 'expected mac' (20 bytes)" \
1449 -S "dumping 'expected mac' (10 bytes)"
1450
1451requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1452run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1453 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001454 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001455 0 \
1456 -s "dumping 'expected mac' (20 bytes)" \
1457 -S "dumping 'expected mac' (10 bytes)"
1458
1459requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1460run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1461 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001462 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001463 0 \
1464 -s "dumping 'expected mac' (20 bytes)" \
1465 -S "dumping 'expected mac' (10 bytes)"
1466
1467requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1468run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1469 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001470 "$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 +01001471 0 \
1472 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001473 -s "dumping 'expected mac' (10 bytes)"
1474
Jarno Lamsa2937d812019-06-04 11:33:23 +03001475# Tests for Context serialization
1476
1477requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001478run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001479 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001480 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1481 0 \
1482 -c "Deserializing connection..." \
1483 -S "Deserializing connection..."
1484
1485requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1486run_test "Context serialization, client serializes, ChaChaPoly" \
1487 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1488 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1489 0 \
1490 -c "Deserializing connection..." \
1491 -S "Deserializing connection..."
1492
1493requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1494run_test "Context serialization, client serializes, GCM" \
1495 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1496 "$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 +03001497 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001498 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001499 -S "Deserializing connection..."
1500
1501requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001502requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1503run_test "Context serialization, client serializes, with CID" \
1504 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1505 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1506 0 \
1507 -c "Deserializing connection..." \
1508 -S "Deserializing connection..."
1509
1510requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001511run_test "Context serialization, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001512 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001513 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1514 0 \
1515 -C "Deserializing connection..." \
1516 -s "Deserializing connection..."
1517
1518requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1519run_test "Context serialization, server serializes, ChaChaPoly" \
1520 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1521 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1522 0 \
1523 -C "Deserializing connection..." \
1524 -s "Deserializing connection..."
1525
1526requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1527run_test "Context serialization, server serializes, GCM" \
1528 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1529 "$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 +03001530 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001531 -C "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001532 -s "Deserializing connection..."
1533
1534requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001535requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1536run_test "Context serialization, server serializes, with CID" \
1537 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1538 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1539 0 \
1540 -C "Deserializing connection..." \
1541 -s "Deserializing connection..."
1542
1543requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001544run_test "Context serialization, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001545 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001546 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1547 0 \
1548 -c "Deserializing connection..." \
1549 -s "Deserializing connection..."
1550
1551requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1552run_test "Context serialization, both serialize, ChaChaPoly" \
1553 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1554 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1555 0 \
1556 -c "Deserializing connection..." \
1557 -s "Deserializing connection..."
1558
1559requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1560run_test "Context serialization, both serialize, GCM" \
1561 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1562 "$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 +03001563 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001564 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001565 -s "Deserializing connection..."
1566
Jarno Lamsac2376f02019-06-06 10:44:14 +03001567requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001568requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1569run_test "Context serialization, both serialize, with CID" \
1570 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1571 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1572 0 \
1573 -c "Deserializing connection..." \
1574 -s "Deserializing connection..."
1575
1576requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001577run_test "Context serialization, re-init, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001578 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001579 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1580 0 \
1581 -c "Deserializing connection..." \
1582 -S "Deserializing connection..."
1583
1584requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1585run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1586 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1587 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1588 0 \
1589 -c "Deserializing connection..." \
1590 -S "Deserializing connection..."
1591
1592requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1593run_test "Context serialization, re-init, client serializes, GCM" \
1594 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1595 "$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 +03001596 0 \
1597 -c "Deserializing connection..." \
1598 -S "Deserializing connection..."
1599
Jarno Lamsac2376f02019-06-06 10:44:14 +03001600requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001601requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1602run_test "Context serialization, re-init, client serializes, with CID" \
1603 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1604 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1605 0 \
1606 -c "Deserializing connection..." \
1607 -S "Deserializing connection..."
1608
1609requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001610run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001611 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001612 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1613 0 \
1614 -C "Deserializing connection..." \
1615 -s "Deserializing connection..."
1616
1617requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1618run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1619 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1620 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1621 0 \
1622 -C "Deserializing connection..." \
1623 -s "Deserializing connection..."
1624
1625requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1626run_test "Context serialization, re-init, server serializes, GCM" \
1627 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1628 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001629 0 \
1630 -C "Deserializing connection..." \
1631 -s "Deserializing connection..."
1632
Jarno Lamsac2376f02019-06-06 10:44:14 +03001633requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001634requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1635run_test "Context serialization, re-init, server serializes, with CID" \
1636 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1637 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1638 0 \
1639 -C "Deserializing connection..." \
1640 -s "Deserializing connection..."
1641
1642requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001643run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001644 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001645 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1646 0 \
1647 -c "Deserializing connection..." \
1648 -s "Deserializing connection..."
1649
1650requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1651run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1652 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1653 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1654 0 \
1655 -c "Deserializing connection..." \
1656 -s "Deserializing connection..."
1657
1658requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1659run_test "Context serialization, re-init, both serialize, GCM" \
1660 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1661 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001662 0 \
1663 -c "Deserializing connection..." \
1664 -s "Deserializing connection..."
1665
Hanno Becker1b18fd32019-08-30 11:18:59 +01001666requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1667requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1668run_test "Context serialization, re-init, both serialize, with CID" \
1669 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1670 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1671 0 \
1672 -c "Deserializing connection..." \
1673 -s "Deserializing connection..."
1674
Piotr Nowicki3de298f2020-04-16 14:35:19 +02001675requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1676run_test "Saving the serialized context to a file" \
1677 "$P_SRV dtls=1 serialize=1 context_file=context_srv.txt" \
1678 "$P_CLI dtls=1 serialize=1 context_file=context_cli.txt" \
1679 0 \
1680 -s "Save serialized context to a file... ok" \
1681 -c "Save serialized context to a file... ok"
1682rm -f context_srv.txt
1683rm -f context_cli.txt
1684
Hanno Becker7cf463e2019-04-09 18:08:47 +01001685# Tests for DTLS Connection ID extension
1686
Hanno Becker7cf463e2019-04-09 18:08:47 +01001687# So far, the CID API isn't implemented, so we can't
1688# grep for output witnessing its use. This needs to be
1689# changed once the CID extension is implemented.
1690
Hanno Beckera0e20d02019-05-15 14:03:01 +01001691requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001692run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001693 "$P_SRV debug_level=3 dtls=1 cid=0" \
1694 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1695 0 \
1696 -s "Disable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001697 -s "found CID extension" \
1698 -s "Client sent CID extension, but CID disabled" \
Hanno Becker6b78c832019-04-25 17:01:43 +01001699 -c "Enable use of CID extension." \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001700 -c "client hello, adding CID extension" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001701 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001702 -C "found CID extension" \
1703 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001704 -C "Copy CIDs into SSL transform" \
1705 -c "Use of Connection ID was rejected by the server"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001706
Hanno Beckera0e20d02019-05-15 14:03:01 +01001707requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001708run_test "Connection ID: Cli disabled, Srv enabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001709 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1710 "$P_CLI debug_level=3 dtls=1 cid=0" \
1711 0 \
1712 -c "Disable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001713 -C "client hello, adding CID extension" \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001714 -S "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001715 -s "Enable use of CID extension." \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001716 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001717 -C "found CID extension" \
1718 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001719 -C "Copy CIDs into SSL transform" \
Hanno Beckerb3e9dd52019-05-08 13:19:53 +01001720 -s "Use of Connection ID was not offered by client"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001721
Hanno Beckera0e20d02019-05-15 14:03:01 +01001722requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001723run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001724 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1725 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1726 0 \
1727 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001728 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001729 -c "client hello, adding CID extension" \
1730 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001731 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001732 -s "server hello, adding CID extension" \
1733 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001734 -c "Use of CID extension negotiated" \
1735 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001736 -c "Copy CIDs into SSL transform" \
1737 -c "Peer CID (length 2 Bytes): de ad" \
1738 -s "Peer CID (length 2 Bytes): be ef" \
1739 -s "Use of Connection ID has been negotiated" \
1740 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001741
Hanno Beckera0e20d02019-05-15 14:03:01 +01001742requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001743run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001744 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001745 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1746 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1747 0 \
1748 -c "Enable use of CID extension." \
1749 -s "Enable use of CID extension." \
1750 -c "client hello, adding CID extension" \
1751 -s "found CID extension" \
1752 -s "Use of CID extension negotiated" \
1753 -s "server hello, adding CID extension" \
1754 -c "found CID extension" \
1755 -c "Use of CID extension negotiated" \
1756 -s "Copy CIDs into SSL transform" \
1757 -c "Copy CIDs into SSL transform" \
1758 -c "Peer CID (length 2 Bytes): de ad" \
1759 -s "Peer CID (length 2 Bytes): be ef" \
1760 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001761 -c "Use of Connection ID has been negotiated" \
1762 -c "ignoring unexpected CID" \
1763 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001764
Hanno Beckera0e20d02019-05-15 14:03:01 +01001765requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001766run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1767 -p "$P_PXY mtu=800" \
1768 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1769 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1770 0 \
1771 -c "Enable use of CID extension." \
1772 -s "Enable use of CID extension." \
1773 -c "client hello, adding CID extension" \
1774 -s "found CID extension" \
1775 -s "Use of CID extension negotiated" \
1776 -s "server hello, adding CID extension" \
1777 -c "found CID extension" \
1778 -c "Use of CID extension negotiated" \
1779 -s "Copy CIDs into SSL transform" \
1780 -c "Copy CIDs into SSL transform" \
1781 -c "Peer CID (length 2 Bytes): de ad" \
1782 -s "Peer CID (length 2 Bytes): be ef" \
1783 -s "Use of Connection ID has been negotiated" \
1784 -c "Use of Connection ID has been negotiated"
1785
Hanno Beckera0e20d02019-05-15 14:03:01 +01001786requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001787run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001788 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001789 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1790 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1791 0 \
1792 -c "Enable use of CID extension." \
1793 -s "Enable use of CID extension." \
1794 -c "client hello, adding CID extension" \
1795 -s "found CID extension" \
1796 -s "Use of CID extension negotiated" \
1797 -s "server hello, adding CID extension" \
1798 -c "found CID extension" \
1799 -c "Use of CID extension negotiated" \
1800 -s "Copy CIDs into SSL transform" \
1801 -c "Copy CIDs into SSL transform" \
1802 -c "Peer CID (length 2 Bytes): de ad" \
1803 -s "Peer CID (length 2 Bytes): be ef" \
1804 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001805 -c "Use of Connection ID has been negotiated" \
1806 -c "ignoring unexpected CID" \
1807 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001808
Hanno Beckera0e20d02019-05-15 14:03:01 +01001809requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001810run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001811 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1812 "$P_CLI debug_level=3 dtls=1 cid=1" \
1813 0 \
1814 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001815 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001816 -c "client hello, adding CID extension" \
1817 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001818 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001819 -s "server hello, adding CID extension" \
1820 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001821 -c "Use of CID extension negotiated" \
1822 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001823 -c "Copy CIDs into SSL transform" \
1824 -c "Peer CID (length 4 Bytes): de ad be ef" \
1825 -s "Peer CID (length 0 Bytes):" \
1826 -s "Use of Connection ID has been negotiated" \
1827 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001828
Hanno Beckera0e20d02019-05-15 14:03:01 +01001829requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001830run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001831 "$P_SRV debug_level=3 dtls=1 cid=1" \
1832 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1833 0 \
1834 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001835 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001836 -c "client hello, adding CID extension" \
1837 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001838 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001839 -s "server hello, adding CID extension" \
1840 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001841 -c "Use of CID extension negotiated" \
1842 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001843 -c "Copy CIDs into SSL transform" \
1844 -s "Peer CID (length 4 Bytes): de ad be ef" \
1845 -c "Peer CID (length 0 Bytes):" \
1846 -s "Use of Connection ID has been negotiated" \
1847 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001848
Hanno Beckera0e20d02019-05-15 14:03:01 +01001849requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001850run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001851 "$P_SRV debug_level=3 dtls=1 cid=1" \
1852 "$P_CLI debug_level=3 dtls=1 cid=1" \
1853 0 \
1854 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001855 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001856 -c "client hello, adding CID extension" \
1857 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001858 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001859 -s "server hello, adding CID extension" \
1860 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001861 -c "Use of CID extension negotiated" \
1862 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001863 -c "Copy CIDs into SSL transform" \
1864 -S "Use of Connection ID has been negotiated" \
1865 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001866
Hanno Beckera0e20d02019-05-15 14:03:01 +01001867requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001868run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001869 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1870 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1871 0 \
1872 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001873 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001874 -c "client hello, adding CID extension" \
1875 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001876 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001877 -s "server hello, adding CID extension" \
1878 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001879 -c "Use of CID extension negotiated" \
1880 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001881 -c "Copy CIDs into SSL transform" \
1882 -c "Peer CID (length 2 Bytes): de ad" \
1883 -s "Peer CID (length 2 Bytes): be ef" \
1884 -s "Use of Connection ID has been negotiated" \
1885 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001886
Hanno Beckera0e20d02019-05-15 14:03:01 +01001887requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001888run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001889 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1890 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1891 0 \
1892 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001893 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001894 -c "client hello, adding CID extension" \
1895 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001896 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001897 -s "server hello, adding CID extension" \
1898 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001899 -c "Use of CID extension negotiated" \
1900 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001901 -c "Copy CIDs into SSL transform" \
1902 -c "Peer CID (length 4 Bytes): de ad be ef" \
1903 -s "Peer CID (length 0 Bytes):" \
1904 -s "Use of Connection ID has been negotiated" \
1905 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001906
Hanno Beckera0e20d02019-05-15 14:03:01 +01001907requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001908run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001909 "$P_SRV debug_level=3 dtls=1 cid=1" \
1910 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1911 0 \
1912 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001913 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001914 -c "client hello, adding CID extension" \
1915 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001916 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001917 -s "server hello, adding CID extension" \
1918 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001919 -c "Use of CID extension negotiated" \
1920 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001921 -c "Copy CIDs into SSL transform" \
1922 -s "Peer CID (length 4 Bytes): de ad be ef" \
1923 -c "Peer CID (length 0 Bytes):" \
1924 -s "Use of Connection ID has been negotiated" \
1925 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001926
Hanno Beckera0e20d02019-05-15 14:03:01 +01001927requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001928run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001929 "$P_SRV debug_level=3 dtls=1 cid=1" \
1930 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1931 0 \
1932 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001933 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001934 -c "client hello, adding CID extension" \
1935 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001936 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001937 -s "server hello, adding CID extension" \
1938 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001939 -c "Use of CID extension negotiated" \
1940 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001941 -c "Copy CIDs into SSL transform" \
1942 -S "Use of Connection ID has been negotiated" \
1943 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001944
Hanno Beckera0e20d02019-05-15 14:03:01 +01001945requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001946run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001947 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1948 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1949 0 \
1950 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001951 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001952 -c "client hello, adding CID extension" \
1953 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001954 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001955 -s "server hello, adding CID extension" \
1956 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001957 -c "Use of CID extension negotiated" \
1958 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001959 -c "Copy CIDs into SSL transform" \
1960 -c "Peer CID (length 2 Bytes): de ad" \
1961 -s "Peer CID (length 2 Bytes): be ef" \
1962 -s "Use of Connection ID has been negotiated" \
1963 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001964
Hanno Beckera0e20d02019-05-15 14:03:01 +01001965requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001966run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001967 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1968 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1969 0 \
1970 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001971 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001972 -c "client hello, adding CID extension" \
1973 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001974 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001975 -s "server hello, adding CID extension" \
1976 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001977 -c "Use of CID extension negotiated" \
1978 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001979 -c "Copy CIDs into SSL transform" \
1980 -c "Peer CID (length 4 Bytes): de ad be ef" \
1981 -s "Peer CID (length 0 Bytes):" \
1982 -s "Use of Connection ID has been negotiated" \
1983 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001984
Hanno Beckera0e20d02019-05-15 14:03:01 +01001985requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001986run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001987 "$P_SRV debug_level=3 dtls=1 cid=1" \
1988 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1989 0 \
1990 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001991 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001992 -c "client hello, adding CID extension" \
1993 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001994 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001995 -s "server hello, adding CID extension" \
1996 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001997 -c "Use of CID extension negotiated" \
1998 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001999 -c "Copy CIDs into SSL transform" \
2000 -s "Peer CID (length 4 Bytes): de ad be ef" \
2001 -c "Peer CID (length 0 Bytes):" \
2002 -s "Use of Connection ID has been negotiated" \
2003 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002004
Hanno Beckera0e20d02019-05-15 14:03:01 +01002005requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002006run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002007 "$P_SRV debug_level=3 dtls=1 cid=1" \
2008 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
2009 0 \
2010 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002011 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002012 -c "client hello, adding CID extension" \
2013 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002014 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002015 -s "server hello, adding CID extension" \
2016 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002017 -c "Use of CID extension negotiated" \
2018 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01002019 -c "Copy CIDs into SSL transform" \
2020 -S "Use of Connection ID has been negotiated" \
2021 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002022
Hanno Beckera0e20d02019-05-15 14:03:01 +01002023requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker9bae30d2019-04-23 11:52:44 +01002024requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002025run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002026 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2027 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2028 0 \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002029 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2030 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2031 -s "(initial handshake) Use of Connection ID has been negotiated" \
2032 -c "(initial handshake) Use of Connection ID has been negotiated" \
2033 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2034 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2035 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2036 -c "(after renegotiation) Use of Connection ID has been negotiated"
2037
Hanno Beckera0e20d02019-05-15 14:03:01 +01002038requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002039requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002040run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002041 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2042 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2043 0 \
2044 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2045 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2046 -s "(initial handshake) Use of Connection ID has been negotiated" \
2047 -c "(initial handshake) Use of Connection ID has been negotiated" \
2048 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2049 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2050 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2051 -c "(after renegotiation) Use of Connection ID has been negotiated"
2052
Hanno Beckera0e20d02019-05-15 14:03:01 +01002053requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002054requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002055run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
2056 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
2057 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2058 0 \
2059 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2060 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2061 -s "(initial handshake) Use of Connection ID has been negotiated" \
2062 -c "(initial handshake) Use of Connection ID has been negotiated" \
2063 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2064 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2065 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2066 -c "(after renegotiation) Use of Connection ID has been negotiated"
2067
Hanno Beckera0e20d02019-05-15 14:03:01 +01002068requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002069requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002070run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002071 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002072 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2073 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2074 0 \
2075 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2076 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2077 -s "(initial handshake) Use of Connection ID has been negotiated" \
2078 -c "(initial handshake) Use of Connection ID has been negotiated" \
2079 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2080 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2081 -s "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002082 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2083 -c "ignoring unexpected CID" \
2084 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002085
Hanno Beckera0e20d02019-05-15 14:03:01 +01002086requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002087requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2088run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002089 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2090 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2091 0 \
2092 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2093 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2094 -s "(initial handshake) Use of Connection ID has been negotiated" \
2095 -c "(initial handshake) Use of Connection ID has been negotiated" \
2096 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2097 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2098 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2099 -S "(after renegotiation) Use of Connection ID has been negotiated"
2100
Hanno Beckera0e20d02019-05-15 14:03:01 +01002101requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002102requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002103run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
2104 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2105 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2106 0 \
2107 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2108 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2109 -s "(initial handshake) Use of Connection ID has been negotiated" \
2110 -c "(initial handshake) Use of Connection ID has been negotiated" \
2111 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2112 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2113 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2114 -S "(after renegotiation) Use of Connection ID has been negotiated"
2115
Hanno Beckera0e20d02019-05-15 14:03:01 +01002116requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002117requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002118run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002119 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002120 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2121 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2122 0 \
2123 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2124 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2125 -s "(initial handshake) Use of Connection ID has been negotiated" \
2126 -c "(initial handshake) Use of Connection ID has been negotiated" \
2127 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2128 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2129 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002130 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2131 -c "ignoring unexpected CID" \
2132 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002133
Hanno Beckera0e20d02019-05-15 14:03:01 +01002134requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002135requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2136run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002137 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2138 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2139 0 \
2140 -S "(initial handshake) Use of Connection ID has been negotiated" \
2141 -C "(initial handshake) Use of Connection ID has been negotiated" \
2142 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2143 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2144 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2145 -s "(after renegotiation) Use of Connection ID has been negotiated"
2146
Hanno Beckera0e20d02019-05-15 14:03:01 +01002147requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002148requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002149run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2150 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2151 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2152 0 \
2153 -S "(initial handshake) Use of Connection ID has been negotiated" \
2154 -C "(initial handshake) Use of Connection ID has been negotiated" \
2155 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2156 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2157 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2158 -s "(after renegotiation) Use of Connection ID has been negotiated"
2159
Hanno Beckera0e20d02019-05-15 14:03:01 +01002160requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002161requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002162run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002163 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002164 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2165 "$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" \
2166 0 \
2167 -S "(initial handshake) Use of Connection ID has been negotiated" \
2168 -C "(initial handshake) Use of Connection ID has been negotiated" \
2169 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2170 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2171 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002172 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2173 -c "ignoring unexpected CID" \
2174 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002175
Hanno Beckera0e20d02019-05-15 14:03:01 +01002176requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002177requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2178run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002179 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2180 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2181 0 \
2182 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2183 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2184 -s "(initial handshake) Use of Connection ID has been negotiated" \
2185 -c "(initial handshake) Use of Connection ID has been negotiated" \
2186 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2187 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2188 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2189 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2190 -s "(after renegotiation) Use of Connection ID was not offered by client"
2191
Hanno Beckera0e20d02019-05-15 14:03:01 +01002192requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002193requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002194run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002195 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002196 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2197 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2198 0 \
2199 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2200 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2201 -s "(initial handshake) Use of Connection ID has been negotiated" \
2202 -c "(initial handshake) Use of Connection ID has been negotiated" \
2203 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2204 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2205 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2206 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002207 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2208 -c "ignoring unexpected CID" \
2209 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002210
Hanno Beckera0e20d02019-05-15 14:03:01 +01002211requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002212requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2213run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2214 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2215 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2216 0 \
2217 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2218 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2219 -s "(initial handshake) Use of Connection ID has been negotiated" \
2220 -c "(initial handshake) Use of Connection ID has been negotiated" \
2221 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2222 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2223 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2224 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2225 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2226
Hanno Beckera0e20d02019-05-15 14:03:01 +01002227requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002228requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2229run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002230 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002231 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2232 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2233 0 \
2234 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2235 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2236 -s "(initial handshake) Use of Connection ID has been negotiated" \
2237 -c "(initial handshake) Use of Connection ID has been negotiated" \
2238 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2239 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2240 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2241 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002242 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2243 -c "ignoring unexpected CID" \
2244 -s "ignoring unexpected CID"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002245
Andrzej Kurekb6577832020-06-08 07:08:03 -04002246requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2247requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2248run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=512" \
2249 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
2250 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=512 dtls=1 cid=1 cid_val=beef" \
2251 0 \
2252 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2253 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2254 -s "(initial handshake) Use of Connection ID has been negotiated" \
2255 -c "(initial handshake) Use of Connection ID has been negotiated" \
2256 -s "Reallocating in_buf" \
2257 -s "Reallocating out_buf"
2258
2259requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2260requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2261run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=1024" \
2262 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
2263 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=1024 dtls=1 cid=1 cid_val=beef" \
2264 0 \
2265 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2266 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2267 -s "(initial handshake) Use of Connection ID has been negotiated" \
2268 -c "(initial handshake) Use of Connection ID has been negotiated" \
2269 -s "Reallocating in_buf" \
2270 -s "Reallocating out_buf"
2271
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002272# Tests for Encrypt-then-MAC extension
2273
2274run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002275 "$P_SRV debug_level=3 \
2276 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002277 "$P_CLI debug_level=3" \
2278 0 \
2279 -c "client hello, adding encrypt_then_mac extension" \
2280 -s "found encrypt then mac extension" \
2281 -s "server hello, adding encrypt then mac extension" \
2282 -c "found encrypt_then_mac extension" \
2283 -c "using encrypt then mac" \
2284 -s "using encrypt then mac"
2285
2286run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002287 "$P_SRV debug_level=3 etm=0 \
2288 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002289 "$P_CLI debug_level=3 etm=1" \
2290 0 \
2291 -c "client hello, adding encrypt_then_mac extension" \
2292 -s "found encrypt then mac extension" \
2293 -S "server hello, adding encrypt then mac extension" \
2294 -C "found encrypt_then_mac extension" \
2295 -C "using encrypt then mac" \
2296 -S "using encrypt then mac"
2297
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002298run_test "Encrypt then MAC: client enabled, aead cipher" \
2299 "$P_SRV debug_level=3 etm=1 \
2300 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2301 "$P_CLI debug_level=3 etm=1" \
2302 0 \
2303 -c "client hello, adding encrypt_then_mac extension" \
2304 -s "found encrypt then mac extension" \
2305 -S "server hello, adding encrypt then mac extension" \
2306 -C "found encrypt_then_mac extension" \
2307 -C "using encrypt then mac" \
2308 -S "using encrypt then mac"
2309
2310run_test "Encrypt then MAC: client enabled, stream cipher" \
2311 "$P_SRV debug_level=3 etm=1 \
2312 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002313 "$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 +01002314 0 \
2315 -c "client hello, adding encrypt_then_mac extension" \
2316 -s "found encrypt then mac extension" \
2317 -S "server hello, adding encrypt then mac extension" \
2318 -C "found encrypt_then_mac extension" \
2319 -C "using encrypt then mac" \
2320 -S "using encrypt then mac"
2321
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002322run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002323 "$P_SRV debug_level=3 etm=1 \
2324 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002325 "$P_CLI debug_level=3 etm=0" \
2326 0 \
2327 -C "client hello, adding encrypt_then_mac extension" \
2328 -S "found encrypt then mac extension" \
2329 -S "server hello, adding encrypt then mac extension" \
2330 -C "found encrypt_then_mac extension" \
2331 -C "using encrypt then mac" \
2332 -S "using encrypt then mac"
2333
Janos Follathe2681a42016-03-07 15:57:05 +00002334requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002335run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002336 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002337 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002338 "$P_CLI debug_level=3 force_version=ssl3" \
2339 0 \
2340 -C "client hello, adding encrypt_then_mac extension" \
2341 -S "found encrypt then mac extension" \
2342 -S "server hello, adding encrypt then mac extension" \
2343 -C "found encrypt_then_mac extension" \
2344 -C "using encrypt then mac" \
2345 -S "using encrypt then mac"
2346
Janos Follathe2681a42016-03-07 15:57:05 +00002347requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002348run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002349 "$P_SRV debug_level=3 force_version=ssl3 \
2350 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002351 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002352 0 \
2353 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002354 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002355 -S "server hello, adding encrypt then mac extension" \
2356 -C "found encrypt_then_mac extension" \
2357 -C "using encrypt then mac" \
2358 -S "using encrypt then mac"
2359
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002360# Tests for Extended Master Secret extension
2361
2362run_test "Extended Master Secret: default" \
2363 "$P_SRV debug_level=3" \
2364 "$P_CLI debug_level=3" \
2365 0 \
2366 -c "client hello, adding extended_master_secret extension" \
2367 -s "found extended master secret extension" \
2368 -s "server hello, adding extended master secret extension" \
2369 -c "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002370 -c "session hash for extended master secret" \
2371 -s "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002372
2373run_test "Extended Master Secret: client enabled, server disabled" \
2374 "$P_SRV debug_level=3 extended_ms=0" \
2375 "$P_CLI debug_level=3 extended_ms=1" \
2376 0 \
2377 -c "client hello, adding extended_master_secret extension" \
2378 -s "found extended master secret extension" \
2379 -S "server hello, adding extended master secret extension" \
2380 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002381 -C "session hash for extended master secret" \
2382 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002383
2384run_test "Extended Master Secret: client disabled, server enabled" \
2385 "$P_SRV debug_level=3 extended_ms=1" \
2386 "$P_CLI debug_level=3 extended_ms=0" \
2387 0 \
2388 -C "client hello, adding extended_master_secret extension" \
2389 -S "found extended master secret extension" \
2390 -S "server hello, adding extended master secret extension" \
2391 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002392 -C "session hash for extended master secret" \
2393 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002394
Janos Follathe2681a42016-03-07 15:57:05 +00002395requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002396run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002397 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002398 "$P_CLI debug_level=3 force_version=ssl3" \
2399 0 \
2400 -C "client hello, adding extended_master_secret extension" \
2401 -S "found extended master secret extension" \
2402 -S "server hello, adding extended master secret extension" \
2403 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002404 -C "session hash for extended master secret" \
2405 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002406
Janos Follathe2681a42016-03-07 15:57:05 +00002407requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002408run_test "Extended Master Secret: client enabled, server SSLv3" \
2409 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002410 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002411 0 \
2412 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002413 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002414 -S "server hello, adding extended master secret extension" \
2415 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002416 -C "session hash for extended master secret" \
2417 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002418
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002419# Tests for FALLBACK_SCSV
2420
2421run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002422 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002423 "$P_CLI debug_level=3 force_version=tls1_1" \
2424 0 \
2425 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002426 -S "received FALLBACK_SCSV" \
2427 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002428 -C "is a fatal alert message (msg 86)"
2429
2430run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002431 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002432 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2433 0 \
2434 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002435 -S "received FALLBACK_SCSV" \
2436 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002437 -C "is a fatal alert message (msg 86)"
2438
2439run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002440 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002441 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002442 1 \
2443 -c "adding FALLBACK_SCSV" \
2444 -s "received FALLBACK_SCSV" \
2445 -s "inapropriate fallback" \
2446 -c "is a fatal alert message (msg 86)"
2447
2448run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002449 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002450 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002451 0 \
2452 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002453 -s "received FALLBACK_SCSV" \
2454 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002455 -C "is a fatal alert message (msg 86)"
2456
2457requires_openssl_with_fallback_scsv
2458run_test "Fallback SCSV: default, openssl server" \
2459 "$O_SRV" \
2460 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2461 0 \
2462 -C "adding FALLBACK_SCSV" \
2463 -C "is a fatal alert message (msg 86)"
2464
2465requires_openssl_with_fallback_scsv
2466run_test "Fallback SCSV: enabled, openssl server" \
2467 "$O_SRV" \
2468 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
2469 1 \
2470 -c "adding FALLBACK_SCSV" \
2471 -c "is a fatal alert message (msg 86)"
2472
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002473requires_openssl_with_fallback_scsv
2474run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002475 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002476 "$O_CLI -tls1_1" \
2477 0 \
2478 -S "received FALLBACK_SCSV" \
2479 -S "inapropriate fallback"
2480
2481requires_openssl_with_fallback_scsv
2482run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002483 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002484 "$O_CLI -tls1_1 -fallback_scsv" \
2485 1 \
2486 -s "received FALLBACK_SCSV" \
2487 -s "inapropriate fallback"
2488
2489requires_openssl_with_fallback_scsv
2490run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002491 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002492 "$O_CLI -fallback_scsv" \
2493 0 \
2494 -s "received FALLBACK_SCSV" \
2495 -S "inapropriate fallback"
2496
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002497# Test sending and receiving empty application data records
2498
2499run_test "Encrypt then MAC: empty application data record" \
2500 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2501 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2502 0 \
2503 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2504 -s "dumping 'input payload after decrypt' (0 bytes)" \
2505 -c "0 bytes written in 1 fragments"
2506
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002507run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002508 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2509 "$P_CLI auth_mode=none etm=0 request_size=0" \
2510 0 \
2511 -s "dumping 'input payload after decrypt' (0 bytes)" \
2512 -c "0 bytes written in 1 fragments"
2513
2514run_test "Encrypt then MAC, DTLS: empty application data record" \
2515 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2516 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2517 0 \
2518 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2519 -s "dumping 'input payload after decrypt' (0 bytes)" \
2520 -c "0 bytes written in 1 fragments"
2521
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002522run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002523 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2524 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2525 0 \
2526 -s "dumping 'input payload after decrypt' (0 bytes)" \
2527 -c "0 bytes written in 1 fragments"
2528
Gilles Peskined50177f2017-05-16 17:53:03 +02002529## ClientHello generated with
2530## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2531## then manually twiddling the ciphersuite list.
2532## The ClientHello content is spelled out below as a hex string as
2533## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2534## The expected response is an inappropriate_fallback alert.
2535requires_openssl_with_fallback_scsv
2536run_test "Fallback SCSV: beginning of list" \
2537 "$P_SRV debug_level=2" \
2538 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2539 0 \
2540 -s "received FALLBACK_SCSV" \
2541 -s "inapropriate fallback"
2542
2543requires_openssl_with_fallback_scsv
2544run_test "Fallback SCSV: end of list" \
2545 "$P_SRV debug_level=2" \
2546 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2547 0 \
2548 -s "received FALLBACK_SCSV" \
2549 -s "inapropriate fallback"
2550
2551## Here the expected response is a valid ServerHello prefix, up to the random.
2552requires_openssl_with_fallback_scsv
2553run_test "Fallback SCSV: not in list" \
2554 "$P_SRV debug_level=2" \
2555 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2556 0 \
2557 -S "received FALLBACK_SCSV" \
2558 -S "inapropriate fallback"
2559
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002560# Tests for CBC 1/n-1 record splitting
2561
2562run_test "CBC Record splitting: TLS 1.2, no splitting" \
2563 "$P_SRV" \
2564 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2565 request_size=123 force_version=tls1_2" \
2566 0 \
2567 -s "Read from client: 123 bytes read" \
2568 -S "Read from client: 1 bytes read" \
2569 -S "122 bytes read"
2570
2571run_test "CBC Record splitting: TLS 1.1, no splitting" \
2572 "$P_SRV" \
2573 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2574 request_size=123 force_version=tls1_1" \
2575 0 \
2576 -s "Read from client: 123 bytes read" \
2577 -S "Read from client: 1 bytes read" \
2578 -S "122 bytes read"
2579
2580run_test "CBC Record splitting: TLS 1.0, splitting" \
2581 "$P_SRV" \
2582 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2583 request_size=123 force_version=tls1" \
2584 0 \
2585 -S "Read from client: 123 bytes read" \
2586 -s "Read from client: 1 bytes read" \
2587 -s "122 bytes read"
2588
Janos Follathe2681a42016-03-07 15:57:05 +00002589requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002590run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002591 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002592 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2593 request_size=123 force_version=ssl3" \
2594 0 \
2595 -S "Read from client: 123 bytes read" \
2596 -s "Read from client: 1 bytes read" \
2597 -s "122 bytes read"
2598
2599run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002600 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002601 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2602 request_size=123 force_version=tls1" \
2603 0 \
2604 -s "Read from client: 123 bytes read" \
2605 -S "Read from client: 1 bytes read" \
2606 -S "122 bytes read"
2607
2608run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2609 "$P_SRV" \
2610 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2611 request_size=123 force_version=tls1 recsplit=0" \
2612 0 \
2613 -s "Read from client: 123 bytes read" \
2614 -S "Read from client: 1 bytes read" \
2615 -S "122 bytes read"
2616
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002617run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2618 "$P_SRV nbio=2" \
2619 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2620 request_size=123 force_version=tls1" \
2621 0 \
2622 -S "Read from client: 123 bytes read" \
2623 -s "Read from client: 1 bytes read" \
2624 -s "122 bytes read"
2625
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002626# Tests for Session Tickets
2627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002628run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002629 "$P_SRV debug_level=3 tickets=1" \
2630 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002631 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002632 -c "client hello, adding session ticket extension" \
2633 -s "found session ticket extension" \
2634 -s "server hello, adding session ticket extension" \
2635 -c "found session_ticket extension" \
2636 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002637 -S "session successfully restored from cache" \
2638 -s "session successfully restored from ticket" \
2639 -s "a session has been resumed" \
2640 -c "a session has been resumed"
2641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002642run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002643 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2644 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002645 0 \
2646 -c "client hello, adding session ticket extension" \
2647 -s "found session ticket extension" \
2648 -s "server hello, adding session ticket extension" \
2649 -c "found session_ticket extension" \
2650 -c "parse new session ticket" \
2651 -S "session successfully restored from cache" \
2652 -s "session successfully restored from ticket" \
2653 -s "a session has been resumed" \
2654 -c "a session has been resumed"
2655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002656run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002657 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2658 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002659 0 \
2660 -c "client hello, adding session ticket extension" \
2661 -s "found session ticket extension" \
2662 -s "server hello, adding session ticket extension" \
2663 -c "found session_ticket extension" \
2664 -c "parse new session ticket" \
2665 -S "session successfully restored from cache" \
2666 -S "session successfully restored from ticket" \
2667 -S "a session has been resumed" \
2668 -C "a session has been resumed"
2669
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002670run_test "Session resume using tickets: session copy" \
2671 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2672 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2673 0 \
2674 -c "client hello, adding session ticket extension" \
2675 -s "found session ticket extension" \
2676 -s "server hello, adding session ticket extension" \
2677 -c "found session_ticket extension" \
2678 -c "parse new session ticket" \
2679 -S "session successfully restored from cache" \
2680 -s "session successfully restored from ticket" \
2681 -s "a session has been resumed" \
2682 -c "a session has been resumed"
2683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002684run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002685 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002686 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002687 0 \
2688 -c "client hello, adding session ticket extension" \
2689 -c "found session_ticket extension" \
2690 -c "parse new session ticket" \
2691 -c "a session has been resumed"
2692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002693run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002694 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002695 "( $O_CLI -sess_out $SESSION; \
2696 $O_CLI -sess_in $SESSION; \
2697 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002698 0 \
2699 -s "found session ticket extension" \
2700 -s "server hello, adding session ticket extension" \
2701 -S "session successfully restored from cache" \
2702 -s "session successfully restored from ticket" \
2703 -s "a session has been resumed"
2704
Hanno Becker1d739932018-08-21 13:55:22 +01002705# Tests for Session Tickets with DTLS
2706
2707run_test "Session resume using tickets, DTLS: basic" \
2708 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002709 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002710 0 \
2711 -c "client hello, adding session ticket extension" \
2712 -s "found session ticket extension" \
2713 -s "server hello, adding session ticket extension" \
2714 -c "found session_ticket extension" \
2715 -c "parse new session ticket" \
2716 -S "session successfully restored from cache" \
2717 -s "session successfully restored from ticket" \
2718 -s "a session has been resumed" \
2719 -c "a session has been resumed"
2720
2721run_test "Session resume using tickets, DTLS: cache disabled" \
2722 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002723 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002724 0 \
2725 -c "client hello, adding session ticket extension" \
2726 -s "found session ticket extension" \
2727 -s "server hello, adding session ticket extension" \
2728 -c "found session_ticket extension" \
2729 -c "parse new session ticket" \
2730 -S "session successfully restored from cache" \
2731 -s "session successfully restored from ticket" \
2732 -s "a session has been resumed" \
2733 -c "a session has been resumed"
2734
2735run_test "Session resume using tickets, DTLS: timeout" \
2736 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002737 "$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 +01002738 0 \
2739 -c "client hello, adding session ticket extension" \
2740 -s "found session ticket extension" \
2741 -s "server hello, adding session ticket extension" \
2742 -c "found session_ticket extension" \
2743 -c "parse new session ticket" \
2744 -S "session successfully restored from cache" \
2745 -S "session successfully restored from ticket" \
2746 -S "a session has been resumed" \
2747 -C "a session has been resumed"
2748
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002749run_test "Session resume using tickets, DTLS: session copy" \
2750 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002751 "$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 +02002752 0 \
2753 -c "client hello, adding session ticket extension" \
2754 -s "found session ticket extension" \
2755 -s "server hello, adding session ticket extension" \
2756 -c "found session_ticket extension" \
2757 -c "parse new session ticket" \
2758 -S "session successfully restored from cache" \
2759 -s "session successfully restored from ticket" \
2760 -s "a session has been resumed" \
2761 -c "a session has been resumed"
2762
Hanno Becker1d739932018-08-21 13:55:22 +01002763run_test "Session resume using tickets, DTLS: openssl server" \
2764 "$O_SRV -dtls1" \
2765 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2766 0 \
2767 -c "client hello, adding session ticket extension" \
2768 -c "found session_ticket extension" \
2769 -c "parse new session ticket" \
2770 -c "a session has been resumed"
2771
2772run_test "Session resume using tickets, DTLS: openssl client" \
2773 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2774 "( $O_CLI -dtls1 -sess_out $SESSION; \
2775 $O_CLI -dtls1 -sess_in $SESSION; \
2776 rm -f $SESSION )" \
2777 0 \
2778 -s "found session ticket extension" \
2779 -s "server hello, adding session ticket extension" \
2780 -S "session successfully restored from cache" \
2781 -s "session successfully restored from ticket" \
2782 -s "a session has been resumed"
2783
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002784# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002786run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002787 "$P_SRV debug_level=3 tickets=0" \
2788 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002789 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002790 -c "client hello, adding session ticket extension" \
2791 -s "found session ticket extension" \
2792 -S "server hello, adding session ticket extension" \
2793 -C "found session_ticket extension" \
2794 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002795 -s "session successfully restored from cache" \
2796 -S "session successfully restored from ticket" \
2797 -s "a session has been resumed" \
2798 -c "a session has been resumed"
2799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002800run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002801 "$P_SRV debug_level=3 tickets=1" \
2802 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002803 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002804 -C "client hello, adding session ticket extension" \
2805 -S "found session ticket extension" \
2806 -S "server hello, adding session ticket extension" \
2807 -C "found session_ticket extension" \
2808 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002809 -s "session successfully restored from cache" \
2810 -S "session successfully restored from ticket" \
2811 -s "a session has been resumed" \
2812 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002814run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002815 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2816 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002817 0 \
2818 -S "session successfully restored from cache" \
2819 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002820 -S "a session has been resumed" \
2821 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002823run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002824 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2825 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002826 0 \
2827 -s "session successfully restored from cache" \
2828 -S "session successfully restored from ticket" \
2829 -s "a session has been resumed" \
2830 -c "a session has been resumed"
2831
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002832run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002833 "$P_SRV debug_level=3 tickets=0" \
2834 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002835 0 \
2836 -s "session successfully restored from cache" \
2837 -S "session successfully restored from ticket" \
2838 -s "a session has been resumed" \
2839 -c "a session has been resumed"
2840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002841run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002842 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2843 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002844 0 \
2845 -S "session successfully restored from cache" \
2846 -S "session successfully restored from ticket" \
2847 -S "a session has been resumed" \
2848 -C "a session has been resumed"
2849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002850run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002851 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2852 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002853 0 \
2854 -s "session successfully restored from cache" \
2855 -S "session successfully restored from ticket" \
2856 -s "a session has been resumed" \
2857 -c "a session has been resumed"
2858
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002859run_test "Session resume using cache: session copy" \
2860 "$P_SRV debug_level=3 tickets=0" \
2861 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2862 0 \
2863 -s "session successfully restored from cache" \
2864 -S "session successfully restored from ticket" \
2865 -s "a session has been resumed" \
2866 -c "a session has been resumed"
2867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002868run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002869 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002870 "( $O_CLI -sess_out $SESSION; \
2871 $O_CLI -sess_in $SESSION; \
2872 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002873 0 \
2874 -s "found session ticket extension" \
2875 -S "server hello, adding session ticket extension" \
2876 -s "session successfully restored from cache" \
2877 -S "session successfully restored from ticket" \
2878 -s "a session has been resumed"
2879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002880run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002881 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002882 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002883 0 \
2884 -C "found session_ticket extension" \
2885 -C "parse new session ticket" \
2886 -c "a session has been resumed"
2887
Hanno Becker1d739932018-08-21 13:55:22 +01002888# Tests for Session Resume based on session-ID and cache, DTLS
2889
2890run_test "Session resume using cache, DTLS: tickets enabled on client" \
2891 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002892 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002893 0 \
2894 -c "client hello, adding session ticket extension" \
2895 -s "found session ticket extension" \
2896 -S "server hello, adding session ticket extension" \
2897 -C "found session_ticket extension" \
2898 -C "parse new session ticket" \
2899 -s "session successfully restored from cache" \
2900 -S "session successfully restored from ticket" \
2901 -s "a session has been resumed" \
2902 -c "a session has been resumed"
2903
2904run_test "Session resume using cache, DTLS: tickets enabled on server" \
2905 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002906 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002907 0 \
2908 -C "client hello, adding session ticket extension" \
2909 -S "found session ticket extension" \
2910 -S "server hello, adding session ticket extension" \
2911 -C "found session_ticket extension" \
2912 -C "parse new session ticket" \
2913 -s "session successfully restored from cache" \
2914 -S "session successfully restored from ticket" \
2915 -s "a session has been resumed" \
2916 -c "a session has been resumed"
2917
2918run_test "Session resume using cache, DTLS: cache_max=0" \
2919 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002920 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002921 0 \
2922 -S "session successfully restored from cache" \
2923 -S "session successfully restored from ticket" \
2924 -S "a session has been resumed" \
2925 -C "a session has been resumed"
2926
2927run_test "Session resume using cache, DTLS: cache_max=1" \
2928 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002929 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002930 0 \
2931 -s "session successfully restored from cache" \
2932 -S "session successfully restored from ticket" \
2933 -s "a session has been resumed" \
2934 -c "a session has been resumed"
2935
2936run_test "Session resume using cache, DTLS: timeout > delay" \
2937 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002938 "$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 +01002939 0 \
2940 -s "session successfully restored from cache" \
2941 -S "session successfully restored from ticket" \
2942 -s "a session has been resumed" \
2943 -c "a session has been resumed"
2944
2945run_test "Session resume using cache, DTLS: timeout < delay" \
2946 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002947 "$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 +01002948 0 \
2949 -S "session successfully restored from cache" \
2950 -S "session successfully restored from ticket" \
2951 -S "a session has been resumed" \
2952 -C "a session has been resumed"
2953
2954run_test "Session resume using cache, DTLS: no timeout" \
2955 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002956 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Becker1d739932018-08-21 13:55:22 +01002957 0 \
2958 -s "session successfully restored from cache" \
2959 -S "session successfully restored from ticket" \
2960 -s "a session has been resumed" \
2961 -c "a session has been resumed"
2962
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002963run_test "Session resume using cache, DTLS: session copy" \
2964 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002965 "$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 +02002966 0 \
2967 -s "session successfully restored from cache" \
2968 -S "session successfully restored from ticket" \
2969 -s "a session has been resumed" \
2970 -c "a session has been resumed"
2971
Hanno Becker1d739932018-08-21 13:55:22 +01002972run_test "Session resume using cache, DTLS: openssl client" \
2973 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2974 "( $O_CLI -dtls1 -sess_out $SESSION; \
2975 $O_CLI -dtls1 -sess_in $SESSION; \
2976 rm -f $SESSION )" \
2977 0 \
2978 -s "found session ticket extension" \
2979 -S "server hello, adding session ticket extension" \
2980 -s "session successfully restored from cache" \
2981 -S "session successfully restored from ticket" \
2982 -s "a session has been resumed"
2983
2984run_test "Session resume using cache, DTLS: openssl server" \
2985 "$O_SRV -dtls1" \
2986 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2987 0 \
2988 -C "found session_ticket extension" \
2989 -C "parse new session ticket" \
2990 -c "a session has been resumed"
2991
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002992# Tests for Max Fragment Length extension
2993
Angus Grattonc4dd0732018-04-11 16:28:39 +10002994if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
2995 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 +01002996 exit 1
2997fi
2998
Angus Grattonc4dd0732018-04-11 16:28:39 +10002999if [ $MAX_CONTENT_LEN -ne 16384 ]; then
3000 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
3001fi
3002
Hanno Becker4aed27e2017-09-18 15:00:34 +01003003requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003004run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003005 "$P_SRV debug_level=3" \
3006 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003007 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003008 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3009 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3010 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3011 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003012 -C "client hello, adding max_fragment_length extension" \
3013 -S "found max fragment length extension" \
3014 -S "server hello, max_fragment_length extension" \
3015 -C "found max_fragment_length extension"
3016
Hanno Becker4aed27e2017-09-18 15:00:34 +01003017requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003018run_test "Max fragment length: enabled, default, larger message" \
3019 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003020 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003021 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003022 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3023 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3024 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3025 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003026 -C "client hello, adding max_fragment_length extension" \
3027 -S "found max fragment length extension" \
3028 -S "server hello, max_fragment_length extension" \
3029 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003030 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3031 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003032 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003033
3034requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3035run_test "Max fragment length, DTLS: enabled, default, larger message" \
3036 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003037 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003038 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003039 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3040 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3041 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3042 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003043 -C "client hello, adding max_fragment_length extension" \
3044 -S "found max fragment length extension" \
3045 -S "server hello, max_fragment_length extension" \
3046 -C "found max_fragment_length extension" \
3047 -c "fragment larger than.*maximum "
3048
Angus Grattonc4dd0732018-04-11 16:28:39 +10003049# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3050# (session fragment length will be 16384 regardless of mbedtls
3051# content length configuration.)
3052
Hanno Beckerc5266962017-09-18 15:01:50 +01003053requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3054run_test "Max fragment length: disabled, larger message" \
3055 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003056 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003057 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003058 -C "Maximum input fragment length is 16384" \
3059 -C "Maximum output fragment length is 16384" \
3060 -S "Maximum input fragment length is 16384" \
3061 -S "Maximum output fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003062 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3063 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003064 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003065
3066requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3067run_test "Max fragment length DTLS: disabled, larger message" \
3068 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003069 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003070 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003071 -C "Maximum input fragment length is 16384" \
3072 -C "Maximum output fragment length is 16384" \
3073 -S "Maximum input fragment length is 16384" \
3074 -S "Maximum output fragment length is 16384" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003075 -c "fragment larger than.*maximum "
3076
3077requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003078run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003079 "$P_SRV debug_level=3" \
3080 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003081 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003082 -c "Maximum input fragment length is 4096" \
3083 -c "Maximum output fragment length is 4096" \
3084 -s "Maximum input fragment length is 4096" \
3085 -s "Maximum output fragment length is 4096" \
3086 -c "client hello, adding max_fragment_length extension" \
3087 -s "found max fragment length extension" \
3088 -s "server hello, max_fragment_length extension" \
3089 -c "found max_fragment_length extension"
3090
3091requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3092run_test "Max fragment length: client 512, server 1024" \
3093 "$P_SRV debug_level=3 max_frag_len=1024" \
3094 "$P_CLI debug_level=3 max_frag_len=512" \
3095 0 \
3096 -c "Maximum input fragment length is 512" \
3097 -c "Maximum output fragment length is 512" \
3098 -s "Maximum input fragment length is 512" \
3099 -s "Maximum output fragment length is 512" \
3100 -c "client hello, adding max_fragment_length extension" \
3101 -s "found max fragment length extension" \
3102 -s "server hello, max_fragment_length extension" \
3103 -c "found max_fragment_length extension"
3104
3105requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3106run_test "Max fragment length: client 512, server 2048" \
3107 "$P_SRV debug_level=3 max_frag_len=2048" \
3108 "$P_CLI debug_level=3 max_frag_len=512" \
3109 0 \
3110 -c "Maximum input fragment length is 512" \
3111 -c "Maximum output fragment length is 512" \
3112 -s "Maximum input fragment length is 512" \
3113 -s "Maximum output fragment length is 512" \
3114 -c "client hello, adding max_fragment_length extension" \
3115 -s "found max fragment length extension" \
3116 -s "server hello, max_fragment_length extension" \
3117 -c "found max_fragment_length extension"
3118
3119requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3120run_test "Max fragment length: client 512, server 4096" \
3121 "$P_SRV debug_level=3 max_frag_len=4096" \
3122 "$P_CLI debug_level=3 max_frag_len=512" \
3123 0 \
3124 -c "Maximum input fragment length is 512" \
3125 -c "Maximum output fragment length is 512" \
3126 -s "Maximum input fragment length is 512" \
3127 -s "Maximum output fragment length is 512" \
3128 -c "client hello, adding max_fragment_length extension" \
3129 -s "found max fragment length extension" \
3130 -s "server hello, max_fragment_length extension" \
3131 -c "found max_fragment_length extension"
3132
3133requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3134run_test "Max fragment length: client 1024, server 512" \
3135 "$P_SRV debug_level=3 max_frag_len=512" \
3136 "$P_CLI debug_level=3 max_frag_len=1024" \
3137 0 \
3138 -c "Maximum input fragment length is 1024" \
3139 -c "Maximum output fragment length is 1024" \
3140 -s "Maximum input fragment length is 1024" \
3141 -s "Maximum output fragment length is 512" \
3142 -c "client hello, adding max_fragment_length extension" \
3143 -s "found max fragment length extension" \
3144 -s "server hello, max_fragment_length extension" \
3145 -c "found max_fragment_length extension"
3146
3147requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3148run_test "Max fragment length: client 1024, server 2048" \
3149 "$P_SRV debug_level=3 max_frag_len=2048" \
3150 "$P_CLI debug_level=3 max_frag_len=1024" \
3151 0 \
3152 -c "Maximum input fragment length is 1024" \
3153 -c "Maximum output fragment length is 1024" \
3154 -s "Maximum input fragment length is 1024" \
3155 -s "Maximum output fragment length is 1024" \
3156 -c "client hello, adding max_fragment_length extension" \
3157 -s "found max fragment length extension" \
3158 -s "server hello, max_fragment_length extension" \
3159 -c "found max_fragment_length extension"
3160
3161requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3162run_test "Max fragment length: client 1024, server 4096" \
3163 "$P_SRV debug_level=3 max_frag_len=4096" \
3164 "$P_CLI debug_level=3 max_frag_len=1024" \
3165 0 \
3166 -c "Maximum input fragment length is 1024" \
3167 -c "Maximum output fragment length is 1024" \
3168 -s "Maximum input fragment length is 1024" \
3169 -s "Maximum output fragment length is 1024" \
3170 -c "client hello, adding max_fragment_length extension" \
3171 -s "found max fragment length extension" \
3172 -s "server hello, max_fragment_length extension" \
3173 -c "found max_fragment_length extension"
3174
3175requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3176run_test "Max fragment length: client 2048, server 512" \
3177 "$P_SRV debug_level=3 max_frag_len=512" \
3178 "$P_CLI debug_level=3 max_frag_len=2048" \
3179 0 \
3180 -c "Maximum input fragment length is 2048" \
3181 -c "Maximum output fragment length is 2048" \
3182 -s "Maximum input fragment length is 2048" \
3183 -s "Maximum output fragment length is 512" \
3184 -c "client hello, adding max_fragment_length extension" \
3185 -s "found max fragment length extension" \
3186 -s "server hello, max_fragment_length extension" \
3187 -c "found max_fragment_length extension"
3188
3189requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3190run_test "Max fragment length: client 2048, server 1024" \
3191 "$P_SRV debug_level=3 max_frag_len=1024" \
3192 "$P_CLI debug_level=3 max_frag_len=2048" \
3193 0 \
3194 -c "Maximum input fragment length is 2048" \
3195 -c "Maximum output fragment length is 2048" \
3196 -s "Maximum input fragment length is 2048" \
3197 -s "Maximum output fragment length is 1024" \
3198 -c "client hello, adding max_fragment_length extension" \
3199 -s "found max fragment length extension" \
3200 -s "server hello, max_fragment_length extension" \
3201 -c "found max_fragment_length extension"
3202
3203requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3204run_test "Max fragment length: client 2048, server 4096" \
3205 "$P_SRV debug_level=3 max_frag_len=4096" \
3206 "$P_CLI debug_level=3 max_frag_len=2048" \
3207 0 \
3208 -c "Maximum input fragment length is 2048" \
3209 -c "Maximum output fragment length is 2048" \
3210 -s "Maximum input fragment length is 2048" \
3211 -s "Maximum output fragment length is 2048" \
3212 -c "client hello, adding max_fragment_length extension" \
3213 -s "found max fragment length extension" \
3214 -s "server hello, max_fragment_length extension" \
3215 -c "found max_fragment_length extension"
3216
3217requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3218run_test "Max fragment length: client 4096, server 512" \
3219 "$P_SRV debug_level=3 max_frag_len=512" \
3220 "$P_CLI debug_level=3 max_frag_len=4096" \
3221 0 \
3222 -c "Maximum input fragment length is 4096" \
3223 -c "Maximum output fragment length is 4096" \
3224 -s "Maximum input fragment length is 4096" \
3225 -s "Maximum output fragment length is 512" \
3226 -c "client hello, adding max_fragment_length extension" \
3227 -s "found max fragment length extension" \
3228 -s "server hello, max_fragment_length extension" \
3229 -c "found max_fragment_length extension"
3230
3231requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3232run_test "Max fragment length: client 4096, server 1024" \
3233 "$P_SRV debug_level=3 max_frag_len=1024" \
3234 "$P_CLI debug_level=3 max_frag_len=4096" \
3235 0 \
3236 -c "Maximum input fragment length is 4096" \
3237 -c "Maximum output fragment length is 4096" \
3238 -s "Maximum input fragment length is 4096" \
3239 -s "Maximum output fragment length is 1024" \
3240 -c "client hello, adding max_fragment_length extension" \
3241 -s "found max fragment length extension" \
3242 -s "server hello, max_fragment_length extension" \
3243 -c "found max_fragment_length extension"
3244
3245requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3246run_test "Max fragment length: client 4096, server 2048" \
3247 "$P_SRV debug_level=3 max_frag_len=2048" \
3248 "$P_CLI debug_level=3 max_frag_len=4096" \
3249 0 \
3250 -c "Maximum input fragment length is 4096" \
3251 -c "Maximum output fragment length is 4096" \
3252 -s "Maximum input fragment length is 4096" \
3253 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003254 -c "client hello, adding max_fragment_length extension" \
3255 -s "found max fragment length extension" \
3256 -s "server hello, max_fragment_length extension" \
3257 -c "found max_fragment_length extension"
3258
Hanno Becker4aed27e2017-09-18 15:00:34 +01003259requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003260run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003261 "$P_SRV debug_level=3 max_frag_len=4096" \
3262 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003263 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003264 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3265 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3266 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3267 -s "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003268 -C "client hello, adding max_fragment_length extension" \
3269 -S "found max fragment length extension" \
3270 -S "server hello, max_fragment_length extension" \
3271 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003272
Hanno Becker4aed27e2017-09-18 15:00:34 +01003273requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003274requires_gnutls
3275run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003276 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003277 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003278 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003279 -c "Maximum input fragment length is 4096" \
3280 -c "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003281 -c "client hello, adding max_fragment_length extension" \
3282 -c "found max_fragment_length extension"
3283
Hanno Becker4aed27e2017-09-18 15:00:34 +01003284requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003285run_test "Max fragment length: client, message just fits" \
3286 "$P_SRV debug_level=3" \
3287 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3288 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003289 -c "Maximum input fragment length is 2048" \
3290 -c "Maximum output fragment length is 2048" \
3291 -s "Maximum input fragment length is 2048" \
3292 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003293 -c "client hello, adding max_fragment_length extension" \
3294 -s "found max fragment length extension" \
3295 -s "server hello, max_fragment_length extension" \
3296 -c "found max_fragment_length extension" \
3297 -c "2048 bytes written in 1 fragments" \
3298 -s "2048 bytes read"
3299
Hanno Becker4aed27e2017-09-18 15:00:34 +01003300requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003301run_test "Max fragment length: client, larger message" \
3302 "$P_SRV debug_level=3" \
3303 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3304 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003305 -c "Maximum input fragment length is 2048" \
3306 -c "Maximum output fragment length is 2048" \
3307 -s "Maximum input fragment length is 2048" \
3308 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003309 -c "client hello, adding max_fragment_length extension" \
3310 -s "found max fragment length extension" \
3311 -s "server hello, max_fragment_length extension" \
3312 -c "found max_fragment_length extension" \
3313 -c "2345 bytes written in 2 fragments" \
3314 -s "2048 bytes read" \
3315 -s "297 bytes read"
3316
Hanno Becker4aed27e2017-09-18 15:00:34 +01003317requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003318run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003319 "$P_SRV debug_level=3 dtls=1" \
3320 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3321 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003322 -c "Maximum input fragment length is 2048" \
3323 -c "Maximum output fragment length is 2048" \
3324 -s "Maximum input fragment length is 2048" \
3325 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003326 -c "client hello, adding max_fragment_length extension" \
3327 -s "found max fragment length extension" \
3328 -s "server hello, max_fragment_length extension" \
3329 -c "found max_fragment_length extension" \
3330 -c "fragment larger than.*maximum"
3331
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003332# Tests for renegotiation
3333
Hanno Becker6a243642017-10-12 15:18:45 +01003334# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003335run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003336 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003337 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003338 0 \
3339 -C "client hello, adding renegotiation extension" \
3340 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3341 -S "found renegotiation extension" \
3342 -s "server hello, secure renegotiation extension" \
3343 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003344 -C "=> renegotiate" \
3345 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003346 -S "write hello request"
3347
Hanno Becker6a243642017-10-12 15:18:45 +01003348requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003349run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003350 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003351 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003352 0 \
3353 -c "client hello, adding renegotiation extension" \
3354 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3355 -s "found renegotiation extension" \
3356 -s "server hello, secure renegotiation extension" \
3357 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003358 -c "=> renegotiate" \
3359 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003360 -S "write hello request"
3361
Hanno Becker6a243642017-10-12 15:18:45 +01003362requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003363run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003364 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003365 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003366 0 \
3367 -c "client hello, adding renegotiation extension" \
3368 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3369 -s "found renegotiation extension" \
3370 -s "server hello, secure renegotiation extension" \
3371 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003372 -c "=> renegotiate" \
3373 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003374 -s "write hello request"
3375
Janos Follathb0f148c2017-10-05 12:29:42 +01003376# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3377# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3378# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003379requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003380run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3381 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3382 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3383 0 \
3384 -c "client hello, adding renegotiation extension" \
3385 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3386 -s "found renegotiation extension" \
3387 -s "server hello, secure renegotiation extension" \
3388 -c "found renegotiation extension" \
3389 -c "=> renegotiate" \
3390 -s "=> renegotiate" \
3391 -S "write hello request" \
3392 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3393
3394# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3395# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3396# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003397requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003398run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3399 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3400 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3401 0 \
3402 -c "client hello, adding renegotiation extension" \
3403 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3404 -s "found renegotiation extension" \
3405 -s "server hello, secure renegotiation extension" \
3406 -c "found renegotiation extension" \
3407 -c "=> renegotiate" \
3408 -s "=> renegotiate" \
3409 -s "write hello request" \
3410 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3411
Hanno Becker6a243642017-10-12 15:18:45 +01003412requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003413run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003414 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003415 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003416 0 \
3417 -c "client hello, adding renegotiation extension" \
3418 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3419 -s "found renegotiation extension" \
3420 -s "server hello, secure renegotiation extension" \
3421 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003422 -c "=> renegotiate" \
3423 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003424 -s "write hello request"
3425
Hanno Becker6a243642017-10-12 15:18:45 +01003426requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andrzej Kurek8ea68722020-04-03 06:40:47 -04003427requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3428run_test "Renegotiation with max fragment length: client 2048, server 512" \
3429 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1 max_frag_len=512" \
3430 "$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" \
3431 0 \
3432 -c "Maximum input fragment length is 2048" \
3433 -c "Maximum output fragment length is 2048" \
3434 -s "Maximum input fragment length is 2048" \
3435 -s "Maximum output fragment length is 512" \
3436 -c "client hello, adding max_fragment_length extension" \
3437 -s "found max fragment length extension" \
3438 -s "server hello, max_fragment_length extension" \
3439 -c "found max_fragment_length extension" \
3440 -c "client hello, adding renegotiation extension" \
3441 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3442 -s "found renegotiation extension" \
3443 -s "server hello, secure renegotiation extension" \
3444 -c "found renegotiation extension" \
3445 -c "=> renegotiate" \
3446 -s "=> renegotiate" \
3447 -s "write hello request"
3448
3449requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003450run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003451 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003452 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003453 1 \
3454 -c "client hello, adding renegotiation extension" \
3455 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3456 -S "found renegotiation extension" \
3457 -s "server hello, secure renegotiation extension" \
3458 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003459 -c "=> renegotiate" \
3460 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003461 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003462 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003463 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003464
Hanno Becker6a243642017-10-12 15:18:45 +01003465requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003466run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003467 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003468 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003469 0 \
3470 -C "client hello, adding renegotiation extension" \
3471 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3472 -S "found renegotiation extension" \
3473 -s "server hello, secure renegotiation extension" \
3474 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003475 -C "=> renegotiate" \
3476 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003477 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003478 -S "SSL - An unexpected message was received from our peer" \
3479 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003480
Hanno Becker6a243642017-10-12 15:18:45 +01003481requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003482run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003483 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003484 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003485 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003486 0 \
3487 -C "client hello, adding renegotiation extension" \
3488 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3489 -S "found renegotiation extension" \
3490 -s "server hello, secure renegotiation extension" \
3491 -c "found renegotiation extension" \
3492 -C "=> renegotiate" \
3493 -S "=> renegotiate" \
3494 -s "write hello request" \
3495 -S "SSL - An unexpected message was received from our peer" \
3496 -S "failed"
3497
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003498# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003499requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003500run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003501 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003502 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003503 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003504 0 \
3505 -C "client hello, adding renegotiation extension" \
3506 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3507 -S "found renegotiation extension" \
3508 -s "server hello, secure renegotiation extension" \
3509 -c "found renegotiation extension" \
3510 -C "=> renegotiate" \
3511 -S "=> renegotiate" \
3512 -s "write hello request" \
3513 -S "SSL - An unexpected message was received from our peer" \
3514 -S "failed"
3515
Hanno Becker6a243642017-10-12 15:18:45 +01003516requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003517run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003518 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003519 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003520 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003521 0 \
3522 -C "client hello, adding renegotiation extension" \
3523 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3524 -S "found renegotiation extension" \
3525 -s "server hello, secure renegotiation extension" \
3526 -c "found renegotiation extension" \
3527 -C "=> renegotiate" \
3528 -S "=> renegotiate" \
3529 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003530 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003531
Hanno Becker6a243642017-10-12 15:18:45 +01003532requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003533run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003534 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003535 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003536 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003537 0 \
3538 -c "client hello, adding renegotiation extension" \
3539 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3540 -s "found renegotiation extension" \
3541 -s "server hello, secure renegotiation extension" \
3542 -c "found renegotiation extension" \
3543 -c "=> renegotiate" \
3544 -s "=> renegotiate" \
3545 -s "write hello request" \
3546 -S "SSL - An unexpected message was received from our peer" \
3547 -S "failed"
3548
Hanno Becker6a243642017-10-12 15:18:45 +01003549requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003550run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003551 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003552 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3553 0 \
3554 -C "client hello, adding renegotiation extension" \
3555 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3556 -S "found renegotiation extension" \
3557 -s "server hello, secure renegotiation extension" \
3558 -c "found renegotiation extension" \
3559 -S "record counter limit reached: renegotiate" \
3560 -C "=> renegotiate" \
3561 -S "=> renegotiate" \
3562 -S "write hello request" \
3563 -S "SSL - An unexpected message was received from our peer" \
3564 -S "failed"
3565
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003566# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003567requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003568run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003569 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003570 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003571 0 \
3572 -c "client hello, adding renegotiation extension" \
3573 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3574 -s "found renegotiation extension" \
3575 -s "server hello, secure renegotiation extension" \
3576 -c "found renegotiation extension" \
3577 -s "record counter limit reached: renegotiate" \
3578 -c "=> renegotiate" \
3579 -s "=> renegotiate" \
3580 -s "write hello request" \
3581 -S "SSL - An unexpected message was received from our peer" \
3582 -S "failed"
3583
Hanno Becker6a243642017-10-12 15:18:45 +01003584requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003585run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003586 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003587 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003588 0 \
3589 -c "client hello, adding renegotiation extension" \
3590 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3591 -s "found renegotiation extension" \
3592 -s "server hello, secure renegotiation extension" \
3593 -c "found renegotiation extension" \
3594 -s "record counter limit reached: renegotiate" \
3595 -c "=> renegotiate" \
3596 -s "=> renegotiate" \
3597 -s "write hello request" \
3598 -S "SSL - An unexpected message was received from our peer" \
3599 -S "failed"
3600
Hanno Becker6a243642017-10-12 15:18:45 +01003601requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003602run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003603 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003604 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3605 0 \
3606 -C "client hello, adding renegotiation extension" \
3607 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3608 -S "found renegotiation extension" \
3609 -s "server hello, secure renegotiation extension" \
3610 -c "found renegotiation extension" \
3611 -S "record counter limit reached: renegotiate" \
3612 -C "=> renegotiate" \
3613 -S "=> renegotiate" \
3614 -S "write hello request" \
3615 -S "SSL - An unexpected message was received from our peer" \
3616 -S "failed"
3617
Hanno Becker6a243642017-10-12 15:18:45 +01003618requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003619run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003620 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003621 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003622 0 \
3623 -c "client hello, adding renegotiation extension" \
3624 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3625 -s "found renegotiation extension" \
3626 -s "server hello, secure renegotiation extension" \
3627 -c "found renegotiation extension" \
3628 -c "=> renegotiate" \
3629 -s "=> renegotiate" \
3630 -S "write hello request"
3631
Hanno Becker6a243642017-10-12 15:18:45 +01003632requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003633run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003634 "$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 +02003635 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003636 0 \
3637 -c "client hello, adding renegotiation extension" \
3638 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3639 -s "found renegotiation extension" \
3640 -s "server hello, secure renegotiation extension" \
3641 -c "found renegotiation extension" \
3642 -c "=> renegotiate" \
3643 -s "=> renegotiate" \
3644 -s "write hello request"
3645
Hanno Becker6a243642017-10-12 15:18:45 +01003646requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003647run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003648 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003649 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003650 0 \
3651 -c "client hello, adding renegotiation extension" \
3652 -c "found renegotiation extension" \
3653 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003654 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003655 -C "error" \
3656 -c "HTTP/1.0 200 [Oo][Kk]"
3657
Paul Bakker539d9722015-02-08 16:18:35 +01003658requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003659requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003660run_test "Renegotiation: gnutls server strict, client-initiated" \
3661 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003662 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003663 0 \
3664 -c "client hello, adding renegotiation extension" \
3665 -c "found renegotiation extension" \
3666 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003667 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003668 -C "error" \
3669 -c "HTTP/1.0 200 [Oo][Kk]"
3670
Paul Bakker539d9722015-02-08 16:18:35 +01003671requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003672requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003673run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3674 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3675 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
3676 1 \
3677 -c "client hello, adding renegotiation extension" \
3678 -C "found renegotiation extension" \
3679 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003680 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003681 -c "error" \
3682 -C "HTTP/1.0 200 [Oo][Kk]"
3683
Paul Bakker539d9722015-02-08 16:18:35 +01003684requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003685requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003686run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3687 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3688 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3689 allow_legacy=0" \
3690 1 \
3691 -c "client hello, adding renegotiation extension" \
3692 -C "found renegotiation extension" \
3693 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003694 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003695 -c "error" \
3696 -C "HTTP/1.0 200 [Oo][Kk]"
3697
Paul Bakker539d9722015-02-08 16:18:35 +01003698requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003699requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003700run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3701 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3702 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3703 allow_legacy=1" \
3704 0 \
3705 -c "client hello, adding renegotiation extension" \
3706 -C "found renegotiation extension" \
3707 -c "=> renegotiate" \
3708 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003709 -C "error" \
3710 -c "HTTP/1.0 200 [Oo][Kk]"
3711
Hanno Becker6a243642017-10-12 15:18:45 +01003712requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003713run_test "Renegotiation: DTLS, client-initiated" \
3714 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3715 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3716 0 \
3717 -c "client hello, adding renegotiation extension" \
3718 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3719 -s "found renegotiation extension" \
3720 -s "server hello, secure renegotiation extension" \
3721 -c "found renegotiation extension" \
3722 -c "=> renegotiate" \
3723 -s "=> renegotiate" \
3724 -S "write hello request"
3725
Hanno Becker6a243642017-10-12 15:18:45 +01003726requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003727run_test "Renegotiation: DTLS, server-initiated" \
3728 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003729 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3730 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003731 0 \
3732 -c "client hello, adding renegotiation extension" \
3733 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3734 -s "found renegotiation extension" \
3735 -s "server hello, secure renegotiation extension" \
3736 -c "found renegotiation extension" \
3737 -c "=> renegotiate" \
3738 -s "=> renegotiate" \
3739 -s "write hello request"
3740
Hanno Becker6a243642017-10-12 15:18:45 +01003741requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003742run_test "Renegotiation: DTLS, renego_period overflow" \
3743 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3744 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3745 0 \
3746 -c "client hello, adding renegotiation extension" \
3747 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3748 -s "found renegotiation extension" \
3749 -s "server hello, secure renegotiation extension" \
3750 -s "record counter limit reached: renegotiate" \
3751 -c "=> renegotiate" \
3752 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003753 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003754
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003755requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003756requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003757run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3758 "$G_SRV -u --mtu 4096" \
3759 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
3760 0 \
3761 -c "client hello, adding renegotiation extension" \
3762 -c "found renegotiation extension" \
3763 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003764 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003765 -C "error" \
3766 -s "Extra-header:"
3767
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003768# Test for the "secure renegotation" extension only (no actual renegotiation)
3769
Paul Bakker539d9722015-02-08 16:18:35 +01003770requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003771run_test "Renego ext: gnutls server strict, client default" \
3772 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
3773 "$P_CLI debug_level=3" \
3774 0 \
3775 -c "found renegotiation extension" \
3776 -C "error" \
3777 -c "HTTP/1.0 200 [Oo][Kk]"
3778
Paul Bakker539d9722015-02-08 16:18:35 +01003779requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003780run_test "Renego ext: gnutls server unsafe, client default" \
3781 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3782 "$P_CLI debug_level=3" \
3783 0 \
3784 -C "found renegotiation extension" \
3785 -C "error" \
3786 -c "HTTP/1.0 200 [Oo][Kk]"
3787
Paul Bakker539d9722015-02-08 16:18:35 +01003788requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003789run_test "Renego ext: gnutls server unsafe, client break legacy" \
3790 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3791 "$P_CLI debug_level=3 allow_legacy=-1" \
3792 1 \
3793 -C "found renegotiation extension" \
3794 -c "error" \
3795 -C "HTTP/1.0 200 [Oo][Kk]"
3796
Paul Bakker539d9722015-02-08 16:18:35 +01003797requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003798run_test "Renego ext: gnutls client strict, server default" \
3799 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003800 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003801 0 \
3802 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3803 -s "server hello, secure renegotiation extension"
3804
Paul Bakker539d9722015-02-08 16:18:35 +01003805requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003806run_test "Renego ext: gnutls client unsafe, server default" \
3807 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003808 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003809 0 \
3810 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3811 -S "server hello, secure renegotiation extension"
3812
Paul Bakker539d9722015-02-08 16:18:35 +01003813requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003814run_test "Renego ext: gnutls client unsafe, server break legacy" \
3815 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003816 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003817 1 \
3818 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3819 -S "server hello, secure renegotiation extension"
3820
Janos Follath0b242342016-02-17 10:11:21 +00003821# Tests for silently dropping trailing extra bytes in .der certificates
3822
3823requires_gnutls
3824run_test "DER format: no trailing bytes" \
3825 "$P_SRV crt_file=data_files/server5-der0.crt \
3826 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003827 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003828 0 \
3829 -c "Handshake was completed" \
3830
3831requires_gnutls
3832run_test "DER format: with a trailing zero byte" \
3833 "$P_SRV crt_file=data_files/server5-der1a.crt \
3834 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003835 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003836 0 \
3837 -c "Handshake was completed" \
3838
3839requires_gnutls
3840run_test "DER format: with a trailing random byte" \
3841 "$P_SRV crt_file=data_files/server5-der1b.crt \
3842 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003843 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003844 0 \
3845 -c "Handshake was completed" \
3846
3847requires_gnutls
3848run_test "DER format: with 2 trailing random bytes" \
3849 "$P_SRV crt_file=data_files/server5-der2.crt \
3850 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003851 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003852 0 \
3853 -c "Handshake was completed" \
3854
3855requires_gnutls
3856run_test "DER format: with 4 trailing random bytes" \
3857 "$P_SRV crt_file=data_files/server5-der4.crt \
3858 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003859 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003860 0 \
3861 -c "Handshake was completed" \
3862
3863requires_gnutls
3864run_test "DER format: with 8 trailing random bytes" \
3865 "$P_SRV crt_file=data_files/server5-der8.crt \
3866 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003867 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003868 0 \
3869 -c "Handshake was completed" \
3870
3871requires_gnutls
3872run_test "DER format: with 9 trailing random bytes" \
3873 "$P_SRV crt_file=data_files/server5-der9.crt \
3874 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003875 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003876 0 \
3877 -c "Handshake was completed" \
3878
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03003879# Tests for auth_mode, there are duplicated tests using ca callback for authentication
3880# When updating these tests, modify the matching authentication tests accordingly
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003882run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003883 "$P_SRV crt_file=data_files/server5-badsign.crt \
3884 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003885 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003886 1 \
3887 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003888 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003889 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003890 -c "X509 - Certificate verification failed"
3891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003892run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003893 "$P_SRV crt_file=data_files/server5-badsign.crt \
3894 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003895 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003896 0 \
3897 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003898 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003899 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003900 -C "X509 - Certificate verification failed"
3901
Hanno Beckere6706e62017-05-15 16:05:15 +01003902run_test "Authentication: server goodcert, client optional, no trusted CA" \
3903 "$P_SRV" \
3904 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3905 0 \
3906 -c "x509_verify_cert() returned" \
3907 -c "! The certificate is not correctly signed by the trusted CA" \
3908 -c "! Certificate verification flags"\
3909 -C "! mbedtls_ssl_handshake returned" \
3910 -C "X509 - Certificate verification failed" \
3911 -C "SSL - No CA Chain is set, but required to operate"
3912
3913run_test "Authentication: server goodcert, client required, no trusted CA" \
3914 "$P_SRV" \
3915 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3916 1 \
3917 -c "x509_verify_cert() returned" \
3918 -c "! The certificate is not correctly signed by the trusted CA" \
3919 -c "! Certificate verification flags"\
3920 -c "! mbedtls_ssl_handshake returned" \
3921 -c "SSL - No CA Chain is set, but required to operate"
3922
3923# The purpose of the next two tests is to test the client's behaviour when receiving a server
3924# certificate with an unsupported elliptic curve. This should usually not happen because
3925# the client informs the server about the supported curves - it does, though, in the
3926# corner case of a static ECDH suite, because the server doesn't check the curve on that
3927# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3928# different means to have the server ignoring the client's supported curve list.
3929
3930requires_config_enabled MBEDTLS_ECP_C
3931run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3932 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3933 crt_file=data_files/server5.ku-ka.crt" \
3934 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3935 1 \
3936 -c "bad certificate (EC key curve)"\
3937 -c "! Certificate verification flags"\
3938 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3939
3940requires_config_enabled MBEDTLS_ECP_C
3941run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3942 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3943 crt_file=data_files/server5.ku-ka.crt" \
3944 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3945 1 \
3946 -c "bad certificate (EC key curve)"\
3947 -c "! Certificate verification flags"\
3948 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3949
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003950run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003951 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003952 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003953 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003954 0 \
3955 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003956 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003957 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003958 -C "X509 - Certificate verification failed"
3959
Simon Butcher99000142016-10-13 17:21:01 +01003960run_test "Authentication: client SHA256, server required" \
3961 "$P_SRV auth_mode=required" \
3962 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3963 key_file=data_files/server6.key \
3964 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3965 0 \
3966 -c "Supported Signature Algorithm found: 4," \
3967 -c "Supported Signature Algorithm found: 5,"
3968
3969run_test "Authentication: client SHA384, server required" \
3970 "$P_SRV auth_mode=required" \
3971 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3972 key_file=data_files/server6.key \
3973 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3974 0 \
3975 -c "Supported Signature Algorithm found: 4," \
3976 -c "Supported Signature Algorithm found: 5,"
3977
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003978requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3979run_test "Authentication: client has no cert, server required (SSLv3)" \
3980 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3981 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3982 key_file=data_files/server5.key" \
3983 1 \
3984 -S "skip write certificate request" \
3985 -C "skip parse certificate request" \
3986 -c "got a certificate request" \
3987 -c "got no certificate to send" \
3988 -S "x509_verify_cert() returned" \
3989 -s "client has no certificate" \
3990 -s "! mbedtls_ssl_handshake returned" \
3991 -c "! mbedtls_ssl_handshake returned" \
3992 -s "No client certification received from the client, but required by the authentication mode"
3993
3994run_test "Authentication: client has no cert, server required (TLS)" \
3995 "$P_SRV debug_level=3 auth_mode=required" \
3996 "$P_CLI debug_level=3 crt_file=none \
3997 key_file=data_files/server5.key" \
3998 1 \
3999 -S "skip write certificate request" \
4000 -C "skip parse certificate request" \
4001 -c "got a certificate request" \
4002 -c "= write certificate$" \
4003 -C "skip write certificate$" \
4004 -S "x509_verify_cert() returned" \
4005 -s "client has no certificate" \
4006 -s "! mbedtls_ssl_handshake returned" \
4007 -c "! mbedtls_ssl_handshake returned" \
4008 -s "No client certification received from the client, but required by the authentication mode"
4009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004010run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004011 "$P_SRV debug_level=3 auth_mode=required" \
4012 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004013 key_file=data_files/server5.key" \
4014 1 \
4015 -S "skip write certificate request" \
4016 -C "skip parse certificate request" \
4017 -c "got a certificate request" \
4018 -C "skip write certificate" \
4019 -C "skip write certificate verify" \
4020 -S "skip parse certificate verify" \
4021 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004022 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004023 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02004024 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004025 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004026 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02004027# We don't check that the client receives the alert because it might
4028# detect that its write end of the connection is closed and abort
4029# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004030
Janos Follath89baba22017-04-10 14:34:35 +01004031run_test "Authentication: client cert not trusted, server required" \
4032 "$P_SRV debug_level=3 auth_mode=required" \
4033 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4034 key_file=data_files/server5.key" \
4035 1 \
4036 -S "skip write certificate request" \
4037 -C "skip parse certificate request" \
4038 -c "got a certificate request" \
4039 -C "skip write certificate" \
4040 -C "skip write certificate verify" \
4041 -S "skip parse certificate verify" \
4042 -s "x509_verify_cert() returned" \
4043 -s "! The certificate is not correctly signed by the trusted CA" \
4044 -s "! mbedtls_ssl_handshake returned" \
4045 -c "! mbedtls_ssl_handshake returned" \
4046 -s "X509 - Certificate verification failed"
4047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004048run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004049 "$P_SRV debug_level=3 auth_mode=optional" \
4050 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004051 key_file=data_files/server5.key" \
4052 0 \
4053 -S "skip write certificate request" \
4054 -C "skip parse certificate request" \
4055 -c "got a certificate request" \
4056 -C "skip write certificate" \
4057 -C "skip write certificate verify" \
4058 -S "skip parse certificate verify" \
4059 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004060 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004061 -S "! mbedtls_ssl_handshake returned" \
4062 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004063 -S "X509 - Certificate verification failed"
4064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004065run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004066 "$P_SRV debug_level=3 auth_mode=none" \
4067 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004068 key_file=data_files/server5.key" \
4069 0 \
4070 -s "skip write certificate request" \
4071 -C "skip parse certificate request" \
4072 -c "got no certificate request" \
4073 -c "skip write certificate" \
4074 -c "skip write certificate verify" \
4075 -s "skip parse certificate verify" \
4076 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004077 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004078 -S "! mbedtls_ssl_handshake returned" \
4079 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004080 -S "X509 - Certificate verification failed"
4081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004082run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004083 "$P_SRV debug_level=3 auth_mode=optional" \
4084 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004085 0 \
4086 -S "skip write certificate request" \
4087 -C "skip parse certificate request" \
4088 -c "got a certificate request" \
4089 -C "skip write certificate$" \
4090 -C "got no certificate to send" \
4091 -S "SSLv3 client has no certificate" \
4092 -c "skip write certificate verify" \
4093 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004094 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004095 -S "! mbedtls_ssl_handshake returned" \
4096 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004097 -S "X509 - Certificate verification failed"
4098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004099run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004100 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004101 "$O_CLI" \
4102 0 \
4103 -S "skip write certificate request" \
4104 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004105 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004106 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004107 -S "X509 - Certificate verification failed"
4108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004109run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004110 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004111 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004112 0 \
4113 -C "skip parse certificate request" \
4114 -c "got a certificate request" \
4115 -C "skip write certificate$" \
4116 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004117 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004118
Gilles Peskinefd8332e2017-05-03 16:25:07 +02004119run_test "Authentication: client no cert, openssl server required" \
4120 "$O_SRV -Verify 10" \
4121 "$P_CLI debug_level=3 crt_file=none key_file=none" \
4122 1 \
4123 -C "skip parse certificate request" \
4124 -c "got a certificate request" \
4125 -C "skip write certificate$" \
4126 -c "skip write certificate verify" \
4127 -c "! mbedtls_ssl_handshake returned"
4128
Janos Follathe2681a42016-03-07 15:57:05 +00004129requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004130run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004131 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004132 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004133 0 \
4134 -S "skip write certificate request" \
4135 -C "skip parse certificate request" \
4136 -c "got a certificate request" \
4137 -C "skip write certificate$" \
4138 -c "skip write certificate verify" \
4139 -c "got no certificate to send" \
4140 -s "SSLv3 client has no certificate" \
4141 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004142 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004143 -S "! mbedtls_ssl_handshake returned" \
4144 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004145 -S "X509 - Certificate verification failed"
4146
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02004147# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
4148# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004149
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004150MAX_IM_CA='8'
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02004151MAX_IM_CA_CONFIG=$( ../scripts/config.py get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004152
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004153if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01004154 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004155 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004156 printf "test value of ${MAX_IM_CA}. \n"
4157 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004158 printf "The tests assume this value and if it changes, the tests in this\n"
4159 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004160 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004161
4162 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004163fi
4164
Angus Grattonc4dd0732018-04-11 16:28:39 +10004165requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004166run_test "Authentication: server max_int chain, client default" \
4167 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4168 key_file=data_files/dir-maxpath/09.key" \
4169 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4170 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004171 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004172
Angus Grattonc4dd0732018-04-11 16:28:39 +10004173requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004174run_test "Authentication: server max_int+1 chain, client default" \
4175 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4176 key_file=data_files/dir-maxpath/10.key" \
4177 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4178 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004179 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004180
Angus Grattonc4dd0732018-04-11 16:28:39 +10004181requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004182run_test "Authentication: server max_int+1 chain, client optional" \
4183 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4184 key_file=data_files/dir-maxpath/10.key" \
4185 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4186 auth_mode=optional" \
4187 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004188 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004189
Angus Grattonc4dd0732018-04-11 16:28:39 +10004190requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004191run_test "Authentication: server max_int+1 chain, client none" \
4192 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4193 key_file=data_files/dir-maxpath/10.key" \
4194 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4195 auth_mode=none" \
4196 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004197 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004198
Angus Grattonc4dd0732018-04-11 16:28:39 +10004199requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004200run_test "Authentication: client max_int+1 chain, server default" \
4201 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4202 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4203 key_file=data_files/dir-maxpath/10.key" \
4204 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004205 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004206
Angus Grattonc4dd0732018-04-11 16:28:39 +10004207requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004208run_test "Authentication: client max_int+1 chain, server optional" \
4209 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4210 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4211 key_file=data_files/dir-maxpath/10.key" \
4212 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004213 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004214
Angus Grattonc4dd0732018-04-11 16:28:39 +10004215requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004216run_test "Authentication: client max_int+1 chain, server required" \
4217 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4218 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4219 key_file=data_files/dir-maxpath/10.key" \
4220 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004221 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004222
Angus Grattonc4dd0732018-04-11 16:28:39 +10004223requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004224run_test "Authentication: client max_int chain, server required" \
4225 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4226 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4227 key_file=data_files/dir-maxpath/09.key" \
4228 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004229 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004230
Janos Follath89baba22017-04-10 14:34:35 +01004231# Tests for CA list in CertificateRequest messages
4232
4233run_test "Authentication: send CA list in CertificateRequest (default)" \
4234 "$P_SRV debug_level=3 auth_mode=required" \
4235 "$P_CLI crt_file=data_files/server6.crt \
4236 key_file=data_files/server6.key" \
4237 0 \
4238 -s "requested DN"
4239
4240run_test "Authentication: do not send CA list in CertificateRequest" \
4241 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4242 "$P_CLI crt_file=data_files/server6.crt \
4243 key_file=data_files/server6.key" \
4244 0 \
4245 -S "requested DN"
4246
4247run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4248 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4249 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4250 key_file=data_files/server5.key" \
4251 1 \
4252 -S "requested DN" \
4253 -s "x509_verify_cert() returned" \
4254 -s "! The certificate is not correctly signed by the trusted CA" \
4255 -s "! mbedtls_ssl_handshake returned" \
4256 -c "! mbedtls_ssl_handshake returned" \
4257 -s "X509 - Certificate verification failed"
4258
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03004259# Tests for auth_mode, using CA callback, these are duplicated from the authentication tests
4260# When updating these tests, modify the matching authentication tests accordingly
Hanno Becker746aaf32019-03-28 15:25:23 +00004261
4262requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4263run_test "Authentication, CA callback: server badcert, client required" \
4264 "$P_SRV crt_file=data_files/server5-badsign.crt \
4265 key_file=data_files/server5.key" \
4266 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required" \
4267 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004268 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004269 -c "x509_verify_cert() returned" \
4270 -c "! The certificate is not correctly signed by the trusted CA" \
4271 -c "! mbedtls_ssl_handshake returned" \
4272 -c "X509 - Certificate verification failed"
4273
4274requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4275run_test "Authentication, CA callback: server badcert, client optional" \
4276 "$P_SRV crt_file=data_files/server5-badsign.crt \
4277 key_file=data_files/server5.key" \
4278 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional" \
4279 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004280 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004281 -c "x509_verify_cert() returned" \
4282 -c "! The certificate is not correctly signed by the trusted CA" \
4283 -C "! mbedtls_ssl_handshake returned" \
4284 -C "X509 - Certificate verification failed"
4285
4286# The purpose of the next two tests is to test the client's behaviour when receiving a server
4287# certificate with an unsupported elliptic curve. This should usually not happen because
4288# the client informs the server about the supported curves - it does, though, in the
4289# corner case of a static ECDH suite, because the server doesn't check the curve on that
4290# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
4291# different means to have the server ignoring the client's supported curve list.
4292
4293requires_config_enabled MBEDTLS_ECP_C
4294requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4295run_test "Authentication, CA callback: server ECDH p256v1, client required, p256v1 unsupported" \
4296 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4297 crt_file=data_files/server5.ku-ka.crt" \
4298 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required curves=secp521r1" \
4299 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004300 -c "use CA callback for X.509 CRT verification" \
4301 -c "bad certificate (EC key curve)" \
4302 -c "! Certificate verification flags" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004303 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
4304
4305requires_config_enabled MBEDTLS_ECP_C
4306requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4307run_test "Authentication, CA callback: server ECDH p256v1, client optional, p256v1 unsupported" \
4308 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4309 crt_file=data_files/server5.ku-ka.crt" \
4310 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional curves=secp521r1" \
4311 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004312 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004313 -c "bad certificate (EC key curve)"\
4314 -c "! Certificate verification flags"\
4315 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
4316
4317requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4318run_test "Authentication, CA callback: client SHA256, server required" \
4319 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4320 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4321 key_file=data_files/server6.key \
4322 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
4323 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004324 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004325 -c "Supported Signature Algorithm found: 4," \
4326 -c "Supported Signature Algorithm found: 5,"
4327
4328requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4329run_test "Authentication, CA callback: client SHA384, server required" \
4330 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4331 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4332 key_file=data_files/server6.key \
4333 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
4334 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004335 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004336 -c "Supported Signature Algorithm found: 4," \
4337 -c "Supported Signature Algorithm found: 5,"
4338
4339requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4340run_test "Authentication, CA callback: client badcert, server required" \
4341 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4342 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4343 key_file=data_files/server5.key" \
4344 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004345 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004346 -S "skip write certificate request" \
4347 -C "skip parse certificate request" \
4348 -c "got a certificate request" \
4349 -C "skip write certificate" \
4350 -C "skip write certificate verify" \
4351 -S "skip parse certificate verify" \
4352 -s "x509_verify_cert() returned" \
4353 -s "! The certificate is not correctly signed by the trusted CA" \
4354 -s "! mbedtls_ssl_handshake returned" \
4355 -s "send alert level=2 message=48" \
4356 -c "! mbedtls_ssl_handshake returned" \
4357 -s "X509 - Certificate verification failed"
4358# We don't check that the client receives the alert because it might
4359# detect that its write end of the connection is closed and abort
4360# before reading the alert message.
4361
4362requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4363run_test "Authentication, CA callback: client cert not trusted, server required" \
4364 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4365 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4366 key_file=data_files/server5.key" \
4367 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004368 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004369 -S "skip write certificate request" \
4370 -C "skip parse certificate request" \
4371 -c "got a certificate request" \
4372 -C "skip write certificate" \
4373 -C "skip write certificate verify" \
4374 -S "skip parse certificate verify" \
4375 -s "x509_verify_cert() returned" \
4376 -s "! The certificate is not correctly signed by the trusted CA" \
4377 -s "! mbedtls_ssl_handshake returned" \
4378 -c "! mbedtls_ssl_handshake returned" \
4379 -s "X509 - Certificate verification failed"
4380
4381requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4382run_test "Authentication, CA callback: client badcert, server optional" \
4383 "$P_SRV ca_callback=1 debug_level=3 auth_mode=optional" \
4384 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4385 key_file=data_files/server5.key" \
4386 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004387 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004388 -S "skip write certificate request" \
4389 -C "skip parse certificate request" \
4390 -c "got a certificate request" \
4391 -C "skip write certificate" \
4392 -C "skip write certificate verify" \
4393 -S "skip parse certificate verify" \
4394 -s "x509_verify_cert() returned" \
4395 -s "! The certificate is not correctly signed by the trusted CA" \
4396 -S "! mbedtls_ssl_handshake returned" \
4397 -C "! mbedtls_ssl_handshake returned" \
4398 -S "X509 - Certificate verification failed"
4399
4400requires_full_size_output_buffer
4401requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4402run_test "Authentication, CA callback: server max_int chain, client default" \
4403 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4404 key_file=data_files/dir-maxpath/09.key" \
4405 "$P_CLI ca_callback=1 debug_level=3 server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4406 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004407 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004408 -C "X509 - A fatal error occurred"
4409
4410requires_full_size_output_buffer
4411requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4412run_test "Authentication, CA callback: server max_int+1 chain, client default" \
4413 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4414 key_file=data_files/dir-maxpath/10.key" \
4415 "$P_CLI debug_level=3 ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4416 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004417 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004418 -c "X509 - A fatal error occurred"
4419
4420requires_full_size_output_buffer
4421requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4422run_test "Authentication, CA callback: server max_int+1 chain, client optional" \
4423 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4424 key_file=data_files/dir-maxpath/10.key" \
4425 "$P_CLI ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4426 debug_level=3 auth_mode=optional" \
4427 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004428 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004429 -c "X509 - A fatal error occurred"
4430
4431requires_full_size_output_buffer
4432requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4433run_test "Authentication, CA callback: client max_int+1 chain, server optional" \
4434 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4435 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4436 key_file=data_files/dir-maxpath/10.key" \
4437 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004438 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004439 -s "X509 - A fatal error occurred"
4440
4441requires_full_size_output_buffer
4442requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4443run_test "Authentication, CA callback: client max_int+1 chain, server required" \
4444 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4445 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4446 key_file=data_files/dir-maxpath/10.key" \
4447 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004448 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004449 -s "X509 - A fatal error occurred"
4450
4451requires_full_size_output_buffer
4452requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4453run_test "Authentication, CA callback: client max_int chain, server required" \
4454 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4455 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4456 key_file=data_files/dir-maxpath/09.key" \
4457 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004458 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004459 -S "X509 - A fatal error occurred"
4460
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004461# Tests for certificate selection based on SHA verson
4462
4463run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4464 "$P_SRV crt_file=data_files/server5.crt \
4465 key_file=data_files/server5.key \
4466 crt_file2=data_files/server5-sha1.crt \
4467 key_file2=data_files/server5.key" \
4468 "$P_CLI force_version=tls1_2" \
4469 0 \
4470 -c "signed using.*ECDSA with SHA256" \
4471 -C "signed using.*ECDSA with SHA1"
4472
4473run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4474 "$P_SRV crt_file=data_files/server5.crt \
4475 key_file=data_files/server5.key \
4476 crt_file2=data_files/server5-sha1.crt \
4477 key_file2=data_files/server5.key" \
4478 "$P_CLI force_version=tls1_1" \
4479 0 \
4480 -C "signed using.*ECDSA with SHA256" \
4481 -c "signed using.*ECDSA with SHA1"
4482
4483run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4484 "$P_SRV crt_file=data_files/server5.crt \
4485 key_file=data_files/server5.key \
4486 crt_file2=data_files/server5-sha1.crt \
4487 key_file2=data_files/server5.key" \
4488 "$P_CLI force_version=tls1" \
4489 0 \
4490 -C "signed using.*ECDSA with SHA256" \
4491 -c "signed using.*ECDSA with SHA1"
4492
4493run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4494 "$P_SRV crt_file=data_files/server5.crt \
4495 key_file=data_files/server5.key \
4496 crt_file2=data_files/server6.crt \
4497 key_file2=data_files/server6.key" \
4498 "$P_CLI force_version=tls1_1" \
4499 0 \
4500 -c "serial number.*09" \
4501 -c "signed using.*ECDSA with SHA256" \
4502 -C "signed using.*ECDSA with SHA1"
4503
4504run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4505 "$P_SRV crt_file=data_files/server6.crt \
4506 key_file=data_files/server6.key \
4507 crt_file2=data_files/server5.crt \
4508 key_file2=data_files/server5.key" \
4509 "$P_CLI force_version=tls1_1" \
4510 0 \
4511 -c "serial number.*0A" \
4512 -c "signed using.*ECDSA with SHA256" \
4513 -C "signed using.*ECDSA with SHA1"
4514
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004515# tests for SNI
4516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004517run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004518 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004519 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004520 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004521 0 \
4522 -S "parse ServerName extension" \
4523 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4524 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004526run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004527 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004528 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004529 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 +02004530 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004531 0 \
4532 -s "parse ServerName extension" \
4533 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4534 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004535
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004536run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004537 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004538 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004539 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 +02004540 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004541 0 \
4542 -s "parse ServerName extension" \
4543 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4544 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004546run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004547 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004548 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004549 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 +02004550 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004551 1 \
4552 -s "parse ServerName extension" \
4553 -s "ssl_sni_wrapper() returned" \
4554 -s "mbedtls_ssl_handshake returned" \
4555 -c "mbedtls_ssl_handshake returned" \
4556 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004557
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004558run_test "SNI: client auth no override: optional" \
4559 "$P_SRV debug_level=3 auth_mode=optional \
4560 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4561 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4562 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004563 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004564 -S "skip write certificate request" \
4565 -C "skip parse certificate request" \
4566 -c "got a certificate request" \
4567 -C "skip write certificate" \
4568 -C "skip write certificate verify" \
4569 -S "skip parse certificate verify"
4570
4571run_test "SNI: client auth override: none -> optional" \
4572 "$P_SRV debug_level=3 auth_mode=none \
4573 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4574 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4575 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004576 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004577 -S "skip write certificate request" \
4578 -C "skip parse certificate request" \
4579 -c "got a certificate request" \
4580 -C "skip write certificate" \
4581 -C "skip write certificate verify" \
4582 -S "skip parse certificate verify"
4583
4584run_test "SNI: client auth override: optional -> none" \
4585 "$P_SRV debug_level=3 auth_mode=optional \
4586 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4587 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4588 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004589 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004590 -s "skip write certificate request" \
4591 -C "skip parse certificate request" \
4592 -c "got no certificate request" \
4593 -c "skip write certificate" \
4594 -c "skip write certificate verify" \
4595 -s "skip parse certificate verify"
4596
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004597run_test "SNI: CA no override" \
4598 "$P_SRV debug_level=3 auth_mode=optional \
4599 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4600 ca_file=data_files/test-ca.crt \
4601 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4602 "$P_CLI debug_level=3 server_name=localhost \
4603 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4604 1 \
4605 -S "skip write certificate request" \
4606 -C "skip parse certificate request" \
4607 -c "got a certificate request" \
4608 -C "skip write certificate" \
4609 -C "skip write certificate verify" \
4610 -S "skip parse certificate verify" \
4611 -s "x509_verify_cert() returned" \
4612 -s "! The certificate is not correctly signed by the trusted CA" \
4613 -S "The certificate has been revoked (is on a CRL)"
4614
4615run_test "SNI: CA override" \
4616 "$P_SRV debug_level=3 auth_mode=optional \
4617 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4618 ca_file=data_files/test-ca.crt \
4619 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4620 "$P_CLI debug_level=3 server_name=localhost \
4621 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4622 0 \
4623 -S "skip write certificate request" \
4624 -C "skip parse certificate request" \
4625 -c "got a certificate request" \
4626 -C "skip write certificate" \
4627 -C "skip write certificate verify" \
4628 -S "skip parse certificate verify" \
4629 -S "x509_verify_cert() returned" \
4630 -S "! The certificate is not correctly signed by the trusted CA" \
4631 -S "The certificate has been revoked (is on a CRL)"
4632
4633run_test "SNI: CA override with CRL" \
4634 "$P_SRV debug_level=3 auth_mode=optional \
4635 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4636 ca_file=data_files/test-ca.crt \
4637 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4638 "$P_CLI debug_level=3 server_name=localhost \
4639 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4640 1 \
4641 -S "skip write certificate request" \
4642 -C "skip parse certificate request" \
4643 -c "got a certificate request" \
4644 -C "skip write certificate" \
4645 -C "skip write certificate verify" \
4646 -S "skip parse certificate verify" \
4647 -s "x509_verify_cert() returned" \
4648 -S "! The certificate is not correctly signed by the trusted CA" \
4649 -s "The certificate has been revoked (is on a CRL)"
4650
Andres AG1a834452016-12-07 10:01:30 +00004651# Tests for SNI and DTLS
4652
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004653run_test "SNI: DTLS, no SNI callback" \
4654 "$P_SRV debug_level=3 dtls=1 \
4655 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
4656 "$P_CLI server_name=localhost dtls=1" \
4657 0 \
4658 -S "parse ServerName extension" \
4659 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4660 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4661
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004662run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004663 "$P_SRV debug_level=3 dtls=1 \
4664 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4665 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4666 "$P_CLI server_name=localhost dtls=1" \
4667 0 \
4668 -s "parse ServerName extension" \
4669 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4670 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4671
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004672run_test "SNI: DTLS, matching cert 2" \
4673 "$P_SRV debug_level=3 dtls=1 \
4674 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4675 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4676 "$P_CLI server_name=polarssl.example dtls=1" \
4677 0 \
4678 -s "parse ServerName extension" \
4679 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4680 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4681
4682run_test "SNI: DTLS, no matching cert" \
4683 "$P_SRV debug_level=3 dtls=1 \
4684 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4685 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4686 "$P_CLI server_name=nonesuch.example dtls=1" \
4687 1 \
4688 -s "parse ServerName extension" \
4689 -s "ssl_sni_wrapper() returned" \
4690 -s "mbedtls_ssl_handshake returned" \
4691 -c "mbedtls_ssl_handshake returned" \
4692 -c "SSL - A fatal alert message was received from our peer"
4693
4694run_test "SNI: DTLS, client auth no override: optional" \
4695 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4696 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4697 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4698 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4699 0 \
4700 -S "skip write certificate request" \
4701 -C "skip parse certificate request" \
4702 -c "got a certificate request" \
4703 -C "skip write certificate" \
4704 -C "skip write certificate verify" \
4705 -S "skip parse certificate verify"
4706
4707run_test "SNI: DTLS, client auth override: none -> optional" \
4708 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4709 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4710 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4711 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4712 0 \
4713 -S "skip write certificate request" \
4714 -C "skip parse certificate request" \
4715 -c "got a certificate request" \
4716 -C "skip write certificate" \
4717 -C "skip write certificate verify" \
4718 -S "skip parse certificate verify"
4719
4720run_test "SNI: DTLS, client auth override: optional -> none" \
4721 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4722 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4723 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4724 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4725 0 \
4726 -s "skip write certificate request" \
4727 -C "skip parse certificate request" \
4728 -c "got no certificate request" \
4729 -c "skip write certificate" \
4730 -c "skip write certificate verify" \
4731 -s "skip parse certificate verify"
4732
4733run_test "SNI: DTLS, CA no override" \
4734 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4735 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4736 ca_file=data_files/test-ca.crt \
4737 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4738 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4739 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4740 1 \
4741 -S "skip write certificate request" \
4742 -C "skip parse certificate request" \
4743 -c "got a certificate request" \
4744 -C "skip write certificate" \
4745 -C "skip write certificate verify" \
4746 -S "skip parse certificate verify" \
4747 -s "x509_verify_cert() returned" \
4748 -s "! The certificate is not correctly signed by the trusted CA" \
4749 -S "The certificate has been revoked (is on a CRL)"
4750
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004751run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004752 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4753 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4754 ca_file=data_files/test-ca.crt \
4755 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4756 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4757 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4758 0 \
4759 -S "skip write certificate request" \
4760 -C "skip parse certificate request" \
4761 -c "got a certificate request" \
4762 -C "skip write certificate" \
4763 -C "skip write certificate verify" \
4764 -S "skip parse certificate verify" \
4765 -S "x509_verify_cert() returned" \
4766 -S "! The certificate is not correctly signed by the trusted CA" \
4767 -S "The certificate has been revoked (is on a CRL)"
4768
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004769run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004770 "$P_SRV debug_level=3 auth_mode=optional \
4771 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4772 ca_file=data_files/test-ca.crt \
4773 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4774 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4775 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4776 1 \
4777 -S "skip write certificate request" \
4778 -C "skip parse certificate request" \
4779 -c "got a certificate request" \
4780 -C "skip write certificate" \
4781 -C "skip write certificate verify" \
4782 -S "skip parse certificate verify" \
4783 -s "x509_verify_cert() returned" \
4784 -S "! The certificate is not correctly signed by the trusted CA" \
4785 -s "The certificate has been revoked (is on a CRL)"
4786
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004787# Tests for non-blocking I/O: exercise a variety of handshake flows
4788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004789run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004790 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4791 "$P_CLI nbio=2 tickets=0" \
4792 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004793 -S "mbedtls_ssl_handshake returned" \
4794 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004795 -c "Read from server: .* bytes read"
4796
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004797run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004798 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4799 "$P_CLI nbio=2 tickets=0" \
4800 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004801 -S "mbedtls_ssl_handshake returned" \
4802 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004803 -c "Read from server: .* bytes read"
4804
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004805run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004806 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4807 "$P_CLI nbio=2 tickets=1" \
4808 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004809 -S "mbedtls_ssl_handshake returned" \
4810 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004811 -c "Read from server: .* bytes read"
4812
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004813run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004814 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4815 "$P_CLI nbio=2 tickets=1" \
4816 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004817 -S "mbedtls_ssl_handshake returned" \
4818 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004819 -c "Read from server: .* bytes read"
4820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004821run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004822 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4823 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4824 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004825 -S "mbedtls_ssl_handshake returned" \
4826 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004827 -c "Read from server: .* bytes read"
4828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004829run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004830 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4831 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4832 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004833 -S "mbedtls_ssl_handshake returned" \
4834 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004835 -c "Read from server: .* bytes read"
4836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004837run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004838 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4839 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4840 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004841 -S "mbedtls_ssl_handshake returned" \
4842 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004843 -c "Read from server: .* bytes read"
4844
Hanno Becker00076712017-11-15 16:39:08 +00004845# Tests for event-driven I/O: exercise a variety of handshake flows
4846
4847run_test "Event-driven I/O: basic handshake" \
4848 "$P_SRV event=1 tickets=0 auth_mode=none" \
4849 "$P_CLI event=1 tickets=0" \
4850 0 \
4851 -S "mbedtls_ssl_handshake returned" \
4852 -C "mbedtls_ssl_handshake returned" \
4853 -c "Read from server: .* bytes read"
4854
4855run_test "Event-driven I/O: client auth" \
4856 "$P_SRV event=1 tickets=0 auth_mode=required" \
4857 "$P_CLI event=1 tickets=0" \
4858 0 \
4859 -S "mbedtls_ssl_handshake returned" \
4860 -C "mbedtls_ssl_handshake returned" \
4861 -c "Read from server: .* bytes read"
4862
4863run_test "Event-driven I/O: ticket" \
4864 "$P_SRV event=1 tickets=1 auth_mode=none" \
4865 "$P_CLI event=1 tickets=1" \
4866 0 \
4867 -S "mbedtls_ssl_handshake returned" \
4868 -C "mbedtls_ssl_handshake returned" \
4869 -c "Read from server: .* bytes read"
4870
4871run_test "Event-driven I/O: ticket + client auth" \
4872 "$P_SRV event=1 tickets=1 auth_mode=required" \
4873 "$P_CLI event=1 tickets=1" \
4874 0 \
4875 -S "mbedtls_ssl_handshake returned" \
4876 -C "mbedtls_ssl_handshake returned" \
4877 -c "Read from server: .* bytes read"
4878
4879run_test "Event-driven I/O: ticket + client auth + resume" \
4880 "$P_SRV event=1 tickets=1 auth_mode=required" \
4881 "$P_CLI event=1 tickets=1 reconnect=1" \
4882 0 \
4883 -S "mbedtls_ssl_handshake returned" \
4884 -C "mbedtls_ssl_handshake returned" \
4885 -c "Read from server: .* bytes read"
4886
4887run_test "Event-driven I/O: ticket + resume" \
4888 "$P_SRV event=1 tickets=1 auth_mode=none" \
4889 "$P_CLI event=1 tickets=1 reconnect=1" \
4890 0 \
4891 -S "mbedtls_ssl_handshake returned" \
4892 -C "mbedtls_ssl_handshake returned" \
4893 -c "Read from server: .* bytes read"
4894
4895run_test "Event-driven I/O: session-id resume" \
4896 "$P_SRV event=1 tickets=0 auth_mode=none" \
4897 "$P_CLI event=1 tickets=0 reconnect=1" \
4898 0 \
4899 -S "mbedtls_ssl_handshake returned" \
4900 -C "mbedtls_ssl_handshake returned" \
4901 -c "Read from server: .* bytes read"
4902
Hanno Becker6a33f592018-03-13 11:38:46 +00004903run_test "Event-driven I/O, DTLS: basic handshake" \
4904 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4905 "$P_CLI dtls=1 event=1 tickets=0" \
4906 0 \
4907 -c "Read from server: .* bytes read"
4908
4909run_test "Event-driven I/O, DTLS: client auth" \
4910 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4911 "$P_CLI dtls=1 event=1 tickets=0" \
4912 0 \
4913 -c "Read from server: .* bytes read"
4914
4915run_test "Event-driven I/O, DTLS: ticket" \
4916 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4917 "$P_CLI dtls=1 event=1 tickets=1" \
4918 0 \
4919 -c "Read from server: .* bytes read"
4920
4921run_test "Event-driven I/O, DTLS: ticket + client auth" \
4922 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4923 "$P_CLI dtls=1 event=1 tickets=1" \
4924 0 \
4925 -c "Read from server: .* bytes read"
4926
4927run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4928 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004929 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004930 0 \
4931 -c "Read from server: .* bytes read"
4932
4933run_test "Event-driven I/O, DTLS: ticket + resume" \
4934 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004935 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004936 0 \
4937 -c "Read from server: .* bytes read"
4938
4939run_test "Event-driven I/O, DTLS: session-id resume" \
4940 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004941 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004942 0 \
4943 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004944
4945# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4946# During session resumption, the client will send its ApplicationData record
4947# within the same datagram as the Finished messages. In this situation, the
4948# server MUST NOT idle on the underlying transport after handshake completion,
4949# because the ApplicationData request has already been queued internally.
4950run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004951 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004952 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004953 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004954 0 \
4955 -c "Read from server: .* bytes read"
4956
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004957# Tests for version negotiation
4958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004959run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004960 "$P_SRV" \
4961 "$P_CLI" \
4962 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004963 -S "mbedtls_ssl_handshake returned" \
4964 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004965 -s "Protocol is TLSv1.2" \
4966 -c "Protocol is TLSv1.2"
4967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004968run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004969 "$P_SRV" \
4970 "$P_CLI max_version=tls1_1" \
4971 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004972 -S "mbedtls_ssl_handshake returned" \
4973 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004974 -s "Protocol is TLSv1.1" \
4975 -c "Protocol is TLSv1.1"
4976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004977run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004978 "$P_SRV max_version=tls1_1" \
4979 "$P_CLI" \
4980 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004981 -S "mbedtls_ssl_handshake returned" \
4982 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004983 -s "Protocol is TLSv1.1" \
4984 -c "Protocol is TLSv1.1"
4985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004986run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004987 "$P_SRV max_version=tls1_1" \
4988 "$P_CLI max_version=tls1_1" \
4989 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004990 -S "mbedtls_ssl_handshake returned" \
4991 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004992 -s "Protocol is TLSv1.1" \
4993 -c "Protocol is TLSv1.1"
4994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004995run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004996 "$P_SRV min_version=tls1_1" \
4997 "$P_CLI max_version=tls1_1" \
4998 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004999 -S "mbedtls_ssl_handshake returned" \
5000 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005001 -s "Protocol is TLSv1.1" \
5002 -c "Protocol is TLSv1.1"
5003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005004run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005005 "$P_SRV max_version=tls1_1" \
5006 "$P_CLI min_version=tls1_1" \
5007 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005008 -S "mbedtls_ssl_handshake returned" \
5009 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005010 -s "Protocol is TLSv1.1" \
5011 -c "Protocol is TLSv1.1"
5012
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005013run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005014 "$P_SRV max_version=tls1_1" \
5015 "$P_CLI min_version=tls1_2" \
5016 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005017 -s "mbedtls_ssl_handshake returned" \
5018 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005019 -c "SSL - Handshake protocol not within min/max boundaries"
5020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005021run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005022 "$P_SRV min_version=tls1_2" \
5023 "$P_CLI max_version=tls1_1" \
5024 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005025 -s "mbedtls_ssl_handshake returned" \
5026 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005027 -s "SSL - Handshake protocol not within min/max boundaries"
5028
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005029# Tests for ALPN extension
5030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005031run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005032 "$P_SRV debug_level=3" \
5033 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005034 0 \
5035 -C "client hello, adding alpn extension" \
5036 -S "found alpn extension" \
5037 -C "got an alert message, type: \\[2:120]" \
5038 -S "server hello, adding alpn extension" \
5039 -C "found alpn extension " \
5040 -C "Application Layer Protocol is" \
5041 -S "Application Layer Protocol is"
5042
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005043run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005044 "$P_SRV debug_level=3" \
5045 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005046 0 \
5047 -c "client hello, adding alpn extension" \
5048 -s "found alpn extension" \
5049 -C "got an alert message, type: \\[2:120]" \
5050 -S "server hello, adding alpn extension" \
5051 -C "found alpn extension " \
5052 -c "Application Layer Protocol is (none)" \
5053 -S "Application Layer Protocol is"
5054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005055run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005056 "$P_SRV debug_level=3 alpn=abc,1234" \
5057 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005058 0 \
5059 -C "client hello, adding alpn extension" \
5060 -S "found alpn extension" \
5061 -C "got an alert message, type: \\[2:120]" \
5062 -S "server hello, adding alpn extension" \
5063 -C "found alpn extension " \
5064 -C "Application Layer Protocol is" \
5065 -s "Application Layer Protocol is (none)"
5066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005067run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005068 "$P_SRV debug_level=3 alpn=abc,1234" \
5069 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005070 0 \
5071 -c "client hello, adding alpn extension" \
5072 -s "found alpn extension" \
5073 -C "got an alert message, type: \\[2:120]" \
5074 -s "server hello, adding alpn extension" \
5075 -c "found alpn extension" \
5076 -c "Application Layer Protocol is abc" \
5077 -s "Application Layer Protocol is abc"
5078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005079run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005080 "$P_SRV debug_level=3 alpn=abc,1234" \
5081 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005082 0 \
5083 -c "client hello, adding alpn extension" \
5084 -s "found alpn extension" \
5085 -C "got an alert message, type: \\[2:120]" \
5086 -s "server hello, adding alpn extension" \
5087 -c "found alpn extension" \
5088 -c "Application Layer Protocol is abc" \
5089 -s "Application Layer Protocol is abc"
5090
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005091run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005092 "$P_SRV debug_level=3 alpn=abc,1234" \
5093 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005094 0 \
5095 -c "client hello, adding alpn extension" \
5096 -s "found alpn extension" \
5097 -C "got an alert message, type: \\[2:120]" \
5098 -s "server hello, adding alpn extension" \
5099 -c "found alpn extension" \
5100 -c "Application Layer Protocol is 1234" \
5101 -s "Application Layer Protocol is 1234"
5102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005103run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005104 "$P_SRV debug_level=3 alpn=abc,123" \
5105 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005106 1 \
5107 -c "client hello, adding alpn extension" \
5108 -s "found alpn extension" \
5109 -c "got an alert message, type: \\[2:120]" \
5110 -S "server hello, adding alpn extension" \
5111 -C "found alpn extension" \
5112 -C "Application Layer Protocol is 1234" \
5113 -S "Application Layer Protocol is 1234"
5114
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02005115
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005116# Tests for keyUsage in leaf certificates, part 1:
5117# server-side certificate/suite selection
5118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005119run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005120 "$P_SRV key_file=data_files/server2.key \
5121 crt_file=data_files/server2.ku-ds.crt" \
5122 "$P_CLI" \
5123 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02005124 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005125
5126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005127run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005128 "$P_SRV key_file=data_files/server2.key \
5129 crt_file=data_files/server2.ku-ke.crt" \
5130 "$P_CLI" \
5131 0 \
5132 -c "Ciphersuite is TLS-RSA-WITH-"
5133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005134run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005135 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005136 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005137 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005138 1 \
5139 -C "Ciphersuite is "
5140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005141run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005142 "$P_SRV key_file=data_files/server5.key \
5143 crt_file=data_files/server5.ku-ds.crt" \
5144 "$P_CLI" \
5145 0 \
5146 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
5147
5148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005149run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005150 "$P_SRV key_file=data_files/server5.key \
5151 crt_file=data_files/server5.ku-ka.crt" \
5152 "$P_CLI" \
5153 0 \
5154 -c "Ciphersuite is TLS-ECDH-"
5155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005156run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005157 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005158 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005159 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005160 1 \
5161 -C "Ciphersuite is "
5162
5163# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005164# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005165
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005166run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005167 "$O_SRV -key data_files/server2.key \
5168 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005169 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005170 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5171 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005172 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005173 -C "Processing of the Certificate handshake message failed" \
5174 -c "Ciphersuite is TLS-"
5175
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005176run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005177 "$O_SRV -key data_files/server2.key \
5178 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005179 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005180 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5181 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005182 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005183 -C "Processing of the Certificate handshake message failed" \
5184 -c "Ciphersuite is TLS-"
5185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005186run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005187 "$O_SRV -key data_files/server2.key \
5188 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005189 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005190 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5191 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005192 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005193 -C "Processing of the Certificate handshake message failed" \
5194 -c "Ciphersuite is TLS-"
5195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005196run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005197 "$O_SRV -key data_files/server2.key \
5198 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005199 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005200 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5201 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005202 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005203 -c "Processing of the Certificate handshake message failed" \
5204 -C "Ciphersuite is TLS-"
5205
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01005206run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
5207 "$O_SRV -key data_files/server2.key \
5208 -cert data_files/server2.ku-ke.crt" \
5209 "$P_CLI debug_level=1 auth_mode=optional \
5210 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5211 0 \
5212 -c "bad certificate (usage extensions)" \
5213 -C "Processing of the Certificate handshake message failed" \
5214 -c "Ciphersuite is TLS-" \
5215 -c "! Usage does not match the keyUsage extension"
5216
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005217run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005218 "$O_SRV -key data_files/server2.key \
5219 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005220 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005221 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5222 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005223 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005224 -C "Processing of the Certificate handshake message failed" \
5225 -c "Ciphersuite is TLS-"
5226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005227run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005228 "$O_SRV -key data_files/server2.key \
5229 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005230 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005231 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5232 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005233 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005234 -c "Processing of the Certificate handshake message failed" \
5235 -C "Ciphersuite is TLS-"
5236
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01005237run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
5238 "$O_SRV -key data_files/server2.key \
5239 -cert data_files/server2.ku-ds.crt" \
5240 "$P_CLI debug_level=1 auth_mode=optional \
5241 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5242 0 \
5243 -c "bad certificate (usage extensions)" \
5244 -C "Processing of the Certificate handshake message failed" \
5245 -c "Ciphersuite is TLS-" \
5246 -c "! Usage does not match the keyUsage extension"
5247
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005248# Tests for keyUsage in leaf certificates, part 3:
5249# server-side checking of client cert
5250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005251run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005252 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005253 "$O_CLI -key data_files/server2.key \
5254 -cert data_files/server2.ku-ds.crt" \
5255 0 \
5256 -S "bad certificate (usage extensions)" \
5257 -S "Processing of the Certificate handshake message failed"
5258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005259run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005260 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005261 "$O_CLI -key data_files/server2.key \
5262 -cert data_files/server2.ku-ke.crt" \
5263 0 \
5264 -s "bad certificate (usage extensions)" \
5265 -S "Processing of the Certificate handshake message failed"
5266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005267run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005268 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005269 "$O_CLI -key data_files/server2.key \
5270 -cert data_files/server2.ku-ke.crt" \
5271 1 \
5272 -s "bad certificate (usage extensions)" \
5273 -s "Processing of the Certificate handshake message failed"
5274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005275run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005276 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005277 "$O_CLI -key data_files/server5.key \
5278 -cert data_files/server5.ku-ds.crt" \
5279 0 \
5280 -S "bad certificate (usage extensions)" \
5281 -S "Processing of the Certificate handshake message failed"
5282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005283run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005284 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005285 "$O_CLI -key data_files/server5.key \
5286 -cert data_files/server5.ku-ka.crt" \
5287 0 \
5288 -s "bad certificate (usage extensions)" \
5289 -S "Processing of the Certificate handshake message failed"
5290
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005291# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
5292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005293run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005294 "$P_SRV key_file=data_files/server5.key \
5295 crt_file=data_files/server5.eku-srv.crt" \
5296 "$P_CLI" \
5297 0
5298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005299run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005300 "$P_SRV key_file=data_files/server5.key \
5301 crt_file=data_files/server5.eku-srv.crt" \
5302 "$P_CLI" \
5303 0
5304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005305run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005306 "$P_SRV key_file=data_files/server5.key \
5307 crt_file=data_files/server5.eku-cs_any.crt" \
5308 "$P_CLI" \
5309 0
5310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005311run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005312 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005313 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005314 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005315 1
5316
5317# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005319run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005320 "$O_SRV -key data_files/server5.key \
5321 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005322 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005323 0 \
5324 -C "bad certificate (usage extensions)" \
5325 -C "Processing of the Certificate handshake message failed" \
5326 -c "Ciphersuite is TLS-"
5327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005328run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005329 "$O_SRV -key data_files/server5.key \
5330 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005331 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005332 0 \
5333 -C "bad certificate (usage extensions)" \
5334 -C "Processing of the Certificate handshake message failed" \
5335 -c "Ciphersuite is TLS-"
5336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005337run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005338 "$O_SRV -key data_files/server5.key \
5339 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005340 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005341 0 \
5342 -C "bad certificate (usage extensions)" \
5343 -C "Processing of the Certificate handshake message failed" \
5344 -c "Ciphersuite is TLS-"
5345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005346run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005347 "$O_SRV -key data_files/server5.key \
5348 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005349 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005350 1 \
5351 -c "bad certificate (usage extensions)" \
5352 -c "Processing of the Certificate handshake message failed" \
5353 -C "Ciphersuite is TLS-"
5354
5355# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005357run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005358 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005359 "$O_CLI -key data_files/server5.key \
5360 -cert data_files/server5.eku-cli.crt" \
5361 0 \
5362 -S "bad certificate (usage extensions)" \
5363 -S "Processing of the Certificate handshake message failed"
5364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005365run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005366 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005367 "$O_CLI -key data_files/server5.key \
5368 -cert data_files/server5.eku-srv_cli.crt" \
5369 0 \
5370 -S "bad certificate (usage extensions)" \
5371 -S "Processing of the Certificate handshake message failed"
5372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005373run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005374 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005375 "$O_CLI -key data_files/server5.key \
5376 -cert data_files/server5.eku-cs_any.crt" \
5377 0 \
5378 -S "bad certificate (usage extensions)" \
5379 -S "Processing of the Certificate handshake message failed"
5380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005381run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005382 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005383 "$O_CLI -key data_files/server5.key \
5384 -cert data_files/server5.eku-cs.crt" \
5385 0 \
5386 -s "bad certificate (usage extensions)" \
5387 -S "Processing of the Certificate handshake message failed"
5388
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005389run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005390 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005391 "$O_CLI -key data_files/server5.key \
5392 -cert data_files/server5.eku-cs.crt" \
5393 1 \
5394 -s "bad certificate (usage extensions)" \
5395 -s "Processing of the Certificate handshake message failed"
5396
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005397# Tests for DHM parameters loading
5398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005399run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005400 "$P_SRV" \
5401 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5402 debug_level=3" \
5403 0 \
5404 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005405 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005406
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005407run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005408 "$P_SRV dhm_file=data_files/dhparams.pem" \
5409 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5410 debug_level=3" \
5411 0 \
5412 -c "value of 'DHM: P ' (1024 bits)" \
5413 -c "value of 'DHM: G ' (2 bits)"
5414
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005415# Tests for DHM client-side size checking
5416
5417run_test "DHM size: server default, client default, OK" \
5418 "$P_SRV" \
5419 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5420 debug_level=1" \
5421 0 \
5422 -C "DHM prime too short:"
5423
5424run_test "DHM size: server default, client 2048, OK" \
5425 "$P_SRV" \
5426 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5427 debug_level=1 dhmlen=2048" \
5428 0 \
5429 -C "DHM prime too short:"
5430
5431run_test "DHM size: server 1024, client default, OK" \
5432 "$P_SRV dhm_file=data_files/dhparams.pem" \
5433 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5434 debug_level=1" \
5435 0 \
5436 -C "DHM prime too short:"
5437
5438run_test "DHM size: server 1000, client default, rejected" \
5439 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5440 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5441 debug_level=1" \
5442 1 \
5443 -c "DHM prime too short:"
5444
5445run_test "DHM size: server default, client 2049, rejected" \
5446 "$P_SRV" \
5447 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5448 debug_level=1 dhmlen=2049" \
5449 1 \
5450 -c "DHM prime too short:"
5451
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005452# Tests for PSK callback
5453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005454run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005455 "$P_SRV psk=abc123 psk_identity=foo" \
5456 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5457 psk_identity=foo psk=abc123" \
5458 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005459 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005460 -S "SSL - Unknown identity received" \
5461 -S "SSL - Verification of the message MAC failed"
5462
Hanno Beckerf7027512018-10-23 15:27:39 +01005463requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5464run_test "PSK callback: opaque psk on client, no callback" \
5465 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5466 "$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 +00005467 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005468 0 \
5469 -c "skip PMS generation for opaque PSK"\
5470 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005471 -C "session hash for extended master secret"\
5472 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005473 -S "SSL - None of the common ciphersuites is usable" \
5474 -S "SSL - Unknown identity received" \
5475 -S "SSL - Verification of the message MAC failed"
5476
5477requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5478run_test "PSK callback: opaque psk on client, no callback, SHA-384" \
5479 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5480 "$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 +00005481 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005482 0 \
5483 -c "skip PMS generation for opaque PSK"\
5484 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005485 -C "session hash for extended master secret"\
5486 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005487 -S "SSL - None of the common ciphersuites is usable" \
5488 -S "SSL - Unknown identity received" \
5489 -S "SSL - Verification of the message MAC failed"
5490
5491requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5492run_test "PSK callback: opaque psk on client, no callback, EMS" \
5493 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5494 "$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 +00005495 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005496 0 \
5497 -c "skip PMS generation for opaque PSK"\
5498 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005499 -c "session hash for extended master secret"\
5500 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005501 -S "SSL - None of the common ciphersuites is usable" \
5502 -S "SSL - Unknown identity received" \
5503 -S "SSL - Verification of the message MAC failed"
5504
5505requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5506run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \
5507 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5508 "$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 +00005509 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005510 0 \
5511 -c "skip PMS generation for opaque PSK"\
5512 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005513 -c "session hash for extended master secret"\
5514 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005515 -S "SSL - None of the common ciphersuites is usable" \
5516 -S "SSL - Unknown identity received" \
5517 -S "SSL - Verification of the message MAC failed"
5518
Hanno Becker28c79dc2018-10-26 13:15:08 +01005519requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5520run_test "PSK callback: raw psk on client, static opaque on server, no callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005521 "$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 +01005522 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5523 psk_identity=foo psk=abc123" \
5524 0 \
5525 -C "skip PMS generation for opaque PSK"\
5526 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005527 -C "session hash for extended master secret"\
5528 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005529 -S "SSL - None of the common ciphersuites is usable" \
5530 -S "SSL - Unknown identity received" \
5531 -S "SSL - Verification of the message MAC failed"
5532
5533requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5534run_test "PSK callback: raw psk on client, static opaque on server, no callback, SHA-384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005535 "$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 +01005536 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5537 psk_identity=foo psk=abc123" \
5538 0 \
5539 -C "skip PMS generation for opaque PSK"\
5540 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005541 -C "session hash for extended master secret"\
5542 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005543 -S "SSL - None of the common ciphersuites is usable" \
5544 -S "SSL - Unknown identity received" \
5545 -S "SSL - Verification of the message MAC failed"
5546
5547requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5548run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005549 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005550 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5551 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5552 psk_identity=foo psk=abc123 extended_ms=1" \
5553 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005554 -c "session hash for extended master secret"\
5555 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005556 -C "skip PMS generation for opaque PSK"\
5557 -s "skip PMS generation for opaque PSK"\
5558 -S "SSL - None of the common ciphersuites is usable" \
5559 -S "SSL - Unknown identity received" \
5560 -S "SSL - Verification of the message MAC failed"
5561
5562requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5563run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS, SHA384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005564 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005565 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5566 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5567 psk_identity=foo psk=abc123 extended_ms=1" \
5568 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005569 -c "session hash for extended master secret"\
5570 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005571 -C "skip PMS generation for opaque PSK"\
5572 -s "skip PMS generation for opaque PSK"\
5573 -S "SSL - None of the common ciphersuites is usable" \
5574 -S "SSL - Unknown identity received" \
5575 -S "SSL - Verification of the message MAC failed"
5576
5577requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5578run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005579 "$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 +01005580 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5581 psk_identity=def psk=beef" \
5582 0 \
5583 -C "skip PMS generation for opaque PSK"\
5584 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005585 -C "session hash for extended master secret"\
5586 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005587 -S "SSL - None of the common ciphersuites is usable" \
5588 -S "SSL - Unknown identity received" \
5589 -S "SSL - Verification of the message MAC failed"
5590
5591requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5592run_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 +00005593 "$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 +01005594 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5595 psk_identity=def psk=beef" \
5596 0 \
5597 -C "skip PMS generation for opaque PSK"\
5598 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005599 -C "session hash for extended master secret"\
5600 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005601 -S "SSL - None of the common ciphersuites is usable" \
5602 -S "SSL - Unknown identity received" \
5603 -S "SSL - Verification of the message MAC failed"
5604
5605requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5606run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005607 "$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 +01005608 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5609 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5610 psk_identity=abc psk=dead extended_ms=1" \
5611 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005612 -c "session hash for extended master secret"\
5613 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005614 -C "skip PMS generation for opaque PSK"\
5615 -s "skip PMS generation for opaque PSK"\
5616 -S "SSL - None of the common ciphersuites is usable" \
5617 -S "SSL - Unknown identity received" \
5618 -S "SSL - Verification of the message MAC failed"
5619
5620requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5621run_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 +00005622 "$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 +01005623 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5624 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5625 psk_identity=abc psk=dead extended_ms=1" \
5626 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005627 -c "session hash for extended master secret"\
5628 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005629 -C "skip PMS generation for opaque PSK"\
5630 -s "skip PMS generation for opaque PSK"\
5631 -S "SSL - None of the common ciphersuites is usable" \
5632 -S "SSL - Unknown identity received" \
5633 -S "SSL - Verification of the message MAC failed"
5634
5635requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5636run_test "PSK callback: raw psk on client, mismatching static raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005637 "$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 +01005638 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5639 psk_identity=def psk=beef" \
5640 0 \
5641 -C "skip PMS generation for opaque PSK"\
5642 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005643 -C "session hash for extended master secret"\
5644 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005645 -S "SSL - None of the common ciphersuites is usable" \
5646 -S "SSL - Unknown identity received" \
5647 -S "SSL - Verification of the message MAC failed"
5648
5649requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5650run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005651 "$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 +01005652 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5653 psk_identity=def psk=beef" \
5654 0 \
5655 -C "skip PMS generation for opaque PSK"\
5656 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005657 -C "session hash for extended master secret"\
5658 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005659 -S "SSL - None of the common ciphersuites is usable" \
5660 -S "SSL - Unknown identity received" \
5661 -S "SSL - Verification of the message MAC failed"
5662
5663requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5664run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, raw PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005665 "$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 +01005666 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5667 psk_identity=def psk=beef" \
5668 0 \
5669 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005670 -C "session hash for extended master secret"\
5671 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005672 -S "SSL - None of the common ciphersuites is usable" \
5673 -S "SSL - Unknown identity received" \
5674 -S "SSL - Verification of the message MAC failed"
5675
5676requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5677run_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 +00005678 "$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 +01005679 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5680 psk_identity=def psk=beef" \
5681 0 \
5682 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005683 -C "session hash for extended master secret"\
5684 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005685 -S "SSL - None of the common ciphersuites is usable" \
5686 -S "SSL - Unknown identity received" \
5687 -S "SSL - Verification of the message MAC failed"
5688
5689requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5690run_test "PSK callback: raw psk on client, matching opaque PSK on server, wrong opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005691 "$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 +01005692 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5693 psk_identity=def psk=beef" \
5694 1 \
5695 -s "SSL - Verification of the message MAC failed"
5696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005697run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005698 "$P_SRV" \
5699 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5700 psk_identity=foo psk=abc123" \
5701 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005702 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005703 -S "SSL - Unknown identity received" \
5704 -S "SSL - Verification of the message MAC failed"
5705
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005706run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005707 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5708 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5709 psk_identity=foo psk=abc123" \
5710 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005711 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005712 -s "SSL - Unknown identity received" \
5713 -S "SSL - Verification of the message MAC failed"
5714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005715run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005716 "$P_SRV psk_list=abc,dead,def,beef" \
5717 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5718 psk_identity=abc psk=dead" \
5719 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005720 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005721 -S "SSL - Unknown identity received" \
5722 -S "SSL - Verification of the message MAC failed"
5723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005724run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005725 "$P_SRV psk_list=abc,dead,def,beef" \
5726 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5727 psk_identity=def psk=beef" \
5728 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005729 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005730 -S "SSL - Unknown identity received" \
5731 -S "SSL - Verification of the message MAC failed"
5732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005733run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005734 "$P_SRV psk_list=abc,dead,def,beef" \
5735 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5736 psk_identity=ghi psk=beef" \
5737 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005738 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005739 -s "SSL - Unknown identity received" \
5740 -S "SSL - Verification of the message MAC failed"
5741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005742run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005743 "$P_SRV psk_list=abc,dead,def,beef" \
5744 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5745 psk_identity=abc psk=beef" \
5746 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005747 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005748 -S "SSL - Unknown identity received" \
5749 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005750
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005751# Tests for EC J-PAKE
5752
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005753requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005754run_test "ECJPAKE: client not configured" \
5755 "$P_SRV debug_level=3" \
5756 "$P_CLI debug_level=3" \
5757 0 \
5758 -C "add ciphersuite: c0ff" \
5759 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005760 -S "found ecjpake kkpp extension" \
5761 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005762 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005763 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005764 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005765 -S "None of the common ciphersuites is usable"
5766
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005767requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005768run_test "ECJPAKE: server not configured" \
5769 "$P_SRV debug_level=3" \
5770 "$P_CLI debug_level=3 ecjpake_pw=bla \
5771 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5772 1 \
5773 -c "add ciphersuite: c0ff" \
5774 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005775 -s "found ecjpake kkpp extension" \
5776 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005777 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005778 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005779 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005780 -s "None of the common ciphersuites is usable"
5781
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005782requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005783run_test "ECJPAKE: working, TLS" \
5784 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5785 "$P_CLI debug_level=3 ecjpake_pw=bla \
5786 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005787 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005788 -c "add ciphersuite: c0ff" \
5789 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005790 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005791 -s "found ecjpake kkpp extension" \
5792 -S "skip ecjpake kkpp extension" \
5793 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005794 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005795 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005796 -S "None of the common ciphersuites is usable" \
5797 -S "SSL - Verification of the message MAC failed"
5798
Janos Follath74537a62016-09-02 13:45:28 +01005799server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005800requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005801run_test "ECJPAKE: password mismatch, TLS" \
5802 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5803 "$P_CLI debug_level=3 ecjpake_pw=bad \
5804 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5805 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005806 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005807 -s "SSL - Verification of the message MAC failed"
5808
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005809requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005810run_test "ECJPAKE: working, DTLS" \
5811 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5812 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5813 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5814 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005815 -c "re-using cached ecjpake parameters" \
5816 -S "SSL - Verification of the message MAC failed"
5817
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005818requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005819run_test "ECJPAKE: working, DTLS, no cookie" \
5820 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5821 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5822 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5823 0 \
5824 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005825 -S "SSL - Verification of the message MAC failed"
5826
Janos Follath74537a62016-09-02 13:45:28 +01005827server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005828requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005829run_test "ECJPAKE: password mismatch, DTLS" \
5830 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5831 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5832 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5833 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005834 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005835 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005836
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005837# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005838requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005839run_test "ECJPAKE: working, DTLS, nolog" \
5840 "$P_SRV dtls=1 ecjpake_pw=bla" \
5841 "$P_CLI dtls=1 ecjpake_pw=bla \
5842 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5843 0
5844
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005845# Tests for ciphersuites per version
5846
Janos Follathe2681a42016-03-07 15:57:05 +00005847requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005848requires_config_enabled MBEDTLS_CAMELLIA_C
5849requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005850run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005851 "$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 +02005852 "$P_CLI force_version=ssl3" \
5853 0 \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005854 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005855
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005856requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5857requires_config_enabled MBEDTLS_CAMELLIA_C
5858requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005859run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005860 "$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 +01005861 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005862 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005863 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005864
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005865requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5866requires_config_enabled MBEDTLS_CAMELLIA_C
5867requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005868run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005869 "$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 +02005870 "$P_CLI force_version=tls1_1" \
5871 0 \
5872 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5873
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005874requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5875requires_config_enabled MBEDTLS_CAMELLIA_C
5876requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005877run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005878 "$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 +02005879 "$P_CLI force_version=tls1_2" \
5880 0 \
5881 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5882
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005883# Test for ClientHello without extensions
5884
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005885requires_gnutls
Manuel Pégourié-Gonnardbc4da292020-01-30 12:45:14 +01005886run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard77cbeff2020-01-30 10:58:57 +01005887 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005888 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005889 0 \
5890 -s "dumping 'client hello extensions' (0 bytes)"
5891
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005892# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005893
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005894run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005895 "$P_SRV" \
5896 "$P_CLI request_size=100" \
5897 0 \
5898 -s "Read from client: 100 bytes read$"
5899
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005900run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005901 "$P_SRV" \
5902 "$P_CLI request_size=500" \
5903 0 \
5904 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005905
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005906# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005907
Janos Follathe2681a42016-03-07 15:57:05 +00005908requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005909run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005910 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005911 "$P_CLI request_size=1 force_version=ssl3 \
5912 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5913 0 \
5914 -s "Read from client: 1 bytes read"
5915
Janos Follathe2681a42016-03-07 15:57:05 +00005916requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005917run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005918 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005919 "$P_CLI request_size=1 force_version=ssl3 \
5920 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5921 0 \
5922 -s "Read from client: 1 bytes read"
5923
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005924run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005925 "$P_SRV" \
5926 "$P_CLI request_size=1 force_version=tls1 \
5927 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5928 0 \
5929 -s "Read from client: 1 bytes read"
5930
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005931run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005932 "$P_SRV" \
5933 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5934 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5935 0 \
5936 -s "Read from client: 1 bytes read"
5937
Hanno Becker32c55012017-11-10 08:42:54 +00005938requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005939run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005940 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005941 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005942 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005943 0 \
5944 -s "Read from client: 1 bytes read"
5945
Hanno Becker32c55012017-11-10 08:42:54 +00005946requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005947run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005948 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005949 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005950 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005951 0 \
5952 -s "Read from client: 1 bytes read"
5953
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005954run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005955 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005956 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005957 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5958 0 \
5959 -s "Read from client: 1 bytes read"
5960
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005961run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005962 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5963 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005964 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005965 0 \
5966 -s "Read from client: 1 bytes read"
5967
5968requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005969run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005970 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005971 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005972 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005973 0 \
5974 -s "Read from client: 1 bytes read"
5975
Hanno Becker8501f982017-11-10 08:59:04 +00005976requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005977run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005978 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5979 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5980 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005981 0 \
5982 -s "Read from client: 1 bytes read"
5983
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005984run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005985 "$P_SRV" \
5986 "$P_CLI request_size=1 force_version=tls1_1 \
5987 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5988 0 \
5989 -s "Read from client: 1 bytes read"
5990
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005991run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005992 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005993 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005994 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005995 0 \
5996 -s "Read from client: 1 bytes read"
5997
5998requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005999run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006000 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006001 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006002 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006003 0 \
6004 -s "Read from client: 1 bytes read"
6005
6006requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006007run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006008 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006009 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006010 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006011 0 \
6012 -s "Read from client: 1 bytes read"
6013
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006014run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006015 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006016 "$P_CLI request_size=1 force_version=tls1_1 \
6017 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6018 0 \
6019 -s "Read from client: 1 bytes read"
6020
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006021run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00006022 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006023 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006024 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006025 0 \
6026 -s "Read from client: 1 bytes read"
6027
Hanno Becker8501f982017-11-10 08:59:04 +00006028requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006029run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006030 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006031 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006032 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006033 0 \
6034 -s "Read from client: 1 bytes read"
6035
Hanno Becker32c55012017-11-10 08:42:54 +00006036requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006037run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006038 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006039 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006040 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006041 0 \
6042 -s "Read from client: 1 bytes read"
6043
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006044run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006045 "$P_SRV" \
6046 "$P_CLI request_size=1 force_version=tls1_2 \
6047 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6048 0 \
6049 -s "Read from client: 1 bytes read"
6050
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006051run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006052 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00006053 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006054 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006055 0 \
6056 -s "Read from client: 1 bytes read"
6057
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006058run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006059 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006060 "$P_CLI request_size=1 force_version=tls1_2 \
6061 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006062 0 \
6063 -s "Read from client: 1 bytes read"
6064
Hanno Becker32c55012017-11-10 08:42:54 +00006065requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006066run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006067 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006068 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006069 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006070 0 \
6071 -s "Read from client: 1 bytes read"
6072
Hanno Becker8501f982017-11-10 08:59:04 +00006073requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006074run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006075 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006076 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006077 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006078 0 \
6079 -s "Read from client: 1 bytes read"
6080
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006081run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006082 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006083 "$P_CLI request_size=1 force_version=tls1_2 \
6084 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6085 0 \
6086 -s "Read from client: 1 bytes read"
6087
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006088run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006089 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006090 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006091 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00006092 0 \
6093 -s "Read from client: 1 bytes read"
6094
Hanno Becker32c55012017-11-10 08:42:54 +00006095requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006096run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006097 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006098 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006099 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006100 0 \
6101 -s "Read from client: 1 bytes read"
6102
Hanno Becker8501f982017-11-10 08:59:04 +00006103requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006104run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006105 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006106 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006107 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006108 0 \
6109 -s "Read from client: 1 bytes read"
6110
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006111run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006112 "$P_SRV" \
6113 "$P_CLI request_size=1 force_version=tls1_2 \
6114 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6115 0 \
6116 -s "Read from client: 1 bytes read"
6117
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006118run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006119 "$P_SRV" \
6120 "$P_CLI request_size=1 force_version=tls1_2 \
6121 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6122 0 \
6123 -s "Read from client: 1 bytes read"
6124
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006125# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00006126
6127requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006128run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006129 "$P_SRV dtls=1 force_version=dtls1" \
6130 "$P_CLI dtls=1 request_size=1 \
6131 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6132 0 \
6133 -s "Read from client: 1 bytes read"
6134
6135requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006136run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00006137 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
6138 "$P_CLI dtls=1 request_size=1 \
6139 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6140 0 \
6141 -s "Read from client: 1 bytes read"
6142
6143requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6144requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006145run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006146 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
6147 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00006148 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6149 0 \
6150 -s "Read from client: 1 bytes read"
6151
6152requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6153requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006154run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006155 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006156 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006157 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00006158 0 \
6159 -s "Read from client: 1 bytes read"
6160
6161requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006162run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00006163 "$P_SRV dtls=1 force_version=dtls1_2" \
6164 "$P_CLI dtls=1 request_size=1 \
6165 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6166 0 \
6167 -s "Read from client: 1 bytes read"
6168
6169requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006170run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006171 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006172 "$P_CLI dtls=1 request_size=1 \
6173 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6174 0 \
6175 -s "Read from client: 1 bytes read"
6176
6177requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6178requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006179run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006180 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00006181 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006182 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00006183 0 \
6184 -s "Read from client: 1 bytes read"
6185
6186requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6187requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006188run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006189 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006190 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006191 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00006192 0 \
6193 -s "Read from client: 1 bytes read"
6194
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006195# Tests for small server packets
6196
6197requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6198run_test "Small server packet SSLv3 BlockCipher" \
6199 "$P_SRV response_size=1 min_version=ssl3" \
6200 "$P_CLI force_version=ssl3 \
6201 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6202 0 \
6203 -c "Read from server: 1 bytes read"
6204
6205requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6206run_test "Small server packet SSLv3 StreamCipher" \
6207 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6208 "$P_CLI force_version=ssl3 \
6209 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6210 0 \
6211 -c "Read from server: 1 bytes read"
6212
6213run_test "Small server packet TLS 1.0 BlockCipher" \
6214 "$P_SRV response_size=1" \
6215 "$P_CLI force_version=tls1 \
6216 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6217 0 \
6218 -c "Read from server: 1 bytes read"
6219
6220run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
6221 "$P_SRV response_size=1" \
6222 "$P_CLI force_version=tls1 etm=0 \
6223 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6224 0 \
6225 -c "Read from server: 1 bytes read"
6226
6227requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6228run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
6229 "$P_SRV response_size=1 trunc_hmac=1" \
6230 "$P_CLI force_version=tls1 \
6231 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6232 0 \
6233 -c "Read from server: 1 bytes read"
6234
6235requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6236run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
6237 "$P_SRV response_size=1 trunc_hmac=1" \
6238 "$P_CLI force_version=tls1 \
6239 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6240 0 \
6241 -c "Read from server: 1 bytes read"
6242
6243run_test "Small server packet TLS 1.0 StreamCipher" \
6244 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6245 "$P_CLI force_version=tls1 \
6246 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6247 0 \
6248 -c "Read from server: 1 bytes read"
6249
6250run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
6251 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6252 "$P_CLI force_version=tls1 \
6253 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6254 0 \
6255 -c "Read from server: 1 bytes read"
6256
6257requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6258run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
6259 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6260 "$P_CLI force_version=tls1 \
6261 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6262 0 \
6263 -c "Read from server: 1 bytes read"
6264
6265requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6266run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6267 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6268 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6269 trunc_hmac=1 etm=0" \
6270 0 \
6271 -c "Read from server: 1 bytes read"
6272
6273run_test "Small server packet TLS 1.1 BlockCipher" \
6274 "$P_SRV response_size=1" \
6275 "$P_CLI force_version=tls1_1 \
6276 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6277 0 \
6278 -c "Read from server: 1 bytes read"
6279
6280run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
6281 "$P_SRV response_size=1" \
6282 "$P_CLI force_version=tls1_1 \
6283 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
6284 0 \
6285 -c "Read from server: 1 bytes read"
6286
6287requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6288run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
6289 "$P_SRV response_size=1 trunc_hmac=1" \
6290 "$P_CLI force_version=tls1_1 \
6291 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6292 0 \
6293 -c "Read from server: 1 bytes read"
6294
6295requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6296run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6297 "$P_SRV response_size=1 trunc_hmac=1" \
6298 "$P_CLI force_version=tls1_1 \
6299 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6300 0 \
6301 -c "Read from server: 1 bytes read"
6302
6303run_test "Small server packet TLS 1.1 StreamCipher" \
6304 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6305 "$P_CLI force_version=tls1_1 \
6306 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6307 0 \
6308 -c "Read from server: 1 bytes read"
6309
6310run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
6311 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6312 "$P_CLI force_version=tls1_1 \
6313 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6314 0 \
6315 -c "Read from server: 1 bytes read"
6316
6317requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6318run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
6319 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6320 "$P_CLI force_version=tls1_1 \
6321 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6322 0 \
6323 -c "Read from server: 1 bytes read"
6324
6325requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6326run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6327 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6328 "$P_CLI force_version=tls1_1 \
6329 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6330 0 \
6331 -c "Read from server: 1 bytes read"
6332
6333run_test "Small server packet TLS 1.2 BlockCipher" \
6334 "$P_SRV response_size=1" \
6335 "$P_CLI force_version=tls1_2 \
6336 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6337 0 \
6338 -c "Read from server: 1 bytes read"
6339
6340run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
6341 "$P_SRV response_size=1" \
6342 "$P_CLI force_version=tls1_2 \
6343 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
6344 0 \
6345 -c "Read from server: 1 bytes read"
6346
6347run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
6348 "$P_SRV response_size=1" \
6349 "$P_CLI force_version=tls1_2 \
6350 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6351 0 \
6352 -c "Read from server: 1 bytes read"
6353
6354requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6355run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
6356 "$P_SRV response_size=1 trunc_hmac=1" \
6357 "$P_CLI force_version=tls1_2 \
6358 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6359 0 \
6360 -c "Read from server: 1 bytes read"
6361
6362requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6363run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6364 "$P_SRV response_size=1 trunc_hmac=1" \
6365 "$P_CLI force_version=tls1_2 \
6366 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6367 0 \
6368 -c "Read from server: 1 bytes read"
6369
6370run_test "Small server packet TLS 1.2 StreamCipher" \
6371 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6372 "$P_CLI force_version=tls1_2 \
6373 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6374 0 \
6375 -c "Read from server: 1 bytes read"
6376
6377run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
6378 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6379 "$P_CLI force_version=tls1_2 \
6380 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6381 0 \
6382 -c "Read from server: 1 bytes read"
6383
6384requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6385run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
6386 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6387 "$P_CLI force_version=tls1_2 \
6388 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6389 0 \
6390 -c "Read from server: 1 bytes read"
6391
6392requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6393run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6394 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6395 "$P_CLI force_version=tls1_2 \
6396 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6397 0 \
6398 -c "Read from server: 1 bytes read"
6399
6400run_test "Small server packet TLS 1.2 AEAD" \
6401 "$P_SRV response_size=1" \
6402 "$P_CLI force_version=tls1_2 \
6403 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6404 0 \
6405 -c "Read from server: 1 bytes read"
6406
6407run_test "Small server packet TLS 1.2 AEAD shorter tag" \
6408 "$P_SRV response_size=1" \
6409 "$P_CLI force_version=tls1_2 \
6410 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6411 0 \
6412 -c "Read from server: 1 bytes read"
6413
6414# Tests for small server packets in DTLS
6415
6416requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6417run_test "Small server packet DTLS 1.0" \
6418 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
6419 "$P_CLI dtls=1 \
6420 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6421 0 \
6422 -c "Read from server: 1 bytes read"
6423
6424requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6425run_test "Small server packet DTLS 1.0, without EtM" \
6426 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
6427 "$P_CLI dtls=1 \
6428 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6429 0 \
6430 -c "Read from server: 1 bytes read"
6431
6432requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6433requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6434run_test "Small server packet DTLS 1.0, truncated hmac" \
6435 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
6436 "$P_CLI dtls=1 trunc_hmac=1 \
6437 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6438 0 \
6439 -c "Read from server: 1 bytes read"
6440
6441requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6442requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6443run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
6444 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
6445 "$P_CLI dtls=1 \
6446 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
6447 0 \
6448 -c "Read from server: 1 bytes read"
6449
6450requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6451run_test "Small server packet DTLS 1.2" \
6452 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
6453 "$P_CLI dtls=1 \
6454 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6455 0 \
6456 -c "Read from server: 1 bytes read"
6457
6458requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6459run_test "Small server packet DTLS 1.2, without EtM" \
6460 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
6461 "$P_CLI dtls=1 \
6462 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6463 0 \
6464 -c "Read from server: 1 bytes read"
6465
6466requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6467requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6468run_test "Small server packet DTLS 1.2, truncated hmac" \
6469 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
6470 "$P_CLI dtls=1 \
6471 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6472 0 \
6473 -c "Read from server: 1 bytes read"
6474
6475requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6476requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6477run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
6478 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
6479 "$P_CLI dtls=1 \
6480 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
6481 0 \
6482 -c "Read from server: 1 bytes read"
6483
Janos Follath00efff72016-05-06 13:48:23 +01006484# A test for extensions in SSLv3
6485
6486requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6487run_test "SSLv3 with extensions, server side" \
6488 "$P_SRV min_version=ssl3 debug_level=3" \
6489 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
6490 0 \
6491 -S "dumping 'client hello extensions'" \
6492 -S "server hello, total extension length:"
6493
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006494# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006495
Angus Grattonc4dd0732018-04-11 16:28:39 +10006496# How many fragments do we expect to write $1 bytes?
6497fragments_for_write() {
6498 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
6499}
6500
Janos Follathe2681a42016-03-07 15:57:05 +00006501requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006502run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01006503 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006504 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006505 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6506 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006507 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6508 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006509
Janos Follathe2681a42016-03-07 15:57:05 +00006510requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006511run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006512 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006513 "$P_CLI request_size=16384 force_version=ssl3 \
6514 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6515 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006516 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6517 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006518
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006519run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006520 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006521 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006522 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6523 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006524 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6525 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006526
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006527run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006528 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006529 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
6530 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6531 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006532 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006533
Hanno Becker32c55012017-11-10 08:42:54 +00006534requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006535run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006536 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006537 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006538 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006539 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006540 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6541 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006542
Hanno Becker32c55012017-11-10 08:42:54 +00006543requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006544run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006545 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006546 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006547 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006548 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006549 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006550
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006551run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006552 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006553 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006554 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6555 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006556 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006557
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006558run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006559 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6560 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006561 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006562 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006563 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006564
6565requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006566run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006567 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006568 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006569 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006570 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006571 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006572
Hanno Becker278fc7a2017-11-10 09:16:28 +00006573requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006574run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006575 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006576 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006577 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006578 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006579 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6580 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006581
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006582run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006583 "$P_SRV" \
6584 "$P_CLI request_size=16384 force_version=tls1_1 \
6585 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6586 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006587 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6588 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006589
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006590run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006591 "$P_SRV" \
6592 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6593 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006594 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006595 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006596
Hanno Becker32c55012017-11-10 08:42:54 +00006597requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006598run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006599 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006600 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006601 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006602 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006603 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006604
Hanno Becker32c55012017-11-10 08:42:54 +00006605requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006606run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006607 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006608 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006609 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006610 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006611 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006612
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006613run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006614 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6615 "$P_CLI request_size=16384 force_version=tls1_1 \
6616 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6617 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006618 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6619 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006620
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006621run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006622 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006623 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006624 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006625 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006626 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6627 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006628
Hanno Becker278fc7a2017-11-10 09:16:28 +00006629requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006630run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006631 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006632 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006633 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006634 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006635 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006636
Hanno Becker278fc7a2017-11-10 09:16:28 +00006637requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006638run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006639 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006640 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006641 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006642 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006643 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6644 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006645
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006646run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006647 "$P_SRV" \
6648 "$P_CLI request_size=16384 force_version=tls1_2 \
6649 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6650 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006651 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6652 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006653
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006654run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006655 "$P_SRV" \
6656 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6657 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6658 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006659 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006660
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006661run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006662 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006663 "$P_CLI request_size=16384 force_version=tls1_2 \
6664 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006665 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006666 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6667 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006668
Hanno Becker32c55012017-11-10 08:42:54 +00006669requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006670run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006671 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006672 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006673 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006674 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006675 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006676
Hanno Becker278fc7a2017-11-10 09:16:28 +00006677requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006678run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006679 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006680 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006681 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006682 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006683 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6684 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006685
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006686run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006687 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006688 "$P_CLI request_size=16384 force_version=tls1_2 \
6689 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6690 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006691 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6692 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006693
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006694run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006695 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006696 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006697 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6698 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006699 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006700
Hanno Becker32c55012017-11-10 08:42:54 +00006701requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006702run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006703 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006704 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006705 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006706 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006707 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006708
Hanno Becker278fc7a2017-11-10 09:16:28 +00006709requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006710run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006711 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006712 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006713 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006714 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006715 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6716 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006717
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006718run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006719 "$P_SRV" \
6720 "$P_CLI request_size=16384 force_version=tls1_2 \
6721 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6722 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006723 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6724 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006725
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006726run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006727 "$P_SRV" \
6728 "$P_CLI request_size=16384 force_version=tls1_2 \
6729 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6730 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006731 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6732 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006733
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006734# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006735requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6736run_test "Large server packet SSLv3 StreamCipher" \
6737 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6738 "$P_CLI force_version=ssl3 \
6739 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6740 0 \
6741 -c "Read from server: 16384 bytes read"
6742
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006743# Checking next 4 tests logs for 1n-1 split against BEAST too
6744requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6745run_test "Large server packet SSLv3 BlockCipher" \
6746 "$P_SRV response_size=16384 min_version=ssl3" \
6747 "$P_CLI force_version=ssl3 recsplit=0 \
6748 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6749 0 \
6750 -c "Read from server: 1 bytes read"\
6751 -c "16383 bytes read"\
6752 -C "Read from server: 16384 bytes read"
6753
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006754run_test "Large server packet TLS 1.0 BlockCipher" \
6755 "$P_SRV response_size=16384" \
6756 "$P_CLI force_version=tls1 recsplit=0 \
6757 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6758 0 \
6759 -c "Read from server: 1 bytes read"\
6760 -c "16383 bytes read"\
6761 -C "Read from server: 16384 bytes read"
6762
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006763run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6764 "$P_SRV response_size=16384" \
6765 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6766 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6767 0 \
6768 -c "Read from server: 1 bytes read"\
6769 -c "16383 bytes read"\
6770 -C "Read from server: 16384 bytes read"
6771
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006772requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6773run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6774 "$P_SRV response_size=16384" \
6775 "$P_CLI force_version=tls1 recsplit=0 \
6776 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6777 trunc_hmac=1" \
6778 0 \
6779 -c "Read from server: 1 bytes read"\
6780 -c "16383 bytes read"\
6781 -C "Read from server: 16384 bytes read"
6782
6783requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6784run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6785 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6786 "$P_CLI force_version=tls1 \
6787 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6788 trunc_hmac=1" \
6789 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006790 -s "16384 bytes written in 1 fragments" \
6791 -c "Read from server: 16384 bytes read"
6792
6793run_test "Large server packet TLS 1.0 StreamCipher" \
6794 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6795 "$P_CLI force_version=tls1 \
6796 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6797 0 \
6798 -s "16384 bytes written in 1 fragments" \
6799 -c "Read from server: 16384 bytes read"
6800
6801run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6802 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6803 "$P_CLI force_version=tls1 \
6804 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6805 0 \
6806 -s "16384 bytes written in 1 fragments" \
6807 -c "Read from server: 16384 bytes read"
6808
6809requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6810run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6811 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6812 "$P_CLI force_version=tls1 \
6813 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6814 0 \
6815 -s "16384 bytes written in 1 fragments" \
6816 -c "Read from server: 16384 bytes read"
6817
6818requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6819run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6820 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6821 "$P_CLI force_version=tls1 \
6822 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6823 0 \
6824 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006825 -c "Read from server: 16384 bytes read"
6826
6827run_test "Large server packet TLS 1.1 BlockCipher" \
6828 "$P_SRV response_size=16384" \
6829 "$P_CLI force_version=tls1_1 \
6830 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6831 0 \
6832 -c "Read from server: 16384 bytes read"
6833
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006834run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6835 "$P_SRV response_size=16384" \
6836 "$P_CLI force_version=tls1_1 etm=0 \
6837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006838 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006839 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006840 -c "Read from server: 16384 bytes read"
6841
6842requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6843run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6844 "$P_SRV response_size=16384" \
6845 "$P_CLI force_version=tls1_1 \
6846 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6847 trunc_hmac=1" \
6848 0 \
6849 -c "Read from server: 16384 bytes read"
6850
6851requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006852run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6853 "$P_SRV response_size=16384 trunc_hmac=1" \
6854 "$P_CLI force_version=tls1_1 \
6855 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6856 0 \
6857 -s "16384 bytes written in 1 fragments" \
6858 -c "Read from server: 16384 bytes read"
6859
6860run_test "Large server packet TLS 1.1 StreamCipher" \
6861 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6862 "$P_CLI force_version=tls1_1 \
6863 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6864 0 \
6865 -c "Read from server: 16384 bytes read"
6866
6867run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6868 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6869 "$P_CLI force_version=tls1_1 \
6870 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6871 0 \
6872 -s "16384 bytes written in 1 fragments" \
6873 -c "Read from server: 16384 bytes read"
6874
6875requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006876run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6877 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6878 "$P_CLI force_version=tls1_1 \
6879 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6880 trunc_hmac=1" \
6881 0 \
6882 -c "Read from server: 16384 bytes read"
6883
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006884run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6885 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6886 "$P_CLI force_version=tls1_1 \
6887 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6888 0 \
6889 -s "16384 bytes written in 1 fragments" \
6890 -c "Read from server: 16384 bytes read"
6891
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006892run_test "Large server packet TLS 1.2 BlockCipher" \
6893 "$P_SRV response_size=16384" \
6894 "$P_CLI force_version=tls1_2 \
6895 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6896 0 \
6897 -c "Read from server: 16384 bytes read"
6898
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006899run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6900 "$P_SRV response_size=16384" \
6901 "$P_CLI force_version=tls1_2 etm=0 \
6902 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6903 0 \
6904 -s "16384 bytes written in 1 fragments" \
6905 -c "Read from server: 16384 bytes read"
6906
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006907run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6908 "$P_SRV response_size=16384" \
6909 "$P_CLI force_version=tls1_2 \
6910 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6911 0 \
6912 -c "Read from server: 16384 bytes read"
6913
6914requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6915run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6916 "$P_SRV response_size=16384" \
6917 "$P_CLI force_version=tls1_2 \
6918 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6919 trunc_hmac=1" \
6920 0 \
6921 -c "Read from server: 16384 bytes read"
6922
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006923run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6924 "$P_SRV response_size=16384 trunc_hmac=1" \
6925 "$P_CLI force_version=tls1_2 \
6926 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6927 0 \
6928 -s "16384 bytes written in 1 fragments" \
6929 -c "Read from server: 16384 bytes read"
6930
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006931run_test "Large server packet TLS 1.2 StreamCipher" \
6932 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6933 "$P_CLI force_version=tls1_2 \
6934 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6935 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006936 -s "16384 bytes written in 1 fragments" \
6937 -c "Read from server: 16384 bytes read"
6938
6939run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6940 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6941 "$P_CLI force_version=tls1_2 \
6942 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6943 0 \
6944 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006945 -c "Read from server: 16384 bytes read"
6946
6947requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6948run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6949 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6950 "$P_CLI force_version=tls1_2 \
6951 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6952 trunc_hmac=1" \
6953 0 \
6954 -c "Read from server: 16384 bytes read"
6955
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006956requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6957run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6958 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6959 "$P_CLI force_version=tls1_2 \
6960 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6961 0 \
6962 -s "16384 bytes written in 1 fragments" \
6963 -c "Read from server: 16384 bytes read"
6964
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006965run_test "Large server packet TLS 1.2 AEAD" \
6966 "$P_SRV response_size=16384" \
6967 "$P_CLI force_version=tls1_2 \
6968 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6969 0 \
6970 -c "Read from server: 16384 bytes read"
6971
6972run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6973 "$P_SRV response_size=16384" \
6974 "$P_CLI force_version=tls1_2 \
6975 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6976 0 \
6977 -c "Read from server: 16384 bytes read"
6978
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006979# Tests for restartable ECC
6980
6981requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6982run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006983 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006984 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006985 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006986 debug_level=1" \
6987 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006988 -C "x509_verify_cert.*4b00" \
6989 -C "mbedtls_pk_verify.*4b00" \
6990 -C "mbedtls_ecdh_make_public.*4b00" \
6991 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006992
6993requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6994run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006995 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006996 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006997 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006998 debug_level=1 ec_max_ops=0" \
6999 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007000 -C "x509_verify_cert.*4b00" \
7001 -C "mbedtls_pk_verify.*4b00" \
7002 -C "mbedtls_ecdh_make_public.*4b00" \
7003 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007004
7005requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7006run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007007 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007008 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007009 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007010 debug_level=1 ec_max_ops=65535" \
7011 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007012 -C "x509_verify_cert.*4b00" \
7013 -C "mbedtls_pk_verify.*4b00" \
7014 -C "mbedtls_ecdh_make_public.*4b00" \
7015 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007016
7017requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7018run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007019 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007020 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007021 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007022 debug_level=1 ec_max_ops=1000" \
7023 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007024 -c "x509_verify_cert.*4b00" \
7025 -c "mbedtls_pk_verify.*4b00" \
7026 -c "mbedtls_ecdh_make_public.*4b00" \
7027 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007028
7029requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007030run_test "EC restart: TLS, max_ops=1000, badsign" \
7031 "$P_SRV auth_mode=required \
7032 crt_file=data_files/server5-badsign.crt \
7033 key_file=data_files/server5.key" \
7034 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7035 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7036 debug_level=1 ec_max_ops=1000" \
7037 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007038 -c "x509_verify_cert.*4b00" \
7039 -C "mbedtls_pk_verify.*4b00" \
7040 -C "mbedtls_ecdh_make_public.*4b00" \
7041 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007042 -c "! The certificate is not correctly signed by the trusted CA" \
7043 -c "! mbedtls_ssl_handshake returned" \
7044 -c "X509 - Certificate verification failed"
7045
7046requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7047run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
7048 "$P_SRV auth_mode=required \
7049 crt_file=data_files/server5-badsign.crt \
7050 key_file=data_files/server5.key" \
7051 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7052 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7053 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
7054 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007055 -c "x509_verify_cert.*4b00" \
7056 -c "mbedtls_pk_verify.*4b00" \
7057 -c "mbedtls_ecdh_make_public.*4b00" \
7058 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007059 -c "! The certificate is not correctly signed by the trusted CA" \
7060 -C "! mbedtls_ssl_handshake returned" \
7061 -C "X509 - Certificate verification failed"
7062
7063requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7064run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
7065 "$P_SRV auth_mode=required \
7066 crt_file=data_files/server5-badsign.crt \
7067 key_file=data_files/server5.key" \
7068 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7069 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7070 debug_level=1 ec_max_ops=1000 auth_mode=none" \
7071 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007072 -C "x509_verify_cert.*4b00" \
7073 -c "mbedtls_pk_verify.*4b00" \
7074 -c "mbedtls_ecdh_make_public.*4b00" \
7075 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007076 -C "! The certificate is not correctly signed by the trusted CA" \
7077 -C "! mbedtls_ssl_handshake returned" \
7078 -C "X509 - Certificate verification failed"
7079
7080requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007081run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007082 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007083 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007084 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007085 dtls=1 debug_level=1 ec_max_ops=1000" \
7086 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007087 -c "x509_verify_cert.*4b00" \
7088 -c "mbedtls_pk_verify.*4b00" \
7089 -c "mbedtls_ecdh_make_public.*4b00" \
7090 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007091
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007092requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7093run_test "EC restart: TLS, max_ops=1000 no client auth" \
7094 "$P_SRV" \
7095 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7096 debug_level=1 ec_max_ops=1000" \
7097 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007098 -c "x509_verify_cert.*4b00" \
7099 -c "mbedtls_pk_verify.*4b00" \
7100 -c "mbedtls_ecdh_make_public.*4b00" \
7101 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007102
7103requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7104run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
7105 "$P_SRV psk=abc123" \
7106 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
7107 psk=abc123 debug_level=1 ec_max_ops=1000" \
7108 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007109 -C "x509_verify_cert.*4b00" \
7110 -C "mbedtls_pk_verify.*4b00" \
7111 -C "mbedtls_ecdh_make_public.*4b00" \
7112 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007113
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007114# Tests of asynchronous private key support in SSL
7115
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007116requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007117run_test "SSL async private: sign, delay=0" \
7118 "$P_SRV \
7119 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007120 "$P_CLI" \
7121 0 \
7122 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007123 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007124
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007125requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007126run_test "SSL async private: sign, delay=1" \
7127 "$P_SRV \
7128 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007129 "$P_CLI" \
7130 0 \
7131 -s "Async sign callback: using key slot " \
7132 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007133 -s "Async resume (slot [0-9]): sign done, status=0"
7134
Gilles Peskine12d0cc12018-04-26 15:06:56 +02007135requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7136run_test "SSL async private: sign, delay=2" \
7137 "$P_SRV \
7138 async_operations=s async_private_delay1=2 async_private_delay2=2" \
7139 "$P_CLI" \
7140 0 \
7141 -s "Async sign callback: using key slot " \
7142 -U "Async sign callback: using key slot " \
7143 -s "Async resume (slot [0-9]): call 1 more times." \
7144 -s "Async resume (slot [0-9]): call 0 more times." \
7145 -s "Async resume (slot [0-9]): sign done, status=0"
7146
Gilles Peskined3268832018-04-26 06:23:59 +02007147# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
7148# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
7149requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7150requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7151run_test "SSL async private: sign, RSA, TLS 1.1" \
7152 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
7153 async_operations=s async_private_delay1=0 async_private_delay2=0" \
7154 "$P_CLI force_version=tls1_1" \
7155 0 \
7156 -s "Async sign callback: using key slot " \
7157 -s "Async resume (slot [0-9]): sign done, status=0"
7158
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007159requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02007160run_test "SSL async private: sign, SNI" \
7161 "$P_SRV debug_level=3 \
7162 async_operations=s async_private_delay1=0 async_private_delay2=0 \
7163 crt_file=data_files/server5.crt key_file=data_files/server5.key \
7164 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
7165 "$P_CLI server_name=polarssl.example" \
7166 0 \
7167 -s "Async sign callback: using key slot " \
7168 -s "Async resume (slot [0-9]): sign done, status=0" \
7169 -s "parse ServerName extension" \
7170 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
7171 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
7172
7173requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007174run_test "SSL async private: decrypt, delay=0" \
7175 "$P_SRV \
7176 async_operations=d async_private_delay1=0 async_private_delay2=0" \
7177 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7178 0 \
7179 -s "Async decrypt callback: using key slot " \
7180 -s "Async resume (slot [0-9]): decrypt done, status=0"
7181
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007182requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007183run_test "SSL async private: decrypt, delay=1" \
7184 "$P_SRV \
7185 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7186 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7187 0 \
7188 -s "Async decrypt callback: using key slot " \
7189 -s "Async resume (slot [0-9]): call 0 more times." \
7190 -s "Async resume (slot [0-9]): decrypt done, status=0"
7191
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007192requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007193run_test "SSL async private: decrypt RSA-PSK, delay=0" \
7194 "$P_SRV psk=abc123 \
7195 async_operations=d async_private_delay1=0 async_private_delay2=0" \
7196 "$P_CLI psk=abc123 \
7197 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
7198 0 \
7199 -s "Async decrypt callback: using key slot " \
7200 -s "Async resume (slot [0-9]): decrypt done, status=0"
7201
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007202requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007203run_test "SSL async private: decrypt RSA-PSK, delay=1" \
7204 "$P_SRV psk=abc123 \
7205 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7206 "$P_CLI psk=abc123 \
7207 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
7208 0 \
7209 -s "Async decrypt callback: using key slot " \
7210 -s "Async resume (slot [0-9]): call 0 more times." \
7211 -s "Async resume (slot [0-9]): decrypt done, status=0"
7212
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007213requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007214run_test "SSL async private: sign callback not present" \
7215 "$P_SRV \
7216 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7217 "$P_CLI; [ \$? -eq 1 ] &&
7218 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7219 0 \
7220 -S "Async sign callback" \
7221 -s "! mbedtls_ssl_handshake returned" \
7222 -s "The own private key or pre-shared key is not set, but needed" \
7223 -s "Async resume (slot [0-9]): decrypt done, status=0" \
7224 -s "Successful connection"
7225
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007226requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007227run_test "SSL async private: decrypt callback not present" \
7228 "$P_SRV debug_level=1 \
7229 async_operations=s async_private_delay1=1 async_private_delay2=1" \
7230 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
7231 [ \$? -eq 1 ] && $P_CLI" \
7232 0 \
7233 -S "Async decrypt callback" \
7234 -s "! mbedtls_ssl_handshake returned" \
7235 -s "got no RSA private key" \
7236 -s "Async resume (slot [0-9]): sign done, status=0" \
7237 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007238
7239# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007240requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007241run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007242 "$P_SRV \
7243 async_operations=s async_private_delay1=1 \
7244 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7245 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007246 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7247 0 \
7248 -s "Async sign callback: using key slot 0," \
7249 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007250 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007251
7252# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007253requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007254run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007255 "$P_SRV \
7256 async_operations=s async_private_delay2=1 \
7257 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7258 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007259 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7260 0 \
7261 -s "Async sign callback: using key slot 0," \
7262 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007263 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007264
7265# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007266requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02007267run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007268 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02007269 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007270 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7271 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007272 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7273 0 \
7274 -s "Async sign callback: using key slot 1," \
7275 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007276 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007277
7278# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007279requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007280run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007281 "$P_SRV \
7282 async_operations=s async_private_delay1=1 \
7283 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7284 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007285 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7286 0 \
7287 -s "Async sign callback: no key matches this certificate."
7288
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007289requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007290run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007291 "$P_SRV \
7292 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7293 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007294 "$P_CLI" \
7295 1 \
7296 -s "Async sign callback: injected error" \
7297 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02007298 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007299 -s "! mbedtls_ssl_handshake returned"
7300
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007301requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007302run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007303 "$P_SRV \
7304 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7305 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007306 "$P_CLI" \
7307 1 \
7308 -s "Async sign callback: using key slot " \
7309 -S "Async resume" \
7310 -s "Async cancel"
7311
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007312requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007313run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007314 "$P_SRV \
7315 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7316 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007317 "$P_CLI" \
7318 1 \
7319 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007320 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02007321 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007322 -s "! mbedtls_ssl_handshake returned"
7323
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007324requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007325run_test "SSL async private: decrypt, error in start" \
7326 "$P_SRV \
7327 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7328 async_private_error=1" \
7329 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7330 1 \
7331 -s "Async decrypt callback: injected error" \
7332 -S "Async resume" \
7333 -S "Async cancel" \
7334 -s "! mbedtls_ssl_handshake returned"
7335
7336requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7337run_test "SSL async private: decrypt, cancel after start" \
7338 "$P_SRV \
7339 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7340 async_private_error=2" \
7341 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7342 1 \
7343 -s "Async decrypt callback: using key slot " \
7344 -S "Async resume" \
7345 -s "Async cancel"
7346
7347requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7348run_test "SSL async private: decrypt, error in resume" \
7349 "$P_SRV \
7350 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7351 async_private_error=3" \
7352 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7353 1 \
7354 -s "Async decrypt callback: using key slot " \
7355 -s "Async resume callback: decrypt done but injected error" \
7356 -S "Async cancel" \
7357 -s "! mbedtls_ssl_handshake returned"
7358
7359requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007360run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007361 "$P_SRV \
7362 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7363 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007364 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
7365 0 \
7366 -s "Async cancel" \
7367 -s "! mbedtls_ssl_handshake returned" \
7368 -s "Async resume" \
7369 -s "Successful connection"
7370
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007371requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007372run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007373 "$P_SRV \
7374 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7375 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007376 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
7377 0 \
7378 -s "! mbedtls_ssl_handshake returned" \
7379 -s "Async resume" \
7380 -s "Successful connection"
7381
7382# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007383requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007384run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007385 "$P_SRV \
7386 async_operations=s async_private_delay1=1 async_private_error=-2 \
7387 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7388 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007389 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
7390 [ \$? -eq 1 ] &&
7391 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7392 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02007393 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007394 -S "Async resume" \
7395 -s "Async cancel" \
7396 -s "! mbedtls_ssl_handshake returned" \
7397 -s "Async sign callback: no key matches this certificate." \
7398 -s "Successful connection"
7399
7400# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007401requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007402run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007403 "$P_SRV \
7404 async_operations=s async_private_delay1=1 async_private_error=-3 \
7405 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7406 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007407 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
7408 [ \$? -eq 1 ] &&
7409 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7410 0 \
7411 -s "Async resume" \
7412 -s "! mbedtls_ssl_handshake returned" \
7413 -s "Async sign callback: no key matches this certificate." \
7414 -s "Successful connection"
7415
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007416requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007417requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007418run_test "SSL async private: renegotiation: client-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007419 "$P_SRV \
7420 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007421 exchanges=2 renegotiation=1" \
7422 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
7423 0 \
7424 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007425 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007426
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007427requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007428requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007429run_test "SSL async private: renegotiation: server-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007430 "$P_SRV \
7431 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007432 exchanges=2 renegotiation=1 renegotiate=1" \
7433 "$P_CLI exchanges=2 renegotiation=1" \
7434 0 \
7435 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007436 -s "Async resume (slot [0-9]): sign done, status=0"
7437
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007438requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007439requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007440run_test "SSL async private: renegotiation: client-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007441 "$P_SRV \
7442 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7443 exchanges=2 renegotiation=1" \
7444 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
7445 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7446 0 \
7447 -s "Async decrypt callback: using key slot " \
7448 -s "Async resume (slot [0-9]): decrypt done, status=0"
7449
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007450requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007451requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007452run_test "SSL async private: renegotiation: server-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007453 "$P_SRV \
7454 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7455 exchanges=2 renegotiation=1 renegotiate=1" \
7456 "$P_CLI exchanges=2 renegotiation=1 \
7457 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7458 0 \
7459 -s "Async decrypt callback: using key slot " \
7460 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007461
Ron Eldor58093c82018-06-28 13:22:05 +03007462# Tests for ECC extensions (rfc 4492)
7463
Ron Eldor643df7c2018-06-28 16:17:00 +03007464requires_config_enabled MBEDTLS_AES_C
7465requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7466requires_config_enabled MBEDTLS_SHA256_C
7467requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007468run_test "Force a non ECC ciphersuite in the client side" \
7469 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03007470 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03007471 0 \
7472 -C "client hello, adding supported_elliptic_curves extension" \
7473 -C "client hello, adding supported_point_formats extension" \
7474 -S "found supported elliptic curves extension" \
7475 -S "found supported point formats extension"
7476
Ron Eldor643df7c2018-06-28 16:17:00 +03007477requires_config_enabled MBEDTLS_AES_C
7478requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7479requires_config_enabled MBEDTLS_SHA256_C
7480requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007481run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03007482 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03007483 "$P_CLI debug_level=3" \
7484 0 \
7485 -C "found supported_point_formats extension" \
7486 -S "server hello, supported_point_formats extension"
7487
Ron Eldor643df7c2018-06-28 16:17:00 +03007488requires_config_enabled MBEDTLS_AES_C
7489requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7490requires_config_enabled MBEDTLS_SHA256_C
7491requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007492run_test "Force an ECC ciphersuite in the client side" \
7493 "$P_SRV debug_level=3" \
7494 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7495 0 \
7496 -c "client hello, adding supported_elliptic_curves extension" \
7497 -c "client hello, adding supported_point_formats extension" \
7498 -s "found supported elliptic curves extension" \
7499 -s "found supported point formats extension"
7500
Ron Eldor643df7c2018-06-28 16:17:00 +03007501requires_config_enabled MBEDTLS_AES_C
7502requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7503requires_config_enabled MBEDTLS_SHA256_C
7504requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007505run_test "Force an ECC ciphersuite in the server side" \
7506 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7507 "$P_CLI debug_level=3" \
7508 0 \
7509 -c "found supported_point_formats extension" \
7510 -s "server hello, supported_point_formats extension"
7511
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007512# Tests for DTLS HelloVerifyRequest
7513
7514run_test "DTLS cookie: enabled" \
7515 "$P_SRV dtls=1 debug_level=2" \
7516 "$P_CLI dtls=1 debug_level=2" \
7517 0 \
7518 -s "cookie verification failed" \
7519 -s "cookie verification passed" \
7520 -S "cookie verification skipped" \
7521 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007522 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007523 -S "SSL - The requested feature is not available"
7524
7525run_test "DTLS cookie: disabled" \
7526 "$P_SRV dtls=1 debug_level=2 cookies=0" \
7527 "$P_CLI dtls=1 debug_level=2" \
7528 0 \
7529 -S "cookie verification failed" \
7530 -S "cookie verification passed" \
7531 -s "cookie verification skipped" \
7532 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007533 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007534 -S "SSL - The requested feature is not available"
7535
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007536run_test "DTLS cookie: default (failing)" \
7537 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
7538 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
7539 1 \
7540 -s "cookie verification failed" \
7541 -S "cookie verification passed" \
7542 -S "cookie verification skipped" \
7543 -C "received hello verify request" \
7544 -S "hello verification requested" \
7545 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007546
7547requires_ipv6
7548run_test "DTLS cookie: enabled, IPv6" \
7549 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
7550 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
7551 0 \
7552 -s "cookie verification failed" \
7553 -s "cookie verification passed" \
7554 -S "cookie verification skipped" \
7555 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007556 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007557 -S "SSL - The requested feature is not available"
7558
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007559run_test "DTLS cookie: enabled, nbio" \
7560 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7561 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7562 0 \
7563 -s "cookie verification failed" \
7564 -s "cookie verification passed" \
7565 -S "cookie verification skipped" \
7566 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007567 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007568 -S "SSL - The requested feature is not available"
7569
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007570# Tests for client reconnecting from the same port with DTLS
7571
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007572not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007573run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007574 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7575 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007576 0 \
7577 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007578 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007579 -S "Client initiated reconnection from same port"
7580
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007581not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007582run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007583 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7584 "$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 +02007585 0 \
7586 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007587 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007588 -s "Client initiated reconnection from same port"
7589
Paul Bakker362689d2016-05-13 10:33:25 +01007590not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
7591run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007592 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7593 "$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 +02007594 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007595 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007596 -s "Client initiated reconnection from same port"
7597
Paul Bakker362689d2016-05-13 10:33:25 +01007598only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
7599run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7600 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7601 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7602 0 \
7603 -S "The operation timed out" \
7604 -s "Client initiated reconnection from same port"
7605
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007606run_test "DTLS client reconnect from same port: no cookies" \
7607 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007608 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7609 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007610 -s "The operation timed out" \
7611 -S "Client initiated reconnection from same port"
7612
Manuel Pégourié-Gonnardbaad2de2020-03-13 11:11:02 +01007613run_test "DTLS client reconnect from same port: attacker-injected" \
7614 -p "$P_PXY inject_clihlo=1" \
7615 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
7616 "$P_CLI dtls=1 exchanges=2" \
7617 0 \
7618 -s "possible client reconnect from the same port" \
7619 -S "Client initiated reconnection from same port"
7620
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007621# Tests for various cases of client authentication with DTLS
7622# (focused on handshake flows and message parsing)
7623
7624run_test "DTLS client auth: required" \
7625 "$P_SRV dtls=1 auth_mode=required" \
7626 "$P_CLI dtls=1" \
7627 0 \
7628 -s "Verifying peer X.509 certificate... ok"
7629
7630run_test "DTLS client auth: optional, client has no cert" \
7631 "$P_SRV dtls=1 auth_mode=optional" \
7632 "$P_CLI dtls=1 crt_file=none key_file=none" \
7633 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007634 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007635
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007636run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007637 "$P_SRV dtls=1 auth_mode=none" \
7638 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7639 0 \
7640 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007641 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007642
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007643run_test "DTLS wrong PSK: badmac alert" \
7644 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7645 "$P_CLI dtls=1 psk=abc124" \
7646 1 \
7647 -s "SSL - Verification of the message MAC failed" \
7648 -c "SSL - A fatal alert message was received from our peer"
7649
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007650# Tests for receiving fragmented handshake messages with DTLS
7651
7652requires_gnutls
7653run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7654 "$G_SRV -u --mtu 2048 -a" \
7655 "$P_CLI dtls=1 debug_level=2" \
7656 0 \
7657 -C "found fragmented DTLS handshake message" \
7658 -C "error"
7659
7660requires_gnutls
7661run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7662 "$G_SRV -u --mtu 512" \
7663 "$P_CLI dtls=1 debug_level=2" \
7664 0 \
7665 -c "found fragmented DTLS handshake message" \
7666 -C "error"
7667
7668requires_gnutls
7669run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7670 "$G_SRV -u --mtu 128" \
7671 "$P_CLI dtls=1 debug_level=2" \
7672 0 \
7673 -c "found fragmented DTLS handshake message" \
7674 -C "error"
7675
7676requires_gnutls
7677run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7678 "$G_SRV -u --mtu 128" \
7679 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7680 0 \
7681 -c "found fragmented DTLS handshake message" \
7682 -C "error"
7683
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007684requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007685requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007686run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7687 "$G_SRV -u --mtu 256" \
7688 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
7689 0 \
7690 -c "found fragmented DTLS handshake message" \
7691 -c "client hello, adding renegotiation extension" \
7692 -c "found renegotiation extension" \
7693 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007694 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007695 -C "error" \
7696 -s "Extra-header:"
7697
7698requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007699requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007700run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7701 "$G_SRV -u --mtu 256" \
7702 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
7703 0 \
7704 -c "found fragmented DTLS handshake message" \
7705 -c "client hello, adding renegotiation extension" \
7706 -c "found renegotiation extension" \
7707 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007708 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007709 -C "error" \
7710 -s "Extra-header:"
7711
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007712run_test "DTLS reassembly: no fragmentation (openssl server)" \
7713 "$O_SRV -dtls1 -mtu 2048" \
7714 "$P_CLI dtls=1 debug_level=2" \
7715 0 \
7716 -C "found fragmented DTLS handshake message" \
7717 -C "error"
7718
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007719run_test "DTLS reassembly: some fragmentation (openssl server)" \
7720 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007721 "$P_CLI dtls=1 debug_level=2" \
7722 0 \
7723 -c "found fragmented DTLS handshake message" \
7724 -C "error"
7725
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007726run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007727 "$O_SRV -dtls1 -mtu 256" \
7728 "$P_CLI dtls=1 debug_level=2" \
7729 0 \
7730 -c "found fragmented DTLS handshake message" \
7731 -C "error"
7732
7733run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7734 "$O_SRV -dtls1 -mtu 256" \
7735 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7736 0 \
7737 -c "found fragmented DTLS handshake message" \
7738 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007739
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007740# Tests for sending fragmented handshake messages with DTLS
7741#
7742# Use client auth when we need the client to send large messages,
7743# and use large cert chains on both sides too (the long chains we have all use
7744# both RSA and ECDSA, but ideally we should have long chains with either).
7745# Sizes reached (UDP payload):
7746# - 2037B for server certificate
7747# - 1542B for client certificate
7748# - 1013B for newsessionticket
7749# - all others below 512B
7750# All those tests assume MAX_CONTENT_LEN is at least 2048
7751
7752requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7753requires_config_enabled MBEDTLS_RSA_C
7754requires_config_enabled MBEDTLS_ECDSA_C
7755requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7756run_test "DTLS fragmenting: none (for reference)" \
7757 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7758 crt_file=data_files/server7_int-ca.crt \
7759 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007760 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007761 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007762 "$P_CLI dtls=1 debug_level=2 \
7763 crt_file=data_files/server8_int-ca2.crt \
7764 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007765 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007766 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007767 0 \
7768 -S "found fragmented DTLS handshake message" \
7769 -C "found fragmented DTLS handshake message" \
7770 -C "error"
7771
7772requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7773requires_config_enabled MBEDTLS_RSA_C
7774requires_config_enabled MBEDTLS_ECDSA_C
7775requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007776run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007777 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7778 crt_file=data_files/server7_int-ca.crt \
7779 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007780 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007781 max_frag_len=1024" \
7782 "$P_CLI dtls=1 debug_level=2 \
7783 crt_file=data_files/server8_int-ca2.crt \
7784 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007785 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007786 max_frag_len=2048" \
7787 0 \
7788 -S "found fragmented DTLS handshake message" \
7789 -c "found fragmented DTLS handshake message" \
7790 -C "error"
7791
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007792# With the MFL extension, the server has no way of forcing
7793# the client to not exceed a certain MTU; hence, the following
7794# test can't be replicated with an MTU proxy such as the one
7795# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007796requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7797requires_config_enabled MBEDTLS_RSA_C
7798requires_config_enabled MBEDTLS_ECDSA_C
7799requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007800run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007801 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7802 crt_file=data_files/server7_int-ca.crt \
7803 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007804 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007805 max_frag_len=512" \
7806 "$P_CLI dtls=1 debug_level=2 \
7807 crt_file=data_files/server8_int-ca2.crt \
7808 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007809 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007810 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007811 0 \
7812 -S "found fragmented DTLS handshake message" \
7813 -c "found fragmented DTLS handshake message" \
7814 -C "error"
7815
7816requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7817requires_config_enabled MBEDTLS_RSA_C
7818requires_config_enabled MBEDTLS_ECDSA_C
7819requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007820run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007821 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7822 crt_file=data_files/server7_int-ca.crt \
7823 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007824 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007825 max_frag_len=2048" \
7826 "$P_CLI dtls=1 debug_level=2 \
7827 crt_file=data_files/server8_int-ca2.crt \
7828 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007829 hs_timeout=2500-60000 \
7830 max_frag_len=1024" \
7831 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007832 -S "found fragmented DTLS handshake message" \
7833 -c "found fragmented DTLS handshake message" \
7834 -C "error"
7835
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007836# While not required by the standard defining the MFL extension
7837# (according to which it only applies to records, not to datagrams),
7838# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7839# as otherwise there wouldn't be any means to communicate MTU restrictions
7840# to the peer.
7841# The next test checks that no datagrams significantly larger than the
7842# negotiated MFL are sent.
7843requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7844requires_config_enabled MBEDTLS_RSA_C
7845requires_config_enabled MBEDTLS_ECDSA_C
7846requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7847run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007848 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007849 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7850 crt_file=data_files/server7_int-ca.crt \
7851 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007852 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007853 max_frag_len=2048" \
7854 "$P_CLI dtls=1 debug_level=2 \
7855 crt_file=data_files/server8_int-ca2.crt \
7856 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007857 hs_timeout=2500-60000 \
7858 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007859 0 \
7860 -S "found fragmented DTLS handshake message" \
7861 -c "found fragmented DTLS handshake message" \
7862 -C "error"
7863
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007864requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7865requires_config_enabled MBEDTLS_RSA_C
7866requires_config_enabled MBEDTLS_ECDSA_C
7867requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007868run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007869 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7870 crt_file=data_files/server7_int-ca.crt \
7871 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007872 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007873 max_frag_len=2048" \
7874 "$P_CLI dtls=1 debug_level=2 \
7875 crt_file=data_files/server8_int-ca2.crt \
7876 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007877 hs_timeout=2500-60000 \
7878 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007879 0 \
7880 -s "found fragmented DTLS handshake message" \
7881 -c "found fragmented DTLS handshake message" \
7882 -C "error"
7883
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007884# While not required by the standard defining the MFL extension
7885# (according to which it only applies to records, not to datagrams),
7886# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7887# as otherwise there wouldn't be any means to communicate MTU restrictions
7888# to the peer.
7889# The next test checks that no datagrams significantly larger than the
7890# negotiated MFL are sent.
7891requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7892requires_config_enabled MBEDTLS_RSA_C
7893requires_config_enabled MBEDTLS_ECDSA_C
7894requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7895run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007896 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007897 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7898 crt_file=data_files/server7_int-ca.crt \
7899 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007900 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007901 max_frag_len=2048" \
7902 "$P_CLI dtls=1 debug_level=2 \
7903 crt_file=data_files/server8_int-ca2.crt \
7904 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007905 hs_timeout=2500-60000 \
7906 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007907 0 \
7908 -s "found fragmented DTLS handshake message" \
7909 -c "found fragmented DTLS handshake message" \
7910 -C "error"
7911
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007912requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7913requires_config_enabled MBEDTLS_RSA_C
7914requires_config_enabled MBEDTLS_ECDSA_C
7915run_test "DTLS fragmenting: none (for reference) (MTU)" \
7916 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7917 crt_file=data_files/server7_int-ca.crt \
7918 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007919 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007920 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007921 "$P_CLI dtls=1 debug_level=2 \
7922 crt_file=data_files/server8_int-ca2.crt \
7923 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007924 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007925 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007926 0 \
7927 -S "found fragmented DTLS handshake message" \
7928 -C "found fragmented DTLS handshake message" \
7929 -C "error"
7930
7931requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7932requires_config_enabled MBEDTLS_RSA_C
7933requires_config_enabled MBEDTLS_ECDSA_C
7934run_test "DTLS fragmenting: client (MTU)" \
7935 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7936 crt_file=data_files/server7_int-ca.crt \
7937 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007938 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007939 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007940 "$P_CLI dtls=1 debug_level=2 \
7941 crt_file=data_files/server8_int-ca2.crt \
7942 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007943 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007944 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007945 0 \
7946 -s "found fragmented DTLS handshake message" \
7947 -C "found fragmented DTLS handshake message" \
7948 -C "error"
7949
7950requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7951requires_config_enabled MBEDTLS_RSA_C
7952requires_config_enabled MBEDTLS_ECDSA_C
7953run_test "DTLS fragmenting: server (MTU)" \
7954 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7955 crt_file=data_files/server7_int-ca.crt \
7956 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007957 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007958 mtu=512" \
7959 "$P_CLI dtls=1 debug_level=2 \
7960 crt_file=data_files/server8_int-ca2.crt \
7961 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007962 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007963 mtu=2048" \
7964 0 \
7965 -S "found fragmented DTLS handshake message" \
7966 -c "found fragmented DTLS handshake message" \
7967 -C "error"
7968
7969requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7970requires_config_enabled MBEDTLS_RSA_C
7971requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007972run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007973 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007974 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7975 crt_file=data_files/server7_int-ca.crt \
7976 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007977 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007978 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007979 "$P_CLI dtls=1 debug_level=2 \
7980 crt_file=data_files/server8_int-ca2.crt \
7981 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007982 hs_timeout=2500-60000 \
7983 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007984 0 \
7985 -s "found fragmented DTLS handshake message" \
7986 -c "found fragmented DTLS handshake message" \
7987 -C "error"
7988
Andrzej Kurek77826052018-10-11 07:34:08 -04007989# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007990requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7991requires_config_enabled MBEDTLS_RSA_C
7992requires_config_enabled MBEDTLS_ECDSA_C
7993requires_config_enabled MBEDTLS_SHA256_C
7994requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7995requires_config_enabled MBEDTLS_AES_C
7996requires_config_enabled MBEDTLS_GCM_C
7997run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007998 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007999 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8000 crt_file=data_files/server7_int-ca.crt \
8001 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008002 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00008003 mtu=512" \
8004 "$P_CLI dtls=1 debug_level=2 \
8005 crt_file=data_files/server8_int-ca2.crt \
8006 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008007 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8008 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008009 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008010 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008011 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008012 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008013 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008014
Andrzej Kurek7311c782018-10-11 06:49:41 -04008015# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04008016# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008017# The ratio of max/min timeout should ideally equal 4 to accept two
8018# retransmissions, but in some cases (like both the server and client using
8019# fragmentation and auto-reduction) an extra retransmission might occur,
8020# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01008021not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008022requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8023requires_config_enabled MBEDTLS_RSA_C
8024requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008025requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8026requires_config_enabled MBEDTLS_AES_C
8027requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02008028run_test "DTLS fragmenting: proxy MTU: auto-reduction (not valgrind)" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008029 -p "$P_PXY mtu=508" \
8030 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8031 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008032 key_file=data_files/server7.key \
8033 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008034 "$P_CLI dtls=1 debug_level=2 \
8035 crt_file=data_files/server8_int-ca2.crt \
8036 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008037 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8038 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008039 0 \
8040 -s "found fragmented DTLS handshake message" \
8041 -c "found fragmented DTLS handshake message" \
8042 -C "error"
8043
Andrzej Kurek77826052018-10-11 07:34:08 -04008044# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01008045only_with_valgrind
8046requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8047requires_config_enabled MBEDTLS_RSA_C
8048requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008049requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8050requires_config_enabled MBEDTLS_AES_C
8051requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02008052run_test "DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)" \
Hanno Becker108992e2018-08-29 17:04:18 +01008053 -p "$P_PXY mtu=508" \
8054 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8055 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008056 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01008057 hs_timeout=250-10000" \
8058 "$P_CLI dtls=1 debug_level=2 \
8059 crt_file=data_files/server8_int-ca2.crt \
8060 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008061 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01008062 hs_timeout=250-10000" \
8063 0 \
8064 -s "found fragmented DTLS handshake message" \
8065 -c "found fragmented DTLS handshake message" \
8066 -C "error"
8067
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008068# 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 +02008069# OTOH the client might resend if the server is to slow to reset after sending
8070# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008071not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008072requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8073requires_config_enabled MBEDTLS_RSA_C
8074requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008075run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008076 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008077 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8078 crt_file=data_files/server7_int-ca.crt \
8079 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008080 hs_timeout=10000-60000 \
8081 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008082 "$P_CLI dtls=1 debug_level=2 \
8083 crt_file=data_files/server8_int-ca2.crt \
8084 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008085 hs_timeout=10000-60000 \
8086 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008087 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008088 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008089 -s "found fragmented DTLS handshake message" \
8090 -c "found fragmented DTLS handshake message" \
8091 -C "error"
8092
Andrzej Kurek77826052018-10-11 07:34:08 -04008093# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008094# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
8095# OTOH the client might resend if the server is to slow to reset after sending
8096# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008097not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008098requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8099requires_config_enabled MBEDTLS_RSA_C
8100requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008101requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8102requires_config_enabled MBEDTLS_AES_C
8103requires_config_enabled MBEDTLS_GCM_C
8104run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008105 -p "$P_PXY mtu=512" \
8106 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8107 crt_file=data_files/server7_int-ca.crt \
8108 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008109 hs_timeout=10000-60000 \
8110 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008111 "$P_CLI dtls=1 debug_level=2 \
8112 crt_file=data_files/server8_int-ca2.crt \
8113 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008114 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8115 hs_timeout=10000-60000 \
8116 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008117 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008118 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008119 -s "found fragmented DTLS handshake message" \
8120 -c "found fragmented DTLS handshake message" \
8121 -C "error"
8122
Andrzej Kurek7311c782018-10-11 06:49:41 -04008123not_with_valgrind # spurious autoreduction due to timeout
8124requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8125requires_config_enabled MBEDTLS_RSA_C
8126requires_config_enabled MBEDTLS_ECDSA_C
8127run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008128 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008129 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8130 crt_file=data_files/server7_int-ca.crt \
8131 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008132 hs_timeout=10000-60000 \
8133 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008134 "$P_CLI dtls=1 debug_level=2 \
8135 crt_file=data_files/server8_int-ca2.crt \
8136 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008137 hs_timeout=10000-60000 \
8138 mtu=1024 nbio=2" \
8139 0 \
8140 -S "autoreduction" \
8141 -s "found fragmented DTLS handshake message" \
8142 -c "found fragmented DTLS handshake message" \
8143 -C "error"
8144
Andrzej Kurek77826052018-10-11 07:34:08 -04008145# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008146not_with_valgrind # spurious autoreduction due to timeout
8147requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8148requires_config_enabled MBEDTLS_RSA_C
8149requires_config_enabled MBEDTLS_ECDSA_C
8150requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8151requires_config_enabled MBEDTLS_AES_C
8152requires_config_enabled MBEDTLS_GCM_C
8153run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
8154 -p "$P_PXY mtu=512" \
8155 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8156 crt_file=data_files/server7_int-ca.crt \
8157 key_file=data_files/server7.key \
8158 hs_timeout=10000-60000 \
8159 mtu=512 nbio=2" \
8160 "$P_CLI dtls=1 debug_level=2 \
8161 crt_file=data_files/server8_int-ca2.crt \
8162 key_file=data_files/server8.key \
8163 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8164 hs_timeout=10000-60000 \
8165 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008166 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008167 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008168 -s "found fragmented DTLS handshake message" \
8169 -c "found fragmented DTLS handshake message" \
8170 -C "error"
8171
Andrzej Kurek77826052018-10-11 07:34:08 -04008172# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01008173# This ensures things still work after session_reset().
8174# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008175# Since we don't support reading fragmented ClientHello yet,
8176# up the MTU to 1450 (larger than ClientHello with session ticket,
8177# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008178# An autoreduction on the client-side might happen if the server is
8179# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02008180# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008181# resumed listening, which would result in a spurious autoreduction.
8182not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008183requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8184requires_config_enabled MBEDTLS_RSA_C
8185requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008186requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8187requires_config_enabled MBEDTLS_AES_C
8188requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008189run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
8190 -p "$P_PXY mtu=1450" \
8191 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8192 crt_file=data_files/server7_int-ca.crt \
8193 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008194 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008195 mtu=1450" \
8196 "$P_CLI dtls=1 debug_level=2 \
8197 crt_file=data_files/server8_int-ca2.crt \
8198 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008199 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008200 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01008201 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008202 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008203 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008204 -s "found fragmented DTLS handshake message" \
8205 -c "found fragmented DTLS handshake message" \
8206 -C "error"
8207
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008208# An autoreduction on the client-side might happen if the server is
8209# slow to reset, therefore omitting '-C "autoreduction"' below.
8210not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008211requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8212requires_config_enabled MBEDTLS_RSA_C
8213requires_config_enabled MBEDTLS_ECDSA_C
8214requires_config_enabled MBEDTLS_SHA256_C
8215requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8216requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8217requires_config_enabled MBEDTLS_CHACHAPOLY_C
8218run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
8219 -p "$P_PXY mtu=512" \
8220 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8221 crt_file=data_files/server7_int-ca.crt \
8222 key_file=data_files/server7.key \
8223 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008224 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008225 mtu=512" \
8226 "$P_CLI dtls=1 debug_level=2 \
8227 crt_file=data_files/server8_int-ca2.crt \
8228 key_file=data_files/server8.key \
8229 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008230 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008231 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008232 mtu=512" \
8233 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008234 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008235 -s "found fragmented DTLS handshake message" \
8236 -c "found fragmented DTLS handshake message" \
8237 -C "error"
8238
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008239# An autoreduction on the client-side might happen if the server is
8240# slow to reset, therefore omitting '-C "autoreduction"' below.
8241not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008242requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8243requires_config_enabled MBEDTLS_RSA_C
8244requires_config_enabled MBEDTLS_ECDSA_C
8245requires_config_enabled MBEDTLS_SHA256_C
8246requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8247requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8248requires_config_enabled MBEDTLS_AES_C
8249requires_config_enabled MBEDTLS_GCM_C
8250run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
8251 -p "$P_PXY mtu=512" \
8252 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8253 crt_file=data_files/server7_int-ca.crt \
8254 key_file=data_files/server7.key \
8255 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008256 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008257 mtu=512" \
8258 "$P_CLI dtls=1 debug_level=2 \
8259 crt_file=data_files/server8_int-ca2.crt \
8260 key_file=data_files/server8.key \
8261 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008262 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008263 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008264 mtu=512" \
8265 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008266 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008267 -s "found fragmented DTLS handshake message" \
8268 -c "found fragmented DTLS handshake message" \
8269 -C "error"
8270
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008271# An autoreduction on the client-side might happen if the server is
8272# slow to reset, therefore omitting '-C "autoreduction"' below.
8273not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008274requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8275requires_config_enabled MBEDTLS_RSA_C
8276requires_config_enabled MBEDTLS_ECDSA_C
8277requires_config_enabled MBEDTLS_SHA256_C
8278requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8279requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8280requires_config_enabled MBEDTLS_AES_C
8281requires_config_enabled MBEDTLS_CCM_C
8282run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008283 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008284 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8285 crt_file=data_files/server7_int-ca.crt \
8286 key_file=data_files/server7.key \
8287 exchanges=2 renegotiation=1 \
8288 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008289 hs_timeout=10000-60000 \
8290 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008291 "$P_CLI dtls=1 debug_level=2 \
8292 crt_file=data_files/server8_int-ca2.crt \
8293 key_file=data_files/server8.key \
8294 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008295 hs_timeout=10000-60000 \
8296 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008297 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008298 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008299 -s "found fragmented DTLS handshake message" \
8300 -c "found fragmented DTLS handshake message" \
8301 -C "error"
8302
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008303# An autoreduction on the client-side might happen if the server is
8304# slow to reset, therefore omitting '-C "autoreduction"' below.
8305not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008306requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8307requires_config_enabled MBEDTLS_RSA_C
8308requires_config_enabled MBEDTLS_ECDSA_C
8309requires_config_enabled MBEDTLS_SHA256_C
8310requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8311requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8312requires_config_enabled MBEDTLS_AES_C
8313requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
8314requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
8315run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008316 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008317 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8318 crt_file=data_files/server7_int-ca.crt \
8319 key_file=data_files/server7.key \
8320 exchanges=2 renegotiation=1 \
8321 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008322 hs_timeout=10000-60000 \
8323 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008324 "$P_CLI dtls=1 debug_level=2 \
8325 crt_file=data_files/server8_int-ca2.crt \
8326 key_file=data_files/server8.key \
8327 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008328 hs_timeout=10000-60000 \
8329 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008330 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008331 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008332 -s "found fragmented DTLS handshake message" \
8333 -c "found fragmented DTLS handshake message" \
8334 -C "error"
8335
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008336# An autoreduction on the client-side might happen if the server is
8337# slow to reset, therefore omitting '-C "autoreduction"' below.
8338not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008339requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8340requires_config_enabled MBEDTLS_RSA_C
8341requires_config_enabled MBEDTLS_ECDSA_C
8342requires_config_enabled MBEDTLS_SHA256_C
8343requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8344requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8345requires_config_enabled MBEDTLS_AES_C
8346requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
8347run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008348 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008349 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8350 crt_file=data_files/server7_int-ca.crt \
8351 key_file=data_files/server7.key \
8352 exchanges=2 renegotiation=1 \
8353 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008354 hs_timeout=10000-60000 \
8355 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008356 "$P_CLI dtls=1 debug_level=2 \
8357 crt_file=data_files/server8_int-ca2.crt \
8358 key_file=data_files/server8.key \
8359 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008360 hs_timeout=10000-60000 \
8361 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008362 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008363 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008364 -s "found fragmented DTLS handshake message" \
8365 -c "found fragmented DTLS handshake message" \
8366 -C "error"
8367
Andrzej Kurek77826052018-10-11 07:34:08 -04008368# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008369requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8370requires_config_enabled MBEDTLS_RSA_C
8371requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008372requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8373requires_config_enabled MBEDTLS_AES_C
8374requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008375client_needs_more_time 2
8376run_test "DTLS fragmenting: proxy MTU + 3d" \
8377 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008378 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008379 crt_file=data_files/server7_int-ca.crt \
8380 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008381 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008382 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008383 crt_file=data_files/server8_int-ca2.crt \
8384 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008385 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008386 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008387 0 \
8388 -s "found fragmented DTLS handshake message" \
8389 -c "found fragmented DTLS handshake message" \
8390 -C "error"
8391
Andrzej Kurek77826052018-10-11 07:34:08 -04008392# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008393requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8394requires_config_enabled MBEDTLS_RSA_C
8395requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008396requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8397requires_config_enabled MBEDTLS_AES_C
8398requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008399client_needs_more_time 2
8400run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
8401 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
8402 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8403 crt_file=data_files/server7_int-ca.crt \
8404 key_file=data_files/server7.key \
8405 hs_timeout=250-10000 mtu=512 nbio=2" \
8406 "$P_CLI dtls=1 debug_level=2 \
8407 crt_file=data_files/server8_int-ca2.crt \
8408 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008409 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008410 hs_timeout=250-10000 mtu=512 nbio=2" \
8411 0 \
8412 -s "found fragmented DTLS handshake message" \
8413 -c "found fragmented DTLS handshake message" \
8414 -C "error"
8415
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008416# interop tests for DTLS fragmentating with reliable connection
8417#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008418# here and below we just want to test that the we fragment in a way that
8419# pleases other implementations, so we don't need the peer to fragment
8420requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8421requires_config_enabled MBEDTLS_RSA_C
8422requires_config_enabled MBEDTLS_ECDSA_C
8423requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008424requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008425run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
8426 "$G_SRV -u" \
8427 "$P_CLI dtls=1 debug_level=2 \
8428 crt_file=data_files/server8_int-ca2.crt \
8429 key_file=data_files/server8.key \
8430 mtu=512 force_version=dtls1_2" \
8431 0 \
8432 -c "fragmenting handshake message" \
8433 -C "error"
8434
8435requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8436requires_config_enabled MBEDTLS_RSA_C
8437requires_config_enabled MBEDTLS_ECDSA_C
8438requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008439requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008440run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
8441 "$G_SRV -u" \
8442 "$P_CLI dtls=1 debug_level=2 \
8443 crt_file=data_files/server8_int-ca2.crt \
8444 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008445 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008446 0 \
8447 -c "fragmenting handshake message" \
8448 -C "error"
8449
Hanno Beckerb9a00862018-08-28 10:20:22 +01008450# We use --insecure for the GnuTLS client because it expects
8451# the hostname / IP it connects to to be the name used in the
8452# certificate obtained from the server. Here, however, it
8453# connects to 127.0.0.1 while our test certificates use 'localhost'
8454# as the server name in the certificate. This will make the
8455# certifiate validation fail, but passing --insecure makes
8456# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008457requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8458requires_config_enabled MBEDTLS_RSA_C
8459requires_config_enabled MBEDTLS_ECDSA_C
8460requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008461requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008462requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008463run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008464 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008465 crt_file=data_files/server7_int-ca.crt \
8466 key_file=data_files/server7.key \
8467 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008468 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008469 0 \
8470 -s "fragmenting handshake message"
8471
Hanno Beckerb9a00862018-08-28 10:20:22 +01008472# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008473requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8474requires_config_enabled MBEDTLS_RSA_C
8475requires_config_enabled MBEDTLS_ECDSA_C
8476requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008477requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008478requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008479run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008480 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008481 crt_file=data_files/server7_int-ca.crt \
8482 key_file=data_files/server7.key \
8483 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008484 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008485 0 \
8486 -s "fragmenting handshake message"
8487
8488requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8489requires_config_enabled MBEDTLS_RSA_C
8490requires_config_enabled MBEDTLS_ECDSA_C
8491requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8492run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
8493 "$O_SRV -dtls1_2 -verify 10" \
8494 "$P_CLI dtls=1 debug_level=2 \
8495 crt_file=data_files/server8_int-ca2.crt \
8496 key_file=data_files/server8.key \
8497 mtu=512 force_version=dtls1_2" \
8498 0 \
8499 -c "fragmenting handshake message" \
8500 -C "error"
8501
8502requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8503requires_config_enabled MBEDTLS_RSA_C
8504requires_config_enabled MBEDTLS_ECDSA_C
8505requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8506run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
8507 "$O_SRV -dtls1 -verify 10" \
8508 "$P_CLI dtls=1 debug_level=2 \
8509 crt_file=data_files/server8_int-ca2.crt \
8510 key_file=data_files/server8.key \
8511 mtu=512 force_version=dtls1" \
8512 0 \
8513 -c "fragmenting handshake message" \
8514 -C "error"
8515
8516requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8517requires_config_enabled MBEDTLS_RSA_C
8518requires_config_enabled MBEDTLS_ECDSA_C
8519requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8520run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
8521 "$P_SRV dtls=1 debug_level=2 \
8522 crt_file=data_files/server7_int-ca.crt \
8523 key_file=data_files/server7.key \
8524 mtu=512 force_version=dtls1_2" \
8525 "$O_CLI -dtls1_2" \
8526 0 \
8527 -s "fragmenting handshake message"
8528
8529requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8530requires_config_enabled MBEDTLS_RSA_C
8531requires_config_enabled MBEDTLS_ECDSA_C
8532requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8533run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8534 "$P_SRV dtls=1 debug_level=2 \
8535 crt_file=data_files/server7_int-ca.crt \
8536 key_file=data_files/server7.key \
8537 mtu=512 force_version=dtls1" \
8538 "$O_CLI -dtls1" \
8539 0 \
8540 -s "fragmenting handshake message"
8541
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008542# interop tests for DTLS fragmentating with unreliable connection
8543#
8544# again we just want to test that the we fragment in a way that
8545# pleases other implementations, so we don't need the peer to fragment
8546requires_gnutls_next
8547requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8548requires_config_enabled MBEDTLS_RSA_C
8549requires_config_enabled MBEDTLS_ECDSA_C
8550requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008551client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008552run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8553 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8554 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008555 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008556 crt_file=data_files/server8_int-ca2.crt \
8557 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008558 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008559 0 \
8560 -c "fragmenting handshake message" \
8561 -C "error"
8562
8563requires_gnutls_next
8564requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8565requires_config_enabled MBEDTLS_RSA_C
8566requires_config_enabled MBEDTLS_ECDSA_C
8567requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008568client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008569run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8570 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8571 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008572 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008573 crt_file=data_files/server8_int-ca2.crt \
8574 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008575 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008576 0 \
8577 -c "fragmenting handshake message" \
8578 -C "error"
8579
k-stachowiak17a38d32019-02-18 15:29:56 +01008580requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008581requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8582requires_config_enabled MBEDTLS_RSA_C
8583requires_config_enabled MBEDTLS_ECDSA_C
8584requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8585client_needs_more_time 4
8586run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8587 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8588 "$P_SRV dtls=1 debug_level=2 \
8589 crt_file=data_files/server7_int-ca.crt \
8590 key_file=data_files/server7.key \
8591 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008592 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008593 0 \
8594 -s "fragmenting handshake message"
8595
k-stachowiak17a38d32019-02-18 15:29:56 +01008596requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008597requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8598requires_config_enabled MBEDTLS_RSA_C
8599requires_config_enabled MBEDTLS_ECDSA_C
8600requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8601client_needs_more_time 4
8602run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8603 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8604 "$P_SRV dtls=1 debug_level=2 \
8605 crt_file=data_files/server7_int-ca.crt \
8606 key_file=data_files/server7.key \
8607 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008608 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008609 0 \
8610 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008611
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008612## Interop test with OpenSSL might trigger a bug in recent versions (including
8613## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008614## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008615## They should be re-enabled once a fixed version of OpenSSL is available
8616## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008617skip_next_test
8618requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8619requires_config_enabled MBEDTLS_RSA_C
8620requires_config_enabled MBEDTLS_ECDSA_C
8621requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8622client_needs_more_time 4
8623run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8624 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8625 "$O_SRV -dtls1_2 -verify 10" \
8626 "$P_CLI dtls=1 debug_level=2 \
8627 crt_file=data_files/server8_int-ca2.crt \
8628 key_file=data_files/server8.key \
8629 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8630 0 \
8631 -c "fragmenting handshake message" \
8632 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008633
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008634skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008635requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8636requires_config_enabled MBEDTLS_RSA_C
8637requires_config_enabled MBEDTLS_ECDSA_C
8638requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008639client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008640run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8641 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008642 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008643 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008644 crt_file=data_files/server8_int-ca2.crt \
8645 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008646 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008647 0 \
8648 -c "fragmenting handshake message" \
8649 -C "error"
8650
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008651skip_next_test
8652requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8653requires_config_enabled MBEDTLS_RSA_C
8654requires_config_enabled MBEDTLS_ECDSA_C
8655requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8656client_needs_more_time 4
8657run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8658 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8659 "$P_SRV dtls=1 debug_level=2 \
8660 crt_file=data_files/server7_int-ca.crt \
8661 key_file=data_files/server7.key \
8662 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8663 "$O_CLI -dtls1_2" \
8664 0 \
8665 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008666
8667# -nbio is added to prevent s_client from blocking in case of duplicated
8668# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008669skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008670requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8671requires_config_enabled MBEDTLS_RSA_C
8672requires_config_enabled MBEDTLS_ECDSA_C
8673requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008674client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008675run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8676 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008677 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008678 crt_file=data_files/server7_int-ca.crt \
8679 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008680 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008681 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008682 0 \
8683 -s "fragmenting handshake message"
8684
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008685# Tests for specific things with "unreliable" UDP connection
8686
8687not_with_valgrind # spurious resend due to timeout
8688run_test "DTLS proxy: reference" \
8689 -p "$P_PXY" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008690 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
8691 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008692 0 \
8693 -C "replayed record" \
8694 -S "replayed record" \
Hanno Beckerb2a86c32019-07-19 15:43:09 +01008695 -C "Buffer record from epoch" \
8696 -S "Buffer record from epoch" \
8697 -C "ssl_buffer_message" \
8698 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008699 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008700 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008701 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008702 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008703 -c "HTTP/1.0 200 OK"
8704
8705not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008706run_test "DTLS proxy: duplicate every packet" \
8707 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008708 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
8709 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008710 0 \
8711 -c "replayed record" \
8712 -s "replayed record" \
8713 -c "record from another epoch" \
8714 -s "record from another epoch" \
8715 -S "resend" \
8716 -s "Extra-header:" \
8717 -c "HTTP/1.0 200 OK"
8718
8719run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8720 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008721 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8722 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008723 0 \
8724 -c "replayed record" \
8725 -S "replayed record" \
8726 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008727 -s "record from another epoch" \
8728 -c "resend" \
8729 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008730 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008731 -c "HTTP/1.0 200 OK"
8732
8733run_test "DTLS proxy: multiple records in same datagram" \
8734 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008735 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8736 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008737 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008738 -c "next record in same datagram" \
8739 -s "next record in same datagram"
8740
8741run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8742 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008743 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8744 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008745 0 \
8746 -c "next record in same datagram" \
8747 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008748
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008749run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8750 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008751 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8752 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008753 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008754 -c "discarding invalid record (mac)" \
8755 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008756 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008757 -c "HTTP/1.0 200 OK" \
8758 -S "too many records with bad MAC" \
8759 -S "Verification of the message MAC failed"
8760
8761run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8762 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008763 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8764 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008765 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008766 -C "discarding invalid record (mac)" \
8767 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008768 -S "Extra-header:" \
8769 -C "HTTP/1.0 200 OK" \
8770 -s "too many records with bad MAC" \
8771 -s "Verification of the message MAC failed"
8772
8773run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8774 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008775 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8776 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008777 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008778 -c "discarding invalid record (mac)" \
8779 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008780 -s "Extra-header:" \
8781 -c "HTTP/1.0 200 OK" \
8782 -S "too many records with bad MAC" \
8783 -S "Verification of the message MAC failed"
8784
8785run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8786 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008787 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8788 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008789 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008790 -c "discarding invalid record (mac)" \
8791 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008792 -s "Extra-header:" \
8793 -c "HTTP/1.0 200 OK" \
8794 -s "too many records with bad MAC" \
8795 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008796
8797run_test "DTLS proxy: delay ChangeCipherSpec" \
8798 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008799 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8800 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008801 0 \
8802 -c "record from another epoch" \
8803 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008804 -s "Extra-header:" \
8805 -c "HTTP/1.0 200 OK"
8806
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008807# Tests for reordering support with DTLS
8808
Hanno Becker56cdfd12018-08-17 13:42:15 +01008809run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8810 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008811 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8812 hs_timeout=2500-60000" \
8813 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8814 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008815 0 \
8816 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008817 -c "Next handshake message has been buffered - load"\
8818 -S "Buffering HS message" \
8819 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008820 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008821 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008822 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008823 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008824
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008825run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8826 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008827 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8828 hs_timeout=2500-60000" \
8829 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8830 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008831 0 \
8832 -c "Buffering HS message" \
8833 -c "found fragmented DTLS handshake message"\
8834 -c "Next handshake message 1 not or only partially bufffered" \
8835 -c "Next handshake message has been buffered - load"\
8836 -S "Buffering HS message" \
8837 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008838 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008839 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008840 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008841 -S "Remember CCS message"
8842
Hanno Beckera1adcca2018-08-24 14:41:07 +01008843# The client buffers the ServerKeyExchange before receiving the fragmented
8844# Certificate message; at the time of writing, together these are aroudn 1200b
8845# in size, so that the bound below ensures that the certificate can be reassembled
8846# while keeping the ServerKeyExchange.
8847requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8848run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008849 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008850 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8851 hs_timeout=2500-60000" \
8852 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8853 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008854 0 \
8855 -c "Buffering HS message" \
8856 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008857 -C "attempt to make space by freeing buffered messages" \
8858 -S "Buffering HS message" \
8859 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008860 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008861 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008862 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008863 -S "Remember CCS message"
8864
8865# The size constraints ensure that the delayed certificate message can't
8866# be reassembled while keeping the ServerKeyExchange message, but it can
8867# when dropping it first.
8868requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8869requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8870run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8871 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008872 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8873 hs_timeout=2500-60000" \
8874 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8875 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008876 0 \
8877 -c "Buffering HS message" \
8878 -c "attempt to make space by freeing buffered future messages" \
8879 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008880 -S "Buffering HS message" \
8881 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008882 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008883 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008884 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008885 -S "Remember CCS message"
8886
Hanno Becker56cdfd12018-08-17 13:42:15 +01008887run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8888 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008889 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8890 hs_timeout=2500-60000" \
8891 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8892 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008893 0 \
8894 -C "Buffering HS message" \
8895 -C "Next handshake message has been buffered - load"\
8896 -s "Buffering HS message" \
8897 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008898 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008899 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008900 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008901 -S "Remember CCS message"
8902
8903run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8904 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008905 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8906 hs_timeout=2500-60000" \
8907 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8908 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008909 0 \
8910 -C "Buffering HS message" \
8911 -C "Next handshake message has been buffered - load"\
8912 -S "Buffering HS message" \
8913 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008914 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008915 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008916 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008917 -S "Remember CCS message"
8918
8919run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8920 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008921 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8922 hs_timeout=2500-60000" \
8923 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8924 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008925 0 \
8926 -C "Buffering HS message" \
8927 -C "Next handshake message has been buffered - load"\
8928 -S "Buffering HS message" \
8929 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008930 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008931 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008932 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008933 -s "Remember CCS message"
8934
Hanno Beckera1adcca2018-08-24 14:41:07 +01008935run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008936 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008937 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8938 hs_timeout=2500-60000" \
8939 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8940 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008941 0 \
8942 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008943 -s "Found buffered record from current epoch - load" \
8944 -c "Buffer record from epoch 1" \
8945 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008946
Hanno Beckera1adcca2018-08-24 14:41:07 +01008947# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8948# from the server are delayed, so that the encrypted Finished message
8949# is received and buffered. When the fragmented NewSessionTicket comes
8950# in afterwards, the encrypted Finished message must be freed in order
8951# to make space for the NewSessionTicket to be reassembled.
8952# This works only in very particular circumstances:
8953# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8954# of the NewSessionTicket, but small enough to also allow buffering of
8955# the encrypted Finished message.
8956# - The MTU setting on the server must be so small that the NewSessionTicket
8957# needs to be fragmented.
8958# - All messages sent by the server must be small enough to be either sent
8959# without fragmentation or be reassembled within the bounds of
8960# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8961# handshake, omitting CRTs.
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02008962requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8963requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008964run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8965 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02008966 "$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 +01008967 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8968 0 \
8969 -s "Buffer record from epoch 1" \
8970 -s "Found buffered record from current epoch - load" \
8971 -c "Buffer record from epoch 1" \
8972 -C "Found buffered record from current epoch - load" \
8973 -c "Enough space available after freeing future epoch record"
8974
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008975# Tests for "randomly unreliable connection": try a variety of flows and peers
8976
8977client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008978run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8979 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008980 "$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 +02008981 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008982 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008983 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8984 0 \
8985 -s "Extra-header:" \
8986 -c "HTTP/1.0 200 OK"
8987
Janos Follath74537a62016-09-02 13:45:28 +01008988client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008989run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8990 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008991 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8992 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008993 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8994 0 \
8995 -s "Extra-header:" \
8996 -c "HTTP/1.0 200 OK"
8997
Janos Follath74537a62016-09-02 13:45:28 +01008998client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008999run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
9000 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009001 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
9002 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009003 0 \
9004 -s "Extra-header:" \
9005 -c "HTTP/1.0 200 OK"
9006
Janos Follath74537a62016-09-02 13:45:28 +01009007client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009008run_test "DTLS proxy: 3d, FS, client auth" \
9009 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009010 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
9011 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009012 0 \
9013 -s "Extra-header:" \
9014 -c "HTTP/1.0 200 OK"
9015
Janos Follath74537a62016-09-02 13:45:28 +01009016client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009017run_test "DTLS proxy: 3d, FS, ticket" \
9018 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009019 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
9020 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009021 0 \
9022 -s "Extra-header:" \
9023 -c "HTTP/1.0 200 OK"
9024
Janos Follath74537a62016-09-02 13:45:28 +01009025client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009026run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
9027 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009028 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
9029 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02009030 0 \
9031 -s "Extra-header:" \
9032 -c "HTTP/1.0 200 OK"
9033
Janos Follath74537a62016-09-02 13:45:28 +01009034client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009035run_test "DTLS proxy: 3d, max handshake, nbio" \
9036 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009037 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009038 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009039 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009040 0 \
9041 -s "Extra-header:" \
9042 -c "HTTP/1.0 200 OK"
9043
Janos Follath74537a62016-09-02 13:45:28 +01009044client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02009045run_test "DTLS proxy: 3d, min handshake, resumption" \
9046 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009047 "$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 +02009048 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009049 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01009050 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02009051 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9052 0 \
9053 -s "a session has been resumed" \
9054 -c "a session has been resumed" \
9055 -s "Extra-header:" \
9056 -c "HTTP/1.0 200 OK"
9057
Janos Follath74537a62016-09-02 13:45:28 +01009058client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02009059run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
9060 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009061 "$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 +02009062 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009063 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01009064 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02009065 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
9066 0 \
9067 -s "a session has been resumed" \
9068 -c "a session has been resumed" \
9069 -s "Extra-header:" \
9070 -c "HTTP/1.0 200 OK"
9071
Janos Follath74537a62016-09-02 13:45:28 +01009072client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009073requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009074run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02009075 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009076 "$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 +02009077 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009078 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009079 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02009080 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9081 0 \
9082 -c "=> renegotiate" \
9083 -s "=> renegotiate" \
9084 -s "Extra-header:" \
9085 -c "HTTP/1.0 200 OK"
9086
Janos Follath74537a62016-09-02 13:45:28 +01009087client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009088requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009089run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
9090 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009091 "$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 +02009092 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009093 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009094 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009095 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9096 0 \
9097 -c "=> renegotiate" \
9098 -s "=> renegotiate" \
9099 -s "Extra-header:" \
9100 -c "HTTP/1.0 200 OK"
9101
Janos Follath74537a62016-09-02 13:45:28 +01009102client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009103requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009104run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009105 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009106 "$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 +02009107 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009108 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009109 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009110 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009111 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9112 0 \
9113 -c "=> renegotiate" \
9114 -s "=> renegotiate" \
9115 -s "Extra-header:" \
9116 -c "HTTP/1.0 200 OK"
9117
Janos Follath74537a62016-09-02 13:45:28 +01009118client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009119requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009120run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009121 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009122 "$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 +02009123 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009124 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009125 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009126 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009127 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9128 0 \
9129 -c "=> renegotiate" \
9130 -s "=> renegotiate" \
9131 -s "Extra-header:" \
9132 -c "HTTP/1.0 200 OK"
9133
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009134## Interop tests with OpenSSL might trigger a bug in recent versions (including
9135## all versions installed on the CI machines), reported here:
9136## Bug report: https://github.com/openssl/openssl/issues/6902
9137## They should be re-enabled once a fixed version of OpenSSL is available
9138## (this should happen in some 1.1.1_ release according to the ticket).
9139skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01009140client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009141not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009142run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009143 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9144 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009145 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009146 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009147 -c "HTTP/1.0 200 OK"
9148
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009149skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01009150client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009151not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009152run_test "DTLS proxy: 3d, openssl server, fragmentation" \
9153 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9154 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009155 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009156 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009157 -c "HTTP/1.0 200 OK"
9158
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009159skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01009160client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009161not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009162run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
9163 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9164 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009165 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009166 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009167 -c "HTTP/1.0 200 OK"
9168
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00009169requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01009170client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009171not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009172run_test "DTLS proxy: 3d, gnutls server" \
9173 -p "$P_PXY drop=5 delay=5 duplicate=5" \
9174 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009175 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009176 0 \
9177 -s "Extra-header:" \
9178 -c "Extra-header:"
9179
k-stachowiak17a38d32019-02-18 15:29:56 +01009180requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01009181client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009182not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009183run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
9184 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01009185 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009186 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009187 0 \
9188 -s "Extra-header:" \
9189 -c "Extra-header:"
9190
k-stachowiak17a38d32019-02-18 15:29:56 +01009191requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01009192client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009193not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009194run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
9195 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01009196 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009197 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009198 0 \
9199 -s "Extra-header:" \
9200 -c "Extra-header:"
9201
Ron Eldorf75e2522019-05-14 20:38:49 +03009202requires_config_enabled MBEDTLS_SSL_EXPORT_KEYS
9203run_test "export keys functionality" \
9204 "$P_SRV eap_tls=1 debug_level=3" \
9205 "$P_CLI eap_tls=1 debug_level=3" \
9206 0 \
9207 -s "exported maclen is " \
9208 -s "exported keylen is " \
9209 -s "exported ivlen is " \
9210 -c "exported maclen is " \
9211 -c "exported keylen is " \
Ron Eldor65d8c262019-06-04 13:05:36 +03009212 -c "exported ivlen is " \
9213 -c "EAP-TLS key material is:"\
9214 -s "EAP-TLS key material is:"\
9215 -c "EAP-TLS IV is:" \
9216 -s "EAP-TLS IV is:"
Ron Eldorf75e2522019-05-14 20:38:49 +03009217
Piotr Nowicki0937ed22019-11-26 16:32:40 +01009218# Test heap memory usage after handshake
9219requires_config_enabled MBEDTLS_MEMORY_DEBUG
9220requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C
9221requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
9222run_tests_memory_after_hanshake
9223
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01009224# Final report
9225
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009226echo "------------------------------------------------------------------------"
9227
9228if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01009229 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009230else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01009231 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009232fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02009233PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02009234echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009235
9236exit $FAILS