blob: 8d28b63c35c44086a31352e02bb962d32ebd4ad3 [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
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200244# skip next test if OpenSSL doesn't support FALLBACK_SCSV
245requires_openssl_with_fallback_scsv() {
246 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
247 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
248 then
249 OPENSSL_HAS_FBSCSV="YES"
250 else
251 OPENSSL_HAS_FBSCSV="NO"
252 fi
253 fi
254 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
255 SKIP_NEXT="YES"
256 fi
257}
258
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200259# skip next test if GnuTLS isn't available
260requires_gnutls() {
261 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200262 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200263 GNUTLS_AVAILABLE="YES"
264 else
265 GNUTLS_AVAILABLE="NO"
266 fi
267 fi
268 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
269 SKIP_NEXT="YES"
270 fi
271}
272
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200273# skip next test if GnuTLS-next isn't available
274requires_gnutls_next() {
275 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
276 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
277 GNUTLS_NEXT_AVAILABLE="YES"
278 else
279 GNUTLS_NEXT_AVAILABLE="NO"
280 fi
281 fi
282 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
283 SKIP_NEXT="YES"
284 fi
285}
286
287# skip next test if OpenSSL-legacy isn't available
288requires_openssl_legacy() {
289 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
290 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
291 OPENSSL_LEGACY_AVAILABLE="YES"
292 else
293 OPENSSL_LEGACY_AVAILABLE="NO"
294 fi
295 fi
296 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
297 SKIP_NEXT="YES"
298 fi
299}
300
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200301# skip next test if IPv6 isn't available on this host
302requires_ipv6() {
303 if [ -z "${HAS_IPV6:-}" ]; then
304 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
305 SRV_PID=$!
306 sleep 1
307 kill $SRV_PID >/dev/null 2>&1
308 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
309 HAS_IPV6="NO"
310 else
311 HAS_IPV6="YES"
312 fi
313 rm -r $SRV_OUT
314 fi
315
316 if [ "$HAS_IPV6" = "NO" ]; then
317 SKIP_NEXT="YES"
318 fi
319}
320
Andrzej Kurekb4593462018-10-11 08:43:30 -0400321# skip next test if it's i686 or uname is not available
322requires_not_i686() {
323 if [ -z "${IS_I686:-}" ]; then
324 IS_I686="YES"
325 if which "uname" >/dev/null 2>&1; then
326 if [ -z "$(uname -a | grep i686)" ]; then
327 IS_I686="NO"
328 fi
329 fi
330 fi
331 if [ "$IS_I686" = "YES" ]; then
332 SKIP_NEXT="YES"
333 fi
334}
335
Angus Grattonc4dd0732018-04-11 16:28:39 +1000336# Calculate the input & output maximum content lengths set in the config
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200337MAX_CONTENT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
338MAX_IN_LEN=$( ../scripts/config.py get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
339MAX_OUT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
Angus Grattonc4dd0732018-04-11 16:28:39 +1000340
341if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
342 MAX_CONTENT_LEN="$MAX_IN_LEN"
343fi
344if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
345 MAX_CONTENT_LEN="$MAX_OUT_LEN"
346fi
347
348# skip the next test if the SSL output buffer is less than 16KB
349requires_full_size_output_buffer() {
350 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
351 SKIP_NEXT="YES"
352 fi
353}
354
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200355# skip the next test if valgrind is in use
356not_with_valgrind() {
357 if [ "$MEMCHECK" -gt 0 ]; then
358 SKIP_NEXT="YES"
359 fi
360}
361
Paul Bakker362689d2016-05-13 10:33:25 +0100362# skip the next test if valgrind is NOT in use
363only_with_valgrind() {
364 if [ "$MEMCHECK" -eq 0 ]; then
365 SKIP_NEXT="YES"
366 fi
367}
368
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200369# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100370client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200371 CLI_DELAY_FACTOR=$1
372}
373
Janos Follath74537a62016-09-02 13:45:28 +0100374# wait for the given seconds after the client finished in the next test
375server_needs_more_time() {
376 SRV_DELAY_SECONDS=$1
377}
378
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100379# print_name <name>
380print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100381 TESTS=$(( $TESTS + 1 ))
382 LINE=""
383
384 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
385 LINE="$TESTS "
386 fi
387
388 LINE="$LINE$1"
389 printf "$LINE "
390 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100391 for i in `seq 1 $LEN`; do printf '.'; done
392 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100393
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100394}
395
Gilles Peskine560280b2019-09-16 15:17:38 +0200396# record_outcome <outcome> [<failure-reason>]
397# The test name must be in $NAME.
398record_outcome() {
399 echo "$1"
400 if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ]; then
401 printf '%s;%s;%s;%s;%s;%s\n' \
402 "$MBEDTLS_TEST_PLATFORM" "$MBEDTLS_TEST_CONFIGURATION" \
403 "ssl-opt" "$NAME" \
404 "$1" "${2-}" \
405 >>"$MBEDTLS_TEST_OUTCOME_FILE"
406 fi
407}
408
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100409# fail <message>
410fail() {
Gilles Peskine560280b2019-09-16 15:17:38 +0200411 record_outcome "FAIL" "$1"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100412 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100413
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200414 mv $SRV_OUT o-srv-${TESTS}.log
415 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200416 if [ -n "$PXY_CMD" ]; then
417 mv $PXY_OUT o-pxy-${TESTS}.log
418 fi
419 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100420
Azim Khan19d13732018-03-29 11:04:20 +0100421 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot -o "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200422 echo " ! server output:"
423 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200424 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200425 echo " ! client output:"
426 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200427 if [ -n "$PXY_CMD" ]; then
428 echo " ! ========================================================"
429 echo " ! proxy output:"
430 cat o-pxy-${TESTS}.log
431 fi
432 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200433 fi
434
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200435 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100436}
437
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100438# is_polar <cmd_line>
439is_polar() {
440 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
441}
442
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200443# openssl s_server doesn't have -www with DTLS
444check_osrv_dtls() {
445 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
446 NEEDS_INPUT=1
447 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
448 else
449 NEEDS_INPUT=0
450 fi
451}
452
453# provide input to commands that need it
454provide_input() {
455 if [ $NEEDS_INPUT -eq 0 ]; then
456 return
457 fi
458
459 while true; do
460 echo "HTTP/1.0 200 OK"
461 sleep 1
462 done
463}
464
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100465# has_mem_err <log_file_name>
466has_mem_err() {
467 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
468 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
469 then
470 return 1 # false: does not have errors
471 else
472 return 0 # true: has errors
473 fi
474}
475
Unknownd364f4c2019-09-02 10:42:57 -0400476# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100477if type lsof >/dev/null 2>/dev/null; then
Unknownd364f4c2019-09-02 10:42:57 -0400478 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100479 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200480 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100481 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200482 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100483 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200484 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100485 # Make a tight loop, server normally takes less than 1s to start.
486 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
487 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknownd364f4c2019-09-02 10:42:57 -0400488 echo "$3 START TIMEOUT"
489 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100490 break
491 fi
492 # Linux and *BSD support decimal arguments to sleep. On other
493 # OSes this may be a tight loop.
494 sleep 0.1 2>/dev/null || true
495 done
496 }
497else
Unknownd364f4c2019-09-02 10:42:57 -0400498 echo "Warning: lsof not available, wait_app_start = sleep"
499 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200500 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100501 }
502fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200503
Unknownd364f4c2019-09-02 10:42:57 -0400504# Wait for server process $2 to be listening on port $1.
505wait_server_start() {
506 wait_app_start $1 $2 "SERVER" $SRV_OUT
507}
508
509# Wait for proxy process $2 to be listening on port $1.
510wait_proxy_start() {
511 wait_app_start $1 $2 "PROXY" $PXY_OUT
512}
513
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100514# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100515# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100516# acceptable bounds
517check_server_hello_time() {
518 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100519 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100520 # Get the Unix timestamp for now
521 CUR_TIME=$(date +'%s')
522 THRESHOLD_IN_SECS=300
523
524 # Check if the ServerHello time was printed
525 if [ -z "$SERVER_HELLO_TIME" ]; then
526 return 1
527 fi
528
529 # Check the time in ServerHello is within acceptable bounds
530 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
531 # The time in ServerHello is at least 5 minutes before now
532 return 1
533 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100534 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100535 return 1
536 else
537 return 0
538 fi
539}
540
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100541# Get handshake memory usage from server or client output and put it into the variable specified by the first argument
542handshake_memory_get() {
543 OUTPUT_VARIABLE="$1"
544 OUTPUT_FILE="$2"
545
546 # Get memory usage from a pattern like "Heap memory usage after handshake: 23112 bytes. Peak memory usage was 33112"
547 MEM_USAGE=$(sed -n 's/.*Heap memory usage after handshake: //p' < "$OUTPUT_FILE" | grep -o "[0-9]*" | head -1)
548
549 # Check if memory usage was read
550 if [ -z "$MEM_USAGE" ]; then
551 echo "Error: Can not read the value of handshake memory usage"
552 return 1
553 else
554 eval "$OUTPUT_VARIABLE=$MEM_USAGE"
555 return 0
556 fi
557}
558
559# Get handshake memory usage from server or client output and check if this value
560# is not higher than the maximum given by the first argument
561handshake_memory_check() {
562 MAX_MEMORY="$1"
563 OUTPUT_FILE="$2"
564
565 # Get memory usage
566 if ! handshake_memory_get "MEMORY_USAGE" "$OUTPUT_FILE"; then
567 return 1
568 fi
569
570 # Check if memory usage is below max value
571 if [ "$MEMORY_USAGE" -gt "$MAX_MEMORY" ]; then
572 echo "\nFailed: Handshake memory usage was $MEMORY_USAGE bytes," \
573 "but should be below $MAX_MEMORY bytes"
574 return 1
575 else
576 return 0
577 fi
578}
579
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200580# wait for client to terminate and set CLI_EXIT
581# must be called right after starting the client
582wait_client_done() {
583 CLI_PID=$!
584
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200585 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
586 CLI_DELAY_FACTOR=1
587
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200588 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200589 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200590
591 wait $CLI_PID
592 CLI_EXIT=$?
593
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200594 kill $DOG_PID >/dev/null 2>&1
595 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200596
597 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100598
599 sleep $SRV_DELAY_SECONDS
600 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200601}
602
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200603# check if the given command uses dtls and sets global variable DTLS
604detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200605 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200606 DTLS=1
607 else
608 DTLS=0
609 fi
610}
611
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200612# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100613# Options: -s pattern pattern that must be present in server output
614# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100615# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100616# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100617# -S pattern pattern that must be absent in server output
618# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100619# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100620# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100621run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100622 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200623 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100624
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100625 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
626 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200627 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200628 # There was no request to run the test, so don't record its outcome.
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100629 return
630 fi
631
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100632 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100633
Paul Bakkerb7584a52016-05-10 10:50:43 +0100634 # Do we only run numbered tests?
635 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
636 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
637 else
638 SKIP_NEXT="YES"
639 fi
640
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200641 # does this test use a proxy?
642 if [ "X$1" = "X-p" ]; then
643 PXY_CMD="$2"
644 shift 2
645 else
646 PXY_CMD=""
647 fi
648
649 # get commands and client output
650 SRV_CMD="$1"
651 CLI_CMD="$2"
652 CLI_EXPECT="$3"
653 shift 3
654
Hanno Becker91e72c32019-05-10 14:38:42 +0100655 # Check if test uses files
656 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
657 if [ ! -z "$TEST_USES_FILES" ]; then
658 requires_config_enabled MBEDTLS_FS_IO
659 fi
660
Hanno Becker9d76d562018-11-16 17:27:29 +0000661 # Check if server forces ciphersuite
662 FORCE_CIPHERSUITE=$(echo "$SRV_CMD" | sed -n 's/^.*force_ciphersuite=\([a-zA-Z0-9\-]*\).*$/\1/p')
663 if [ ! -z "$FORCE_CIPHERSUITE" ]; then
664 requires_ciphersuite_enabled $FORCE_CIPHERSUITE
665 fi
666
667 # Check if client forces ciphersuite
668 FORCE_CIPHERSUITE=$(echo "$CLI_CMD" | sed -n 's/^.*force_ciphersuite=\([a-zA-Z0-9\-]*\).*$/\1/p')
669 if [ ! -z "$FORCE_CIPHERSUITE" ]; then
670 requires_ciphersuite_enabled $FORCE_CIPHERSUITE
671 fi
672
673 # should we skip?
674 if [ "X$SKIP_NEXT" = "XYES" ]; then
675 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200676 record_outcome "SKIP"
Hanno Becker9d76d562018-11-16 17:27:29 +0000677 SKIPS=$(( $SKIPS + 1 ))
678 return
679 fi
680
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200681 # fix client port
682 if [ -n "$PXY_CMD" ]; then
683 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
684 else
685 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
686 fi
687
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200688 # update DTLS variable
689 detect_dtls "$SRV_CMD"
690
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100691 # prepend valgrind to our commands if active
692 if [ "$MEMCHECK" -gt 0 ]; then
693 if is_polar "$SRV_CMD"; then
694 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
695 fi
696 if is_polar "$CLI_CMD"; then
697 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
698 fi
699 fi
700
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200701 TIMES_LEFT=2
702 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200703 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200704
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200705 # run the commands
706 if [ -n "$PXY_CMD" ]; then
707 echo "$PXY_CMD" > $PXY_OUT
708 $PXY_CMD >> $PXY_OUT 2>&1 &
709 PXY_PID=$!
Unknownd364f4c2019-09-02 10:42:57 -0400710 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200711 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200712
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200713 check_osrv_dtls
714 echo "$SRV_CMD" > $SRV_OUT
715 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
716 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100717 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200718
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200719 echo "$CLI_CMD" > $CLI_OUT
720 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
721 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100722
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100723 sleep 0.05
724
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200725 # terminate the server (and the proxy)
726 kill $SRV_PID
727 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100728
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200729 if [ -n "$PXY_CMD" ]; then
730 kill $PXY_PID >/dev/null 2>&1
731 wait $PXY_PID
732 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100733
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200734 # retry only on timeouts
735 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
736 printf "RETRY "
737 else
738 TIMES_LEFT=0
739 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200740 done
741
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100742 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200743 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100744 # expected client exit to incorrectly succeed in case of catastrophic
745 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100746 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200747 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100748 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100749 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100750 return
751 fi
752 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100753 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200754 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100755 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100756 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100757 return
758 fi
759 fi
760
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100761 # check server exit code
762 if [ $? != 0 ]; then
763 fail "server fail"
764 return
765 fi
766
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100767 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100768 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
769 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100770 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200771 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100772 return
773 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100774
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100775 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200776 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100777 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100778 while [ $# -gt 0 ]
779 do
780 case $1 in
781 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100782 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 +0100783 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100784 return
785 fi
786 ;;
787
788 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100789 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 +0100790 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100791 return
792 fi
793 ;;
794
795 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100796 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 +0100797 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100798 return
799 fi
800 ;;
801
802 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100803 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 +0100804 fail "pattern '$2' MUST NOT be present in the Client output"
805 return
806 fi
807 ;;
808
809 # The filtering in the following two options (-u and -U) do the following
810 # - ignore valgrind output
Antonin Décimo36e89b52019-01-23 15:24:37 +0100811 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100812 # - keep one of each non-unique line
813 # - count how many lines remain
814 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
815 # if there were no duplicates.
816 "-U")
817 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
818 fail "lines following pattern '$2' must be unique in Server output"
819 return
820 fi
821 ;;
822
823 "-u")
824 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
825 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100826 return
827 fi
828 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100829 "-F")
830 if ! $2 "$SRV_OUT"; then
831 fail "function call to '$2' failed on Server output"
832 return
833 fi
834 ;;
835 "-f")
836 if ! $2 "$CLI_OUT"; then
837 fail "function call to '$2' failed on Client output"
838 return
839 fi
840 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100841
842 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200843 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100844 exit 1
845 esac
846 shift 2
847 done
848
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100849 # check valgrind's results
850 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200851 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100852 fail "Server has memory errors"
853 return
854 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200855 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100856 fail "Client has memory errors"
857 return
858 fi
859 fi
860
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100861 # if we're here, everything is ok
Gilles Peskine560280b2019-09-16 15:17:38 +0200862 record_outcome "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100863 if [ "$PRESERVE_LOGS" -gt 0 ]; then
864 mv $SRV_OUT o-srv-${TESTS}.log
865 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100866 if [ -n "$PXY_CMD" ]; then
867 mv $PXY_OUT o-pxy-${TESTS}.log
868 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100869 fi
870
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200871 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100872}
873
Hanno Becker9b5853c2018-11-16 17:28:40 +0000874run_test_psa() {
875 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
Hanno Beckere9420c22018-11-20 11:37:34 +0000876 run_test "PSA-supported ciphersuite: $1" \
Hanno Becker4c8c7aa2019-04-10 09:25:41 +0100877 "$P_SRV debug_level=3 force_version=tls1_2" \
878 "$P_CLI debug_level=3 force_version=tls1_2 force_ciphersuite=$1" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000879 0 \
880 -c "Successfully setup PSA-based decryption cipher context" \
881 -c "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500882 -c "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500883 -c "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000884 -s "Successfully setup PSA-based decryption cipher context" \
885 -s "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500886 -s "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500887 -s "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000888 -C "Failed to setup PSA-based cipher context"\
889 -S "Failed to setup PSA-based cipher context"\
890 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000891 -c "Perform PSA-based ECDH computation."\
Andrzej Kureke85414e2019-01-15 05:23:59 -0500892 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000893 -S "error" \
894 -C "error"
895}
896
Hanno Becker354e2482019-01-08 11:40:25 +0000897run_test_psa_force_curve() {
898 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
899 run_test "PSA - ECDH with $1" \
900 "$P_SRV debug_level=4 force_version=tls1_2" \
901 "$P_CLI debug_level=4 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=$1" \
902 0 \
Hanno Becker28f78442019-02-18 16:47:50 +0000903 -c "Successfully setup PSA-based decryption cipher context" \
904 -c "Successfully setup PSA-based encryption cipher context" \
905 -c "PSA calc verify" \
906 -c "calc PSA finished" \
907 -s "Successfully setup PSA-based decryption cipher context" \
908 -s "Successfully setup PSA-based encryption cipher context" \
909 -s "PSA calc verify" \
910 -s "calc PSA finished" \
911 -C "Failed to setup PSA-based cipher context"\
912 -S "Failed to setup PSA-based cipher context"\
Hanno Becker354e2482019-01-08 11:40:25 +0000913 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000914 -c "Perform PSA-based ECDH computation."\
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100915 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200916 -S "error" \
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200917 -C "error"
918}
919
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100920# Test that the server's memory usage after a handshake is reduced when a client specifies
921# a maximum fragment length.
922# first argument ($1) is MFL for SSL client
923# second argument ($2) is memory usage for SSL client with default MFL (16k)
924run_test_memory_after_hanshake_with_mfl()
925{
926 # The test passes if the difference is around 2*(16k-MFL)
927 local MEMORY_USAGE_LIMIT="$(( $2 - ( 2 * ( 16384 - $1 )) ))"
928
929 # Leave some margin for robustness
930 MEMORY_USAGE_LIMIT="$(( ( MEMORY_USAGE_LIMIT * 110 ) / 100 ))"
931
932 run_test "Handshake memory usage (MFL $1)" \
933 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
934 "$P_CLI debug_level=3 force_version=tls1_2 \
935 crt_file=data_files/server5.crt key_file=data_files/server5.key \
936 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM max_frag_len=$1" \
937 0 \
938 -F "handshake_memory_check $MEMORY_USAGE_LIMIT"
939}
940
941
942# Test that the server's memory usage after a handshake is reduced when a client specifies
943# different values of Maximum Fragment Length: default (16k), 4k, 2k, 1k and 512 bytes
944run_tests_memory_after_hanshake()
945{
946 # all tests in this sequence requires the same configuration (see requires_config_enabled())
947 SKIP_THIS_TESTS="$SKIP_NEXT"
948
949 # first test with default MFU is to get reference memory usage
950 MEMORY_USAGE_MFL_16K=0
951 run_test "Handshake memory usage initial (MFL 16384 - default)" \
952 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
953 "$P_CLI debug_level=3 force_version=tls1_2 \
954 crt_file=data_files/server5.crt key_file=data_files/server5.key \
955 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM" \
956 0 \
957 -F "handshake_memory_get MEMORY_USAGE_MFL_16K"
958
959 SKIP_NEXT="$SKIP_THIS_TESTS"
960 run_test_memory_after_hanshake_with_mfl 4096 "$MEMORY_USAGE_MFL_16K"
961
962 SKIP_NEXT="$SKIP_THIS_TESTS"
963 run_test_memory_after_hanshake_with_mfl 2048 "$MEMORY_USAGE_MFL_16K"
964
965 SKIP_NEXT="$SKIP_THIS_TESTS"
966 run_test_memory_after_hanshake_with_mfl 1024 "$MEMORY_USAGE_MFL_16K"
967
968 SKIP_NEXT="$SKIP_THIS_TESTS"
969 run_test_memory_after_hanshake_with_mfl 512 "$MEMORY_USAGE_MFL_16K"
970}
971
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100972cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200973 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Piotr Nowicki3de298f2020-04-16 14:35:19 +0200974 rm -f context_srv.txt
975 rm -f context_cli.txt
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200976 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
977 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
978 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
979 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100980 exit 1
981}
982
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100983#
984# MAIN
985#
986
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100987get_options "$@"
988
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100989# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100990P_SRV_BIN="${P_SRV%%[ ]*}"
991P_CLI_BIN="${P_CLI%%[ ]*}"
992P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100993if [ ! -x "$P_SRV_BIN" ]; then
994 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100995 exit 1
996fi
Hanno Becker17c04932017-10-10 14:44:53 +0100997if [ ! -x "$P_CLI_BIN" ]; then
998 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100999 exit 1
1000fi
Hanno Becker17c04932017-10-10 14:44:53 +01001001if [ ! -x "$P_PXY_BIN" ]; then
1002 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001003 exit 1
1004fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +01001005if [ "$MEMCHECK" -gt 0 ]; then
1006 if which valgrind >/dev/null 2>&1; then :; else
1007 echo "Memcheck not possible. Valgrind not found"
1008 exit 1
1009 fi
1010fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001011if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1012 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001013 exit 1
1014fi
1015
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001016# used by watchdog
1017MAIN_PID="$$"
1018
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001019# We use somewhat arbitrary delays for tests:
1020# - how long do we wait for the server to start (when lsof not available)?
1021# - how long do we allow for the client to finish?
1022# (not to check performance, just to avoid waiting indefinitely)
1023# Things are slower with valgrind, so give extra time here.
1024#
1025# Note: without lsof, there is a trade-off between the running time of this
1026# script and the risk of spurious errors because we didn't wait long enough.
1027# The watchdog delay on the other hand doesn't affect normal running time of
1028# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001029if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001030 START_DELAY=6
1031 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001032else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001033 START_DELAY=2
1034 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001035fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001036
1037# some particular tests need more time:
1038# - for the client, we multiply the usual watchdog limit by a factor
1039# - for the server, we sleep for a number of seconds after the client exits
1040# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001041CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001042SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001043
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001044# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001045# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001046P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1047P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001048P_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 +02001049O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001050O_CLI="$O_CLI -connect localhost:+SRV_PORT"
1051G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001052G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001053
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001054if [ -n "${OPENSSL_LEGACY:-}" ]; then
1055 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1056 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1057fi
1058
Hanno Becker58e9dc32018-08-17 15:53:21 +01001059if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001060 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1061fi
1062
Hanno Becker58e9dc32018-08-17 15:53:21 +01001063if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001064 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001065fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001066
Gilles Peskine62469d92017-05-10 10:13:59 +02001067# Allow SHA-1, because many of our test certificates use it
1068P_SRV="$P_SRV allow_sha1=1"
1069P_CLI="$P_CLI allow_sha1=1"
1070
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001071# Also pick a unique name for intermediate files
1072SRV_OUT="srv_out.$$"
1073CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001074PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001075SESSION="session.$$"
1076
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001077SKIP_NEXT="NO"
1078
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001079trap cleanup INT TERM HUP
1080
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001081# Basic test
1082
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001083# Checks that:
1084# - things work with all ciphersuites active (used with config-full in all.sh)
1085# - the expected (highest security) parameters are selected
1086# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001087run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001088 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001089 "$P_CLI" \
1090 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001091 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001092 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001093 -s "client hello v3, signature_algorithm ext: 6" \
1094 -s "ECDHE curve: secp521r1" \
1095 -S "error" \
1096 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001097
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001098run_test "Default, DTLS" \
1099 "$P_SRV dtls=1" \
1100 "$P_CLI dtls=1" \
1101 0 \
1102 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001103 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001104
Manuel Pégourié-Gonnard342d2ca2020-01-02 11:58:00 +01001105requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1106run_test "Default (compression enabled)" \
1107 "$P_SRV debug_level=3" \
1108 "$P_CLI debug_level=3" \
1109 0 \
1110 -s "Allocating compression buffer" \
1111 -c "Allocating compression buffer" \
1112 -s "Record expansion is unknown (compression)" \
1113 -c "Record expansion is unknown (compression)" \
1114 -S "error" \
1115 -C "error"
1116
Hanno Becker746aaf32019-03-28 15:25:23 +00001117requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1118run_test "CA callback on client" \
1119 "$P_SRV debug_level=3" \
1120 "$P_CLI ca_callback=1 debug_level=3 " \
1121 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001122 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001123 -S "error" \
1124 -C "error"
1125
1126requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1127requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1128requires_config_enabled MBEDTLS_ECDSA_C
1129requires_config_enabled MBEDTLS_SHA256_C
1130run_test "CA callback on server" \
1131 "$P_SRV auth_mode=required" \
1132 "$P_CLI ca_callback=1 debug_level=3 crt_file=data_files/server5.crt \
1133 key_file=data_files/server5.key" \
1134 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001135 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001136 -s "Verifying peer X.509 certificate... ok" \
1137 -S "error" \
1138 -C "error"
1139
Manuel Pégourié-Gonnardcfdf8f42018-11-08 09:52:25 +01001140# Test using an opaque private key for client authentication
1141requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
1142requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1143requires_config_enabled MBEDTLS_ECDSA_C
1144requires_config_enabled MBEDTLS_SHA256_C
1145run_test "Opaque key for client authentication" \
1146 "$P_SRV auth_mode=required" \
1147 "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \
1148 key_file=data_files/server5.key" \
1149 0 \
1150 -c "key type: Opaque" \
1151 -s "Verifying peer X.509 certificate... ok" \
1152 -S "error" \
1153 -C "error"
1154
Hanno Becker9b5853c2018-11-16 17:28:40 +00001155# Test ciphersuites which we expect to be fully supported by PSA Crypto
1156# and check that we don't fall back to Mbed TLS' internal crypto primitives.
1157run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM
1158run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
1159run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM
1160run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8
1161run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
1162run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384
1163run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA
1164run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
1165run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384
1166
Hanno Becker354e2482019-01-08 11:40:25 +00001167requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1168run_test_psa_force_curve "secp521r1"
1169requires_config_enabled MBEDTLS_ECP_DP_BP512R1_ENABLED
1170run_test_psa_force_curve "brainpoolP512r1"
1171requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
1172run_test_psa_force_curve "secp384r1"
1173requires_config_enabled MBEDTLS_ECP_DP_BP384R1_ENABLED
1174run_test_psa_force_curve "brainpoolP384r1"
1175requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED
1176run_test_psa_force_curve "secp256r1"
1177requires_config_enabled MBEDTLS_ECP_DP_SECP256K1_ENABLED
1178run_test_psa_force_curve "secp256k1"
1179requires_config_enabled MBEDTLS_ECP_DP_BP256R1_ENABLED
1180run_test_psa_force_curve "brainpoolP256r1"
1181requires_config_enabled MBEDTLS_ECP_DP_SECP224R1_ENABLED
1182run_test_psa_force_curve "secp224r1"
1183requires_config_enabled MBEDTLS_ECP_DP_SECP224K1_ENABLED
1184run_test_psa_force_curve "secp224k1"
1185requires_config_enabled MBEDTLS_ECP_DP_SECP192R1_ENABLED
1186run_test_psa_force_curve "secp192r1"
1187requires_config_enabled MBEDTLS_ECP_DP_SECP192K1_ENABLED
1188run_test_psa_force_curve "secp192k1"
1189
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001190# Test current time in ServerHello
1191requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001192run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001193 "$P_SRV debug_level=3" \
1194 "$P_CLI debug_level=3" \
1195 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001196 -f "check_server_hello_time" \
1197 -F "check_server_hello_time"
1198
Simon Butcher8e004102016-10-14 00:48:33 +01001199# Test for uniqueness of IVs in AEAD ciphersuites
1200run_test "Unique IV in GCM" \
1201 "$P_SRV exchanges=20 debug_level=4" \
1202 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1203 0 \
1204 -u "IV used" \
1205 -U "IV used"
1206
Janos Follathee11be62019-04-04 12:03:30 +01001207# Tests for certificate verification callback
1208run_test "Configuration-specific CRT verification callback" \
1209 "$P_SRV debug_level=3" \
1210 "$P_CLI context_crt_cb=0 debug_level=3" \
1211 0 \
Janos Follathee11be62019-04-04 12:03:30 +01001212 -S "error" \
1213 -c "Verify requested for " \
1214 -c "Use configuration-specific verification callback" \
1215 -C "Use context-specific verification callback" \
1216 -C "error"
1217
Hanno Beckerefb440a2019-04-03 13:04:33 +01001218run_test "Context-specific CRT verification callback" \
1219 "$P_SRV debug_level=3" \
1220 "$P_CLI context_crt_cb=1 debug_level=3" \
1221 0 \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001222 -S "error" \
Janos Follathee11be62019-04-04 12:03:30 +01001223 -c "Verify requested for " \
1224 -c "Use context-specific verification callback" \
1225 -C "Use configuration-specific verification callback" \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001226 -C "error"
1227
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001228# Tests for rc4 option
1229
Simon Butchera410af52016-05-19 22:12:18 +01001230requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001231run_test "RC4: server disabled, client enabled" \
1232 "$P_SRV" \
1233 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1234 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001235 -s "SSL - The server has no ciphersuites in common"
1236
Simon Butchera410af52016-05-19 22:12:18 +01001237requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001238run_test "RC4: server half, client enabled" \
1239 "$P_SRV arc4=1" \
1240 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1241 1 \
1242 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001243
1244run_test "RC4: server enabled, client disabled" \
1245 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1246 "$P_CLI" \
1247 1 \
1248 -s "SSL - The server has no ciphersuites in common"
1249
1250run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001251 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001252 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1253 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001254 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001255 -S "SSL - The server has no ciphersuites in common"
1256
Hanno Beckerd26bb202018-08-17 09:54:10 +01001257# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1258
1259requires_gnutls
1260requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1261run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1262 "$G_SRV"\
1263 "$P_CLI force_version=tls1_1" \
1264 0
1265
1266requires_gnutls
1267requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1268run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1269 "$G_SRV"\
1270 "$P_CLI force_version=tls1" \
1271 0
1272
Gilles Peskinebc70a182017-05-09 15:59:24 +02001273# Tests for SHA-1 support
1274
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001275requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001276run_test "SHA-1 forbidden by default in server certificate" \
1277 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1278 "$P_CLI debug_level=2 allow_sha1=0" \
1279 1 \
1280 -c "The certificate is signed with an unacceptable hash"
1281
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001282requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02001283run_test "SHA-1 allowed by default in server certificate" \
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001284 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1285 "$P_CLI debug_level=2 allow_sha1=0" \
1286 0
1287
Gilles Peskinebc70a182017-05-09 15:59:24 +02001288run_test "SHA-1 explicitly allowed in server certificate" \
1289 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1290 "$P_CLI allow_sha1=1" \
1291 0
1292
1293run_test "SHA-256 allowed by default in server certificate" \
1294 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1295 "$P_CLI allow_sha1=0" \
1296 0
1297
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001298requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001299run_test "SHA-1 forbidden by default in client certificate" \
1300 "$P_SRV auth_mode=required allow_sha1=0" \
1301 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1302 1 \
1303 -s "The certificate is signed with an unacceptable hash"
1304
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001305requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02001306run_test "SHA-1 allowed by default in client certificate" \
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001307 "$P_SRV auth_mode=required allow_sha1=0" \
1308 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1309 0
1310
Gilles Peskinebc70a182017-05-09 15:59:24 +02001311run_test "SHA-1 explicitly allowed in client certificate" \
1312 "$P_SRV auth_mode=required allow_sha1=1" \
1313 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1314 0
1315
1316run_test "SHA-256 allowed by default in client certificate" \
1317 "$P_SRV auth_mode=required allow_sha1=0" \
1318 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1319 0
1320
Hanno Becker7ae8a762018-08-14 15:43:35 +01001321# Tests for datagram packing
1322run_test "DTLS: multiple records in same datagram, client and server" \
1323 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1324 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1325 0 \
1326 -c "next record in same datagram" \
1327 -s "next record in same datagram"
1328
1329run_test "DTLS: multiple records in same datagram, client only" \
1330 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1331 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1332 0 \
1333 -s "next record in same datagram" \
1334 -C "next record in same datagram"
1335
1336run_test "DTLS: multiple records in same datagram, server only" \
1337 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1338 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1339 0 \
1340 -S "next record in same datagram" \
1341 -c "next record in same datagram"
1342
1343run_test "DTLS: multiple records in same datagram, neither client nor server" \
1344 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1345 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1346 0 \
1347 -S "next record in same datagram" \
1348 -C "next record in same datagram"
1349
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001350# Tests for Truncated HMAC extension
1351
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001352run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001353 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001354 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001355 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001356 -s "dumping 'expected mac' (20 bytes)" \
1357 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001358
Hanno Becker32c55012017-11-10 08:42:54 +00001359requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001360run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001361 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001362 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001363 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001364 -s "dumping 'expected mac' (20 bytes)" \
1365 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001366
Hanno Becker32c55012017-11-10 08:42:54 +00001367requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001368run_test "Truncated HMAC: client enabled, server default" \
1369 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001370 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001371 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001372 -s "dumping 'expected mac' (20 bytes)" \
1373 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001374
Hanno Becker32c55012017-11-10 08:42:54 +00001375requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001376run_test "Truncated HMAC: client enabled, server disabled" \
1377 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001378 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001379 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001380 -s "dumping 'expected mac' (20 bytes)" \
1381 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001382
Hanno Becker32c55012017-11-10 08:42:54 +00001383requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001384run_test "Truncated HMAC: client disabled, server enabled" \
1385 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001386 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001387 0 \
1388 -s "dumping 'expected mac' (20 bytes)" \
1389 -S "dumping 'expected mac' (10 bytes)"
1390
1391requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001392run_test "Truncated HMAC: client enabled, server enabled" \
1393 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001394 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001395 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001396 -S "dumping 'expected mac' (20 bytes)" \
1397 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001398
Hanno Becker4c4f4102017-11-10 09:16:05 +00001399run_test "Truncated HMAC, DTLS: client default, server default" \
1400 "$P_SRV dtls=1 debug_level=4" \
1401 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1402 0 \
1403 -s "dumping 'expected mac' (20 bytes)" \
1404 -S "dumping 'expected mac' (10 bytes)"
1405
1406requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1407run_test "Truncated HMAC, DTLS: client disabled, server default" \
1408 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001409 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001410 0 \
1411 -s "dumping 'expected mac' (20 bytes)" \
1412 -S "dumping 'expected mac' (10 bytes)"
1413
1414requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1415run_test "Truncated HMAC, DTLS: client enabled, server default" \
1416 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001417 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001418 0 \
1419 -s "dumping 'expected mac' (20 bytes)" \
1420 -S "dumping 'expected mac' (10 bytes)"
1421
1422requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1423run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1424 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001425 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001426 0 \
1427 -s "dumping 'expected mac' (20 bytes)" \
1428 -S "dumping 'expected mac' (10 bytes)"
1429
1430requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1431run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1432 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001433 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001434 0 \
1435 -s "dumping 'expected mac' (20 bytes)" \
1436 -S "dumping 'expected mac' (10 bytes)"
1437
1438requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1439run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1440 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001441 "$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 +01001442 0 \
1443 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001444 -s "dumping 'expected mac' (10 bytes)"
1445
Jarno Lamsa2937d812019-06-04 11:33:23 +03001446# Tests for Context serialization
1447
1448requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001449run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001450 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001451 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1452 0 \
1453 -c "Deserializing connection..." \
1454 -S "Deserializing connection..."
1455
1456requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1457run_test "Context serialization, client serializes, ChaChaPoly" \
1458 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1459 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1460 0 \
1461 -c "Deserializing connection..." \
1462 -S "Deserializing connection..."
1463
1464requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1465run_test "Context serialization, client serializes, GCM" \
1466 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1467 "$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 +03001468 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001469 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001470 -S "Deserializing connection..."
1471
1472requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001473requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1474run_test "Context serialization, client serializes, with CID" \
1475 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1476 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1477 0 \
1478 -c "Deserializing connection..." \
1479 -S "Deserializing connection..."
1480
1481requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001482run_test "Context serialization, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001483 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001484 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1485 0 \
1486 -C "Deserializing connection..." \
1487 -s "Deserializing connection..."
1488
1489requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1490run_test "Context serialization, server serializes, ChaChaPoly" \
1491 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1492 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1493 0 \
1494 -C "Deserializing connection..." \
1495 -s "Deserializing connection..."
1496
1497requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1498run_test "Context serialization, server serializes, GCM" \
1499 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1500 "$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 +03001501 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001502 -C "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001503 -s "Deserializing connection..."
1504
1505requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001506requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1507run_test "Context serialization, server serializes, with CID" \
1508 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1509 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1510 0 \
1511 -C "Deserializing connection..." \
1512 -s "Deserializing connection..."
1513
1514requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001515run_test "Context serialization, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001516 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001517 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1518 0 \
1519 -c "Deserializing connection..." \
1520 -s "Deserializing connection..."
1521
1522requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1523run_test "Context serialization, both serialize, ChaChaPoly" \
1524 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1525 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1526 0 \
1527 -c "Deserializing connection..." \
1528 -s "Deserializing connection..."
1529
1530requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1531run_test "Context serialization, both serialize, GCM" \
1532 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1533 "$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 +03001534 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001535 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001536 -s "Deserializing connection..."
1537
Jarno Lamsac2376f02019-06-06 10:44:14 +03001538requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001539requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1540run_test "Context serialization, both serialize, with CID" \
1541 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1542 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1543 0 \
1544 -c "Deserializing connection..." \
1545 -s "Deserializing connection..."
1546
1547requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001548run_test "Context serialization, re-init, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001549 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001550 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1551 0 \
1552 -c "Deserializing connection..." \
1553 -S "Deserializing connection..."
1554
1555requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1556run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1557 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1558 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1559 0 \
1560 -c "Deserializing connection..." \
1561 -S "Deserializing connection..."
1562
1563requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1564run_test "Context serialization, re-init, client serializes, GCM" \
1565 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1566 "$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 +03001567 0 \
1568 -c "Deserializing connection..." \
1569 -S "Deserializing connection..."
1570
Jarno Lamsac2376f02019-06-06 10:44:14 +03001571requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001572requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1573run_test "Context serialization, re-init, client serializes, with CID" \
1574 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1575 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1576 0 \
1577 -c "Deserializing connection..." \
1578 -S "Deserializing connection..."
1579
1580requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001581run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001582 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001583 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1584 0 \
1585 -C "Deserializing connection..." \
1586 -s "Deserializing connection..."
1587
1588requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1589run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1590 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1591 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1592 0 \
1593 -C "Deserializing connection..." \
1594 -s "Deserializing connection..."
1595
1596requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1597run_test "Context serialization, re-init, server serializes, GCM" \
1598 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1599 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001600 0 \
1601 -C "Deserializing connection..." \
1602 -s "Deserializing connection..."
1603
Jarno Lamsac2376f02019-06-06 10:44:14 +03001604requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001605requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1606run_test "Context serialization, re-init, server serializes, with CID" \
1607 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1608 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1609 0 \
1610 -C "Deserializing connection..." \
1611 -s "Deserializing connection..."
1612
1613requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001614run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001615 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001616 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1617 0 \
1618 -c "Deserializing connection..." \
1619 -s "Deserializing connection..."
1620
1621requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1622run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1623 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1624 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1625 0 \
1626 -c "Deserializing connection..." \
1627 -s "Deserializing connection..."
1628
1629requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1630run_test "Context serialization, re-init, both serialize, GCM" \
1631 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1632 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001633 0 \
1634 -c "Deserializing connection..." \
1635 -s "Deserializing connection..."
1636
Hanno Becker1b18fd32019-08-30 11:18:59 +01001637requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1638requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1639run_test "Context serialization, re-init, both serialize, with CID" \
1640 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1641 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1642 0 \
1643 -c "Deserializing connection..." \
1644 -s "Deserializing connection..."
1645
Piotr Nowicki3de298f2020-04-16 14:35:19 +02001646requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1647run_test "Saving the serialized context to a file" \
1648 "$P_SRV dtls=1 serialize=1 context_file=context_srv.txt" \
1649 "$P_CLI dtls=1 serialize=1 context_file=context_cli.txt" \
1650 0 \
1651 -s "Save serialized context to a file... ok" \
1652 -c "Save serialized context to a file... ok"
1653rm -f context_srv.txt
1654rm -f context_cli.txt
1655
Hanno Becker7cf463e2019-04-09 18:08:47 +01001656# Tests for DTLS Connection ID extension
1657
Hanno Becker7cf463e2019-04-09 18:08:47 +01001658# So far, the CID API isn't implemented, so we can't
1659# grep for output witnessing its use. This needs to be
1660# changed once the CID extension is implemented.
1661
Hanno Beckera0e20d02019-05-15 14:03:01 +01001662requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001663run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001664 "$P_SRV debug_level=3 dtls=1 cid=0" \
1665 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1666 0 \
1667 -s "Disable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001668 -s "found CID extension" \
1669 -s "Client sent CID extension, but CID disabled" \
Hanno Becker6b78c832019-04-25 17:01:43 +01001670 -c "Enable use of CID extension." \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001671 -c "client hello, adding CID extension" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001672 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001673 -C "found CID extension" \
1674 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001675 -C "Copy CIDs into SSL transform" \
1676 -c "Use of Connection ID was rejected by the server"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001677
Hanno Beckera0e20d02019-05-15 14:03:01 +01001678requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001679run_test "Connection ID: Cli disabled, Srv enabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001680 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1681 "$P_CLI debug_level=3 dtls=1 cid=0" \
1682 0 \
1683 -c "Disable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001684 -C "client hello, adding CID extension" \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001685 -S "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001686 -s "Enable use of CID extension." \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001687 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001688 -C "found CID extension" \
1689 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001690 -C "Copy CIDs into SSL transform" \
Hanno Beckerb3e9dd52019-05-08 13:19:53 +01001691 -s "Use of Connection ID was not offered by client"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001692
Hanno Beckera0e20d02019-05-15 14:03:01 +01001693requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001694run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001695 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1696 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1697 0 \
1698 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001699 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001700 -c "client hello, adding CID extension" \
1701 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001702 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001703 -s "server hello, adding CID extension" \
1704 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001705 -c "Use of CID extension negotiated" \
1706 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001707 -c "Copy CIDs into SSL transform" \
1708 -c "Peer CID (length 2 Bytes): de ad" \
1709 -s "Peer CID (length 2 Bytes): be ef" \
1710 -s "Use of Connection ID has been negotiated" \
1711 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001712
Hanno Beckera0e20d02019-05-15 14:03:01 +01001713requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001714run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001715 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001716 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1717 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1718 0 \
1719 -c "Enable use of CID extension." \
1720 -s "Enable use of CID extension." \
1721 -c "client hello, adding CID extension" \
1722 -s "found CID extension" \
1723 -s "Use of CID extension negotiated" \
1724 -s "server hello, adding CID extension" \
1725 -c "found CID extension" \
1726 -c "Use of CID extension negotiated" \
1727 -s "Copy CIDs into SSL transform" \
1728 -c "Copy CIDs into SSL transform" \
1729 -c "Peer CID (length 2 Bytes): de ad" \
1730 -s "Peer CID (length 2 Bytes): be ef" \
1731 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001732 -c "Use of Connection ID has been negotiated" \
1733 -c "ignoring unexpected CID" \
1734 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001735
Hanno Beckera0e20d02019-05-15 14:03:01 +01001736requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001737run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1738 -p "$P_PXY mtu=800" \
1739 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1740 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1741 0 \
1742 -c "Enable use of CID extension." \
1743 -s "Enable use of CID extension." \
1744 -c "client hello, adding CID extension" \
1745 -s "found CID extension" \
1746 -s "Use of CID extension negotiated" \
1747 -s "server hello, adding CID extension" \
1748 -c "found CID extension" \
1749 -c "Use of CID extension negotiated" \
1750 -s "Copy CIDs into SSL transform" \
1751 -c "Copy CIDs into SSL transform" \
1752 -c "Peer CID (length 2 Bytes): de ad" \
1753 -s "Peer CID (length 2 Bytes): be ef" \
1754 -s "Use of Connection ID has been negotiated" \
1755 -c "Use of Connection ID has been negotiated"
1756
Hanno Beckera0e20d02019-05-15 14:03:01 +01001757requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001758run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001759 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001760 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1761 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1762 0 \
1763 -c "Enable use of CID extension." \
1764 -s "Enable use of CID extension." \
1765 -c "client hello, adding CID extension" \
1766 -s "found CID extension" \
1767 -s "Use of CID extension negotiated" \
1768 -s "server hello, adding CID extension" \
1769 -c "found CID extension" \
1770 -c "Use of CID extension negotiated" \
1771 -s "Copy CIDs into SSL transform" \
1772 -c "Copy CIDs into SSL transform" \
1773 -c "Peer CID (length 2 Bytes): de ad" \
1774 -s "Peer CID (length 2 Bytes): be ef" \
1775 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001776 -c "Use of Connection ID has been negotiated" \
1777 -c "ignoring unexpected CID" \
1778 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001779
Hanno Beckera0e20d02019-05-15 14:03:01 +01001780requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001781run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001782 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1783 "$P_CLI debug_level=3 dtls=1 cid=1" \
1784 0 \
1785 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001786 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001787 -c "client hello, adding CID extension" \
1788 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001789 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001790 -s "server hello, adding CID extension" \
1791 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001792 -c "Use of CID extension negotiated" \
1793 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001794 -c "Copy CIDs into SSL transform" \
1795 -c "Peer CID (length 4 Bytes): de ad be ef" \
1796 -s "Peer CID (length 0 Bytes):" \
1797 -s "Use of Connection ID has been negotiated" \
1798 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001799
Hanno Beckera0e20d02019-05-15 14:03:01 +01001800requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001801run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001802 "$P_SRV debug_level=3 dtls=1 cid=1" \
1803 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1804 0 \
1805 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001806 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001807 -c "client hello, adding CID extension" \
1808 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001809 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001810 -s "server hello, adding CID extension" \
1811 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001812 -c "Use of CID extension negotiated" \
1813 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001814 -c "Copy CIDs into SSL transform" \
1815 -s "Peer CID (length 4 Bytes): de ad be ef" \
1816 -c "Peer CID (length 0 Bytes):" \
1817 -s "Use of Connection ID has been negotiated" \
1818 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001819
Hanno Beckera0e20d02019-05-15 14:03:01 +01001820requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001821run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001822 "$P_SRV debug_level=3 dtls=1 cid=1" \
1823 "$P_CLI debug_level=3 dtls=1 cid=1" \
1824 0 \
1825 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001826 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001827 -c "client hello, adding CID extension" \
1828 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001829 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001830 -s "server hello, adding CID extension" \
1831 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001832 -c "Use of CID extension negotiated" \
1833 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001834 -c "Copy CIDs into SSL transform" \
1835 -S "Use of Connection ID has been negotiated" \
1836 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001837
Hanno Beckera0e20d02019-05-15 14:03:01 +01001838requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001839run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001840 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1841 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1842 0 \
1843 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001844 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001845 -c "client hello, adding CID extension" \
1846 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001847 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001848 -s "server hello, adding CID extension" \
1849 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001850 -c "Use of CID extension negotiated" \
1851 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001852 -c "Copy CIDs into SSL transform" \
1853 -c "Peer CID (length 2 Bytes): de ad" \
1854 -s "Peer CID (length 2 Bytes): be ef" \
1855 -s "Use of Connection ID has been negotiated" \
1856 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001857
Hanno Beckera0e20d02019-05-15 14:03:01 +01001858requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001859run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001860 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1861 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1862 0 \
1863 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001864 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001865 -c "client hello, adding CID extension" \
1866 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001867 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001868 -s "server hello, adding CID extension" \
1869 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001870 -c "Use of CID extension negotiated" \
1871 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001872 -c "Copy CIDs into SSL transform" \
1873 -c "Peer CID (length 4 Bytes): de ad be ef" \
1874 -s "Peer CID (length 0 Bytes):" \
1875 -s "Use of Connection ID has been negotiated" \
1876 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001877
Hanno Beckera0e20d02019-05-15 14:03:01 +01001878requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001879run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001880 "$P_SRV debug_level=3 dtls=1 cid=1" \
1881 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1882 0 \
1883 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001884 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001885 -c "client hello, adding CID extension" \
1886 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001887 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001888 -s "server hello, adding CID extension" \
1889 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001890 -c "Use of CID extension negotiated" \
1891 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001892 -c "Copy CIDs into SSL transform" \
1893 -s "Peer CID (length 4 Bytes): de ad be ef" \
1894 -c "Peer CID (length 0 Bytes):" \
1895 -s "Use of Connection ID has been negotiated" \
1896 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001897
Hanno Beckera0e20d02019-05-15 14:03:01 +01001898requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001899run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001900 "$P_SRV debug_level=3 dtls=1 cid=1" \
1901 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1902 0 \
1903 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001904 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001905 -c "client hello, adding CID extension" \
1906 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001907 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001908 -s "server hello, adding CID extension" \
1909 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001910 -c "Use of CID extension negotiated" \
1911 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001912 -c "Copy CIDs into SSL transform" \
1913 -S "Use of Connection ID has been negotiated" \
1914 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001915
Hanno Beckera0e20d02019-05-15 14:03:01 +01001916requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001917run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001918 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1919 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1920 0 \
1921 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001922 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001923 -c "client hello, adding CID extension" \
1924 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001925 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001926 -s "server hello, adding CID extension" \
1927 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001928 -c "Use of CID extension negotiated" \
1929 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001930 -c "Copy CIDs into SSL transform" \
1931 -c "Peer CID (length 2 Bytes): de ad" \
1932 -s "Peer CID (length 2 Bytes): be ef" \
1933 -s "Use of Connection ID has been negotiated" \
1934 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001935
Hanno Beckera0e20d02019-05-15 14:03:01 +01001936requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001937run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001938 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1939 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1940 0 \
1941 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001942 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001943 -c "client hello, adding CID extension" \
1944 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001945 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001946 -s "server hello, adding CID extension" \
1947 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001948 -c "Use of CID extension negotiated" \
1949 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001950 -c "Copy CIDs into SSL transform" \
1951 -c "Peer CID (length 4 Bytes): de ad be ef" \
1952 -s "Peer CID (length 0 Bytes):" \
1953 -s "Use of Connection ID has been negotiated" \
1954 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001955
Hanno Beckera0e20d02019-05-15 14:03:01 +01001956requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001957run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001958 "$P_SRV debug_level=3 dtls=1 cid=1" \
1959 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1960 0 \
1961 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001962 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001963 -c "client hello, adding CID extension" \
1964 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001965 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001966 -s "server hello, adding CID extension" \
1967 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001968 -c "Use of CID extension negotiated" \
1969 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001970 -c "Copy CIDs into SSL transform" \
1971 -s "Peer CID (length 4 Bytes): de ad be ef" \
1972 -c "Peer CID (length 0 Bytes):" \
1973 -s "Use of Connection ID has been negotiated" \
1974 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001975
Hanno Beckera0e20d02019-05-15 14:03:01 +01001976requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001977run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001978 "$P_SRV debug_level=3 dtls=1 cid=1" \
1979 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1980 0 \
1981 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001982 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001983 -c "client hello, adding CID extension" \
1984 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001985 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001986 -s "server hello, adding CID extension" \
1987 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001988 -c "Use of CID extension negotiated" \
1989 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001990 -c "Copy CIDs into SSL transform" \
1991 -S "Use of Connection ID has been negotiated" \
1992 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001993
Hanno Beckera0e20d02019-05-15 14:03:01 +01001994requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker9bae30d2019-04-23 11:52:44 +01001995requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01001996run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001997 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1998 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1999 0 \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002000 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2001 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2002 -s "(initial handshake) Use of Connection ID has been negotiated" \
2003 -c "(initial handshake) Use of Connection ID has been negotiated" \
2004 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2005 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2006 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2007 -c "(after renegotiation) Use of Connection ID has been negotiated"
2008
Hanno Beckera0e20d02019-05-15 14:03:01 +01002009requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002010requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002011run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002012 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2013 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2014 0 \
2015 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2016 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2017 -s "(initial handshake) Use of Connection ID has been negotiated" \
2018 -c "(initial handshake) Use of Connection ID has been negotiated" \
2019 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2020 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2021 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2022 -c "(after renegotiation) Use of Connection ID has been negotiated"
2023
Hanno Beckera0e20d02019-05-15 14:03:01 +01002024requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002025requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002026run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
2027 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
2028 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2029 0 \
2030 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2031 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2032 -s "(initial handshake) Use of Connection ID has been negotiated" \
2033 -c "(initial handshake) Use of Connection ID has been negotiated" \
2034 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2035 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2036 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2037 -c "(after renegotiation) Use of Connection ID has been negotiated"
2038
Hanno Beckera0e20d02019-05-15 14:03:01 +01002039requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002040requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002041run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002042 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002043 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2044 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2045 0 \
2046 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2047 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2048 -s "(initial handshake) Use of Connection ID has been negotiated" \
2049 -c "(initial handshake) Use of Connection ID has been negotiated" \
2050 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2051 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2052 -s "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002053 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2054 -c "ignoring unexpected CID" \
2055 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002056
Hanno Beckera0e20d02019-05-15 14:03:01 +01002057requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002058requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2059run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002060 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2061 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2062 0 \
2063 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2064 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2065 -s "(initial handshake) Use of Connection ID has been negotiated" \
2066 -c "(initial handshake) Use of Connection ID has been negotiated" \
2067 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2068 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2069 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2070 -S "(after renegotiation) Use of Connection ID has been negotiated"
2071
Hanno Beckera0e20d02019-05-15 14:03:01 +01002072requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002073requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002074run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
2075 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2076 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2077 0 \
2078 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2079 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2080 -s "(initial handshake) Use of Connection ID has been negotiated" \
2081 -c "(initial handshake) Use of Connection ID has been negotiated" \
2082 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2083 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2084 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2085 -S "(after renegotiation) Use of Connection ID has been negotiated"
2086
Hanno Beckera0e20d02019-05-15 14:03:01 +01002087requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002088requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002089run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002090 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002091 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2092 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2093 0 \
2094 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2095 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2096 -s "(initial handshake) Use of Connection ID has been negotiated" \
2097 -c "(initial handshake) Use of Connection ID has been negotiated" \
2098 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2099 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2100 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002101 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2102 -c "ignoring unexpected CID" \
2103 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002104
Hanno Beckera0e20d02019-05-15 14:03:01 +01002105requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002106requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2107run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002108 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2109 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2110 0 \
2111 -S "(initial handshake) Use of Connection ID has been negotiated" \
2112 -C "(initial handshake) Use of Connection ID has been negotiated" \
2113 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2114 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2115 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2116 -s "(after renegotiation) Use of Connection ID has been negotiated"
2117
Hanno Beckera0e20d02019-05-15 14:03:01 +01002118requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002119requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002120run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2121 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2122 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2123 0 \
2124 -S "(initial handshake) Use of Connection ID has been negotiated" \
2125 -C "(initial handshake) Use of Connection ID has been negotiated" \
2126 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2127 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2128 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2129 -s "(after renegotiation) Use of Connection ID has been negotiated"
2130
Hanno Beckera0e20d02019-05-15 14:03:01 +01002131requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002132requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002133run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002134 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002135 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2136 "$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" \
2137 0 \
2138 -S "(initial handshake) Use of Connection ID has been negotiated" \
2139 -C "(initial handshake) Use of Connection ID has been negotiated" \
2140 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2141 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2142 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002143 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2144 -c "ignoring unexpected CID" \
2145 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002146
Hanno Beckera0e20d02019-05-15 14:03:01 +01002147requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002148requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2149run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002150 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2151 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2152 0 \
2153 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2154 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2155 -s "(initial handshake) Use of Connection ID has been negotiated" \
2156 -c "(initial handshake) Use of Connection ID has been negotiated" \
2157 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2158 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2159 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2160 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2161 -s "(after renegotiation) Use of Connection ID was not offered by client"
2162
Hanno Beckera0e20d02019-05-15 14:03:01 +01002163requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002164requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002165run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002166 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002167 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2168 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2169 0 \
2170 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2171 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2172 -s "(initial handshake) Use of Connection ID has been negotiated" \
2173 -c "(initial handshake) Use of Connection ID has been negotiated" \
2174 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2175 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2176 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2177 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002178 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2179 -c "ignoring unexpected CID" \
2180 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002181
Hanno Beckera0e20d02019-05-15 14:03:01 +01002182requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002183requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2184run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2185 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2186 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2187 0 \
2188 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2189 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2190 -s "(initial handshake) Use of Connection ID has been negotiated" \
2191 -c "(initial handshake) Use of Connection ID has been negotiated" \
2192 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2193 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2194 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2195 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2196 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2197
Hanno Beckera0e20d02019-05-15 14:03:01 +01002198requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002199requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2200run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002201 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002202 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2203 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2204 0 \
2205 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2206 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2207 -s "(initial handshake) Use of Connection ID has been negotiated" \
2208 -c "(initial handshake) Use of Connection ID has been negotiated" \
2209 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2210 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2211 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2212 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002213 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2214 -c "ignoring unexpected CID" \
2215 -s "ignoring unexpected CID"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002216
Andrzej Kurekb6577832020-06-08 07:08:03 -04002217requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2218requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2219run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=512" \
2220 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
2221 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=512 dtls=1 cid=1 cid_val=beef" \
2222 0 \
2223 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2224 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2225 -s "(initial handshake) Use of Connection ID has been negotiated" \
2226 -c "(initial handshake) Use of Connection ID has been negotiated" \
2227 -s "Reallocating in_buf" \
2228 -s "Reallocating out_buf"
2229
2230requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2231requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2232run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=1024" \
2233 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
2234 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=1024 dtls=1 cid=1 cid_val=beef" \
2235 0 \
2236 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2237 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2238 -s "(initial handshake) Use of Connection ID has been negotiated" \
2239 -c "(initial handshake) Use of Connection ID has been negotiated" \
2240 -s "Reallocating in_buf" \
2241 -s "Reallocating out_buf"
2242
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002243# Tests for Encrypt-then-MAC extension
2244
2245run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002246 "$P_SRV debug_level=3 \
2247 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002248 "$P_CLI debug_level=3" \
2249 0 \
2250 -c "client hello, adding encrypt_then_mac extension" \
2251 -s "found encrypt then mac extension" \
2252 -s "server hello, adding encrypt then mac extension" \
2253 -c "found encrypt_then_mac extension" \
2254 -c "using encrypt then mac" \
2255 -s "using encrypt then mac"
2256
2257run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002258 "$P_SRV debug_level=3 etm=0 \
2259 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002260 "$P_CLI debug_level=3 etm=1" \
2261 0 \
2262 -c "client hello, adding encrypt_then_mac extension" \
2263 -s "found encrypt then mac extension" \
2264 -S "server hello, adding encrypt then mac extension" \
2265 -C "found encrypt_then_mac extension" \
2266 -C "using encrypt then mac" \
2267 -S "using encrypt then mac"
2268
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002269run_test "Encrypt then MAC: client enabled, aead cipher" \
2270 "$P_SRV debug_level=3 etm=1 \
2271 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2272 "$P_CLI debug_level=3 etm=1" \
2273 0 \
2274 -c "client hello, adding encrypt_then_mac extension" \
2275 -s "found encrypt then mac extension" \
2276 -S "server hello, adding encrypt then mac extension" \
2277 -C "found encrypt_then_mac extension" \
2278 -C "using encrypt then mac" \
2279 -S "using encrypt then mac"
2280
2281run_test "Encrypt then MAC: client enabled, stream cipher" \
2282 "$P_SRV debug_level=3 etm=1 \
2283 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002284 "$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 +01002285 0 \
2286 -c "client hello, adding encrypt_then_mac extension" \
2287 -s "found encrypt then mac extension" \
2288 -S "server hello, adding encrypt then mac extension" \
2289 -C "found encrypt_then_mac extension" \
2290 -C "using encrypt then mac" \
2291 -S "using encrypt then mac"
2292
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002293run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002294 "$P_SRV debug_level=3 etm=1 \
2295 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002296 "$P_CLI debug_level=3 etm=0" \
2297 0 \
2298 -C "client hello, adding encrypt_then_mac extension" \
2299 -S "found encrypt then mac extension" \
2300 -S "server hello, adding encrypt then mac extension" \
2301 -C "found encrypt_then_mac extension" \
2302 -C "using encrypt then mac" \
2303 -S "using encrypt then mac"
2304
Janos Follathe2681a42016-03-07 15:57:05 +00002305requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002306run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002307 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002308 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002309 "$P_CLI debug_level=3 force_version=ssl3" \
2310 0 \
2311 -C "client hello, adding encrypt_then_mac extension" \
2312 -S "found encrypt then mac extension" \
2313 -S "server hello, adding encrypt then mac extension" \
2314 -C "found encrypt_then_mac extension" \
2315 -C "using encrypt then mac" \
2316 -S "using encrypt then mac"
2317
Janos Follathe2681a42016-03-07 15:57:05 +00002318requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002319run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002320 "$P_SRV debug_level=3 force_version=ssl3 \
2321 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002322 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002323 0 \
2324 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002325 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002326 -S "server hello, adding encrypt then mac extension" \
2327 -C "found encrypt_then_mac extension" \
2328 -C "using encrypt then mac" \
2329 -S "using encrypt then mac"
2330
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002331# Tests for Extended Master Secret extension
2332
2333run_test "Extended Master Secret: default" \
2334 "$P_SRV debug_level=3" \
2335 "$P_CLI debug_level=3" \
2336 0 \
2337 -c "client hello, adding extended_master_secret extension" \
2338 -s "found extended master secret extension" \
2339 -s "server hello, adding extended master secret extension" \
2340 -c "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002341 -c "session hash for extended master secret" \
2342 -s "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002343
2344run_test "Extended Master Secret: client enabled, server disabled" \
2345 "$P_SRV debug_level=3 extended_ms=0" \
2346 "$P_CLI debug_level=3 extended_ms=1" \
2347 0 \
2348 -c "client hello, adding extended_master_secret extension" \
2349 -s "found extended master secret extension" \
2350 -S "server hello, adding extended master secret extension" \
2351 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002352 -C "session hash for extended master secret" \
2353 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002354
2355run_test "Extended Master Secret: client disabled, server enabled" \
2356 "$P_SRV debug_level=3 extended_ms=1" \
2357 "$P_CLI debug_level=3 extended_ms=0" \
2358 0 \
2359 -C "client hello, adding extended_master_secret extension" \
2360 -S "found extended master secret extension" \
2361 -S "server hello, adding extended master secret extension" \
2362 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002363 -C "session hash for extended master secret" \
2364 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002365
Janos Follathe2681a42016-03-07 15:57:05 +00002366requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002367run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002368 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002369 "$P_CLI debug_level=3 force_version=ssl3" \
2370 0 \
2371 -C "client hello, adding extended_master_secret extension" \
2372 -S "found extended master secret extension" \
2373 -S "server hello, adding extended master secret extension" \
2374 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002375 -C "session hash for extended master secret" \
2376 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002377
Janos Follathe2681a42016-03-07 15:57:05 +00002378requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002379run_test "Extended Master Secret: client enabled, server SSLv3" \
2380 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002381 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002382 0 \
2383 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002384 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002385 -S "server hello, adding extended master secret extension" \
2386 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002387 -C "session hash for extended master secret" \
2388 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002389
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002390# Tests for FALLBACK_SCSV
2391
2392run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002393 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002394 "$P_CLI debug_level=3 force_version=tls1_1" \
2395 0 \
2396 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002397 -S "received FALLBACK_SCSV" \
2398 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002399 -C "is a fatal alert message (msg 86)"
2400
2401run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002402 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002403 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2404 0 \
2405 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002406 -S "received FALLBACK_SCSV" \
2407 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002408 -C "is a fatal alert message (msg 86)"
2409
2410run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002411 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002412 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002413 1 \
2414 -c "adding FALLBACK_SCSV" \
2415 -s "received FALLBACK_SCSV" \
2416 -s "inapropriate fallback" \
2417 -c "is a fatal alert message (msg 86)"
2418
2419run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002420 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002421 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002422 0 \
2423 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002424 -s "received FALLBACK_SCSV" \
2425 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002426 -C "is a fatal alert message (msg 86)"
2427
2428requires_openssl_with_fallback_scsv
2429run_test "Fallback SCSV: default, openssl server" \
2430 "$O_SRV" \
2431 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2432 0 \
2433 -C "adding FALLBACK_SCSV" \
2434 -C "is a fatal alert message (msg 86)"
2435
2436requires_openssl_with_fallback_scsv
2437run_test "Fallback SCSV: enabled, openssl server" \
2438 "$O_SRV" \
2439 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
2440 1 \
2441 -c "adding FALLBACK_SCSV" \
2442 -c "is a fatal alert message (msg 86)"
2443
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002444requires_openssl_with_fallback_scsv
2445run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002446 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002447 "$O_CLI -tls1_1" \
2448 0 \
2449 -S "received FALLBACK_SCSV" \
2450 -S "inapropriate fallback"
2451
2452requires_openssl_with_fallback_scsv
2453run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002454 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002455 "$O_CLI -tls1_1 -fallback_scsv" \
2456 1 \
2457 -s "received FALLBACK_SCSV" \
2458 -s "inapropriate fallback"
2459
2460requires_openssl_with_fallback_scsv
2461run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002462 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002463 "$O_CLI -fallback_scsv" \
2464 0 \
2465 -s "received FALLBACK_SCSV" \
2466 -S "inapropriate fallback"
2467
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002468# Test sending and receiving empty application data records
2469
2470run_test "Encrypt then MAC: empty application data record" \
2471 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2472 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2473 0 \
2474 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2475 -s "dumping 'input payload after decrypt' (0 bytes)" \
2476 -c "0 bytes written in 1 fragments"
2477
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002478run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002479 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2480 "$P_CLI auth_mode=none etm=0 request_size=0" \
2481 0 \
2482 -s "dumping 'input payload after decrypt' (0 bytes)" \
2483 -c "0 bytes written in 1 fragments"
2484
2485run_test "Encrypt then MAC, DTLS: empty application data record" \
2486 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2487 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2488 0 \
2489 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2490 -s "dumping 'input payload after decrypt' (0 bytes)" \
2491 -c "0 bytes written in 1 fragments"
2492
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002493run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002494 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2495 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2496 0 \
2497 -s "dumping 'input payload after decrypt' (0 bytes)" \
2498 -c "0 bytes written in 1 fragments"
2499
Gilles Peskined50177f2017-05-16 17:53:03 +02002500## ClientHello generated with
2501## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2502## then manually twiddling the ciphersuite list.
2503## The ClientHello content is spelled out below as a hex string as
2504## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2505## The expected response is an inappropriate_fallback alert.
2506requires_openssl_with_fallback_scsv
2507run_test "Fallback SCSV: beginning of list" \
2508 "$P_SRV debug_level=2" \
2509 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2510 0 \
2511 -s "received FALLBACK_SCSV" \
2512 -s "inapropriate fallback"
2513
2514requires_openssl_with_fallback_scsv
2515run_test "Fallback SCSV: end of list" \
2516 "$P_SRV debug_level=2" \
2517 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2518 0 \
2519 -s "received FALLBACK_SCSV" \
2520 -s "inapropriate fallback"
2521
2522## Here the expected response is a valid ServerHello prefix, up to the random.
2523requires_openssl_with_fallback_scsv
2524run_test "Fallback SCSV: not in list" \
2525 "$P_SRV debug_level=2" \
2526 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2527 0 \
2528 -S "received FALLBACK_SCSV" \
2529 -S "inapropriate fallback"
2530
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002531# Tests for CBC 1/n-1 record splitting
2532
2533run_test "CBC Record splitting: TLS 1.2, no splitting" \
2534 "$P_SRV" \
2535 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2536 request_size=123 force_version=tls1_2" \
2537 0 \
2538 -s "Read from client: 123 bytes read" \
2539 -S "Read from client: 1 bytes read" \
2540 -S "122 bytes read"
2541
2542run_test "CBC Record splitting: TLS 1.1, no splitting" \
2543 "$P_SRV" \
2544 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2545 request_size=123 force_version=tls1_1" \
2546 0 \
2547 -s "Read from client: 123 bytes read" \
2548 -S "Read from client: 1 bytes read" \
2549 -S "122 bytes read"
2550
2551run_test "CBC Record splitting: TLS 1.0, splitting" \
2552 "$P_SRV" \
2553 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2554 request_size=123 force_version=tls1" \
2555 0 \
2556 -S "Read from client: 123 bytes read" \
2557 -s "Read from client: 1 bytes read" \
2558 -s "122 bytes read"
2559
Janos Follathe2681a42016-03-07 15:57:05 +00002560requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002561run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002562 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002563 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2564 request_size=123 force_version=ssl3" \
2565 0 \
2566 -S "Read from client: 123 bytes read" \
2567 -s "Read from client: 1 bytes read" \
2568 -s "122 bytes read"
2569
2570run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002571 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002572 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2573 request_size=123 force_version=tls1" \
2574 0 \
2575 -s "Read from client: 123 bytes read" \
2576 -S "Read from client: 1 bytes read" \
2577 -S "122 bytes read"
2578
2579run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2580 "$P_SRV" \
2581 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2582 request_size=123 force_version=tls1 recsplit=0" \
2583 0 \
2584 -s "Read from client: 123 bytes read" \
2585 -S "Read from client: 1 bytes read" \
2586 -S "122 bytes read"
2587
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002588run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2589 "$P_SRV nbio=2" \
2590 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2591 request_size=123 force_version=tls1" \
2592 0 \
2593 -S "Read from client: 123 bytes read" \
2594 -s "Read from client: 1 bytes read" \
2595 -s "122 bytes read"
2596
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002597# Tests for Session Tickets
2598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002599run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002600 "$P_SRV debug_level=3 tickets=1" \
2601 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002602 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002603 -c "client hello, adding session ticket extension" \
2604 -s "found session ticket extension" \
2605 -s "server hello, adding session ticket extension" \
2606 -c "found session_ticket extension" \
2607 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002608 -S "session successfully restored from cache" \
2609 -s "session successfully restored from ticket" \
2610 -s "a session has been resumed" \
2611 -c "a session has been resumed"
2612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002613run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002614 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2615 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002616 0 \
2617 -c "client hello, adding session ticket extension" \
2618 -s "found session ticket extension" \
2619 -s "server hello, adding session ticket extension" \
2620 -c "found session_ticket extension" \
2621 -c "parse new session ticket" \
2622 -S "session successfully restored from cache" \
2623 -s "session successfully restored from ticket" \
2624 -s "a session has been resumed" \
2625 -c "a session has been resumed"
2626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002627run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002628 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2629 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002630 0 \
2631 -c "client hello, adding session ticket extension" \
2632 -s "found session ticket extension" \
2633 -s "server hello, adding session ticket extension" \
2634 -c "found session_ticket extension" \
2635 -c "parse new session ticket" \
2636 -S "session successfully restored from cache" \
2637 -S "session successfully restored from ticket" \
2638 -S "a session has been resumed" \
2639 -C "a session has been resumed"
2640
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002641run_test "Session resume using tickets: session copy" \
2642 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2643 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2644 0 \
2645 -c "client hello, adding session ticket extension" \
2646 -s "found session ticket extension" \
2647 -s "server hello, adding session ticket extension" \
2648 -c "found session_ticket extension" \
2649 -c "parse new session ticket" \
2650 -S "session successfully restored from cache" \
2651 -s "session successfully restored from ticket" \
2652 -s "a session has been resumed" \
2653 -c "a session has been resumed"
2654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002655run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002656 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002657 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002658 0 \
2659 -c "client hello, adding session ticket extension" \
2660 -c "found session_ticket extension" \
2661 -c "parse new session ticket" \
2662 -c "a session has been resumed"
2663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002664run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002665 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002666 "( $O_CLI -sess_out $SESSION; \
2667 $O_CLI -sess_in $SESSION; \
2668 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002669 0 \
2670 -s "found session ticket extension" \
2671 -s "server hello, adding session ticket extension" \
2672 -S "session successfully restored from cache" \
2673 -s "session successfully restored from ticket" \
2674 -s "a session has been resumed"
2675
Hanno Becker1d739932018-08-21 13:55:22 +01002676# Tests for Session Tickets with DTLS
2677
2678run_test "Session resume using tickets, DTLS: basic" \
2679 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002680 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002681 0 \
2682 -c "client hello, adding session ticket extension" \
2683 -s "found session ticket extension" \
2684 -s "server hello, adding session ticket extension" \
2685 -c "found session_ticket extension" \
2686 -c "parse new session ticket" \
2687 -S "session successfully restored from cache" \
2688 -s "session successfully restored from ticket" \
2689 -s "a session has been resumed" \
2690 -c "a session has been resumed"
2691
2692run_test "Session resume using tickets, DTLS: cache disabled" \
2693 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002694 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002695 0 \
2696 -c "client hello, adding session ticket extension" \
2697 -s "found session ticket extension" \
2698 -s "server hello, adding session ticket extension" \
2699 -c "found session_ticket extension" \
2700 -c "parse new session ticket" \
2701 -S "session successfully restored from cache" \
2702 -s "session successfully restored from ticket" \
2703 -s "a session has been resumed" \
2704 -c "a session has been resumed"
2705
2706run_test "Session resume using tickets, DTLS: timeout" \
2707 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002708 "$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 +01002709 0 \
2710 -c "client hello, adding session ticket extension" \
2711 -s "found session ticket extension" \
2712 -s "server hello, adding session ticket extension" \
2713 -c "found session_ticket extension" \
2714 -c "parse new session ticket" \
2715 -S "session successfully restored from cache" \
2716 -S "session successfully restored from ticket" \
2717 -S "a session has been resumed" \
2718 -C "a session has been resumed"
2719
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002720run_test "Session resume using tickets, DTLS: session copy" \
2721 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002722 "$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 +02002723 0 \
2724 -c "client hello, adding session ticket extension" \
2725 -s "found session ticket extension" \
2726 -s "server hello, adding session ticket extension" \
2727 -c "found session_ticket extension" \
2728 -c "parse new session ticket" \
2729 -S "session successfully restored from cache" \
2730 -s "session successfully restored from ticket" \
2731 -s "a session has been resumed" \
2732 -c "a session has been resumed"
2733
Hanno Becker1d739932018-08-21 13:55:22 +01002734run_test "Session resume using tickets, DTLS: openssl server" \
2735 "$O_SRV -dtls1" \
2736 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2737 0 \
2738 -c "client hello, adding session ticket extension" \
2739 -c "found session_ticket extension" \
2740 -c "parse new session ticket" \
2741 -c "a session has been resumed"
2742
2743run_test "Session resume using tickets, DTLS: openssl client" \
2744 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2745 "( $O_CLI -dtls1 -sess_out $SESSION; \
2746 $O_CLI -dtls1 -sess_in $SESSION; \
2747 rm -f $SESSION )" \
2748 0 \
2749 -s "found session ticket extension" \
2750 -s "server hello, adding session ticket extension" \
2751 -S "session successfully restored from cache" \
2752 -s "session successfully restored from ticket" \
2753 -s "a session has been resumed"
2754
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002755# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002757run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002758 "$P_SRV debug_level=3 tickets=0" \
2759 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002760 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002761 -c "client hello, adding session ticket extension" \
2762 -s "found session ticket extension" \
2763 -S "server hello, adding session ticket extension" \
2764 -C "found session_ticket extension" \
2765 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002766 -s "session successfully restored from cache" \
2767 -S "session successfully restored from ticket" \
2768 -s "a session has been resumed" \
2769 -c "a session has been resumed"
2770
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002771run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002772 "$P_SRV debug_level=3 tickets=1" \
2773 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002774 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002775 -C "client hello, adding session ticket extension" \
2776 -S "found session ticket extension" \
2777 -S "server hello, adding session ticket extension" \
2778 -C "found session_ticket extension" \
2779 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002780 -s "session successfully restored from cache" \
2781 -S "session successfully restored from ticket" \
2782 -s "a session has been resumed" \
2783 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002784
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002785run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002786 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2787 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002788 0 \
2789 -S "session successfully restored from cache" \
2790 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002791 -S "a session has been resumed" \
2792 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002794run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002795 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2796 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002797 0 \
2798 -s "session successfully restored from cache" \
2799 -S "session successfully restored from ticket" \
2800 -s "a session has been resumed" \
2801 -c "a session has been resumed"
2802
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002803run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002804 "$P_SRV debug_level=3 tickets=0" \
2805 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002806 0 \
2807 -s "session successfully restored from cache" \
2808 -S "session successfully restored from ticket" \
2809 -s "a session has been resumed" \
2810 -c "a session has been resumed"
2811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002812run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002813 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2814 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002815 0 \
2816 -S "session successfully restored from cache" \
2817 -S "session successfully restored from ticket" \
2818 -S "a session has been resumed" \
2819 -C "a session has been resumed"
2820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002821run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002822 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2823 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002824 0 \
2825 -s "session successfully restored from cache" \
2826 -S "session successfully restored from ticket" \
2827 -s "a session has been resumed" \
2828 -c "a session has been resumed"
2829
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002830run_test "Session resume using cache: session copy" \
2831 "$P_SRV debug_level=3 tickets=0" \
2832 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2833 0 \
2834 -s "session successfully restored from cache" \
2835 -S "session successfully restored from ticket" \
2836 -s "a session has been resumed" \
2837 -c "a session has been resumed"
2838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002839run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002840 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002841 "( $O_CLI -sess_out $SESSION; \
2842 $O_CLI -sess_in $SESSION; \
2843 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002844 0 \
2845 -s "found session ticket extension" \
2846 -S "server hello, adding session ticket extension" \
2847 -s "session successfully restored from cache" \
2848 -S "session successfully restored from ticket" \
2849 -s "a session has been resumed"
2850
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002851run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002852 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002853 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002854 0 \
2855 -C "found session_ticket extension" \
2856 -C "parse new session ticket" \
2857 -c "a session has been resumed"
2858
Hanno Becker1d739932018-08-21 13:55:22 +01002859# Tests for Session Resume based on session-ID and cache, DTLS
2860
2861run_test "Session resume using cache, DTLS: tickets enabled on client" \
2862 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002863 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002864 0 \
2865 -c "client hello, adding session ticket extension" \
2866 -s "found session ticket extension" \
2867 -S "server hello, adding session ticket extension" \
2868 -C "found session_ticket extension" \
2869 -C "parse new session ticket" \
2870 -s "session successfully restored from cache" \
2871 -S "session successfully restored from ticket" \
2872 -s "a session has been resumed" \
2873 -c "a session has been resumed"
2874
2875run_test "Session resume using cache, DTLS: tickets enabled on server" \
2876 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002877 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002878 0 \
2879 -C "client hello, adding session ticket extension" \
2880 -S "found session ticket extension" \
2881 -S "server hello, adding session ticket extension" \
2882 -C "found session_ticket extension" \
2883 -C "parse new session ticket" \
2884 -s "session successfully restored from cache" \
2885 -S "session successfully restored from ticket" \
2886 -s "a session has been resumed" \
2887 -c "a session has been resumed"
2888
2889run_test "Session resume using cache, DTLS: cache_max=0" \
2890 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002891 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002892 0 \
2893 -S "session successfully restored from cache" \
2894 -S "session successfully restored from ticket" \
2895 -S "a session has been resumed" \
2896 -C "a session has been resumed"
2897
2898run_test "Session resume using cache, DTLS: cache_max=1" \
2899 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002900 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002901 0 \
2902 -s "session successfully restored from cache" \
2903 -S "session successfully restored from ticket" \
2904 -s "a session has been resumed" \
2905 -c "a session has been resumed"
2906
2907run_test "Session resume using cache, DTLS: timeout > delay" \
2908 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002909 "$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 +01002910 0 \
2911 -s "session successfully restored from cache" \
2912 -S "session successfully restored from ticket" \
2913 -s "a session has been resumed" \
2914 -c "a session has been resumed"
2915
2916run_test "Session resume using cache, DTLS: timeout < delay" \
2917 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002918 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Becker1d739932018-08-21 13:55:22 +01002919 0 \
2920 -S "session successfully restored from cache" \
2921 -S "session successfully restored from ticket" \
2922 -S "a session has been resumed" \
2923 -C "a session has been resumed"
2924
2925run_test "Session resume using cache, DTLS: no timeout" \
2926 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002927 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Becker1d739932018-08-21 13:55:22 +01002928 0 \
2929 -s "session successfully restored from cache" \
2930 -S "session successfully restored from ticket" \
2931 -s "a session has been resumed" \
2932 -c "a session has been resumed"
2933
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002934run_test "Session resume using cache, DTLS: session copy" \
2935 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002936 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_mode=0" \
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002937 0 \
2938 -s "session successfully restored from cache" \
2939 -S "session successfully restored from ticket" \
2940 -s "a session has been resumed" \
2941 -c "a session has been resumed"
2942
Hanno Becker1d739932018-08-21 13:55:22 +01002943run_test "Session resume using cache, DTLS: openssl client" \
2944 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2945 "( $O_CLI -dtls1 -sess_out $SESSION; \
2946 $O_CLI -dtls1 -sess_in $SESSION; \
2947 rm -f $SESSION )" \
2948 0 \
2949 -s "found session ticket extension" \
2950 -S "server hello, adding session ticket extension" \
2951 -s "session successfully restored from cache" \
2952 -S "session successfully restored from ticket" \
2953 -s "a session has been resumed"
2954
2955run_test "Session resume using cache, DTLS: openssl server" \
2956 "$O_SRV -dtls1" \
2957 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2958 0 \
2959 -C "found session_ticket extension" \
2960 -C "parse new session ticket" \
2961 -c "a session has been resumed"
2962
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002963# Tests for Max Fragment Length extension
2964
Angus Grattonc4dd0732018-04-11 16:28:39 +10002965if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
2966 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 +01002967 exit 1
2968fi
2969
Angus Grattonc4dd0732018-04-11 16:28:39 +10002970if [ $MAX_CONTENT_LEN -ne 16384 ]; then
2971 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
2972fi
2973
Hanno Becker4aed27e2017-09-18 15:00:34 +01002974requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002975run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002976 "$P_SRV debug_level=3" \
2977 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002978 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002979 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
2980 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
2981 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
2982 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002983 -C "client hello, adding max_fragment_length extension" \
2984 -S "found max fragment length extension" \
2985 -S "server hello, max_fragment_length extension" \
2986 -C "found max_fragment_length extension"
2987
Hanno Becker4aed27e2017-09-18 15:00:34 +01002988requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002989run_test "Max fragment length: enabled, default, larger message" \
2990 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002991 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002992 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002993 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
2994 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
2995 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
2996 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002997 -C "client hello, adding max_fragment_length extension" \
2998 -S "found max fragment length extension" \
2999 -S "server hello, max_fragment_length extension" \
3000 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003001 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3002 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003003 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003004
3005requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3006run_test "Max fragment length, DTLS: enabled, default, larger message" \
3007 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003008 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003009 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003010 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3011 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3012 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3013 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003014 -C "client hello, adding max_fragment_length extension" \
3015 -S "found max fragment length extension" \
3016 -S "server hello, max_fragment_length extension" \
3017 -C "found max_fragment_length extension" \
3018 -c "fragment larger than.*maximum "
3019
Angus Grattonc4dd0732018-04-11 16:28:39 +10003020# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3021# (session fragment length will be 16384 regardless of mbedtls
3022# content length configuration.)
3023
Hanno Beckerc5266962017-09-18 15:01:50 +01003024requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3025run_test "Max fragment length: disabled, larger message" \
3026 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003027 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003028 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003029 -C "Maximum input fragment length is 16384" \
3030 -C "Maximum output fragment length is 16384" \
3031 -S "Maximum input fragment length is 16384" \
3032 -S "Maximum output fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003033 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3034 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003035 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003036
3037requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3038run_test "Max fragment length DTLS: disabled, larger message" \
3039 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003040 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003041 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003042 -C "Maximum input fragment length is 16384" \
3043 -C "Maximum output fragment length is 16384" \
3044 -S "Maximum input fragment length is 16384" \
3045 -S "Maximum output fragment length is 16384" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003046 -c "fragment larger than.*maximum "
3047
3048requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003049run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003050 "$P_SRV debug_level=3" \
3051 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003052 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003053 -c "Maximum input fragment length is 4096" \
3054 -c "Maximum output fragment length is 4096" \
3055 -s "Maximum input fragment length is 4096" \
3056 -s "Maximum output fragment length is 4096" \
3057 -c "client hello, adding max_fragment_length extension" \
3058 -s "found max fragment length extension" \
3059 -s "server hello, max_fragment_length extension" \
3060 -c "found max_fragment_length extension"
3061
3062requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3063run_test "Max fragment length: client 512, server 1024" \
3064 "$P_SRV debug_level=3 max_frag_len=1024" \
3065 "$P_CLI debug_level=3 max_frag_len=512" \
3066 0 \
3067 -c "Maximum input fragment length is 512" \
3068 -c "Maximum output fragment length is 512" \
3069 -s "Maximum input fragment length is 512" \
3070 -s "Maximum output fragment length is 512" \
3071 -c "client hello, adding max_fragment_length extension" \
3072 -s "found max fragment length extension" \
3073 -s "server hello, max_fragment_length extension" \
3074 -c "found max_fragment_length extension"
3075
3076requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3077run_test "Max fragment length: client 512, server 2048" \
3078 "$P_SRV debug_level=3 max_frag_len=2048" \
3079 "$P_CLI debug_level=3 max_frag_len=512" \
3080 0 \
3081 -c "Maximum input fragment length is 512" \
3082 -c "Maximum output fragment length is 512" \
3083 -s "Maximum input fragment length is 512" \
3084 -s "Maximum output fragment length is 512" \
3085 -c "client hello, adding max_fragment_length extension" \
3086 -s "found max fragment length extension" \
3087 -s "server hello, max_fragment_length extension" \
3088 -c "found max_fragment_length extension"
3089
3090requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3091run_test "Max fragment length: client 512, server 4096" \
3092 "$P_SRV debug_level=3 max_frag_len=4096" \
3093 "$P_CLI debug_level=3 max_frag_len=512" \
3094 0 \
3095 -c "Maximum input fragment length is 512" \
3096 -c "Maximum output fragment length is 512" \
3097 -s "Maximum input fragment length is 512" \
3098 -s "Maximum output fragment length is 512" \
3099 -c "client hello, adding max_fragment_length extension" \
3100 -s "found max fragment length extension" \
3101 -s "server hello, max_fragment_length extension" \
3102 -c "found max_fragment_length extension"
3103
3104requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3105run_test "Max fragment length: client 1024, server 512" \
3106 "$P_SRV debug_level=3 max_frag_len=512" \
3107 "$P_CLI debug_level=3 max_frag_len=1024" \
3108 0 \
3109 -c "Maximum input fragment length is 1024" \
3110 -c "Maximum output fragment length is 1024" \
3111 -s "Maximum input fragment length is 1024" \
3112 -s "Maximum output fragment length is 512" \
3113 -c "client hello, adding max_fragment_length extension" \
3114 -s "found max fragment length extension" \
3115 -s "server hello, max_fragment_length extension" \
3116 -c "found max_fragment_length extension"
3117
3118requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3119run_test "Max fragment length: client 1024, server 2048" \
3120 "$P_SRV debug_level=3 max_frag_len=2048" \
3121 "$P_CLI debug_level=3 max_frag_len=1024" \
3122 0 \
3123 -c "Maximum input fragment length is 1024" \
3124 -c "Maximum output fragment length is 1024" \
3125 -s "Maximum input fragment length is 1024" \
3126 -s "Maximum output fragment length is 1024" \
3127 -c "client hello, adding max_fragment_length extension" \
3128 -s "found max fragment length extension" \
3129 -s "server hello, max_fragment_length extension" \
3130 -c "found max_fragment_length extension"
3131
3132requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3133run_test "Max fragment length: client 1024, server 4096" \
3134 "$P_SRV debug_level=3 max_frag_len=4096" \
3135 "$P_CLI debug_level=3 max_frag_len=1024" \
3136 0 \
3137 -c "Maximum input fragment length is 1024" \
3138 -c "Maximum output fragment length is 1024" \
3139 -s "Maximum input fragment length is 1024" \
3140 -s "Maximum output fragment length is 1024" \
3141 -c "client hello, adding max_fragment_length extension" \
3142 -s "found max fragment length extension" \
3143 -s "server hello, max_fragment_length extension" \
3144 -c "found max_fragment_length extension"
3145
3146requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3147run_test "Max fragment length: client 2048, server 512" \
3148 "$P_SRV debug_level=3 max_frag_len=512" \
3149 "$P_CLI debug_level=3 max_frag_len=2048" \
3150 0 \
3151 -c "Maximum input fragment length is 2048" \
3152 -c "Maximum output fragment length is 2048" \
3153 -s "Maximum input fragment length is 2048" \
3154 -s "Maximum output fragment length is 512" \
3155 -c "client hello, adding max_fragment_length extension" \
3156 -s "found max fragment length extension" \
3157 -s "server hello, max_fragment_length extension" \
3158 -c "found max_fragment_length extension"
3159
3160requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3161run_test "Max fragment length: client 2048, server 1024" \
3162 "$P_SRV debug_level=3 max_frag_len=1024" \
3163 "$P_CLI debug_level=3 max_frag_len=2048" \
3164 0 \
3165 -c "Maximum input fragment length is 2048" \
3166 -c "Maximum output fragment length is 2048" \
3167 -s "Maximum input fragment length is 2048" \
3168 -s "Maximum output fragment length is 1024" \
3169 -c "client hello, adding max_fragment_length extension" \
3170 -s "found max fragment length extension" \
3171 -s "server hello, max_fragment_length extension" \
3172 -c "found max_fragment_length extension"
3173
3174requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3175run_test "Max fragment length: client 2048, server 4096" \
3176 "$P_SRV debug_level=3 max_frag_len=4096" \
3177 "$P_CLI debug_level=3 max_frag_len=2048" \
3178 0 \
3179 -c "Maximum input fragment length is 2048" \
3180 -c "Maximum output fragment length is 2048" \
3181 -s "Maximum input fragment length is 2048" \
3182 -s "Maximum output fragment length is 2048" \
3183 -c "client hello, adding max_fragment_length extension" \
3184 -s "found max fragment length extension" \
3185 -s "server hello, max_fragment_length extension" \
3186 -c "found max_fragment_length extension"
3187
3188requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3189run_test "Max fragment length: client 4096, server 512" \
3190 "$P_SRV debug_level=3 max_frag_len=512" \
3191 "$P_CLI debug_level=3 max_frag_len=4096" \
3192 0 \
3193 -c "Maximum input fragment length is 4096" \
3194 -c "Maximum output fragment length is 4096" \
3195 -s "Maximum input fragment length is 4096" \
3196 -s "Maximum output fragment length is 512" \
3197 -c "client hello, adding max_fragment_length extension" \
3198 -s "found max fragment length extension" \
3199 -s "server hello, max_fragment_length extension" \
3200 -c "found max_fragment_length extension"
3201
3202requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3203run_test "Max fragment length: client 4096, server 1024" \
3204 "$P_SRV debug_level=3 max_frag_len=1024" \
3205 "$P_CLI debug_level=3 max_frag_len=4096" \
3206 0 \
3207 -c "Maximum input fragment length is 4096" \
3208 -c "Maximum output fragment length is 4096" \
3209 -s "Maximum input fragment length is 4096" \
3210 -s "Maximum output fragment length is 1024" \
3211 -c "client hello, adding max_fragment_length extension" \
3212 -s "found max fragment length extension" \
3213 -s "server hello, max_fragment_length extension" \
3214 -c "found max_fragment_length extension"
3215
3216requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3217run_test "Max fragment length: client 4096, server 2048" \
3218 "$P_SRV debug_level=3 max_frag_len=2048" \
3219 "$P_CLI debug_level=3 max_frag_len=4096" \
3220 0 \
3221 -c "Maximum input fragment length is 4096" \
3222 -c "Maximum output fragment length is 4096" \
3223 -s "Maximum input fragment length is 4096" \
3224 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003225 -c "client hello, adding max_fragment_length extension" \
3226 -s "found max fragment length extension" \
3227 -s "server hello, max_fragment_length extension" \
3228 -c "found max_fragment_length extension"
3229
Hanno Becker4aed27e2017-09-18 15:00:34 +01003230requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003231run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003232 "$P_SRV debug_level=3 max_frag_len=4096" \
3233 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003234 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003235 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3236 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3237 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3238 -s "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003239 -C "client hello, adding max_fragment_length extension" \
3240 -S "found max fragment length extension" \
3241 -S "server hello, max_fragment_length extension" \
3242 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003243
Hanno Becker4aed27e2017-09-18 15:00:34 +01003244requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003245requires_gnutls
3246run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003247 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003248 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003249 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003250 -c "Maximum input fragment length is 4096" \
3251 -c "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003252 -c "client hello, adding max_fragment_length extension" \
3253 -c "found max_fragment_length extension"
3254
Hanno Becker4aed27e2017-09-18 15:00:34 +01003255requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003256run_test "Max fragment length: client, message just fits" \
3257 "$P_SRV debug_level=3" \
3258 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3259 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003260 -c "Maximum input fragment length is 2048" \
3261 -c "Maximum output fragment length is 2048" \
3262 -s "Maximum input fragment length is 2048" \
3263 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003264 -c "client hello, adding max_fragment_length extension" \
3265 -s "found max fragment length extension" \
3266 -s "server hello, max_fragment_length extension" \
3267 -c "found max_fragment_length extension" \
3268 -c "2048 bytes written in 1 fragments" \
3269 -s "2048 bytes read"
3270
Hanno Becker4aed27e2017-09-18 15:00:34 +01003271requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003272run_test "Max fragment length: client, larger message" \
3273 "$P_SRV debug_level=3" \
3274 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3275 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003276 -c "Maximum input fragment length is 2048" \
3277 -c "Maximum output fragment length is 2048" \
3278 -s "Maximum input fragment length is 2048" \
3279 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003280 -c "client hello, adding max_fragment_length extension" \
3281 -s "found max fragment length extension" \
3282 -s "server hello, max_fragment_length extension" \
3283 -c "found max_fragment_length extension" \
3284 -c "2345 bytes written in 2 fragments" \
3285 -s "2048 bytes read" \
3286 -s "297 bytes read"
3287
Hanno Becker4aed27e2017-09-18 15:00:34 +01003288requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003289run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003290 "$P_SRV debug_level=3 dtls=1" \
3291 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3292 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003293 -c "Maximum input fragment length is 2048" \
3294 -c "Maximum output fragment length is 2048" \
3295 -s "Maximum input fragment length is 2048" \
3296 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003297 -c "client hello, adding max_fragment_length extension" \
3298 -s "found max fragment length extension" \
3299 -s "server hello, max_fragment_length extension" \
3300 -c "found max_fragment_length extension" \
3301 -c "fragment larger than.*maximum"
3302
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003303# Tests for renegotiation
3304
Hanno Becker6a243642017-10-12 15:18:45 +01003305# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003306run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003307 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003308 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003309 0 \
3310 -C "client hello, adding renegotiation extension" \
3311 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3312 -S "found renegotiation extension" \
3313 -s "server hello, secure renegotiation extension" \
3314 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003315 -C "=> renegotiate" \
3316 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003317 -S "write hello request"
3318
Hanno Becker6a243642017-10-12 15:18:45 +01003319requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003320run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003321 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003322 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003323 0 \
3324 -c "client hello, adding renegotiation extension" \
3325 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3326 -s "found renegotiation extension" \
3327 -s "server hello, secure renegotiation extension" \
3328 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003329 -c "=> renegotiate" \
3330 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003331 -S "write hello request"
3332
Hanno Becker6a243642017-10-12 15:18:45 +01003333requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003334run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003335 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003336 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003337 0 \
3338 -c "client hello, adding renegotiation extension" \
3339 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3340 -s "found renegotiation extension" \
3341 -s "server hello, secure renegotiation extension" \
3342 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003343 -c "=> renegotiate" \
3344 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003345 -s "write hello request"
3346
Janos Follathb0f148c2017-10-05 12:29:42 +01003347# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3348# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3349# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003350requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003351run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3352 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3353 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3354 0 \
3355 -c "client hello, adding renegotiation extension" \
3356 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3357 -s "found renegotiation extension" \
3358 -s "server hello, secure renegotiation extension" \
3359 -c "found renegotiation extension" \
3360 -c "=> renegotiate" \
3361 -s "=> renegotiate" \
3362 -S "write hello request" \
3363 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3364
3365# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3366# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3367# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003368requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003369run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3370 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3371 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3372 0 \
3373 -c "client hello, adding renegotiation extension" \
3374 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3375 -s "found renegotiation extension" \
3376 -s "server hello, secure renegotiation extension" \
3377 -c "found renegotiation extension" \
3378 -c "=> renegotiate" \
3379 -s "=> renegotiate" \
3380 -s "write hello request" \
3381 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3382
Hanno Becker6a243642017-10-12 15:18:45 +01003383requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003384run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003385 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003386 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003387 0 \
3388 -c "client hello, adding renegotiation extension" \
3389 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3390 -s "found renegotiation extension" \
3391 -s "server hello, secure renegotiation extension" \
3392 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003393 -c "=> renegotiate" \
3394 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003395 -s "write hello request"
3396
Hanno Becker6a243642017-10-12 15:18:45 +01003397requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andrzej Kurek8ea68722020-04-03 06:40:47 -04003398requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3399run_test "Renegotiation with max fragment length: client 2048, server 512" \
3400 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1 max_frag_len=512" \
3401 "$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" \
3402 0 \
3403 -c "Maximum input fragment length is 2048" \
3404 -c "Maximum output fragment length is 2048" \
3405 -s "Maximum input fragment length is 2048" \
3406 -s "Maximum output fragment length is 512" \
3407 -c "client hello, adding max_fragment_length extension" \
3408 -s "found max fragment length extension" \
3409 -s "server hello, max_fragment_length extension" \
3410 -c "found max_fragment_length extension" \
3411 -c "client hello, adding renegotiation extension" \
3412 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3413 -s "found renegotiation extension" \
3414 -s "server hello, secure renegotiation extension" \
3415 -c "found renegotiation extension" \
3416 -c "=> renegotiate" \
3417 -s "=> renegotiate" \
3418 -s "write hello request"
3419
3420requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003421run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003422 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003423 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003424 1 \
3425 -c "client hello, adding renegotiation extension" \
3426 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3427 -S "found renegotiation extension" \
3428 -s "server hello, secure renegotiation extension" \
3429 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003430 -c "=> renegotiate" \
3431 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003432 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003433 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003434 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003435
Hanno Becker6a243642017-10-12 15:18:45 +01003436requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003437run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003438 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003439 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003440 0 \
3441 -C "client hello, adding renegotiation extension" \
3442 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3443 -S "found renegotiation extension" \
3444 -s "server hello, secure renegotiation extension" \
3445 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003446 -C "=> renegotiate" \
3447 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003448 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003449 -S "SSL - An unexpected message was received from our peer" \
3450 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003451
Hanno Becker6a243642017-10-12 15:18:45 +01003452requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003453run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003454 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003455 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003456 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003457 0 \
3458 -C "client hello, adding renegotiation extension" \
3459 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3460 -S "found renegotiation extension" \
3461 -s "server hello, secure renegotiation extension" \
3462 -c "found renegotiation extension" \
3463 -C "=> renegotiate" \
3464 -S "=> renegotiate" \
3465 -s "write hello request" \
3466 -S "SSL - An unexpected message was received from our peer" \
3467 -S "failed"
3468
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003469# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003470requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003471run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003472 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003473 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003474 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003475 0 \
3476 -C "client hello, adding renegotiation extension" \
3477 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3478 -S "found renegotiation extension" \
3479 -s "server hello, secure renegotiation extension" \
3480 -c "found renegotiation extension" \
3481 -C "=> renegotiate" \
3482 -S "=> renegotiate" \
3483 -s "write hello request" \
3484 -S "SSL - An unexpected message was received from our peer" \
3485 -S "failed"
3486
Hanno Becker6a243642017-10-12 15:18:45 +01003487requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003488run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003489 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003490 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003491 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003492 0 \
3493 -C "client hello, adding renegotiation extension" \
3494 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3495 -S "found renegotiation extension" \
3496 -s "server hello, secure renegotiation extension" \
3497 -c "found renegotiation extension" \
3498 -C "=> renegotiate" \
3499 -S "=> renegotiate" \
3500 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003501 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003502
Hanno Becker6a243642017-10-12 15:18:45 +01003503requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003504run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003505 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003506 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003507 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003508 0 \
3509 -c "client hello, adding renegotiation extension" \
3510 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3511 -s "found renegotiation extension" \
3512 -s "server hello, secure renegotiation extension" \
3513 -c "found renegotiation extension" \
3514 -c "=> renegotiate" \
3515 -s "=> renegotiate" \
3516 -s "write hello request" \
3517 -S "SSL - An unexpected message was received from our peer" \
3518 -S "failed"
3519
Hanno Becker6a243642017-10-12 15:18:45 +01003520requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003521run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003522 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003523 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3524 0 \
3525 -C "client hello, adding renegotiation extension" \
3526 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3527 -S "found renegotiation extension" \
3528 -s "server hello, secure renegotiation extension" \
3529 -c "found renegotiation extension" \
3530 -S "record counter limit reached: renegotiate" \
3531 -C "=> renegotiate" \
3532 -S "=> renegotiate" \
3533 -S "write hello request" \
3534 -S "SSL - An unexpected message was received from our peer" \
3535 -S "failed"
3536
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003537# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003538requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003539run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003540 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003541 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003542 0 \
3543 -c "client hello, adding renegotiation extension" \
3544 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3545 -s "found renegotiation extension" \
3546 -s "server hello, secure renegotiation extension" \
3547 -c "found renegotiation extension" \
3548 -s "record counter limit reached: renegotiate" \
3549 -c "=> renegotiate" \
3550 -s "=> renegotiate" \
3551 -s "write hello request" \
3552 -S "SSL - An unexpected message was received from our peer" \
3553 -S "failed"
3554
Hanno Becker6a243642017-10-12 15:18:45 +01003555requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003556run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003557 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003558 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003559 0 \
3560 -c "client hello, adding renegotiation extension" \
3561 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3562 -s "found renegotiation extension" \
3563 -s "server hello, secure renegotiation extension" \
3564 -c "found renegotiation extension" \
3565 -s "record counter limit reached: renegotiate" \
3566 -c "=> renegotiate" \
3567 -s "=> renegotiate" \
3568 -s "write hello request" \
3569 -S "SSL - An unexpected message was received from our peer" \
3570 -S "failed"
3571
Hanno Becker6a243642017-10-12 15:18:45 +01003572requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003573run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003574 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003575 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3576 0 \
3577 -C "client hello, adding renegotiation extension" \
3578 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3579 -S "found renegotiation extension" \
3580 -s "server hello, secure renegotiation extension" \
3581 -c "found renegotiation extension" \
3582 -S "record counter limit reached: renegotiate" \
3583 -C "=> renegotiate" \
3584 -S "=> renegotiate" \
3585 -S "write hello request" \
3586 -S "SSL - An unexpected message was received from our peer" \
3587 -S "failed"
3588
Hanno Becker6a243642017-10-12 15:18:45 +01003589requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003590run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003591 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003592 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003593 0 \
3594 -c "client hello, adding renegotiation extension" \
3595 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3596 -s "found renegotiation extension" \
3597 -s "server hello, secure renegotiation extension" \
3598 -c "found renegotiation extension" \
3599 -c "=> renegotiate" \
3600 -s "=> renegotiate" \
3601 -S "write hello request"
3602
Hanno Becker6a243642017-10-12 15:18:45 +01003603requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003604run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003605 "$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 +02003606 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003607 0 \
3608 -c "client hello, adding renegotiation extension" \
3609 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3610 -s "found renegotiation extension" \
3611 -s "server hello, secure renegotiation extension" \
3612 -c "found renegotiation extension" \
3613 -c "=> renegotiate" \
3614 -s "=> renegotiate" \
3615 -s "write hello request"
3616
Hanno Becker6a243642017-10-12 15:18:45 +01003617requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003618run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003619 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003620 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003621 0 \
3622 -c "client hello, adding renegotiation extension" \
3623 -c "found renegotiation extension" \
3624 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003625 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003626 -C "error" \
3627 -c "HTTP/1.0 200 [Oo][Kk]"
3628
Paul Bakker539d9722015-02-08 16:18:35 +01003629requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003630requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003631run_test "Renegotiation: gnutls server strict, client-initiated" \
3632 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003633 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003634 0 \
3635 -c "client hello, adding renegotiation extension" \
3636 -c "found renegotiation extension" \
3637 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003638 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003639 -C "error" \
3640 -c "HTTP/1.0 200 [Oo][Kk]"
3641
Paul Bakker539d9722015-02-08 16:18:35 +01003642requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003643requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003644run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3645 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3646 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
3647 1 \
3648 -c "client hello, adding renegotiation extension" \
3649 -C "found renegotiation extension" \
3650 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003651 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003652 -c "error" \
3653 -C "HTTP/1.0 200 [Oo][Kk]"
3654
Paul Bakker539d9722015-02-08 16:18:35 +01003655requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003656requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003657run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3658 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3659 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3660 allow_legacy=0" \
3661 1 \
3662 -c "client hello, adding renegotiation extension" \
3663 -C "found renegotiation extension" \
3664 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003665 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003666 -c "error" \
3667 -C "HTTP/1.0 200 [Oo][Kk]"
3668
Paul Bakker539d9722015-02-08 16:18:35 +01003669requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003670requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003671run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3672 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3673 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3674 allow_legacy=1" \
3675 0 \
3676 -c "client hello, adding renegotiation extension" \
3677 -C "found renegotiation extension" \
3678 -c "=> renegotiate" \
3679 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003680 -C "error" \
3681 -c "HTTP/1.0 200 [Oo][Kk]"
3682
Hanno Becker6a243642017-10-12 15:18:45 +01003683requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003684run_test "Renegotiation: DTLS, client-initiated" \
3685 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3686 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3687 0 \
3688 -c "client hello, adding renegotiation extension" \
3689 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3690 -s "found renegotiation extension" \
3691 -s "server hello, secure renegotiation extension" \
3692 -c "found renegotiation extension" \
3693 -c "=> renegotiate" \
3694 -s "=> renegotiate" \
3695 -S "write hello request"
3696
Hanno Becker6a243642017-10-12 15:18:45 +01003697requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003698run_test "Renegotiation: DTLS, server-initiated" \
3699 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003700 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3701 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003702 0 \
3703 -c "client hello, adding renegotiation extension" \
3704 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3705 -s "found renegotiation extension" \
3706 -s "server hello, secure renegotiation extension" \
3707 -c "found renegotiation extension" \
3708 -c "=> renegotiate" \
3709 -s "=> renegotiate" \
3710 -s "write hello request"
3711
Hanno Becker6a243642017-10-12 15:18:45 +01003712requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003713run_test "Renegotiation: DTLS, renego_period overflow" \
3714 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3715 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=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 -s "record counter limit reached: renegotiate" \
3722 -c "=> renegotiate" \
3723 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003724 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003725
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003726requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003727requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003728run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3729 "$G_SRV -u --mtu 4096" \
3730 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
3731 0 \
3732 -c "client hello, adding renegotiation extension" \
3733 -c "found renegotiation extension" \
3734 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003735 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003736 -C "error" \
3737 -s "Extra-header:"
3738
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003739# Test for the "secure renegotation" extension only (no actual renegotiation)
3740
Paul Bakker539d9722015-02-08 16:18:35 +01003741requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003742run_test "Renego ext: gnutls server strict, client default" \
3743 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
3744 "$P_CLI debug_level=3" \
3745 0 \
3746 -c "found renegotiation extension" \
3747 -C "error" \
3748 -c "HTTP/1.0 200 [Oo][Kk]"
3749
Paul Bakker539d9722015-02-08 16:18:35 +01003750requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003751run_test "Renego ext: gnutls server unsafe, client default" \
3752 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3753 "$P_CLI debug_level=3" \
3754 0 \
3755 -C "found renegotiation extension" \
3756 -C "error" \
3757 -c "HTTP/1.0 200 [Oo][Kk]"
3758
Paul Bakker539d9722015-02-08 16:18:35 +01003759requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003760run_test "Renego ext: gnutls server unsafe, client break legacy" \
3761 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3762 "$P_CLI debug_level=3 allow_legacy=-1" \
3763 1 \
3764 -C "found renegotiation extension" \
3765 -c "error" \
3766 -C "HTTP/1.0 200 [Oo][Kk]"
3767
Paul Bakker539d9722015-02-08 16:18:35 +01003768requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003769run_test "Renego ext: gnutls client strict, server default" \
3770 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003771 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003772 0 \
3773 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3774 -s "server hello, secure renegotiation extension"
3775
Paul Bakker539d9722015-02-08 16:18:35 +01003776requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003777run_test "Renego ext: gnutls client unsafe, server default" \
3778 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003779 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003780 0 \
3781 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3782 -S "server hello, secure renegotiation extension"
3783
Paul Bakker539d9722015-02-08 16:18:35 +01003784requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003785run_test "Renego ext: gnutls client unsafe, server break legacy" \
3786 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003787 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003788 1 \
3789 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3790 -S "server hello, secure renegotiation extension"
3791
Janos Follath0b242342016-02-17 10:11:21 +00003792# Tests for silently dropping trailing extra bytes in .der certificates
3793
3794requires_gnutls
3795run_test "DER format: no trailing bytes" \
3796 "$P_SRV crt_file=data_files/server5-der0.crt \
3797 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003798 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003799 0 \
3800 -c "Handshake was completed" \
3801
3802requires_gnutls
3803run_test "DER format: with a trailing zero byte" \
3804 "$P_SRV crt_file=data_files/server5-der1a.crt \
3805 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003806 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003807 0 \
3808 -c "Handshake was completed" \
3809
3810requires_gnutls
3811run_test "DER format: with a trailing random byte" \
3812 "$P_SRV crt_file=data_files/server5-der1b.crt \
3813 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003814 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003815 0 \
3816 -c "Handshake was completed" \
3817
3818requires_gnutls
3819run_test "DER format: with 2 trailing random bytes" \
3820 "$P_SRV crt_file=data_files/server5-der2.crt \
3821 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003822 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003823 0 \
3824 -c "Handshake was completed" \
3825
3826requires_gnutls
3827run_test "DER format: with 4 trailing random bytes" \
3828 "$P_SRV crt_file=data_files/server5-der4.crt \
3829 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003830 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003831 0 \
3832 -c "Handshake was completed" \
3833
3834requires_gnutls
3835run_test "DER format: with 8 trailing random bytes" \
3836 "$P_SRV crt_file=data_files/server5-der8.crt \
3837 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003838 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003839 0 \
3840 -c "Handshake was completed" \
3841
3842requires_gnutls
3843run_test "DER format: with 9 trailing random bytes" \
3844 "$P_SRV crt_file=data_files/server5-der9.crt \
3845 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003846 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003847 0 \
3848 -c "Handshake was completed" \
3849
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03003850# Tests for auth_mode, there are duplicated tests using ca callback for authentication
3851# When updating these tests, modify the matching authentication tests accordingly
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003853run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003854 "$P_SRV crt_file=data_files/server5-badsign.crt \
3855 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003856 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003857 1 \
3858 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003859 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003860 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003861 -c "X509 - Certificate verification failed"
3862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003863run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003864 "$P_SRV crt_file=data_files/server5-badsign.crt \
3865 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003866 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003867 0 \
3868 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003869 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003870 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003871 -C "X509 - Certificate verification failed"
3872
Hanno Beckere6706e62017-05-15 16:05:15 +01003873run_test "Authentication: server goodcert, client optional, no trusted CA" \
3874 "$P_SRV" \
3875 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3876 0 \
3877 -c "x509_verify_cert() returned" \
3878 -c "! The certificate is not correctly signed by the trusted CA" \
3879 -c "! Certificate verification flags"\
3880 -C "! mbedtls_ssl_handshake returned" \
3881 -C "X509 - Certificate verification failed" \
3882 -C "SSL - No CA Chain is set, but required to operate"
3883
3884run_test "Authentication: server goodcert, client required, no trusted CA" \
3885 "$P_SRV" \
3886 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3887 1 \
3888 -c "x509_verify_cert() returned" \
3889 -c "! The certificate is not correctly signed by the trusted CA" \
3890 -c "! Certificate verification flags"\
3891 -c "! mbedtls_ssl_handshake returned" \
3892 -c "SSL - No CA Chain is set, but required to operate"
3893
3894# The purpose of the next two tests is to test the client's behaviour when receiving a server
3895# certificate with an unsupported elliptic curve. This should usually not happen because
3896# the client informs the server about the supported curves - it does, though, in the
3897# corner case of a static ECDH suite, because the server doesn't check the curve on that
3898# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3899# different means to have the server ignoring the client's supported curve list.
3900
3901requires_config_enabled MBEDTLS_ECP_C
3902run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3903 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3904 crt_file=data_files/server5.ku-ka.crt" \
3905 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3906 1 \
3907 -c "bad certificate (EC key curve)"\
3908 -c "! Certificate verification flags"\
3909 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3910
3911requires_config_enabled MBEDTLS_ECP_C
3912run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3913 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3914 crt_file=data_files/server5.ku-ka.crt" \
3915 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3916 1 \
3917 -c "bad certificate (EC key curve)"\
3918 -c "! Certificate verification flags"\
3919 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3920
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003921run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003922 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003923 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003924 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003925 0 \
3926 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003927 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003928 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003929 -C "X509 - Certificate verification failed"
3930
Simon Butcher99000142016-10-13 17:21:01 +01003931run_test "Authentication: client SHA256, server required" \
3932 "$P_SRV auth_mode=required" \
3933 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3934 key_file=data_files/server6.key \
3935 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3936 0 \
3937 -c "Supported Signature Algorithm found: 4," \
3938 -c "Supported Signature Algorithm found: 5,"
3939
3940run_test "Authentication: client SHA384, server required" \
3941 "$P_SRV auth_mode=required" \
3942 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3943 key_file=data_files/server6.key \
3944 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3945 0 \
3946 -c "Supported Signature Algorithm found: 4," \
3947 -c "Supported Signature Algorithm found: 5,"
3948
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003949requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3950run_test "Authentication: client has no cert, server required (SSLv3)" \
3951 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3952 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3953 key_file=data_files/server5.key" \
3954 1 \
3955 -S "skip write certificate request" \
3956 -C "skip parse certificate request" \
3957 -c "got a certificate request" \
3958 -c "got no certificate to send" \
3959 -S "x509_verify_cert() returned" \
3960 -s "client has no certificate" \
3961 -s "! mbedtls_ssl_handshake returned" \
3962 -c "! mbedtls_ssl_handshake returned" \
3963 -s "No client certification received from the client, but required by the authentication mode"
3964
3965run_test "Authentication: client has no cert, server required (TLS)" \
3966 "$P_SRV debug_level=3 auth_mode=required" \
3967 "$P_CLI debug_level=3 crt_file=none \
3968 key_file=data_files/server5.key" \
3969 1 \
3970 -S "skip write certificate request" \
3971 -C "skip parse certificate request" \
3972 -c "got a certificate request" \
3973 -c "= write certificate$" \
3974 -C "skip write certificate$" \
3975 -S "x509_verify_cert() returned" \
3976 -s "client has no certificate" \
3977 -s "! mbedtls_ssl_handshake returned" \
3978 -c "! mbedtls_ssl_handshake returned" \
3979 -s "No client certification received from the client, but required by the authentication mode"
3980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003981run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003982 "$P_SRV debug_level=3 auth_mode=required" \
3983 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003984 key_file=data_files/server5.key" \
3985 1 \
3986 -S "skip write certificate request" \
3987 -C "skip parse certificate request" \
3988 -c "got a certificate request" \
3989 -C "skip write certificate" \
3990 -C "skip write certificate verify" \
3991 -S "skip parse certificate verify" \
3992 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003993 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003994 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003995 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003996 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003997 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003998# We don't check that the client receives the alert because it might
3999# detect that its write end of the connection is closed and abort
4000# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004001
Janos Follath89baba22017-04-10 14:34:35 +01004002run_test "Authentication: client cert not trusted, server required" \
4003 "$P_SRV debug_level=3 auth_mode=required" \
4004 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4005 key_file=data_files/server5.key" \
4006 1 \
4007 -S "skip write certificate request" \
4008 -C "skip parse certificate request" \
4009 -c "got a certificate request" \
4010 -C "skip write certificate" \
4011 -C "skip write certificate verify" \
4012 -S "skip parse certificate verify" \
4013 -s "x509_verify_cert() returned" \
4014 -s "! The certificate is not correctly signed by the trusted CA" \
4015 -s "! mbedtls_ssl_handshake returned" \
4016 -c "! mbedtls_ssl_handshake returned" \
4017 -s "X509 - Certificate verification failed"
4018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004019run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004020 "$P_SRV debug_level=3 auth_mode=optional" \
4021 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004022 key_file=data_files/server5.key" \
4023 0 \
4024 -S "skip write certificate request" \
4025 -C "skip parse certificate request" \
4026 -c "got a certificate request" \
4027 -C "skip write certificate" \
4028 -C "skip write certificate verify" \
4029 -S "skip parse certificate verify" \
4030 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004031 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004032 -S "! mbedtls_ssl_handshake returned" \
4033 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004034 -S "X509 - Certificate verification failed"
4035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004036run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004037 "$P_SRV debug_level=3 auth_mode=none" \
4038 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004039 key_file=data_files/server5.key" \
4040 0 \
4041 -s "skip write certificate request" \
4042 -C "skip parse certificate request" \
4043 -c "got no certificate request" \
4044 -c "skip write certificate" \
4045 -c "skip write certificate verify" \
4046 -s "skip parse certificate verify" \
4047 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004048 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004049 -S "! mbedtls_ssl_handshake returned" \
4050 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004051 -S "X509 - Certificate verification failed"
4052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004053run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004054 "$P_SRV debug_level=3 auth_mode=optional" \
4055 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004056 0 \
4057 -S "skip write certificate request" \
4058 -C "skip parse certificate request" \
4059 -c "got a certificate request" \
4060 -C "skip write certificate$" \
4061 -C "got no certificate to send" \
4062 -S "SSLv3 client has no certificate" \
4063 -c "skip write certificate verify" \
4064 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004065 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004066 -S "! mbedtls_ssl_handshake returned" \
4067 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004068 -S "X509 - Certificate verification failed"
4069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004070run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004071 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004072 "$O_CLI" \
4073 0 \
4074 -S "skip write certificate request" \
4075 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004076 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004077 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004078 -S "X509 - Certificate verification failed"
4079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004080run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004081 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004082 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004083 0 \
4084 -C "skip parse certificate request" \
4085 -c "got a certificate request" \
4086 -C "skip write certificate$" \
4087 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004088 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004089
Gilles Peskinefd8332e2017-05-03 16:25:07 +02004090run_test "Authentication: client no cert, openssl server required" \
4091 "$O_SRV -Verify 10" \
4092 "$P_CLI debug_level=3 crt_file=none key_file=none" \
4093 1 \
4094 -C "skip parse certificate request" \
4095 -c "got a certificate request" \
4096 -C "skip write certificate$" \
4097 -c "skip write certificate verify" \
4098 -c "! mbedtls_ssl_handshake returned"
4099
Janos Follathe2681a42016-03-07 15:57:05 +00004100requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004101run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004102 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004103 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004104 0 \
4105 -S "skip write certificate request" \
4106 -C "skip parse certificate request" \
4107 -c "got a certificate request" \
4108 -C "skip write certificate$" \
4109 -c "skip write certificate verify" \
4110 -c "got no certificate to send" \
4111 -s "SSLv3 client has no certificate" \
4112 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004113 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004114 -S "! mbedtls_ssl_handshake returned" \
4115 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004116 -S "X509 - Certificate verification failed"
4117
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02004118# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
4119# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004120
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004121MAX_IM_CA='8'
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02004122MAX_IM_CA_CONFIG=$( ../scripts/config.py get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004123
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004124if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01004125 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004126 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004127 printf "test value of ${MAX_IM_CA}. \n"
4128 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004129 printf "The tests assume this value and if it changes, the tests in this\n"
4130 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004131 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004132
4133 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004134fi
4135
Angus Grattonc4dd0732018-04-11 16:28:39 +10004136requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004137run_test "Authentication: server max_int chain, client default" \
4138 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4139 key_file=data_files/dir-maxpath/09.key" \
4140 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4141 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004142 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004143
Angus Grattonc4dd0732018-04-11 16:28:39 +10004144requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004145run_test "Authentication: server max_int+1 chain, client default" \
4146 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4147 key_file=data_files/dir-maxpath/10.key" \
4148 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4149 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004150 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004151
Angus Grattonc4dd0732018-04-11 16:28:39 +10004152requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004153run_test "Authentication: server max_int+1 chain, client optional" \
4154 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4155 key_file=data_files/dir-maxpath/10.key" \
4156 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4157 auth_mode=optional" \
4158 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004159 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004160
Angus Grattonc4dd0732018-04-11 16:28:39 +10004161requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004162run_test "Authentication: server max_int+1 chain, client none" \
4163 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4164 key_file=data_files/dir-maxpath/10.key" \
4165 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4166 auth_mode=none" \
4167 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004168 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004169
Angus Grattonc4dd0732018-04-11 16:28:39 +10004170requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004171run_test "Authentication: client max_int+1 chain, server default" \
4172 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4173 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4174 key_file=data_files/dir-maxpath/10.key" \
4175 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004176 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004177
Angus Grattonc4dd0732018-04-11 16:28:39 +10004178requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004179run_test "Authentication: client max_int+1 chain, server optional" \
4180 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4181 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4182 key_file=data_files/dir-maxpath/10.key" \
4183 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004184 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004185
Angus Grattonc4dd0732018-04-11 16:28:39 +10004186requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004187run_test "Authentication: client max_int+1 chain, server required" \
4188 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4189 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4190 key_file=data_files/dir-maxpath/10.key" \
4191 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004192 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004193
Angus Grattonc4dd0732018-04-11 16:28:39 +10004194requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004195run_test "Authentication: client max_int chain, server required" \
4196 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4197 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4198 key_file=data_files/dir-maxpath/09.key" \
4199 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004200 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004201
Janos Follath89baba22017-04-10 14:34:35 +01004202# Tests for CA list in CertificateRequest messages
4203
4204run_test "Authentication: send CA list in CertificateRequest (default)" \
4205 "$P_SRV debug_level=3 auth_mode=required" \
4206 "$P_CLI crt_file=data_files/server6.crt \
4207 key_file=data_files/server6.key" \
4208 0 \
4209 -s "requested DN"
4210
4211run_test "Authentication: do not send CA list in CertificateRequest" \
4212 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4213 "$P_CLI crt_file=data_files/server6.crt \
4214 key_file=data_files/server6.key" \
4215 0 \
4216 -S "requested DN"
4217
4218run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4219 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4220 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4221 key_file=data_files/server5.key" \
4222 1 \
4223 -S "requested DN" \
4224 -s "x509_verify_cert() returned" \
4225 -s "! The certificate is not correctly signed by the trusted CA" \
4226 -s "! mbedtls_ssl_handshake returned" \
4227 -c "! mbedtls_ssl_handshake returned" \
4228 -s "X509 - Certificate verification failed"
4229
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03004230# Tests for auth_mode, using CA callback, these are duplicated from the authentication tests
4231# When updating these tests, modify the matching authentication tests accordingly
Hanno Becker746aaf32019-03-28 15:25:23 +00004232
4233requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4234run_test "Authentication, CA callback: server badcert, client required" \
4235 "$P_SRV crt_file=data_files/server5-badsign.crt \
4236 key_file=data_files/server5.key" \
4237 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required" \
4238 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004239 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004240 -c "x509_verify_cert() returned" \
4241 -c "! The certificate is not correctly signed by the trusted CA" \
4242 -c "! mbedtls_ssl_handshake returned" \
4243 -c "X509 - Certificate verification failed"
4244
4245requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4246run_test "Authentication, CA callback: server badcert, client optional" \
4247 "$P_SRV crt_file=data_files/server5-badsign.crt \
4248 key_file=data_files/server5.key" \
4249 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional" \
4250 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004251 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004252 -c "x509_verify_cert() returned" \
4253 -c "! The certificate is not correctly signed by the trusted CA" \
4254 -C "! mbedtls_ssl_handshake returned" \
4255 -C "X509 - Certificate verification failed"
4256
4257# The purpose of the next two tests is to test the client's behaviour when receiving a server
4258# certificate with an unsupported elliptic curve. This should usually not happen because
4259# the client informs the server about the supported curves - it does, though, in the
4260# corner case of a static ECDH suite, because the server doesn't check the curve on that
4261# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
4262# different means to have the server ignoring the client's supported curve list.
4263
4264requires_config_enabled MBEDTLS_ECP_C
4265requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4266run_test "Authentication, CA callback: server ECDH p256v1, client required, p256v1 unsupported" \
4267 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4268 crt_file=data_files/server5.ku-ka.crt" \
4269 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required curves=secp521r1" \
4270 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004271 -c "use CA callback for X.509 CRT verification" \
4272 -c "bad certificate (EC key curve)" \
4273 -c "! Certificate verification flags" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004274 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
4275
4276requires_config_enabled MBEDTLS_ECP_C
4277requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4278run_test "Authentication, CA callback: server ECDH p256v1, client optional, p256v1 unsupported" \
4279 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4280 crt_file=data_files/server5.ku-ka.crt" \
4281 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional curves=secp521r1" \
4282 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004283 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004284 -c "bad certificate (EC key curve)"\
4285 -c "! Certificate verification flags"\
4286 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
4287
4288requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4289run_test "Authentication, CA callback: client SHA256, server required" \
4290 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4291 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4292 key_file=data_files/server6.key \
4293 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
4294 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004295 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004296 -c "Supported Signature Algorithm found: 4," \
4297 -c "Supported Signature Algorithm found: 5,"
4298
4299requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4300run_test "Authentication, CA callback: client SHA384, server required" \
4301 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4302 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4303 key_file=data_files/server6.key \
4304 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
4305 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004306 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004307 -c "Supported Signature Algorithm found: 4," \
4308 -c "Supported Signature Algorithm found: 5,"
4309
4310requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4311run_test "Authentication, CA callback: client badcert, server required" \
4312 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4313 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4314 key_file=data_files/server5.key" \
4315 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004316 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004317 -S "skip write certificate request" \
4318 -C "skip parse certificate request" \
4319 -c "got a certificate request" \
4320 -C "skip write certificate" \
4321 -C "skip write certificate verify" \
4322 -S "skip parse certificate verify" \
4323 -s "x509_verify_cert() returned" \
4324 -s "! The certificate is not correctly signed by the trusted CA" \
4325 -s "! mbedtls_ssl_handshake returned" \
4326 -s "send alert level=2 message=48" \
4327 -c "! mbedtls_ssl_handshake returned" \
4328 -s "X509 - Certificate verification failed"
4329# We don't check that the client receives the alert because it might
4330# detect that its write end of the connection is closed and abort
4331# before reading the alert message.
4332
4333requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4334run_test "Authentication, CA callback: client cert not trusted, server required" \
4335 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4336 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4337 key_file=data_files/server5.key" \
4338 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004339 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004340 -S "skip write certificate request" \
4341 -C "skip parse certificate request" \
4342 -c "got a certificate request" \
4343 -C "skip write certificate" \
4344 -C "skip write certificate verify" \
4345 -S "skip parse certificate verify" \
4346 -s "x509_verify_cert() returned" \
4347 -s "! The certificate is not correctly signed by the trusted CA" \
4348 -s "! mbedtls_ssl_handshake returned" \
4349 -c "! mbedtls_ssl_handshake returned" \
4350 -s "X509 - Certificate verification failed"
4351
4352requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4353run_test "Authentication, CA callback: client badcert, server optional" \
4354 "$P_SRV ca_callback=1 debug_level=3 auth_mode=optional" \
4355 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4356 key_file=data_files/server5.key" \
4357 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004358 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004359 -S "skip write certificate request" \
4360 -C "skip parse certificate request" \
4361 -c "got a certificate request" \
4362 -C "skip write certificate" \
4363 -C "skip write certificate verify" \
4364 -S "skip parse certificate verify" \
4365 -s "x509_verify_cert() returned" \
4366 -s "! The certificate is not correctly signed by the trusted CA" \
4367 -S "! mbedtls_ssl_handshake returned" \
4368 -C "! mbedtls_ssl_handshake returned" \
4369 -S "X509 - Certificate verification failed"
4370
4371requires_full_size_output_buffer
4372requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4373run_test "Authentication, CA callback: server max_int chain, client default" \
4374 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4375 key_file=data_files/dir-maxpath/09.key" \
4376 "$P_CLI ca_callback=1 debug_level=3 server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4377 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004378 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004379 -C "X509 - A fatal error occurred"
4380
4381requires_full_size_output_buffer
4382requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4383run_test "Authentication, CA callback: server max_int+1 chain, client default" \
4384 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4385 key_file=data_files/dir-maxpath/10.key" \
4386 "$P_CLI debug_level=3 ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4387 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004388 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004389 -c "X509 - A fatal error occurred"
4390
4391requires_full_size_output_buffer
4392requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4393run_test "Authentication, CA callback: server max_int+1 chain, client optional" \
4394 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4395 key_file=data_files/dir-maxpath/10.key" \
4396 "$P_CLI ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4397 debug_level=3 auth_mode=optional" \
4398 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004399 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004400 -c "X509 - A fatal error occurred"
4401
4402requires_full_size_output_buffer
4403requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4404run_test "Authentication, CA callback: client max_int+1 chain, server optional" \
4405 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4406 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4407 key_file=data_files/dir-maxpath/10.key" \
4408 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004409 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004410 -s "X509 - A fatal error occurred"
4411
4412requires_full_size_output_buffer
4413requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4414run_test "Authentication, CA callback: client max_int+1 chain, server required" \
4415 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4416 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4417 key_file=data_files/dir-maxpath/10.key" \
4418 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004419 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004420 -s "X509 - A fatal error occurred"
4421
4422requires_full_size_output_buffer
4423requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4424run_test "Authentication, CA callback: client max_int chain, server required" \
4425 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4426 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4427 key_file=data_files/dir-maxpath/09.key" \
4428 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004429 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004430 -S "X509 - A fatal error occurred"
4431
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004432# Tests for certificate selection based on SHA verson
4433
4434run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4435 "$P_SRV crt_file=data_files/server5.crt \
4436 key_file=data_files/server5.key \
4437 crt_file2=data_files/server5-sha1.crt \
4438 key_file2=data_files/server5.key" \
4439 "$P_CLI force_version=tls1_2" \
4440 0 \
4441 -c "signed using.*ECDSA with SHA256" \
4442 -C "signed using.*ECDSA with SHA1"
4443
4444run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4445 "$P_SRV crt_file=data_files/server5.crt \
4446 key_file=data_files/server5.key \
4447 crt_file2=data_files/server5-sha1.crt \
4448 key_file2=data_files/server5.key" \
4449 "$P_CLI force_version=tls1_1" \
4450 0 \
4451 -C "signed using.*ECDSA with SHA256" \
4452 -c "signed using.*ECDSA with SHA1"
4453
4454run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4455 "$P_SRV crt_file=data_files/server5.crt \
4456 key_file=data_files/server5.key \
4457 crt_file2=data_files/server5-sha1.crt \
4458 key_file2=data_files/server5.key" \
4459 "$P_CLI force_version=tls1" \
4460 0 \
4461 -C "signed using.*ECDSA with SHA256" \
4462 -c "signed using.*ECDSA with SHA1"
4463
4464run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4465 "$P_SRV crt_file=data_files/server5.crt \
4466 key_file=data_files/server5.key \
4467 crt_file2=data_files/server6.crt \
4468 key_file2=data_files/server6.key" \
4469 "$P_CLI force_version=tls1_1" \
4470 0 \
4471 -c "serial number.*09" \
4472 -c "signed using.*ECDSA with SHA256" \
4473 -C "signed using.*ECDSA with SHA1"
4474
4475run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4476 "$P_SRV crt_file=data_files/server6.crt \
4477 key_file=data_files/server6.key \
4478 crt_file2=data_files/server5.crt \
4479 key_file2=data_files/server5.key" \
4480 "$P_CLI force_version=tls1_1" \
4481 0 \
4482 -c "serial number.*0A" \
4483 -c "signed using.*ECDSA with SHA256" \
4484 -C "signed using.*ECDSA with SHA1"
4485
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004486# tests for SNI
4487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004488run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004489 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004490 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004491 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004492 0 \
4493 -S "parse ServerName extension" \
4494 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4495 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004497run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004498 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004499 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004500 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 +02004501 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004502 0 \
4503 -s "parse ServerName extension" \
4504 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4505 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004507run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004508 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004509 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004510 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 +02004511 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004512 0 \
4513 -s "parse ServerName extension" \
4514 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4515 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004517run_test "SNI: no matching cert" \
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é-Gonnard4d6f1782015-06-19 14:40:39 +02004520 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 +02004521 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004522 1 \
4523 -s "parse ServerName extension" \
4524 -s "ssl_sni_wrapper() returned" \
4525 -s "mbedtls_ssl_handshake returned" \
4526 -c "mbedtls_ssl_handshake returned" \
4527 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004528
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004529run_test "SNI: client auth no override: optional" \
4530 "$P_SRV debug_level=3 auth_mode=optional \
4531 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4532 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4533 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004534 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004535 -S "skip write certificate request" \
4536 -C "skip parse certificate request" \
4537 -c "got a certificate request" \
4538 -C "skip write certificate" \
4539 -C "skip write certificate verify" \
4540 -S "skip parse certificate verify"
4541
4542run_test "SNI: client auth override: none -> optional" \
4543 "$P_SRV debug_level=3 auth_mode=none \
4544 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4545 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4546 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004547 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004548 -S "skip write certificate request" \
4549 -C "skip parse certificate request" \
4550 -c "got a certificate request" \
4551 -C "skip write certificate" \
4552 -C "skip write certificate verify" \
4553 -S "skip parse certificate verify"
4554
4555run_test "SNI: client auth override: optional -> none" \
4556 "$P_SRV debug_level=3 auth_mode=optional \
4557 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4558 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4559 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004560 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004561 -s "skip write certificate request" \
4562 -C "skip parse certificate request" \
4563 -c "got no certificate request" \
4564 -c "skip write certificate" \
4565 -c "skip write certificate verify" \
4566 -s "skip parse certificate verify"
4567
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004568run_test "SNI: CA no override" \
4569 "$P_SRV debug_level=3 auth_mode=optional \
4570 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4571 ca_file=data_files/test-ca.crt \
4572 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4573 "$P_CLI debug_level=3 server_name=localhost \
4574 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4575 1 \
4576 -S "skip write certificate request" \
4577 -C "skip parse certificate request" \
4578 -c "got a certificate request" \
4579 -C "skip write certificate" \
4580 -C "skip write certificate verify" \
4581 -S "skip parse certificate verify" \
4582 -s "x509_verify_cert() returned" \
4583 -s "! The certificate is not correctly signed by the trusted CA" \
4584 -S "The certificate has been revoked (is on a CRL)"
4585
4586run_test "SNI: CA override" \
4587 "$P_SRV debug_level=3 auth_mode=optional \
4588 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4589 ca_file=data_files/test-ca.crt \
4590 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4591 "$P_CLI debug_level=3 server_name=localhost \
4592 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4593 0 \
4594 -S "skip write certificate request" \
4595 -C "skip parse certificate request" \
4596 -c "got a certificate request" \
4597 -C "skip write certificate" \
4598 -C "skip write certificate verify" \
4599 -S "skip parse certificate verify" \
4600 -S "x509_verify_cert() returned" \
4601 -S "! The certificate is not correctly signed by the trusted CA" \
4602 -S "The certificate has been revoked (is on a CRL)"
4603
4604run_test "SNI: CA override with CRL" \
4605 "$P_SRV debug_level=3 auth_mode=optional \
4606 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4607 ca_file=data_files/test-ca.crt \
4608 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4609 "$P_CLI debug_level=3 server_name=localhost \
4610 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4611 1 \
4612 -S "skip write certificate request" \
4613 -C "skip parse certificate request" \
4614 -c "got a certificate request" \
4615 -C "skip write certificate" \
4616 -C "skip write certificate verify" \
4617 -S "skip parse certificate verify" \
4618 -s "x509_verify_cert() returned" \
4619 -S "! The certificate is not correctly signed by the trusted CA" \
4620 -s "The certificate has been revoked (is on a CRL)"
4621
Andres AG1a834452016-12-07 10:01:30 +00004622# Tests for SNI and DTLS
4623
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004624run_test "SNI: DTLS, no SNI callback" \
4625 "$P_SRV debug_level=3 dtls=1 \
4626 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
4627 "$P_CLI server_name=localhost dtls=1" \
4628 0 \
4629 -S "parse ServerName extension" \
4630 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4631 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4632
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004633run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004634 "$P_SRV debug_level=3 dtls=1 \
4635 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4636 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4637 "$P_CLI server_name=localhost dtls=1" \
4638 0 \
4639 -s "parse ServerName extension" \
4640 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4641 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4642
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004643run_test "SNI: DTLS, matching cert 2" \
4644 "$P_SRV debug_level=3 dtls=1 \
4645 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4646 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4647 "$P_CLI server_name=polarssl.example dtls=1" \
4648 0 \
4649 -s "parse ServerName extension" \
4650 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4651 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4652
4653run_test "SNI: DTLS, no matching cert" \
4654 "$P_SRV debug_level=3 dtls=1 \
4655 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4656 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4657 "$P_CLI server_name=nonesuch.example dtls=1" \
4658 1 \
4659 -s "parse ServerName extension" \
4660 -s "ssl_sni_wrapper() returned" \
4661 -s "mbedtls_ssl_handshake returned" \
4662 -c "mbedtls_ssl_handshake returned" \
4663 -c "SSL - A fatal alert message was received from our peer"
4664
4665run_test "SNI: DTLS, client auth no override: optional" \
4666 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4667 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4668 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4669 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4670 0 \
4671 -S "skip write certificate request" \
4672 -C "skip parse certificate request" \
4673 -c "got a certificate request" \
4674 -C "skip write certificate" \
4675 -C "skip write certificate verify" \
4676 -S "skip parse certificate verify"
4677
4678run_test "SNI: DTLS, client auth override: none -> optional" \
4679 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4680 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4681 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4682 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4683 0 \
4684 -S "skip write certificate request" \
4685 -C "skip parse certificate request" \
4686 -c "got a certificate request" \
4687 -C "skip write certificate" \
4688 -C "skip write certificate verify" \
4689 -S "skip parse certificate verify"
4690
4691run_test "SNI: DTLS, client auth override: optional -> none" \
4692 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4693 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4694 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4695 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4696 0 \
4697 -s "skip write certificate request" \
4698 -C "skip parse certificate request" \
4699 -c "got no certificate request" \
4700 -c "skip write certificate" \
4701 -c "skip write certificate verify" \
4702 -s "skip parse certificate verify"
4703
4704run_test "SNI: DTLS, CA no override" \
4705 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4706 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4707 ca_file=data_files/test-ca.crt \
4708 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4709 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4710 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4711 1 \
4712 -S "skip write certificate request" \
4713 -C "skip parse certificate request" \
4714 -c "got a certificate request" \
4715 -C "skip write certificate" \
4716 -C "skip write certificate verify" \
4717 -S "skip parse certificate verify" \
4718 -s "x509_verify_cert() returned" \
4719 -s "! The certificate is not correctly signed by the trusted CA" \
4720 -S "The certificate has been revoked (is on a CRL)"
4721
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004722run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004723 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4724 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4725 ca_file=data_files/test-ca.crt \
4726 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4727 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4728 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4729 0 \
4730 -S "skip write certificate request" \
4731 -C "skip parse certificate request" \
4732 -c "got a certificate request" \
4733 -C "skip write certificate" \
4734 -C "skip write certificate verify" \
4735 -S "skip parse certificate verify" \
4736 -S "x509_verify_cert() returned" \
4737 -S "! The certificate is not correctly signed by the trusted CA" \
4738 -S "The certificate has been revoked (is on a CRL)"
4739
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004740run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004741 "$P_SRV debug_level=3 auth_mode=optional \
4742 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4743 ca_file=data_files/test-ca.crt \
4744 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4745 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4746 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4747 1 \
4748 -S "skip write certificate request" \
4749 -C "skip parse certificate request" \
4750 -c "got a certificate request" \
4751 -C "skip write certificate" \
4752 -C "skip write certificate verify" \
4753 -S "skip parse certificate verify" \
4754 -s "x509_verify_cert() returned" \
4755 -S "! The certificate is not correctly signed by the trusted CA" \
4756 -s "The certificate has been revoked (is on a CRL)"
4757
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004758# Tests for non-blocking I/O: exercise a variety of handshake flows
4759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004760run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004761 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4762 "$P_CLI nbio=2 tickets=0" \
4763 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004764 -S "mbedtls_ssl_handshake returned" \
4765 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004766 -c "Read from server: .* bytes read"
4767
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004768run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004769 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4770 "$P_CLI nbio=2 tickets=0" \
4771 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004772 -S "mbedtls_ssl_handshake returned" \
4773 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004774 -c "Read from server: .* bytes read"
4775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004776run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004777 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4778 "$P_CLI nbio=2 tickets=1" \
4779 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004780 -S "mbedtls_ssl_handshake returned" \
4781 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004782 -c "Read from server: .* bytes read"
4783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004784run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004785 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4786 "$P_CLI nbio=2 tickets=1" \
4787 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004788 -S "mbedtls_ssl_handshake returned" \
4789 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004790 -c "Read from server: .* bytes read"
4791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004792run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004793 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4794 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4795 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004796 -S "mbedtls_ssl_handshake returned" \
4797 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004798 -c "Read from server: .* bytes read"
4799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004800run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004801 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4802 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4803 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004804 -S "mbedtls_ssl_handshake returned" \
4805 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004806 -c "Read from server: .* bytes read"
4807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004808run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004809 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4810 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4811 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004812 -S "mbedtls_ssl_handshake returned" \
4813 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004814 -c "Read from server: .* bytes read"
4815
Hanno Becker00076712017-11-15 16:39:08 +00004816# Tests for event-driven I/O: exercise a variety of handshake flows
4817
4818run_test "Event-driven I/O: basic handshake" \
4819 "$P_SRV event=1 tickets=0 auth_mode=none" \
4820 "$P_CLI event=1 tickets=0" \
4821 0 \
4822 -S "mbedtls_ssl_handshake returned" \
4823 -C "mbedtls_ssl_handshake returned" \
4824 -c "Read from server: .* bytes read"
4825
4826run_test "Event-driven I/O: client auth" \
4827 "$P_SRV event=1 tickets=0 auth_mode=required" \
4828 "$P_CLI event=1 tickets=0" \
4829 0 \
4830 -S "mbedtls_ssl_handshake returned" \
4831 -C "mbedtls_ssl_handshake returned" \
4832 -c "Read from server: .* bytes read"
4833
4834run_test "Event-driven I/O: ticket" \
4835 "$P_SRV event=1 tickets=1 auth_mode=none" \
4836 "$P_CLI event=1 tickets=1" \
4837 0 \
4838 -S "mbedtls_ssl_handshake returned" \
4839 -C "mbedtls_ssl_handshake returned" \
4840 -c "Read from server: .* bytes read"
4841
4842run_test "Event-driven I/O: ticket + client auth" \
4843 "$P_SRV event=1 tickets=1 auth_mode=required" \
4844 "$P_CLI event=1 tickets=1" \
4845 0 \
4846 -S "mbedtls_ssl_handshake returned" \
4847 -C "mbedtls_ssl_handshake returned" \
4848 -c "Read from server: .* bytes read"
4849
4850run_test "Event-driven I/O: ticket + client auth + resume" \
4851 "$P_SRV event=1 tickets=1 auth_mode=required" \
4852 "$P_CLI event=1 tickets=1 reconnect=1" \
4853 0 \
4854 -S "mbedtls_ssl_handshake returned" \
4855 -C "mbedtls_ssl_handshake returned" \
4856 -c "Read from server: .* bytes read"
4857
4858run_test "Event-driven I/O: ticket + resume" \
4859 "$P_SRV event=1 tickets=1 auth_mode=none" \
4860 "$P_CLI event=1 tickets=1 reconnect=1" \
4861 0 \
4862 -S "mbedtls_ssl_handshake returned" \
4863 -C "mbedtls_ssl_handshake returned" \
4864 -c "Read from server: .* bytes read"
4865
4866run_test "Event-driven I/O: session-id resume" \
4867 "$P_SRV event=1 tickets=0 auth_mode=none" \
4868 "$P_CLI event=1 tickets=0 reconnect=1" \
4869 0 \
4870 -S "mbedtls_ssl_handshake returned" \
4871 -C "mbedtls_ssl_handshake returned" \
4872 -c "Read from server: .* bytes read"
4873
Hanno Becker6a33f592018-03-13 11:38:46 +00004874run_test "Event-driven I/O, DTLS: basic handshake" \
4875 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4876 "$P_CLI dtls=1 event=1 tickets=0" \
4877 0 \
4878 -c "Read from server: .* bytes read"
4879
4880run_test "Event-driven I/O, DTLS: client auth" \
4881 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4882 "$P_CLI dtls=1 event=1 tickets=0" \
4883 0 \
4884 -c "Read from server: .* bytes read"
4885
4886run_test "Event-driven I/O, DTLS: ticket" \
4887 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4888 "$P_CLI dtls=1 event=1 tickets=1" \
4889 0 \
4890 -c "Read from server: .* bytes read"
4891
4892run_test "Event-driven I/O, DTLS: ticket + client auth" \
4893 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4894 "$P_CLI dtls=1 event=1 tickets=1" \
4895 0 \
4896 -c "Read from server: .* bytes read"
4897
4898run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4899 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004900 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004901 0 \
4902 -c "Read from server: .* bytes read"
4903
4904run_test "Event-driven I/O, DTLS: ticket + resume" \
4905 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004906 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004907 0 \
4908 -c "Read from server: .* bytes read"
4909
4910run_test "Event-driven I/O, DTLS: session-id resume" \
4911 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004912 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004913 0 \
4914 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004915
4916# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4917# During session resumption, the client will send its ApplicationData record
4918# within the same datagram as the Finished messages. In this situation, the
4919# server MUST NOT idle on the underlying transport after handshake completion,
4920# because the ApplicationData request has already been queued internally.
4921run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004922 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004923 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004924 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004925 0 \
4926 -c "Read from server: .* bytes read"
4927
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004928# Tests for version negotiation
4929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004930run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004931 "$P_SRV" \
4932 "$P_CLI" \
4933 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004934 -S "mbedtls_ssl_handshake returned" \
4935 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004936 -s "Protocol is TLSv1.2" \
4937 -c "Protocol is TLSv1.2"
4938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004939run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004940 "$P_SRV" \
4941 "$P_CLI max_version=tls1_1" \
4942 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004943 -S "mbedtls_ssl_handshake returned" \
4944 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004945 -s "Protocol is TLSv1.1" \
4946 -c "Protocol is TLSv1.1"
4947
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004948run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004949 "$P_SRV max_version=tls1_1" \
4950 "$P_CLI" \
4951 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004952 -S "mbedtls_ssl_handshake returned" \
4953 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004954 -s "Protocol is TLSv1.1" \
4955 -c "Protocol is TLSv1.1"
4956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004957run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004958 "$P_SRV max_version=tls1_1" \
4959 "$P_CLI max_version=tls1_1" \
4960 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004961 -S "mbedtls_ssl_handshake returned" \
4962 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004963 -s "Protocol is TLSv1.1" \
4964 -c "Protocol is TLSv1.1"
4965
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004966run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004967 "$P_SRV min_version=tls1_1" \
4968 "$P_CLI max_version=tls1_1" \
4969 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004970 -S "mbedtls_ssl_handshake returned" \
4971 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004972 -s "Protocol is TLSv1.1" \
4973 -c "Protocol is TLSv1.1"
4974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004975run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004976 "$P_SRV max_version=tls1_1" \
4977 "$P_CLI min_version=tls1_1" \
4978 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004979 -S "mbedtls_ssl_handshake returned" \
4980 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004981 -s "Protocol is TLSv1.1" \
4982 -c "Protocol is TLSv1.1"
4983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004984run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004985 "$P_SRV max_version=tls1_1" \
4986 "$P_CLI min_version=tls1_2" \
4987 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004988 -s "mbedtls_ssl_handshake returned" \
4989 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004990 -c "SSL - Handshake protocol not within min/max boundaries"
4991
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004992run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004993 "$P_SRV min_version=tls1_2" \
4994 "$P_CLI max_version=tls1_1" \
4995 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004996 -s "mbedtls_ssl_handshake returned" \
4997 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004998 -s "SSL - Handshake protocol not within min/max boundaries"
4999
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005000# Tests for ALPN extension
5001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005002run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005003 "$P_SRV debug_level=3" \
5004 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005005 0 \
5006 -C "client hello, adding alpn extension" \
5007 -S "found alpn extension" \
5008 -C "got an alert message, type: \\[2:120]" \
5009 -S "server hello, adding alpn extension" \
5010 -C "found alpn extension " \
5011 -C "Application Layer Protocol is" \
5012 -S "Application Layer Protocol is"
5013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005014run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005015 "$P_SRV debug_level=3" \
5016 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005017 0 \
5018 -c "client hello, adding alpn extension" \
5019 -s "found alpn extension" \
5020 -C "got an alert message, type: \\[2:120]" \
5021 -S "server hello, adding alpn extension" \
5022 -C "found alpn extension " \
5023 -c "Application Layer Protocol is (none)" \
5024 -S "Application Layer Protocol is"
5025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005026run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005027 "$P_SRV debug_level=3 alpn=abc,1234" \
5028 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005029 0 \
5030 -C "client hello, adding alpn extension" \
5031 -S "found alpn extension" \
5032 -C "got an alert message, type: \\[2:120]" \
5033 -S "server hello, adding alpn extension" \
5034 -C "found alpn extension " \
5035 -C "Application Layer Protocol is" \
5036 -s "Application Layer Protocol is (none)"
5037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005038run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005039 "$P_SRV debug_level=3 alpn=abc,1234" \
5040 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005041 0 \
5042 -c "client hello, adding alpn extension" \
5043 -s "found alpn extension" \
5044 -C "got an alert message, type: \\[2:120]" \
5045 -s "server hello, adding alpn extension" \
5046 -c "found alpn extension" \
5047 -c "Application Layer Protocol is abc" \
5048 -s "Application Layer Protocol is abc"
5049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005050run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005051 "$P_SRV debug_level=3 alpn=abc,1234" \
5052 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005053 0 \
5054 -c "client hello, adding alpn extension" \
5055 -s "found alpn extension" \
5056 -C "got an alert message, type: \\[2:120]" \
5057 -s "server hello, adding alpn extension" \
5058 -c "found alpn extension" \
5059 -c "Application Layer Protocol is abc" \
5060 -s "Application Layer Protocol is abc"
5061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005062run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005063 "$P_SRV debug_level=3 alpn=abc,1234" \
5064 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005065 0 \
5066 -c "client hello, adding alpn extension" \
5067 -s "found alpn extension" \
5068 -C "got an alert message, type: \\[2:120]" \
5069 -s "server hello, adding alpn extension" \
5070 -c "found alpn extension" \
5071 -c "Application Layer Protocol is 1234" \
5072 -s "Application Layer Protocol is 1234"
5073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005074run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005075 "$P_SRV debug_level=3 alpn=abc,123" \
5076 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005077 1 \
5078 -c "client hello, adding alpn extension" \
5079 -s "found alpn extension" \
5080 -c "got an alert message, type: \\[2:120]" \
5081 -S "server hello, adding alpn extension" \
5082 -C "found alpn extension" \
5083 -C "Application Layer Protocol is 1234" \
5084 -S "Application Layer Protocol is 1234"
5085
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02005086
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005087# Tests for keyUsage in leaf certificates, part 1:
5088# server-side certificate/suite selection
5089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005090run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005091 "$P_SRV key_file=data_files/server2.key \
5092 crt_file=data_files/server2.ku-ds.crt" \
5093 "$P_CLI" \
5094 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02005095 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005096
5097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005098run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005099 "$P_SRV key_file=data_files/server2.key \
5100 crt_file=data_files/server2.ku-ke.crt" \
5101 "$P_CLI" \
5102 0 \
5103 -c "Ciphersuite is TLS-RSA-WITH-"
5104
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005105run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005106 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005107 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005108 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005109 1 \
5110 -C "Ciphersuite is "
5111
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005112run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005113 "$P_SRV key_file=data_files/server5.key \
5114 crt_file=data_files/server5.ku-ds.crt" \
5115 "$P_CLI" \
5116 0 \
5117 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
5118
5119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005120run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005121 "$P_SRV key_file=data_files/server5.key \
5122 crt_file=data_files/server5.ku-ka.crt" \
5123 "$P_CLI" \
5124 0 \
5125 -c "Ciphersuite is TLS-ECDH-"
5126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005127run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005128 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005129 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005130 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005131 1 \
5132 -C "Ciphersuite is "
5133
5134# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005135# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005136
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005137run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005138 "$O_SRV -key data_files/server2.key \
5139 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005140 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005141 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5142 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005143 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005144 -C "Processing of the Certificate handshake message failed" \
5145 -c "Ciphersuite is TLS-"
5146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005147run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005148 "$O_SRV -key data_files/server2.key \
5149 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005150 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005151 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5152 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005153 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005154 -C "Processing of the Certificate handshake message failed" \
5155 -c "Ciphersuite is TLS-"
5156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005157run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005158 "$O_SRV -key data_files/server2.key \
5159 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005160 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005161 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5162 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005163 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005164 -C "Processing of the Certificate handshake message failed" \
5165 -c "Ciphersuite is TLS-"
5166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005167run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005168 "$O_SRV -key data_files/server2.key \
5169 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005170 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005171 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5172 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005173 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005174 -c "Processing of the Certificate handshake message failed" \
5175 -C "Ciphersuite is TLS-"
5176
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01005177run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
5178 "$O_SRV -key data_files/server2.key \
5179 -cert data_files/server2.ku-ke.crt" \
5180 "$P_CLI debug_level=1 auth_mode=optional \
5181 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5182 0 \
5183 -c "bad certificate (usage extensions)" \
5184 -C "Processing of the Certificate handshake message failed" \
5185 -c "Ciphersuite is TLS-" \
5186 -c "! Usage does not match the keyUsage extension"
5187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005188run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005189 "$O_SRV -key data_files/server2.key \
5190 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005191 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005192 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5193 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005194 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005195 -C "Processing of the Certificate handshake message failed" \
5196 -c "Ciphersuite is TLS-"
5197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005198run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005199 "$O_SRV -key data_files/server2.key \
5200 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005201 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005202 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5203 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005204 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005205 -c "Processing of the Certificate handshake message failed" \
5206 -C "Ciphersuite is TLS-"
5207
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01005208run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
5209 "$O_SRV -key data_files/server2.key \
5210 -cert data_files/server2.ku-ds.crt" \
5211 "$P_CLI debug_level=1 auth_mode=optional \
5212 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5213 0 \
5214 -c "bad certificate (usage extensions)" \
5215 -C "Processing of the Certificate handshake message failed" \
5216 -c "Ciphersuite is TLS-" \
5217 -c "! Usage does not match the keyUsage extension"
5218
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005219# Tests for keyUsage in leaf certificates, part 3:
5220# server-side checking of client cert
5221
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005222run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005223 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005224 "$O_CLI -key data_files/server2.key \
5225 -cert data_files/server2.ku-ds.crt" \
5226 0 \
5227 -S "bad certificate (usage extensions)" \
5228 -S "Processing of the Certificate handshake message failed"
5229
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005230run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005231 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005232 "$O_CLI -key data_files/server2.key \
5233 -cert data_files/server2.ku-ke.crt" \
5234 0 \
5235 -s "bad certificate (usage extensions)" \
5236 -S "Processing of the Certificate handshake message failed"
5237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005238run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005239 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005240 "$O_CLI -key data_files/server2.key \
5241 -cert data_files/server2.ku-ke.crt" \
5242 1 \
5243 -s "bad certificate (usage extensions)" \
5244 -s "Processing of the Certificate handshake message failed"
5245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005246run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005247 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005248 "$O_CLI -key data_files/server5.key \
5249 -cert data_files/server5.ku-ds.crt" \
5250 0 \
5251 -S "bad certificate (usage extensions)" \
5252 -S "Processing of the Certificate handshake message failed"
5253
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005254run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005255 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005256 "$O_CLI -key data_files/server5.key \
5257 -cert data_files/server5.ku-ka.crt" \
5258 0 \
5259 -s "bad certificate (usage extensions)" \
5260 -S "Processing of the Certificate handshake message failed"
5261
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005262# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
5263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005264run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005265 "$P_SRV key_file=data_files/server5.key \
5266 crt_file=data_files/server5.eku-srv.crt" \
5267 "$P_CLI" \
5268 0
5269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005270run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005271 "$P_SRV key_file=data_files/server5.key \
5272 crt_file=data_files/server5.eku-srv.crt" \
5273 "$P_CLI" \
5274 0
5275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005276run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005277 "$P_SRV key_file=data_files/server5.key \
5278 crt_file=data_files/server5.eku-cs_any.crt" \
5279 "$P_CLI" \
5280 0
5281
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005282run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005283 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005284 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005285 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005286 1
5287
5288# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005290run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005291 "$O_SRV -key data_files/server5.key \
5292 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005293 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005294 0 \
5295 -C "bad certificate (usage extensions)" \
5296 -C "Processing of the Certificate handshake message failed" \
5297 -c "Ciphersuite is TLS-"
5298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005299run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005300 "$O_SRV -key data_files/server5.key \
5301 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005302 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005303 0 \
5304 -C "bad certificate (usage extensions)" \
5305 -C "Processing of the Certificate handshake message failed" \
5306 -c "Ciphersuite is TLS-"
5307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005308run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005309 "$O_SRV -key data_files/server5.key \
5310 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005311 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005312 0 \
5313 -C "bad certificate (usage extensions)" \
5314 -C "Processing of the Certificate handshake message failed" \
5315 -c "Ciphersuite is TLS-"
5316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005317run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005318 "$O_SRV -key data_files/server5.key \
5319 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005320 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005321 1 \
5322 -c "bad certificate (usage extensions)" \
5323 -c "Processing of the Certificate handshake message failed" \
5324 -C "Ciphersuite is TLS-"
5325
5326# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005328run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005329 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005330 "$O_CLI -key data_files/server5.key \
5331 -cert data_files/server5.eku-cli.crt" \
5332 0 \
5333 -S "bad certificate (usage extensions)" \
5334 -S "Processing of the Certificate handshake message failed"
5335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005336run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005337 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005338 "$O_CLI -key data_files/server5.key \
5339 -cert data_files/server5.eku-srv_cli.crt" \
5340 0 \
5341 -S "bad certificate (usage extensions)" \
5342 -S "Processing of the Certificate handshake message failed"
5343
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005344run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005345 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005346 "$O_CLI -key data_files/server5.key \
5347 -cert data_files/server5.eku-cs_any.crt" \
5348 0 \
5349 -S "bad certificate (usage extensions)" \
5350 -S "Processing of the Certificate handshake message failed"
5351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005352run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005353 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005354 "$O_CLI -key data_files/server5.key \
5355 -cert data_files/server5.eku-cs.crt" \
5356 0 \
5357 -s "bad certificate (usage extensions)" \
5358 -S "Processing of the Certificate handshake message failed"
5359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005360run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005361 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005362 "$O_CLI -key data_files/server5.key \
5363 -cert data_files/server5.eku-cs.crt" \
5364 1 \
5365 -s "bad certificate (usage extensions)" \
5366 -s "Processing of the Certificate handshake message failed"
5367
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005368# Tests for DHM parameters loading
5369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005370run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005371 "$P_SRV" \
5372 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5373 debug_level=3" \
5374 0 \
5375 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005376 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005378run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005379 "$P_SRV dhm_file=data_files/dhparams.pem" \
5380 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5381 debug_level=3" \
5382 0 \
5383 -c "value of 'DHM: P ' (1024 bits)" \
5384 -c "value of 'DHM: G ' (2 bits)"
5385
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005386# Tests for DHM client-side size checking
5387
5388run_test "DHM size: server default, client default, OK" \
5389 "$P_SRV" \
5390 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5391 debug_level=1" \
5392 0 \
5393 -C "DHM prime too short:"
5394
5395run_test "DHM size: server default, client 2048, OK" \
5396 "$P_SRV" \
5397 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5398 debug_level=1 dhmlen=2048" \
5399 0 \
5400 -C "DHM prime too short:"
5401
5402run_test "DHM size: server 1024, client default, OK" \
5403 "$P_SRV dhm_file=data_files/dhparams.pem" \
5404 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5405 debug_level=1" \
5406 0 \
5407 -C "DHM prime too short:"
5408
5409run_test "DHM size: server 1000, client default, rejected" \
5410 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5411 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5412 debug_level=1" \
5413 1 \
5414 -c "DHM prime too short:"
5415
5416run_test "DHM size: server default, client 2049, rejected" \
5417 "$P_SRV" \
5418 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5419 debug_level=1 dhmlen=2049" \
5420 1 \
5421 -c "DHM prime too short:"
5422
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005423# Tests for PSK callback
5424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005425run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005426 "$P_SRV psk=abc123 psk_identity=foo" \
5427 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5428 psk_identity=foo psk=abc123" \
5429 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005430 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005431 -S "SSL - Unknown identity received" \
5432 -S "SSL - Verification of the message MAC failed"
5433
Hanno Beckerf7027512018-10-23 15:27:39 +01005434requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5435run_test "PSK callback: opaque psk on client, no callback" \
5436 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5437 "$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 +00005438 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005439 0 \
5440 -c "skip PMS generation for opaque PSK"\
5441 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005442 -C "session hash for extended master secret"\
5443 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005444 -S "SSL - None of the common ciphersuites is usable" \
5445 -S "SSL - Unknown identity received" \
5446 -S "SSL - Verification of the message MAC failed"
5447
5448requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5449run_test "PSK callback: opaque psk on client, no callback, SHA-384" \
5450 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5451 "$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 +00005452 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005453 0 \
5454 -c "skip PMS generation for opaque PSK"\
5455 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005456 -C "session hash for extended master secret"\
5457 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005458 -S "SSL - None of the common ciphersuites is usable" \
5459 -S "SSL - Unknown identity received" \
5460 -S "SSL - Verification of the message MAC failed"
5461
5462requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5463run_test "PSK callback: opaque psk on client, no callback, EMS" \
5464 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5465 "$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 +00005466 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005467 0 \
5468 -c "skip PMS generation for opaque PSK"\
5469 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005470 -c "session hash for extended master secret"\
5471 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005472 -S "SSL - None of the common ciphersuites is usable" \
5473 -S "SSL - Unknown identity received" \
5474 -S "SSL - Verification of the message MAC failed"
5475
5476requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5477run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \
5478 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5479 "$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 +00005480 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005481 0 \
5482 -c "skip PMS generation for opaque PSK"\
5483 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005484 -c "session hash for extended master secret"\
5485 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005486 -S "SSL - None of the common ciphersuites is usable" \
5487 -S "SSL - Unknown identity received" \
5488 -S "SSL - Verification of the message MAC failed"
5489
Hanno Becker28c79dc2018-10-26 13:15:08 +01005490requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5491run_test "PSK callback: raw psk on client, static opaque on server, no callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005492 "$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 +01005493 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5494 psk_identity=foo psk=abc123" \
5495 0 \
5496 -C "skip PMS generation for opaque PSK"\
5497 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005498 -C "session hash for extended master secret"\
5499 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005500 -S "SSL - None of the common ciphersuites is usable" \
5501 -S "SSL - Unknown identity received" \
5502 -S "SSL - Verification of the message MAC failed"
5503
5504requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5505run_test "PSK callback: raw psk on client, static opaque on server, no callback, SHA-384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005506 "$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 +01005507 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5508 psk_identity=foo psk=abc123" \
5509 0 \
5510 -C "skip PMS generation for opaque PSK"\
5511 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005512 -C "session hash for extended master secret"\
5513 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005514 -S "SSL - None of the common ciphersuites is usable" \
5515 -S "SSL - Unknown identity received" \
5516 -S "SSL - Verification of the message MAC failed"
5517
5518requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5519run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005520 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005521 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5522 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5523 psk_identity=foo psk=abc123 extended_ms=1" \
5524 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005525 -c "session hash for extended master secret"\
5526 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005527 -C "skip PMS generation for opaque PSK"\
5528 -s "skip PMS generation for opaque PSK"\
5529 -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, EMS, SHA384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005535 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005536 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5537 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5538 psk_identity=foo psk=abc123 extended_ms=1" \
5539 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005540 -c "session hash for extended master secret"\
5541 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005542 -C "skip PMS generation for opaque PSK"\
5543 -s "skip PMS generation for opaque PSK"\
5544 -S "SSL - None of the common ciphersuites is usable" \
5545 -S "SSL - Unknown identity received" \
5546 -S "SSL - Verification of the message MAC failed"
5547
5548requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5549run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005550 "$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 +01005551 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5552 psk_identity=def psk=beef" \
5553 0 \
5554 -C "skip PMS generation for opaque PSK"\
5555 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005556 -C "session hash for extended master secret"\
5557 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005558 -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, no static PSK on server, opaque PSK from callback, SHA-384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005564 "$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 +01005565 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5566 psk_identity=def psk=beef" \
5567 0 \
5568 -C "skip PMS generation for opaque PSK"\
5569 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005570 -C "session hash for extended master secret"\
5571 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005572 -S "SSL - None of the common ciphersuites is usable" \
5573 -S "SSL - Unknown identity received" \
5574 -S "SSL - Verification of the message MAC failed"
5575
5576requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5577run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005578 "$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 +01005579 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5580 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5581 psk_identity=abc psk=dead extended_ms=1" \
5582 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005583 -c "session hash for extended master secret"\
5584 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005585 -C "skip PMS generation for opaque PSK"\
5586 -s "skip PMS generation for opaque PSK"\
5587 -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, EMS, SHA384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005593 "$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 +01005594 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5595 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5596 psk_identity=abc psk=dead extended_ms=1" \
5597 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005598 -c "session hash for extended master secret"\
5599 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005600 -C "skip PMS generation for opaque PSK"\
5601 -s "skip PMS generation for opaque PSK"\
5602 -S "SSL - None of the common ciphersuites is usable" \
5603 -S "SSL - Unknown identity received" \
5604 -S "SSL - Verification of the message MAC failed"
5605
5606requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5607run_test "PSK callback: raw psk on client, mismatching static raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005608 "$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 +01005609 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5610 psk_identity=def psk=beef" \
5611 0 \
5612 -C "skip PMS generation for opaque PSK"\
5613 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005614 -C "session hash for extended master secret"\
5615 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005616 -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, mismatching static opaque PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005622 "$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 +01005623 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5624 psk_identity=def psk=beef" \
5625 0 \
5626 -C "skip PMS generation for opaque PSK"\
5627 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005628 -C "session hash for extended master secret"\
5629 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005630 -S "SSL - None of the common ciphersuites is usable" \
5631 -S "SSL - Unknown identity received" \
5632 -S "SSL - Verification of the message MAC failed"
5633
5634requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5635run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, raw PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005636 "$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 +01005637 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5638 psk_identity=def psk=beef" \
5639 0 \
5640 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005641 -C "session hash for extended master secret"\
5642 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005643 -S "SSL - None of the common ciphersuites is usable" \
5644 -S "SSL - Unknown identity received" \
5645 -S "SSL - Verification of the message MAC failed"
5646
5647requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5648run_test "PSK callback: raw psk on client, id-matching but wrong raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005649 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=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 +01005650 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5651 psk_identity=def psk=beef" \
5652 0 \
5653 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005654 -C "session hash for extended master secret"\
5655 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005656 -S "SSL - None of the common ciphersuites is usable" \
5657 -S "SSL - Unknown identity received" \
5658 -S "SSL - Verification of the message MAC failed"
5659
5660requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5661run_test "PSK callback: raw psk on client, matching opaque PSK on server, wrong opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005662 "$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 +01005663 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5664 psk_identity=def psk=beef" \
5665 1 \
5666 -s "SSL - Verification of the message MAC failed"
5667
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005668run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005669 "$P_SRV" \
5670 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5671 psk_identity=foo psk=abc123" \
5672 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005673 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005674 -S "SSL - Unknown identity received" \
5675 -S "SSL - Verification of the message MAC failed"
5676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005677run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005678 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5679 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5680 psk_identity=foo psk=abc123" \
5681 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005682 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005683 -s "SSL - Unknown identity received" \
5684 -S "SSL - Verification of the message MAC failed"
5685
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005686run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005687 "$P_SRV psk_list=abc,dead,def,beef" \
5688 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5689 psk_identity=abc psk=dead" \
5690 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005691 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005692 -S "SSL - Unknown identity received" \
5693 -S "SSL - Verification of the message MAC failed"
5694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005695run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005696 "$P_SRV psk_list=abc,dead,def,beef" \
5697 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5698 psk_identity=def psk=beef" \
5699 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005700 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005701 -S "SSL - Unknown identity received" \
5702 -S "SSL - Verification of the message MAC failed"
5703
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005704run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005705 "$P_SRV psk_list=abc,dead,def,beef" \
5706 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5707 psk_identity=ghi psk=beef" \
5708 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005709 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005710 -s "SSL - Unknown identity received" \
5711 -S "SSL - Verification of the message MAC failed"
5712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005713run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005714 "$P_SRV psk_list=abc,dead,def,beef" \
5715 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5716 psk_identity=abc psk=beef" \
5717 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005718 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005719 -S "SSL - Unknown identity received" \
5720 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005721
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005722# Tests for EC J-PAKE
5723
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005724requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005725run_test "ECJPAKE: client not configured" \
5726 "$P_SRV debug_level=3" \
5727 "$P_CLI debug_level=3" \
5728 0 \
5729 -C "add ciphersuite: c0ff" \
5730 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005731 -S "found ecjpake kkpp extension" \
5732 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005733 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005734 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005735 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005736 -S "None of the common ciphersuites is usable"
5737
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005738requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005739run_test "ECJPAKE: server not configured" \
5740 "$P_SRV debug_level=3" \
5741 "$P_CLI debug_level=3 ecjpake_pw=bla \
5742 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5743 1 \
5744 -c "add ciphersuite: c0ff" \
5745 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005746 -s "found ecjpake kkpp extension" \
5747 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005748 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005749 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005750 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005751 -s "None of the common ciphersuites is usable"
5752
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005753requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005754run_test "ECJPAKE: working, TLS" \
5755 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5756 "$P_CLI debug_level=3 ecjpake_pw=bla \
5757 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005758 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005759 -c "add ciphersuite: c0ff" \
5760 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005761 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005762 -s "found ecjpake kkpp extension" \
5763 -S "skip ecjpake kkpp extension" \
5764 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005765 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005766 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005767 -S "None of the common ciphersuites is usable" \
5768 -S "SSL - Verification of the message MAC failed"
5769
Janos Follath74537a62016-09-02 13:45:28 +01005770server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005771requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005772run_test "ECJPAKE: password mismatch, TLS" \
5773 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5774 "$P_CLI debug_level=3 ecjpake_pw=bad \
5775 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5776 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005777 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005778 -s "SSL - Verification of the message MAC failed"
5779
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005780requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005781run_test "ECJPAKE: working, DTLS" \
5782 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5783 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5784 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5785 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005786 -c "re-using cached ecjpake parameters" \
5787 -S "SSL - Verification of the message MAC failed"
5788
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005789requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005790run_test "ECJPAKE: working, DTLS, no cookie" \
5791 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5792 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5793 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5794 0 \
5795 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005796 -S "SSL - Verification of the message MAC failed"
5797
Janos Follath74537a62016-09-02 13:45:28 +01005798server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005799requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005800run_test "ECJPAKE: password mismatch, DTLS" \
5801 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5802 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5803 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5804 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005805 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005806 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005807
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005808# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005809requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005810run_test "ECJPAKE: working, DTLS, nolog" \
5811 "$P_SRV dtls=1 ecjpake_pw=bla" \
5812 "$P_CLI dtls=1 ecjpake_pw=bla \
5813 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5814 0
5815
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005816# Tests for ciphersuites per version
5817
Janos Follathe2681a42016-03-07 15:57:05 +00005818requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005819requires_config_enabled MBEDTLS_CAMELLIA_C
5820requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005821run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005822 "$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 +02005823 "$P_CLI force_version=ssl3" \
5824 0 \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005825 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005826
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005827requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5828requires_config_enabled MBEDTLS_CAMELLIA_C
5829requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005830run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005831 "$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 +01005832 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005833 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005834 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005835
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005836requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5837requires_config_enabled MBEDTLS_CAMELLIA_C
5838requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005839run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005840 "$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 +02005841 "$P_CLI force_version=tls1_1" \
5842 0 \
5843 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5844
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005845requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5846requires_config_enabled MBEDTLS_CAMELLIA_C
5847requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005848run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005849 "$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 +02005850 "$P_CLI force_version=tls1_2" \
5851 0 \
5852 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5853
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005854# Test for ClientHello without extensions
5855
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005856requires_gnutls
Manuel Pégourié-Gonnardbc4da292020-01-30 12:45:14 +01005857run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard77cbeff2020-01-30 10:58:57 +01005858 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005859 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005860 0 \
5861 -s "dumping 'client hello extensions' (0 bytes)"
5862
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005863# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005864
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005865run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005866 "$P_SRV" \
5867 "$P_CLI request_size=100" \
5868 0 \
5869 -s "Read from client: 100 bytes read$"
5870
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005871run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005872 "$P_SRV" \
5873 "$P_CLI request_size=500" \
5874 0 \
5875 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005876
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005877# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005878
Janos Follathe2681a42016-03-07 15:57:05 +00005879requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005880run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005881 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005882 "$P_CLI request_size=1 force_version=ssl3 \
5883 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5884 0 \
5885 -s "Read from client: 1 bytes read"
5886
Janos Follathe2681a42016-03-07 15:57:05 +00005887requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005888run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005889 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005890 "$P_CLI request_size=1 force_version=ssl3 \
5891 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5892 0 \
5893 -s "Read from client: 1 bytes read"
5894
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005895run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005896 "$P_SRV" \
5897 "$P_CLI request_size=1 force_version=tls1 \
5898 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5899 0 \
5900 -s "Read from client: 1 bytes read"
5901
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005902run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005903 "$P_SRV" \
5904 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5905 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5906 0 \
5907 -s "Read from client: 1 bytes read"
5908
Hanno Becker32c55012017-11-10 08:42:54 +00005909requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005910run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005911 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005912 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005913 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005914 0 \
5915 -s "Read from client: 1 bytes read"
5916
Hanno Becker32c55012017-11-10 08:42:54 +00005917requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005918run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005919 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005920 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005921 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005922 0 \
5923 -s "Read from client: 1 bytes read"
5924
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005925run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005926 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005927 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005928 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5929 0 \
5930 -s "Read from client: 1 bytes read"
5931
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005932run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005933 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5934 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005935 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005936 0 \
5937 -s "Read from client: 1 bytes read"
5938
5939requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005940run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005941 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005942 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005943 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005944 0 \
5945 -s "Read from client: 1 bytes read"
5946
Hanno Becker8501f982017-11-10 08:59:04 +00005947requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005948run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005949 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5950 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5951 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005952 0 \
5953 -s "Read from client: 1 bytes read"
5954
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005955run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005956 "$P_SRV" \
5957 "$P_CLI request_size=1 force_version=tls1_1 \
5958 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5959 0 \
5960 -s "Read from client: 1 bytes read"
5961
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005962run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005963 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005964 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005965 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005966 0 \
5967 -s "Read from client: 1 bytes read"
5968
5969requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005970run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005971 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005972 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005973 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005974 0 \
5975 -s "Read from client: 1 bytes read"
5976
5977requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005978run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005979 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005980 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005981 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005982 0 \
5983 -s "Read from client: 1 bytes read"
5984
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005985run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005986 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005987 "$P_CLI request_size=1 force_version=tls1_1 \
5988 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5989 0 \
5990 -s "Read from client: 1 bytes read"
5991
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005992run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005993 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005994 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005995 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005996 0 \
5997 -s "Read from client: 1 bytes read"
5998
Hanno Becker8501f982017-11-10 08:59:04 +00005999requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006000run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006001 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006002 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006003 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006004 0 \
6005 -s "Read from client: 1 bytes read"
6006
Hanno Becker32c55012017-11-10 08:42:54 +00006007requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006008run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006009 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006010 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006011 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006012 0 \
6013 -s "Read from client: 1 bytes read"
6014
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006015run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006016 "$P_SRV" \
6017 "$P_CLI request_size=1 force_version=tls1_2 \
6018 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6019 0 \
6020 -s "Read from client: 1 bytes read"
6021
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006022run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006023 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00006024 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006025 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006026 0 \
6027 -s "Read from client: 1 bytes read"
6028
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006029run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006030 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006031 "$P_CLI request_size=1 force_version=tls1_2 \
6032 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
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.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006038 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006039 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006040 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006041 0 \
6042 -s "Read from client: 1 bytes read"
6043
Hanno Becker8501f982017-11-10 08:59:04 +00006044requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006045run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006046 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006047 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006048 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006049 0 \
6050 -s "Read from client: 1 bytes read"
6051
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006052run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006053 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006054 "$P_CLI request_size=1 force_version=tls1_2 \
6055 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6056 0 \
6057 -s "Read from client: 1 bytes read"
6058
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006059run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006060 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006061 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006062 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00006063 0 \
6064 -s "Read from client: 1 bytes read"
6065
Hanno Becker32c55012017-11-10 08:42:54 +00006066requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006067run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006068 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006069 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006070 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006071 0 \
6072 -s "Read from client: 1 bytes read"
6073
Hanno Becker8501f982017-11-10 08:59:04 +00006074requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006075run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006076 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006077 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006078 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006079 0 \
6080 -s "Read from client: 1 bytes read"
6081
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006082run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006083 "$P_SRV" \
6084 "$P_CLI request_size=1 force_version=tls1_2 \
6085 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6086 0 \
6087 -s "Read from client: 1 bytes read"
6088
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006089run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006090 "$P_SRV" \
6091 "$P_CLI request_size=1 force_version=tls1_2 \
6092 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6093 0 \
6094 -s "Read from client: 1 bytes read"
6095
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006096# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00006097
6098requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006099run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006100 "$P_SRV dtls=1 force_version=dtls1" \
6101 "$P_CLI dtls=1 request_size=1 \
6102 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6103 0 \
6104 -s "Read from client: 1 bytes read"
6105
6106requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006107run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00006108 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
6109 "$P_CLI dtls=1 request_size=1 \
6110 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6111 0 \
6112 -s "Read from client: 1 bytes read"
6113
6114requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6115requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006116run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006117 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
6118 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00006119 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6120 0 \
6121 -s "Read from client: 1 bytes read"
6122
6123requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6124requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006125run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006126 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006127 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006128 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00006129 0 \
6130 -s "Read from client: 1 bytes read"
6131
6132requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006133run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00006134 "$P_SRV dtls=1 force_version=dtls1_2" \
6135 "$P_CLI dtls=1 request_size=1 \
6136 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6137 0 \
6138 -s "Read from client: 1 bytes read"
6139
6140requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006141run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006142 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006143 "$P_CLI dtls=1 request_size=1 \
6144 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6145 0 \
6146 -s "Read from client: 1 bytes read"
6147
6148requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6149requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006150run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006151 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00006152 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006153 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00006154 0 \
6155 -s "Read from client: 1 bytes read"
6156
6157requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6158requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006159run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006160 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006161 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006162 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00006163 0 \
6164 -s "Read from client: 1 bytes read"
6165
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006166# Tests for small server packets
6167
6168requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6169run_test "Small server packet SSLv3 BlockCipher" \
6170 "$P_SRV response_size=1 min_version=ssl3" \
6171 "$P_CLI force_version=ssl3 \
6172 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6173 0 \
6174 -c "Read from server: 1 bytes read"
6175
6176requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6177run_test "Small server packet SSLv3 StreamCipher" \
6178 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6179 "$P_CLI force_version=ssl3 \
6180 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6181 0 \
6182 -c "Read from server: 1 bytes read"
6183
6184run_test "Small server packet TLS 1.0 BlockCipher" \
6185 "$P_SRV response_size=1" \
6186 "$P_CLI force_version=tls1 \
6187 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6188 0 \
6189 -c "Read from server: 1 bytes read"
6190
6191run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
6192 "$P_SRV response_size=1" \
6193 "$P_CLI force_version=tls1 etm=0 \
6194 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6195 0 \
6196 -c "Read from server: 1 bytes read"
6197
6198requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6199run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
6200 "$P_SRV response_size=1 trunc_hmac=1" \
6201 "$P_CLI force_version=tls1 \
6202 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6203 0 \
6204 -c "Read from server: 1 bytes read"
6205
6206requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6207run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
6208 "$P_SRV response_size=1 trunc_hmac=1" \
6209 "$P_CLI force_version=tls1 \
6210 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6211 0 \
6212 -c "Read from server: 1 bytes read"
6213
6214run_test "Small server packet TLS 1.0 StreamCipher" \
6215 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6216 "$P_CLI force_version=tls1 \
6217 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6218 0 \
6219 -c "Read from server: 1 bytes read"
6220
6221run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
6222 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6223 "$P_CLI force_version=tls1 \
6224 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6225 0 \
6226 -c "Read from server: 1 bytes read"
6227
6228requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6229run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
6230 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6231 "$P_CLI force_version=tls1 \
6232 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6233 0 \
6234 -c "Read from server: 1 bytes read"
6235
6236requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6237run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6238 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6239 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6240 trunc_hmac=1 etm=0" \
6241 0 \
6242 -c "Read from server: 1 bytes read"
6243
6244run_test "Small server packet TLS 1.1 BlockCipher" \
6245 "$P_SRV response_size=1" \
6246 "$P_CLI force_version=tls1_1 \
6247 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6248 0 \
6249 -c "Read from server: 1 bytes read"
6250
6251run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
6252 "$P_SRV response_size=1" \
6253 "$P_CLI force_version=tls1_1 \
6254 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
6255 0 \
6256 -c "Read from server: 1 bytes read"
6257
6258requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6259run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
6260 "$P_SRV response_size=1 trunc_hmac=1" \
6261 "$P_CLI force_version=tls1_1 \
6262 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6263 0 \
6264 -c "Read from server: 1 bytes read"
6265
6266requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6267run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6268 "$P_SRV response_size=1 trunc_hmac=1" \
6269 "$P_CLI force_version=tls1_1 \
6270 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6271 0 \
6272 -c "Read from server: 1 bytes read"
6273
6274run_test "Small server packet TLS 1.1 StreamCipher" \
6275 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6276 "$P_CLI force_version=tls1_1 \
6277 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6278 0 \
6279 -c "Read from server: 1 bytes read"
6280
6281run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
6282 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6283 "$P_CLI force_version=tls1_1 \
6284 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6285 0 \
6286 -c "Read from server: 1 bytes read"
6287
6288requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6289run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
6290 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6291 "$P_CLI force_version=tls1_1 \
6292 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6293 0 \
6294 -c "Read from server: 1 bytes read"
6295
6296requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6297run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6298 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6299 "$P_CLI force_version=tls1_1 \
6300 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6301 0 \
6302 -c "Read from server: 1 bytes read"
6303
6304run_test "Small server packet TLS 1.2 BlockCipher" \
6305 "$P_SRV response_size=1" \
6306 "$P_CLI force_version=tls1_2 \
6307 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6308 0 \
6309 -c "Read from server: 1 bytes read"
6310
6311run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
6312 "$P_SRV response_size=1" \
6313 "$P_CLI force_version=tls1_2 \
6314 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
6315 0 \
6316 -c "Read from server: 1 bytes read"
6317
6318run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
6319 "$P_SRV response_size=1" \
6320 "$P_CLI force_version=tls1_2 \
6321 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
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.2 BlockCipher, truncated MAC" \
6327 "$P_SRV response_size=1 trunc_hmac=1" \
6328 "$P_CLI force_version=tls1_2 \
6329 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6330 0 \
6331 -c "Read from server: 1 bytes read"
6332
6333requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6334run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6335 "$P_SRV response_size=1 trunc_hmac=1" \
6336 "$P_CLI force_version=tls1_2 \
6337 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6338 0 \
6339 -c "Read from server: 1 bytes read"
6340
6341run_test "Small server packet TLS 1.2 StreamCipher" \
6342 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6343 "$P_CLI force_version=tls1_2 \
6344 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6345 0 \
6346 -c "Read from server: 1 bytes read"
6347
6348run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
6349 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6350 "$P_CLI force_version=tls1_2 \
6351 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6352 0 \
6353 -c "Read from server: 1 bytes read"
6354
6355requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6356run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
6357 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6358 "$P_CLI force_version=tls1_2 \
6359 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6360 0 \
6361 -c "Read from server: 1 bytes read"
6362
6363requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6364run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6365 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6366 "$P_CLI force_version=tls1_2 \
6367 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6368 0 \
6369 -c "Read from server: 1 bytes read"
6370
6371run_test "Small server packet TLS 1.2 AEAD" \
6372 "$P_SRV response_size=1" \
6373 "$P_CLI force_version=tls1_2 \
6374 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6375 0 \
6376 -c "Read from server: 1 bytes read"
6377
6378run_test "Small server packet TLS 1.2 AEAD shorter tag" \
6379 "$P_SRV response_size=1" \
6380 "$P_CLI force_version=tls1_2 \
6381 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6382 0 \
6383 -c "Read from server: 1 bytes read"
6384
6385# Tests for small server packets in DTLS
6386
6387requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6388run_test "Small server packet DTLS 1.0" \
6389 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
6390 "$P_CLI dtls=1 \
6391 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6392 0 \
6393 -c "Read from server: 1 bytes read"
6394
6395requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6396run_test "Small server packet DTLS 1.0, without EtM" \
6397 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
6398 "$P_CLI dtls=1 \
6399 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6400 0 \
6401 -c "Read from server: 1 bytes read"
6402
6403requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6404requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6405run_test "Small server packet DTLS 1.0, truncated hmac" \
6406 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
6407 "$P_CLI dtls=1 trunc_hmac=1 \
6408 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6409 0 \
6410 -c "Read from server: 1 bytes read"
6411
6412requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6413requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6414run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
6415 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
6416 "$P_CLI dtls=1 \
6417 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
6418 0 \
6419 -c "Read from server: 1 bytes read"
6420
6421requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6422run_test "Small server packet DTLS 1.2" \
6423 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
6424 "$P_CLI dtls=1 \
6425 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6426 0 \
6427 -c "Read from server: 1 bytes read"
6428
6429requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6430run_test "Small server packet DTLS 1.2, without EtM" \
6431 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
6432 "$P_CLI dtls=1 \
6433 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6434 0 \
6435 -c "Read from server: 1 bytes read"
6436
6437requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6438requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6439run_test "Small server packet DTLS 1.2, truncated hmac" \
6440 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
6441 "$P_CLI dtls=1 \
6442 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6443 0 \
6444 -c "Read from server: 1 bytes read"
6445
6446requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6447requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6448run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
6449 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
6450 "$P_CLI dtls=1 \
6451 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
6452 0 \
6453 -c "Read from server: 1 bytes read"
6454
Janos Follath00efff72016-05-06 13:48:23 +01006455# A test for extensions in SSLv3
6456
6457requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6458run_test "SSLv3 with extensions, server side" \
6459 "$P_SRV min_version=ssl3 debug_level=3" \
6460 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
6461 0 \
6462 -S "dumping 'client hello extensions'" \
6463 -S "server hello, total extension length:"
6464
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006465# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006466
Angus Grattonc4dd0732018-04-11 16:28:39 +10006467# How many fragments do we expect to write $1 bytes?
6468fragments_for_write() {
6469 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
6470}
6471
Janos Follathe2681a42016-03-07 15:57:05 +00006472requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006473run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01006474 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006475 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006476 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6477 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006478 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6479 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006480
Janos Follathe2681a42016-03-07 15:57:05 +00006481requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006482run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006483 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006484 "$P_CLI request_size=16384 force_version=ssl3 \
6485 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6486 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006487 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6488 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006489
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006490run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006491 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006492 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006493 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6494 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006495 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6496 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006497
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006498run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006499 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006500 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
6501 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6502 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006503 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006504
Hanno Becker32c55012017-11-10 08:42:54 +00006505requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006506run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006507 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006508 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006509 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006510 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006511 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6512 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006513
Hanno Becker32c55012017-11-10 08:42:54 +00006514requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006515run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006516 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006517 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006518 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006519 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006520 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006521
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006522run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006523 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006524 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006525 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6526 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006527 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006528
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006529run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006530 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6531 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006532 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006533 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006534 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006535
6536requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006537run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006538 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006539 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006540 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006541 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006542 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006543
Hanno Becker278fc7a2017-11-10 09:16:28 +00006544requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006545run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006546 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006547 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006548 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006549 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006550 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6551 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006552
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006553run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006554 "$P_SRV" \
6555 "$P_CLI request_size=16384 force_version=tls1_1 \
6556 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6557 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006558 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6559 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006560
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006561run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006562 "$P_SRV" \
6563 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6564 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006565 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006566 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006567
Hanno Becker32c55012017-11-10 08:42:54 +00006568requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006569run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006570 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006571 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006572 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006573 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006574 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006575
Hanno Becker32c55012017-11-10 08:42:54 +00006576requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006577run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006578 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006579 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006580 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006581 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006582 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006583
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006584run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006585 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6586 "$P_CLI request_size=16384 force_version=tls1_1 \
6587 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6588 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006589 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6590 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006591
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006592run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006593 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006594 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006595 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006596 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006597 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6598 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006599
Hanno Becker278fc7a2017-11-10 09:16:28 +00006600requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006601run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006602 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006603 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006604 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006605 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006606 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006607
Hanno Becker278fc7a2017-11-10 09:16:28 +00006608requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006609run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006610 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006611 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006612 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006613 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006614 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6615 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006616
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006617run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006618 "$P_SRV" \
6619 "$P_CLI request_size=16384 force_version=tls1_2 \
6620 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6621 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006622 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6623 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006624
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006625run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006626 "$P_SRV" \
6627 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6628 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6629 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006630 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006631
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006632run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006633 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006634 "$P_CLI request_size=16384 force_version=tls1_2 \
6635 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006636 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006637 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6638 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006639
Hanno Becker32c55012017-11-10 08:42:54 +00006640requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006641run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006642 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006643 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006644 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006645 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006646 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006647
Hanno Becker278fc7a2017-11-10 09:16:28 +00006648requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006649run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006650 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006651 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006652 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006653 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006654 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6655 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006656
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006657run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006658 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006659 "$P_CLI request_size=16384 force_version=tls1_2 \
6660 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6661 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006662 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6663 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006664
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006665run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006666 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006667 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006668 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6669 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006670 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006671
Hanno Becker32c55012017-11-10 08:42:54 +00006672requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006673run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006674 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006675 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006676 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006677 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006678 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006679
Hanno Becker278fc7a2017-11-10 09:16:28 +00006680requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006681run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006682 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006683 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006684 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006685 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006686 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6687 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006688
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006689run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006690 "$P_SRV" \
6691 "$P_CLI request_size=16384 force_version=tls1_2 \
6692 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6693 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006694 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6695 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006696
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006697run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006698 "$P_SRV" \
6699 "$P_CLI request_size=16384 force_version=tls1_2 \
6700 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6701 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006702 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6703 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006704
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006705# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006706requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6707run_test "Large server packet SSLv3 StreamCipher" \
6708 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6709 "$P_CLI force_version=ssl3 \
6710 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6711 0 \
6712 -c "Read from server: 16384 bytes read"
6713
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006714# Checking next 4 tests logs for 1n-1 split against BEAST too
6715requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6716run_test "Large server packet SSLv3 BlockCipher" \
6717 "$P_SRV response_size=16384 min_version=ssl3" \
6718 "$P_CLI force_version=ssl3 recsplit=0 \
6719 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6720 0 \
6721 -c "Read from server: 1 bytes read"\
6722 -c "16383 bytes read"\
6723 -C "Read from server: 16384 bytes read"
6724
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006725run_test "Large server packet TLS 1.0 BlockCipher" \
6726 "$P_SRV response_size=16384" \
6727 "$P_CLI force_version=tls1 recsplit=0 \
6728 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6729 0 \
6730 -c "Read from server: 1 bytes read"\
6731 -c "16383 bytes read"\
6732 -C "Read from server: 16384 bytes read"
6733
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006734run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6735 "$P_SRV response_size=16384" \
6736 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6737 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6738 0 \
6739 -c "Read from server: 1 bytes read"\
6740 -c "16383 bytes read"\
6741 -C "Read from server: 16384 bytes read"
6742
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006743requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6744run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6745 "$P_SRV response_size=16384" \
6746 "$P_CLI force_version=tls1 recsplit=0 \
6747 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6748 trunc_hmac=1" \
6749 0 \
6750 -c "Read from server: 1 bytes read"\
6751 -c "16383 bytes read"\
6752 -C "Read from server: 16384 bytes read"
6753
6754requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6755run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6756 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6757 "$P_CLI force_version=tls1 \
6758 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6759 trunc_hmac=1" \
6760 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006761 -s "16384 bytes written in 1 fragments" \
6762 -c "Read from server: 16384 bytes read"
6763
6764run_test "Large server packet TLS 1.0 StreamCipher" \
6765 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6766 "$P_CLI force_version=tls1 \
6767 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6768 0 \
6769 -s "16384 bytes written in 1 fragments" \
6770 -c "Read from server: 16384 bytes read"
6771
6772run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6773 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6774 "$P_CLI force_version=tls1 \
6775 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6776 0 \
6777 -s "16384 bytes written in 1 fragments" \
6778 -c "Read from server: 16384 bytes read"
6779
6780requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6781run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6782 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6783 "$P_CLI force_version=tls1 \
6784 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6785 0 \
6786 -s "16384 bytes written in 1 fragments" \
6787 -c "Read from server: 16384 bytes read"
6788
6789requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6790run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6791 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6792 "$P_CLI force_version=tls1 \
6793 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6794 0 \
6795 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006796 -c "Read from server: 16384 bytes read"
6797
6798run_test "Large server packet TLS 1.1 BlockCipher" \
6799 "$P_SRV response_size=16384" \
6800 "$P_CLI force_version=tls1_1 \
6801 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6802 0 \
6803 -c "Read from server: 16384 bytes read"
6804
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006805run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6806 "$P_SRV response_size=16384" \
6807 "$P_CLI force_version=tls1_1 etm=0 \
6808 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006809 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006810 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006811 -c "Read from server: 16384 bytes read"
6812
6813requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6814run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6815 "$P_SRV response_size=16384" \
6816 "$P_CLI force_version=tls1_1 \
6817 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6818 trunc_hmac=1" \
6819 0 \
6820 -c "Read from server: 16384 bytes read"
6821
6822requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006823run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6824 "$P_SRV response_size=16384 trunc_hmac=1" \
6825 "$P_CLI force_version=tls1_1 \
6826 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6827 0 \
6828 -s "16384 bytes written in 1 fragments" \
6829 -c "Read from server: 16384 bytes read"
6830
6831run_test "Large server packet TLS 1.1 StreamCipher" \
6832 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6833 "$P_CLI force_version=tls1_1 \
6834 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6835 0 \
6836 -c "Read from server: 16384 bytes read"
6837
6838run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6839 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6840 "$P_CLI force_version=tls1_1 \
6841 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6842 0 \
6843 -s "16384 bytes written in 1 fragments" \
6844 -c "Read from server: 16384 bytes read"
6845
6846requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006847run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6848 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6849 "$P_CLI force_version=tls1_1 \
6850 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6851 trunc_hmac=1" \
6852 0 \
6853 -c "Read from server: 16384 bytes read"
6854
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006855run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6856 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6857 "$P_CLI force_version=tls1_1 \
6858 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6859 0 \
6860 -s "16384 bytes written in 1 fragments" \
6861 -c "Read from server: 16384 bytes read"
6862
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006863run_test "Large server packet TLS 1.2 BlockCipher" \
6864 "$P_SRV response_size=16384" \
6865 "$P_CLI force_version=tls1_2 \
6866 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6867 0 \
6868 -c "Read from server: 16384 bytes read"
6869
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006870run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6871 "$P_SRV response_size=16384" \
6872 "$P_CLI force_version=tls1_2 etm=0 \
6873 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6874 0 \
6875 -s "16384 bytes written in 1 fragments" \
6876 -c "Read from server: 16384 bytes read"
6877
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006878run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6879 "$P_SRV response_size=16384" \
6880 "$P_CLI force_version=tls1_2 \
6881 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6882 0 \
6883 -c "Read from server: 16384 bytes read"
6884
6885requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6886run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6887 "$P_SRV response_size=16384" \
6888 "$P_CLI force_version=tls1_2 \
6889 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6890 trunc_hmac=1" \
6891 0 \
6892 -c "Read from server: 16384 bytes read"
6893
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006894run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6895 "$P_SRV response_size=16384 trunc_hmac=1" \
6896 "$P_CLI force_version=tls1_2 \
6897 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6898 0 \
6899 -s "16384 bytes written in 1 fragments" \
6900 -c "Read from server: 16384 bytes read"
6901
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006902run_test "Large server packet TLS 1.2 StreamCipher" \
6903 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6904 "$P_CLI force_version=tls1_2 \
6905 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6906 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006907 -s "16384 bytes written in 1 fragments" \
6908 -c "Read from server: 16384 bytes read"
6909
6910run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6911 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6912 "$P_CLI force_version=tls1_2 \
6913 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6914 0 \
6915 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006916 -c "Read from server: 16384 bytes read"
6917
6918requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6919run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6920 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6921 "$P_CLI force_version=tls1_2 \
6922 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6923 trunc_hmac=1" \
6924 0 \
6925 -c "Read from server: 16384 bytes read"
6926
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006927requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6928run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6929 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6930 "$P_CLI force_version=tls1_2 \
6931 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6932 0 \
6933 -s "16384 bytes written in 1 fragments" \
6934 -c "Read from server: 16384 bytes read"
6935
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006936run_test "Large server packet TLS 1.2 AEAD" \
6937 "$P_SRV response_size=16384" \
6938 "$P_CLI force_version=tls1_2 \
6939 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6940 0 \
6941 -c "Read from server: 16384 bytes read"
6942
6943run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6944 "$P_SRV response_size=16384" \
6945 "$P_CLI force_version=tls1_2 \
6946 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6947 0 \
6948 -c "Read from server: 16384 bytes read"
6949
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006950# Tests for restartable ECC
6951
6952requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6953run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006954 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006955 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006956 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006957 debug_level=1" \
6958 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006959 -C "x509_verify_cert.*4b00" \
6960 -C "mbedtls_pk_verify.*4b00" \
6961 -C "mbedtls_ecdh_make_public.*4b00" \
6962 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006963
6964requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6965run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006966 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006967 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006968 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006969 debug_level=1 ec_max_ops=0" \
6970 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006971 -C "x509_verify_cert.*4b00" \
6972 -C "mbedtls_pk_verify.*4b00" \
6973 -C "mbedtls_ecdh_make_public.*4b00" \
6974 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006975
6976requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6977run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006978 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006979 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006980 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006981 debug_level=1 ec_max_ops=65535" \
6982 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006983 -C "x509_verify_cert.*4b00" \
6984 -C "mbedtls_pk_verify.*4b00" \
6985 -C "mbedtls_ecdh_make_public.*4b00" \
6986 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006987
6988requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6989run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006990 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006991 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006992 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006993 debug_level=1 ec_max_ops=1000" \
6994 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006995 -c "x509_verify_cert.*4b00" \
6996 -c "mbedtls_pk_verify.*4b00" \
6997 -c "mbedtls_ecdh_make_public.*4b00" \
6998 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006999
7000requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007001run_test "EC restart: TLS, max_ops=1000, badsign" \
7002 "$P_SRV auth_mode=required \
7003 crt_file=data_files/server5-badsign.crt \
7004 key_file=data_files/server5.key" \
7005 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7006 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7007 debug_level=1 ec_max_ops=1000" \
7008 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007009 -c "x509_verify_cert.*4b00" \
7010 -C "mbedtls_pk_verify.*4b00" \
7011 -C "mbedtls_ecdh_make_public.*4b00" \
7012 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007013 -c "! The certificate is not correctly signed by the trusted CA" \
7014 -c "! mbedtls_ssl_handshake returned" \
7015 -c "X509 - Certificate verification failed"
7016
7017requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7018run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
7019 "$P_SRV auth_mode=required \
7020 crt_file=data_files/server5-badsign.crt \
7021 key_file=data_files/server5.key" \
7022 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7023 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7024 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
7025 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007026 -c "x509_verify_cert.*4b00" \
7027 -c "mbedtls_pk_verify.*4b00" \
7028 -c "mbedtls_ecdh_make_public.*4b00" \
7029 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007030 -c "! The certificate is not correctly signed by the trusted CA" \
7031 -C "! mbedtls_ssl_handshake returned" \
7032 -C "X509 - Certificate verification failed"
7033
7034requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7035run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
7036 "$P_SRV auth_mode=required \
7037 crt_file=data_files/server5-badsign.crt \
7038 key_file=data_files/server5.key" \
7039 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7040 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7041 debug_level=1 ec_max_ops=1000 auth_mode=none" \
7042 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007043 -C "x509_verify_cert.*4b00" \
7044 -c "mbedtls_pk_verify.*4b00" \
7045 -c "mbedtls_ecdh_make_public.*4b00" \
7046 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007047 -C "! The certificate is not correctly signed by the trusted CA" \
7048 -C "! mbedtls_ssl_handshake returned" \
7049 -C "X509 - Certificate verification failed"
7050
7051requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007052run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007053 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007054 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007055 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007056 dtls=1 debug_level=1 ec_max_ops=1000" \
7057 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007058 -c "x509_verify_cert.*4b00" \
7059 -c "mbedtls_pk_verify.*4b00" \
7060 -c "mbedtls_ecdh_make_public.*4b00" \
7061 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007062
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007063requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7064run_test "EC restart: TLS, max_ops=1000 no client auth" \
7065 "$P_SRV" \
7066 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7067 debug_level=1 ec_max_ops=1000" \
7068 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007069 -c "x509_verify_cert.*4b00" \
7070 -c "mbedtls_pk_verify.*4b00" \
7071 -c "mbedtls_ecdh_make_public.*4b00" \
7072 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007073
7074requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7075run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
7076 "$P_SRV psk=abc123" \
7077 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
7078 psk=abc123 debug_level=1 ec_max_ops=1000" \
7079 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007080 -C "x509_verify_cert.*4b00" \
7081 -C "mbedtls_pk_verify.*4b00" \
7082 -C "mbedtls_ecdh_make_public.*4b00" \
7083 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007084
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007085# Tests of asynchronous private key support in SSL
7086
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007087requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007088run_test "SSL async private: sign, delay=0" \
7089 "$P_SRV \
7090 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007091 "$P_CLI" \
7092 0 \
7093 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007094 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007095
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007096requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007097run_test "SSL async private: sign, delay=1" \
7098 "$P_SRV \
7099 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007100 "$P_CLI" \
7101 0 \
7102 -s "Async sign callback: using key slot " \
7103 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007104 -s "Async resume (slot [0-9]): sign done, status=0"
7105
Gilles Peskine12d0cc12018-04-26 15:06:56 +02007106requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7107run_test "SSL async private: sign, delay=2" \
7108 "$P_SRV \
7109 async_operations=s async_private_delay1=2 async_private_delay2=2" \
7110 "$P_CLI" \
7111 0 \
7112 -s "Async sign callback: using key slot " \
7113 -U "Async sign callback: using key slot " \
7114 -s "Async resume (slot [0-9]): call 1 more times." \
7115 -s "Async resume (slot [0-9]): call 0 more times." \
7116 -s "Async resume (slot [0-9]): sign done, status=0"
7117
Gilles Peskined3268832018-04-26 06:23:59 +02007118# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
7119# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
7120requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7121requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7122run_test "SSL async private: sign, RSA, TLS 1.1" \
7123 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
7124 async_operations=s async_private_delay1=0 async_private_delay2=0" \
7125 "$P_CLI force_version=tls1_1" \
7126 0 \
7127 -s "Async sign callback: using key slot " \
7128 -s "Async resume (slot [0-9]): sign done, status=0"
7129
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007130requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02007131run_test "SSL async private: sign, SNI" \
7132 "$P_SRV debug_level=3 \
7133 async_operations=s async_private_delay1=0 async_private_delay2=0 \
7134 crt_file=data_files/server5.crt key_file=data_files/server5.key \
7135 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
7136 "$P_CLI server_name=polarssl.example" \
7137 0 \
7138 -s "Async sign callback: using key slot " \
7139 -s "Async resume (slot [0-9]): sign done, status=0" \
7140 -s "parse ServerName extension" \
7141 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
7142 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
7143
7144requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007145run_test "SSL async private: decrypt, delay=0" \
7146 "$P_SRV \
7147 async_operations=d async_private_delay1=0 async_private_delay2=0" \
7148 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7149 0 \
7150 -s "Async decrypt callback: using key slot " \
7151 -s "Async resume (slot [0-9]): decrypt done, status=0"
7152
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007153requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007154run_test "SSL async private: decrypt, delay=1" \
7155 "$P_SRV \
7156 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7157 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7158 0 \
7159 -s "Async decrypt callback: using key slot " \
7160 -s "Async resume (slot [0-9]): call 0 more times." \
7161 -s "Async resume (slot [0-9]): decrypt done, status=0"
7162
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007163requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007164run_test "SSL async private: decrypt RSA-PSK, delay=0" \
7165 "$P_SRV psk=abc123 \
7166 async_operations=d async_private_delay1=0 async_private_delay2=0" \
7167 "$P_CLI psk=abc123 \
7168 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
7169 0 \
7170 -s "Async decrypt callback: using key slot " \
7171 -s "Async resume (slot [0-9]): decrypt done, status=0"
7172
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007173requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007174run_test "SSL async private: decrypt RSA-PSK, delay=1" \
7175 "$P_SRV psk=abc123 \
7176 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7177 "$P_CLI psk=abc123 \
7178 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
7179 0 \
7180 -s "Async decrypt callback: using key slot " \
7181 -s "Async resume (slot [0-9]): call 0 more times." \
7182 -s "Async resume (slot [0-9]): decrypt done, status=0"
7183
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007184requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007185run_test "SSL async private: sign callback not present" \
7186 "$P_SRV \
7187 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7188 "$P_CLI; [ \$? -eq 1 ] &&
7189 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7190 0 \
7191 -S "Async sign callback" \
7192 -s "! mbedtls_ssl_handshake returned" \
7193 -s "The own private key or pre-shared key is not set, but needed" \
7194 -s "Async resume (slot [0-9]): decrypt done, status=0" \
7195 -s "Successful connection"
7196
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007197requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007198run_test "SSL async private: decrypt callback not present" \
7199 "$P_SRV debug_level=1 \
7200 async_operations=s async_private_delay1=1 async_private_delay2=1" \
7201 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
7202 [ \$? -eq 1 ] && $P_CLI" \
7203 0 \
7204 -S "Async decrypt callback" \
7205 -s "! mbedtls_ssl_handshake returned" \
7206 -s "got no RSA private key" \
7207 -s "Async resume (slot [0-9]): sign done, status=0" \
7208 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007209
7210# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007211requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007212run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007213 "$P_SRV \
7214 async_operations=s async_private_delay1=1 \
7215 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7216 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007217 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7218 0 \
7219 -s "Async sign callback: using key slot 0," \
7220 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007221 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007222
7223# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007224requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007225run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007226 "$P_SRV \
7227 async_operations=s async_private_delay2=1 \
7228 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7229 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007230 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7231 0 \
7232 -s "Async sign callback: using key slot 0," \
7233 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007234 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007235
7236# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007237requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02007238run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007239 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02007240 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007241 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7242 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007243 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7244 0 \
7245 -s "Async sign callback: using key slot 1," \
7246 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007247 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007248
7249# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007250requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007251run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007252 "$P_SRV \
7253 async_operations=s async_private_delay1=1 \
7254 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7255 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007256 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7257 0 \
7258 -s "Async sign callback: no key matches this certificate."
7259
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007260requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007261run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007262 "$P_SRV \
7263 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7264 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007265 "$P_CLI" \
7266 1 \
7267 -s "Async sign callback: injected error" \
7268 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02007269 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007270 -s "! mbedtls_ssl_handshake returned"
7271
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007272requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007273run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007274 "$P_SRV \
7275 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7276 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007277 "$P_CLI" \
7278 1 \
7279 -s "Async sign callback: using key slot " \
7280 -S "Async resume" \
7281 -s "Async cancel"
7282
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007283requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007284run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007285 "$P_SRV \
7286 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7287 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007288 "$P_CLI" \
7289 1 \
7290 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007291 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02007292 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007293 -s "! mbedtls_ssl_handshake returned"
7294
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007295requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007296run_test "SSL async private: decrypt, error in start" \
7297 "$P_SRV \
7298 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7299 async_private_error=1" \
7300 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7301 1 \
7302 -s "Async decrypt callback: injected error" \
7303 -S "Async resume" \
7304 -S "Async cancel" \
7305 -s "! mbedtls_ssl_handshake returned"
7306
7307requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7308run_test "SSL async private: decrypt, cancel after start" \
7309 "$P_SRV \
7310 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7311 async_private_error=2" \
7312 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7313 1 \
7314 -s "Async decrypt callback: using key slot " \
7315 -S "Async resume" \
7316 -s "Async cancel"
7317
7318requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7319run_test "SSL async private: decrypt, error in resume" \
7320 "$P_SRV \
7321 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7322 async_private_error=3" \
7323 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7324 1 \
7325 -s "Async decrypt callback: using key slot " \
7326 -s "Async resume callback: decrypt done but injected error" \
7327 -S "Async cancel" \
7328 -s "! mbedtls_ssl_handshake returned"
7329
7330requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007331run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007332 "$P_SRV \
7333 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7334 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007335 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
7336 0 \
7337 -s "Async cancel" \
7338 -s "! mbedtls_ssl_handshake returned" \
7339 -s "Async resume" \
7340 -s "Successful connection"
7341
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007342requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007343run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007344 "$P_SRV \
7345 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7346 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007347 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
7348 0 \
7349 -s "! mbedtls_ssl_handshake returned" \
7350 -s "Async resume" \
7351 -s "Successful connection"
7352
7353# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007354requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007355run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007356 "$P_SRV \
7357 async_operations=s async_private_delay1=1 async_private_error=-2 \
7358 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7359 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007360 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
7361 [ \$? -eq 1 ] &&
7362 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7363 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02007364 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007365 -S "Async resume" \
7366 -s "Async cancel" \
7367 -s "! mbedtls_ssl_handshake returned" \
7368 -s "Async sign callback: no key matches this certificate." \
7369 -s "Successful connection"
7370
7371# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007372requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007373run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007374 "$P_SRV \
7375 async_operations=s async_private_delay1=1 async_private_error=-3 \
7376 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7377 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007378 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
7379 [ \$? -eq 1 ] &&
7380 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7381 0 \
7382 -s "Async resume" \
7383 -s "! mbedtls_ssl_handshake returned" \
7384 -s "Async sign callback: no key matches this certificate." \
7385 -s "Successful connection"
7386
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007387requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007388requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007389run_test "SSL async private: renegotiation: client-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007390 "$P_SRV \
7391 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007392 exchanges=2 renegotiation=1" \
7393 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
7394 0 \
7395 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007396 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007397
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007398requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007399requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007400run_test "SSL async private: renegotiation: server-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007401 "$P_SRV \
7402 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007403 exchanges=2 renegotiation=1 renegotiate=1" \
7404 "$P_CLI exchanges=2 renegotiation=1" \
7405 0 \
7406 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007407 -s "Async resume (slot [0-9]): sign done, status=0"
7408
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007409requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007410requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007411run_test "SSL async private: renegotiation: client-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007412 "$P_SRV \
7413 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7414 exchanges=2 renegotiation=1" \
7415 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
7416 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7417 0 \
7418 -s "Async decrypt callback: using key slot " \
7419 -s "Async resume (slot [0-9]): decrypt done, status=0"
7420
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007421requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007422requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007423run_test "SSL async private: renegotiation: server-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007424 "$P_SRV \
7425 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7426 exchanges=2 renegotiation=1 renegotiate=1" \
7427 "$P_CLI exchanges=2 renegotiation=1 \
7428 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7429 0 \
7430 -s "Async decrypt callback: using key slot " \
7431 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007432
Ron Eldor58093c82018-06-28 13:22:05 +03007433# Tests for ECC extensions (rfc 4492)
7434
Ron Eldor643df7c2018-06-28 16:17:00 +03007435requires_config_enabled MBEDTLS_AES_C
7436requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7437requires_config_enabled MBEDTLS_SHA256_C
7438requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007439run_test "Force a non ECC ciphersuite in the client side" \
7440 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03007441 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03007442 0 \
7443 -C "client hello, adding supported_elliptic_curves extension" \
7444 -C "client hello, adding supported_point_formats extension" \
7445 -S "found supported elliptic curves extension" \
7446 -S "found supported point formats extension"
7447
Ron Eldor643df7c2018-06-28 16:17:00 +03007448requires_config_enabled MBEDTLS_AES_C
7449requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7450requires_config_enabled MBEDTLS_SHA256_C
7451requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007452run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03007453 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03007454 "$P_CLI debug_level=3" \
7455 0 \
7456 -C "found supported_point_formats extension" \
7457 -S "server hello, supported_point_formats extension"
7458
Ron Eldor643df7c2018-06-28 16:17:00 +03007459requires_config_enabled MBEDTLS_AES_C
7460requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7461requires_config_enabled MBEDTLS_SHA256_C
7462requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007463run_test "Force an ECC ciphersuite in the client side" \
7464 "$P_SRV debug_level=3" \
7465 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7466 0 \
7467 -c "client hello, adding supported_elliptic_curves extension" \
7468 -c "client hello, adding supported_point_formats extension" \
7469 -s "found supported elliptic curves extension" \
7470 -s "found supported point formats extension"
7471
Ron Eldor643df7c2018-06-28 16:17:00 +03007472requires_config_enabled MBEDTLS_AES_C
7473requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7474requires_config_enabled MBEDTLS_SHA256_C
7475requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007476run_test "Force an ECC ciphersuite in the server side" \
7477 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7478 "$P_CLI debug_level=3" \
7479 0 \
7480 -c "found supported_point_formats extension" \
7481 -s "server hello, supported_point_formats extension"
7482
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007483# Tests for DTLS HelloVerifyRequest
7484
7485run_test "DTLS cookie: enabled" \
7486 "$P_SRV dtls=1 debug_level=2" \
7487 "$P_CLI dtls=1 debug_level=2" \
7488 0 \
7489 -s "cookie verification failed" \
7490 -s "cookie verification passed" \
7491 -S "cookie verification skipped" \
7492 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007493 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007494 -S "SSL - The requested feature is not available"
7495
7496run_test "DTLS cookie: disabled" \
7497 "$P_SRV dtls=1 debug_level=2 cookies=0" \
7498 "$P_CLI dtls=1 debug_level=2" \
7499 0 \
7500 -S "cookie verification failed" \
7501 -S "cookie verification passed" \
7502 -s "cookie verification skipped" \
7503 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007504 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007505 -S "SSL - The requested feature is not available"
7506
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007507run_test "DTLS cookie: default (failing)" \
7508 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
7509 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
7510 1 \
7511 -s "cookie verification failed" \
7512 -S "cookie verification passed" \
7513 -S "cookie verification skipped" \
7514 -C "received hello verify request" \
7515 -S "hello verification requested" \
7516 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007517
7518requires_ipv6
7519run_test "DTLS cookie: enabled, IPv6" \
7520 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
7521 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
7522 0 \
7523 -s "cookie verification failed" \
7524 -s "cookie verification passed" \
7525 -S "cookie verification skipped" \
7526 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007527 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007528 -S "SSL - The requested feature is not available"
7529
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007530run_test "DTLS cookie: enabled, nbio" \
7531 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7532 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7533 0 \
7534 -s "cookie verification failed" \
7535 -s "cookie verification passed" \
7536 -S "cookie verification skipped" \
7537 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007538 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007539 -S "SSL - The requested feature is not available"
7540
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007541# Tests for client reconnecting from the same port with DTLS
7542
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007543not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007544run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007545 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7546 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007547 0 \
7548 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007549 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007550 -S "Client initiated reconnection from same port"
7551
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007552not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007553run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007554 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7555 "$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 +02007556 0 \
7557 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007558 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007559 -s "Client initiated reconnection from same port"
7560
Paul Bakker362689d2016-05-13 10:33:25 +01007561not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
7562run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007563 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7564 "$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 +02007565 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007566 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007567 -s "Client initiated reconnection from same port"
7568
Paul Bakker362689d2016-05-13 10:33:25 +01007569only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
7570run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7571 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7572 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7573 0 \
7574 -S "The operation timed out" \
7575 -s "Client initiated reconnection from same port"
7576
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007577run_test "DTLS client reconnect from same port: no cookies" \
7578 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007579 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7580 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007581 -s "The operation timed out" \
7582 -S "Client initiated reconnection from same port"
7583
Manuel Pégourié-Gonnardbaad2de2020-03-13 11:11:02 +01007584run_test "DTLS client reconnect from same port: attacker-injected" \
7585 -p "$P_PXY inject_clihlo=1" \
7586 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
7587 "$P_CLI dtls=1 exchanges=2" \
7588 0 \
7589 -s "possible client reconnect from the same port" \
7590 -S "Client initiated reconnection from same port"
7591
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007592# Tests for various cases of client authentication with DTLS
7593# (focused on handshake flows and message parsing)
7594
7595run_test "DTLS client auth: required" \
7596 "$P_SRV dtls=1 auth_mode=required" \
7597 "$P_CLI dtls=1" \
7598 0 \
7599 -s "Verifying peer X.509 certificate... ok"
7600
7601run_test "DTLS client auth: optional, client has no cert" \
7602 "$P_SRV dtls=1 auth_mode=optional" \
7603 "$P_CLI dtls=1 crt_file=none key_file=none" \
7604 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007605 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007606
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007607run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007608 "$P_SRV dtls=1 auth_mode=none" \
7609 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7610 0 \
7611 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007612 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007613
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007614run_test "DTLS wrong PSK: badmac alert" \
7615 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7616 "$P_CLI dtls=1 psk=abc124" \
7617 1 \
7618 -s "SSL - Verification of the message MAC failed" \
7619 -c "SSL - A fatal alert message was received from our peer"
7620
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007621# Tests for receiving fragmented handshake messages with DTLS
7622
7623requires_gnutls
7624run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7625 "$G_SRV -u --mtu 2048 -a" \
7626 "$P_CLI dtls=1 debug_level=2" \
7627 0 \
7628 -C "found fragmented DTLS handshake message" \
7629 -C "error"
7630
7631requires_gnutls
7632run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7633 "$G_SRV -u --mtu 512" \
7634 "$P_CLI dtls=1 debug_level=2" \
7635 0 \
7636 -c "found fragmented DTLS handshake message" \
7637 -C "error"
7638
7639requires_gnutls
7640run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7641 "$G_SRV -u --mtu 128" \
7642 "$P_CLI dtls=1 debug_level=2" \
7643 0 \
7644 -c "found fragmented DTLS handshake message" \
7645 -C "error"
7646
7647requires_gnutls
7648run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7649 "$G_SRV -u --mtu 128" \
7650 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7651 0 \
7652 -c "found fragmented DTLS handshake message" \
7653 -C "error"
7654
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007655requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007656requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007657run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7658 "$G_SRV -u --mtu 256" \
7659 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
7660 0 \
7661 -c "found fragmented DTLS handshake message" \
7662 -c "client hello, adding renegotiation extension" \
7663 -c "found renegotiation extension" \
7664 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007665 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007666 -C "error" \
7667 -s "Extra-header:"
7668
7669requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007670requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007671run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7672 "$G_SRV -u --mtu 256" \
7673 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
7674 0 \
7675 -c "found fragmented DTLS handshake message" \
7676 -c "client hello, adding renegotiation extension" \
7677 -c "found renegotiation extension" \
7678 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007679 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007680 -C "error" \
7681 -s "Extra-header:"
7682
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007683run_test "DTLS reassembly: no fragmentation (openssl server)" \
7684 "$O_SRV -dtls1 -mtu 2048" \
7685 "$P_CLI dtls=1 debug_level=2" \
7686 0 \
7687 -C "found fragmented DTLS handshake message" \
7688 -C "error"
7689
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007690run_test "DTLS reassembly: some fragmentation (openssl server)" \
7691 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007692 "$P_CLI dtls=1 debug_level=2" \
7693 0 \
7694 -c "found fragmented DTLS handshake message" \
7695 -C "error"
7696
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007697run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007698 "$O_SRV -dtls1 -mtu 256" \
7699 "$P_CLI dtls=1 debug_level=2" \
7700 0 \
7701 -c "found fragmented DTLS handshake message" \
7702 -C "error"
7703
7704run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7705 "$O_SRV -dtls1 -mtu 256" \
7706 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7707 0 \
7708 -c "found fragmented DTLS handshake message" \
7709 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007710
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007711# Tests for sending fragmented handshake messages with DTLS
7712#
7713# Use client auth when we need the client to send large messages,
7714# and use large cert chains on both sides too (the long chains we have all use
7715# both RSA and ECDSA, but ideally we should have long chains with either).
7716# Sizes reached (UDP payload):
7717# - 2037B for server certificate
7718# - 1542B for client certificate
7719# - 1013B for newsessionticket
7720# - all others below 512B
7721# All those tests assume MAX_CONTENT_LEN is at least 2048
7722
7723requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7724requires_config_enabled MBEDTLS_RSA_C
7725requires_config_enabled MBEDTLS_ECDSA_C
7726requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7727run_test "DTLS fragmenting: none (for reference)" \
7728 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7729 crt_file=data_files/server7_int-ca.crt \
7730 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007731 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007732 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007733 "$P_CLI dtls=1 debug_level=2 \
7734 crt_file=data_files/server8_int-ca2.crt \
7735 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007736 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007737 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007738 0 \
7739 -S "found fragmented DTLS handshake message" \
7740 -C "found fragmented DTLS handshake message" \
7741 -C "error"
7742
7743requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7744requires_config_enabled MBEDTLS_RSA_C
7745requires_config_enabled MBEDTLS_ECDSA_C
7746requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007747run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007748 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7749 crt_file=data_files/server7_int-ca.crt \
7750 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007751 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007752 max_frag_len=1024" \
7753 "$P_CLI dtls=1 debug_level=2 \
7754 crt_file=data_files/server8_int-ca2.crt \
7755 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007756 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007757 max_frag_len=2048" \
7758 0 \
7759 -S "found fragmented DTLS handshake message" \
7760 -c "found fragmented DTLS handshake message" \
7761 -C "error"
7762
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007763# With the MFL extension, the server has no way of forcing
7764# the client to not exceed a certain MTU; hence, the following
7765# test can't be replicated with an MTU proxy such as the one
7766# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007767requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7768requires_config_enabled MBEDTLS_RSA_C
7769requires_config_enabled MBEDTLS_ECDSA_C
7770requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007771run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007772 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7773 crt_file=data_files/server7_int-ca.crt \
7774 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007775 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007776 max_frag_len=512" \
7777 "$P_CLI dtls=1 debug_level=2 \
7778 crt_file=data_files/server8_int-ca2.crt \
7779 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007780 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007781 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007782 0 \
7783 -S "found fragmented DTLS handshake message" \
7784 -c "found fragmented DTLS handshake message" \
7785 -C "error"
7786
7787requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7788requires_config_enabled MBEDTLS_RSA_C
7789requires_config_enabled MBEDTLS_ECDSA_C
7790requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007791run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007792 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7793 crt_file=data_files/server7_int-ca.crt \
7794 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007795 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007796 max_frag_len=2048" \
7797 "$P_CLI dtls=1 debug_level=2 \
7798 crt_file=data_files/server8_int-ca2.crt \
7799 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007800 hs_timeout=2500-60000 \
7801 max_frag_len=1024" \
7802 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007803 -S "found fragmented DTLS handshake message" \
7804 -c "found fragmented DTLS handshake message" \
7805 -C "error"
7806
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007807# While not required by the standard defining the MFL extension
7808# (according to which it only applies to records, not to datagrams),
7809# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7810# as otherwise there wouldn't be any means to communicate MTU restrictions
7811# to the peer.
7812# The next test checks that no datagrams significantly larger than the
7813# negotiated MFL are sent.
7814requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7815requires_config_enabled MBEDTLS_RSA_C
7816requires_config_enabled MBEDTLS_ECDSA_C
7817requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7818run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007819 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007820 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7821 crt_file=data_files/server7_int-ca.crt \
7822 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007823 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007824 max_frag_len=2048" \
7825 "$P_CLI dtls=1 debug_level=2 \
7826 crt_file=data_files/server8_int-ca2.crt \
7827 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007828 hs_timeout=2500-60000 \
7829 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007830 0 \
7831 -S "found fragmented DTLS handshake message" \
7832 -c "found fragmented DTLS handshake message" \
7833 -C "error"
7834
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007835requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7836requires_config_enabled MBEDTLS_RSA_C
7837requires_config_enabled MBEDTLS_ECDSA_C
7838requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007839run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007840 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7841 crt_file=data_files/server7_int-ca.crt \
7842 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007843 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007844 max_frag_len=2048" \
7845 "$P_CLI dtls=1 debug_level=2 \
7846 crt_file=data_files/server8_int-ca2.crt \
7847 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007848 hs_timeout=2500-60000 \
7849 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007850 0 \
7851 -s "found fragmented DTLS handshake message" \
7852 -c "found fragmented DTLS handshake message" \
7853 -C "error"
7854
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007855# While not required by the standard defining the MFL extension
7856# (according to which it only applies to records, not to datagrams),
7857# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7858# as otherwise there wouldn't be any means to communicate MTU restrictions
7859# to the peer.
7860# The next test checks that no datagrams significantly larger than the
7861# negotiated MFL are sent.
7862requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7863requires_config_enabled MBEDTLS_RSA_C
7864requires_config_enabled MBEDTLS_ECDSA_C
7865requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7866run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007867 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007868 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7869 crt_file=data_files/server7_int-ca.crt \
7870 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007871 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007872 max_frag_len=2048" \
7873 "$P_CLI dtls=1 debug_level=2 \
7874 crt_file=data_files/server8_int-ca2.crt \
7875 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007876 hs_timeout=2500-60000 \
7877 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007878 0 \
7879 -s "found fragmented DTLS handshake message" \
7880 -c "found fragmented DTLS handshake message" \
7881 -C "error"
7882
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007883requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7884requires_config_enabled MBEDTLS_RSA_C
7885requires_config_enabled MBEDTLS_ECDSA_C
7886run_test "DTLS fragmenting: none (for reference) (MTU)" \
7887 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7888 crt_file=data_files/server7_int-ca.crt \
7889 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007890 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007891 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007892 "$P_CLI dtls=1 debug_level=2 \
7893 crt_file=data_files/server8_int-ca2.crt \
7894 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007895 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007896 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007897 0 \
7898 -S "found fragmented DTLS handshake message" \
7899 -C "found fragmented DTLS handshake message" \
7900 -C "error"
7901
7902requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7903requires_config_enabled MBEDTLS_RSA_C
7904requires_config_enabled MBEDTLS_ECDSA_C
7905run_test "DTLS fragmenting: client (MTU)" \
7906 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7907 crt_file=data_files/server7_int-ca.crt \
7908 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007909 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007910 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007911 "$P_CLI dtls=1 debug_level=2 \
7912 crt_file=data_files/server8_int-ca2.crt \
7913 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007914 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007915 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007916 0 \
7917 -s "found fragmented DTLS handshake message" \
7918 -C "found fragmented DTLS handshake message" \
7919 -C "error"
7920
7921requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7922requires_config_enabled MBEDTLS_RSA_C
7923requires_config_enabled MBEDTLS_ECDSA_C
7924run_test "DTLS fragmenting: server (MTU)" \
7925 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7926 crt_file=data_files/server7_int-ca.crt \
7927 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007928 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007929 mtu=512" \
7930 "$P_CLI dtls=1 debug_level=2 \
7931 crt_file=data_files/server8_int-ca2.crt \
7932 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007933 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007934 mtu=2048" \
7935 0 \
7936 -S "found fragmented DTLS handshake message" \
7937 -c "found fragmented DTLS handshake message" \
7938 -C "error"
7939
7940requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7941requires_config_enabled MBEDTLS_RSA_C
7942requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007943run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007944 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007945 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7946 crt_file=data_files/server7_int-ca.crt \
7947 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007948 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007949 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007950 "$P_CLI dtls=1 debug_level=2 \
7951 crt_file=data_files/server8_int-ca2.crt \
7952 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007953 hs_timeout=2500-60000 \
7954 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007955 0 \
7956 -s "found fragmented DTLS handshake message" \
7957 -c "found fragmented DTLS handshake message" \
7958 -C "error"
7959
Andrzej Kurek77826052018-10-11 07:34:08 -04007960# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007961requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7962requires_config_enabled MBEDTLS_RSA_C
7963requires_config_enabled MBEDTLS_ECDSA_C
7964requires_config_enabled MBEDTLS_SHA256_C
7965requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7966requires_config_enabled MBEDTLS_AES_C
7967requires_config_enabled MBEDTLS_GCM_C
7968run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007969 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007970 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7971 crt_file=data_files/server7_int-ca.crt \
7972 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007973 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007974 mtu=512" \
7975 "$P_CLI dtls=1 debug_level=2 \
7976 crt_file=data_files/server8_int-ca2.crt \
7977 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007978 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7979 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007980 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007981 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007982 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007983 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007984 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007985
Andrzej Kurek7311c782018-10-11 06:49:41 -04007986# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007987# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007988# The ratio of max/min timeout should ideally equal 4 to accept two
7989# retransmissions, but in some cases (like both the server and client using
7990# fragmentation and auto-reduction) an extra retransmission might occur,
7991# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007992not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007993requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7994requires_config_enabled MBEDTLS_RSA_C
7995requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007996requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7997requires_config_enabled MBEDTLS_AES_C
7998requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02007999run_test "DTLS fragmenting: proxy MTU: auto-reduction (not valgrind)" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008000 -p "$P_PXY mtu=508" \
8001 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8002 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008003 key_file=data_files/server7.key \
8004 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008005 "$P_CLI dtls=1 debug_level=2 \
8006 crt_file=data_files/server8_int-ca2.crt \
8007 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008008 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8009 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008010 0 \
8011 -s "found fragmented DTLS handshake message" \
8012 -c "found fragmented DTLS handshake message" \
8013 -C "error"
8014
Andrzej Kurek77826052018-10-11 07:34:08 -04008015# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01008016only_with_valgrind
8017requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8018requires_config_enabled MBEDTLS_RSA_C
8019requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008020requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8021requires_config_enabled MBEDTLS_AES_C
8022requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02008023run_test "DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)" \
Hanno Becker108992e2018-08-29 17:04:18 +01008024 -p "$P_PXY mtu=508" \
8025 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8026 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008027 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01008028 hs_timeout=250-10000" \
8029 "$P_CLI dtls=1 debug_level=2 \
8030 crt_file=data_files/server8_int-ca2.crt \
8031 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008032 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01008033 hs_timeout=250-10000" \
8034 0 \
8035 -s "found fragmented DTLS handshake message" \
8036 -c "found fragmented DTLS handshake message" \
8037 -C "error"
8038
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008039# 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 +02008040# OTOH the client might resend if the server is to slow to reset after sending
8041# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008042not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008043requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8044requires_config_enabled MBEDTLS_RSA_C
8045requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008046run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008047 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008048 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8049 crt_file=data_files/server7_int-ca.crt \
8050 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008051 hs_timeout=10000-60000 \
8052 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008053 "$P_CLI dtls=1 debug_level=2 \
8054 crt_file=data_files/server8_int-ca2.crt \
8055 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008056 hs_timeout=10000-60000 \
8057 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008058 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008059 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008060 -s "found fragmented DTLS handshake message" \
8061 -c "found fragmented DTLS handshake message" \
8062 -C "error"
8063
Andrzej Kurek77826052018-10-11 07:34:08 -04008064# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008065# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
8066# OTOH the client might resend if the server is to slow to reset after sending
8067# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008068not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008069requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8070requires_config_enabled MBEDTLS_RSA_C
8071requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008072requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8073requires_config_enabled MBEDTLS_AES_C
8074requires_config_enabled MBEDTLS_GCM_C
8075run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008076 -p "$P_PXY mtu=512" \
8077 "$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 Kurek7311c782018-10-11 06:49:41 -04008080 hs_timeout=10000-60000 \
8081 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +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 Kurek7311c782018-10-11 06:49:41 -04008085 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8086 hs_timeout=10000-60000 \
8087 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008088 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008089 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008090 -s "found fragmented DTLS handshake message" \
8091 -c "found fragmented DTLS handshake message" \
8092 -C "error"
8093
Andrzej Kurek7311c782018-10-11 06:49:41 -04008094not_with_valgrind # spurious autoreduction due to timeout
8095requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8096requires_config_enabled MBEDTLS_RSA_C
8097requires_config_enabled MBEDTLS_ECDSA_C
8098run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008099 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008100 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8101 crt_file=data_files/server7_int-ca.crt \
8102 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008103 hs_timeout=10000-60000 \
8104 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008105 "$P_CLI dtls=1 debug_level=2 \
8106 crt_file=data_files/server8_int-ca2.crt \
8107 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008108 hs_timeout=10000-60000 \
8109 mtu=1024 nbio=2" \
8110 0 \
8111 -S "autoreduction" \
8112 -s "found fragmented DTLS handshake message" \
8113 -c "found fragmented DTLS handshake message" \
8114 -C "error"
8115
Andrzej Kurek77826052018-10-11 07:34:08 -04008116# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008117not_with_valgrind # spurious autoreduction due to timeout
8118requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8119requires_config_enabled MBEDTLS_RSA_C
8120requires_config_enabled MBEDTLS_ECDSA_C
8121requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8122requires_config_enabled MBEDTLS_AES_C
8123requires_config_enabled MBEDTLS_GCM_C
8124run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
8125 -p "$P_PXY mtu=512" \
8126 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8127 crt_file=data_files/server7_int-ca.crt \
8128 key_file=data_files/server7.key \
8129 hs_timeout=10000-60000 \
8130 mtu=512 nbio=2" \
8131 "$P_CLI dtls=1 debug_level=2 \
8132 crt_file=data_files/server8_int-ca2.crt \
8133 key_file=data_files/server8.key \
8134 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8135 hs_timeout=10000-60000 \
8136 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008137 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008138 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008139 -s "found fragmented DTLS handshake message" \
8140 -c "found fragmented DTLS handshake message" \
8141 -C "error"
8142
Andrzej Kurek77826052018-10-11 07:34:08 -04008143# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01008144# This ensures things still work after session_reset().
8145# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008146# Since we don't support reading fragmented ClientHello yet,
8147# up the MTU to 1450 (larger than ClientHello with session ticket,
8148# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008149# An autoreduction on the client-side might happen if the server is
8150# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02008151# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008152# resumed listening, which would result in a spurious autoreduction.
8153not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008154requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8155requires_config_enabled MBEDTLS_RSA_C
8156requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008157requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8158requires_config_enabled MBEDTLS_AES_C
8159requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008160run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
8161 -p "$P_PXY mtu=1450" \
8162 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8163 crt_file=data_files/server7_int-ca.crt \
8164 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008165 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008166 mtu=1450" \
8167 "$P_CLI dtls=1 debug_level=2 \
8168 crt_file=data_files/server8_int-ca2.crt \
8169 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008170 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008171 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01008172 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008173 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008174 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008175 -s "found fragmented DTLS handshake message" \
8176 -c "found fragmented DTLS handshake message" \
8177 -C "error"
8178
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008179# An autoreduction on the client-side might happen if the server is
8180# slow to reset, therefore omitting '-C "autoreduction"' below.
8181not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008182requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8183requires_config_enabled MBEDTLS_RSA_C
8184requires_config_enabled MBEDTLS_ECDSA_C
8185requires_config_enabled MBEDTLS_SHA256_C
8186requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8187requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8188requires_config_enabled MBEDTLS_CHACHAPOLY_C
8189run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
8190 -p "$P_PXY mtu=512" \
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 \
8194 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008195 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008196 mtu=512" \
8197 "$P_CLI dtls=1 debug_level=2 \
8198 crt_file=data_files/server8_int-ca2.crt \
8199 key_file=data_files/server8.key \
8200 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008201 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008202 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008203 mtu=512" \
8204 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008205 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008206 -s "found fragmented DTLS handshake message" \
8207 -c "found fragmented DTLS handshake message" \
8208 -C "error"
8209
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008210# An autoreduction on the client-side might happen if the server is
8211# slow to reset, therefore omitting '-C "autoreduction"' below.
8212not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008213requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8214requires_config_enabled MBEDTLS_RSA_C
8215requires_config_enabled MBEDTLS_ECDSA_C
8216requires_config_enabled MBEDTLS_SHA256_C
8217requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8218requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8219requires_config_enabled MBEDTLS_AES_C
8220requires_config_enabled MBEDTLS_GCM_C
8221run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
8222 -p "$P_PXY mtu=512" \
8223 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8224 crt_file=data_files/server7_int-ca.crt \
8225 key_file=data_files/server7.key \
8226 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008227 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008228 mtu=512" \
8229 "$P_CLI dtls=1 debug_level=2 \
8230 crt_file=data_files/server8_int-ca2.crt \
8231 key_file=data_files/server8.key \
8232 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008233 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008234 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008235 mtu=512" \
8236 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008237 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008238 -s "found fragmented DTLS handshake message" \
8239 -c "found fragmented DTLS handshake message" \
8240 -C "error"
8241
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008242# An autoreduction on the client-side might happen if the server is
8243# slow to reset, therefore omitting '-C "autoreduction"' below.
8244not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008245requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8246requires_config_enabled MBEDTLS_RSA_C
8247requires_config_enabled MBEDTLS_ECDSA_C
8248requires_config_enabled MBEDTLS_SHA256_C
8249requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8250requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8251requires_config_enabled MBEDTLS_AES_C
8252requires_config_enabled MBEDTLS_CCM_C
8253run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008254 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008255 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8256 crt_file=data_files/server7_int-ca.crt \
8257 key_file=data_files/server7.key \
8258 exchanges=2 renegotiation=1 \
8259 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008260 hs_timeout=10000-60000 \
8261 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008262 "$P_CLI dtls=1 debug_level=2 \
8263 crt_file=data_files/server8_int-ca2.crt \
8264 key_file=data_files/server8.key \
8265 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008266 hs_timeout=10000-60000 \
8267 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008268 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008269 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008270 -s "found fragmented DTLS handshake message" \
8271 -c "found fragmented DTLS handshake message" \
8272 -C "error"
8273
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008274# An autoreduction on the client-side might happen if the server is
8275# slow to reset, therefore omitting '-C "autoreduction"' below.
8276not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008277requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8278requires_config_enabled MBEDTLS_RSA_C
8279requires_config_enabled MBEDTLS_ECDSA_C
8280requires_config_enabled MBEDTLS_SHA256_C
8281requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8282requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8283requires_config_enabled MBEDTLS_AES_C
8284requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
8285requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
8286run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008287 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008288 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8289 crt_file=data_files/server7_int-ca.crt \
8290 key_file=data_files/server7.key \
8291 exchanges=2 renegotiation=1 \
8292 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008293 hs_timeout=10000-60000 \
8294 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008295 "$P_CLI dtls=1 debug_level=2 \
8296 crt_file=data_files/server8_int-ca2.crt \
8297 key_file=data_files/server8.key \
8298 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008299 hs_timeout=10000-60000 \
8300 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008301 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008302 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008303 -s "found fragmented DTLS handshake message" \
8304 -c "found fragmented DTLS handshake message" \
8305 -C "error"
8306
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008307# An autoreduction on the client-side might happen if the server is
8308# slow to reset, therefore omitting '-C "autoreduction"' below.
8309not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008310requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8311requires_config_enabled MBEDTLS_RSA_C
8312requires_config_enabled MBEDTLS_ECDSA_C
8313requires_config_enabled MBEDTLS_SHA256_C
8314requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8315requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8316requires_config_enabled MBEDTLS_AES_C
8317requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
8318run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008319 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008320 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8321 crt_file=data_files/server7_int-ca.crt \
8322 key_file=data_files/server7.key \
8323 exchanges=2 renegotiation=1 \
8324 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008325 hs_timeout=10000-60000 \
8326 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008327 "$P_CLI dtls=1 debug_level=2 \
8328 crt_file=data_files/server8_int-ca2.crt \
8329 key_file=data_files/server8.key \
8330 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008331 hs_timeout=10000-60000 \
8332 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008333 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008334 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008335 -s "found fragmented DTLS handshake message" \
8336 -c "found fragmented DTLS handshake message" \
8337 -C "error"
8338
Andrzej Kurek77826052018-10-11 07:34:08 -04008339# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008340requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8341requires_config_enabled MBEDTLS_RSA_C
8342requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008343requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8344requires_config_enabled MBEDTLS_AES_C
8345requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008346client_needs_more_time 2
8347run_test "DTLS fragmenting: proxy MTU + 3d" \
8348 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008349 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008350 crt_file=data_files/server7_int-ca.crt \
8351 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008352 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008353 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008354 crt_file=data_files/server8_int-ca2.crt \
8355 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008356 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008357 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008358 0 \
8359 -s "found fragmented DTLS handshake message" \
8360 -c "found fragmented DTLS handshake message" \
8361 -C "error"
8362
Andrzej Kurek77826052018-10-11 07:34:08 -04008363# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008364requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8365requires_config_enabled MBEDTLS_RSA_C
8366requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008367requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8368requires_config_enabled MBEDTLS_AES_C
8369requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008370client_needs_more_time 2
8371run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
8372 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
8373 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8374 crt_file=data_files/server7_int-ca.crt \
8375 key_file=data_files/server7.key \
8376 hs_timeout=250-10000 mtu=512 nbio=2" \
8377 "$P_CLI dtls=1 debug_level=2 \
8378 crt_file=data_files/server8_int-ca2.crt \
8379 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008380 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008381 hs_timeout=250-10000 mtu=512 nbio=2" \
8382 0 \
8383 -s "found fragmented DTLS handshake message" \
8384 -c "found fragmented DTLS handshake message" \
8385 -C "error"
8386
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008387# interop tests for DTLS fragmentating with reliable connection
8388#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008389# here and below we just want to test that the we fragment in a way that
8390# pleases other implementations, so we don't need the peer to fragment
8391requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8392requires_config_enabled MBEDTLS_RSA_C
8393requires_config_enabled MBEDTLS_ECDSA_C
8394requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008395requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008396run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
8397 "$G_SRV -u" \
8398 "$P_CLI dtls=1 debug_level=2 \
8399 crt_file=data_files/server8_int-ca2.crt \
8400 key_file=data_files/server8.key \
8401 mtu=512 force_version=dtls1_2" \
8402 0 \
8403 -c "fragmenting handshake message" \
8404 -C "error"
8405
8406requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8407requires_config_enabled MBEDTLS_RSA_C
8408requires_config_enabled MBEDTLS_ECDSA_C
8409requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008410requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008411run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
8412 "$G_SRV -u" \
8413 "$P_CLI dtls=1 debug_level=2 \
8414 crt_file=data_files/server8_int-ca2.crt \
8415 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008416 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008417 0 \
8418 -c "fragmenting handshake message" \
8419 -C "error"
8420
Hanno Beckerb9a00862018-08-28 10:20:22 +01008421# We use --insecure for the GnuTLS client because it expects
8422# the hostname / IP it connects to to be the name used in the
8423# certificate obtained from the server. Here, however, it
8424# connects to 127.0.0.1 while our test certificates use 'localhost'
8425# as the server name in the certificate. This will make the
8426# certifiate validation fail, but passing --insecure makes
8427# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008428requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8429requires_config_enabled MBEDTLS_RSA_C
8430requires_config_enabled MBEDTLS_ECDSA_C
8431requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008432requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008433requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008434run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008435 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008436 crt_file=data_files/server7_int-ca.crt \
8437 key_file=data_files/server7.key \
8438 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008439 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008440 0 \
8441 -s "fragmenting handshake message"
8442
Hanno Beckerb9a00862018-08-28 10:20:22 +01008443# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008444requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8445requires_config_enabled MBEDTLS_RSA_C
8446requires_config_enabled MBEDTLS_ECDSA_C
8447requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008448requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008449requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008450run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008451 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008452 crt_file=data_files/server7_int-ca.crt \
8453 key_file=data_files/server7.key \
8454 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008455 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008456 0 \
8457 -s "fragmenting handshake message"
8458
8459requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8460requires_config_enabled MBEDTLS_RSA_C
8461requires_config_enabled MBEDTLS_ECDSA_C
8462requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8463run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
8464 "$O_SRV -dtls1_2 -verify 10" \
8465 "$P_CLI dtls=1 debug_level=2 \
8466 crt_file=data_files/server8_int-ca2.crt \
8467 key_file=data_files/server8.key \
8468 mtu=512 force_version=dtls1_2" \
8469 0 \
8470 -c "fragmenting handshake message" \
8471 -C "error"
8472
8473requires_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
8477run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
8478 "$O_SRV -dtls1 -verify 10" \
8479 "$P_CLI dtls=1 debug_level=2 \
8480 crt_file=data_files/server8_int-ca2.crt \
8481 key_file=data_files/server8.key \
8482 mtu=512 force_version=dtls1" \
8483 0 \
8484 -c "fragmenting handshake message" \
8485 -C "error"
8486
8487requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8488requires_config_enabled MBEDTLS_RSA_C
8489requires_config_enabled MBEDTLS_ECDSA_C
8490requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8491run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
8492 "$P_SRV dtls=1 debug_level=2 \
8493 crt_file=data_files/server7_int-ca.crt \
8494 key_file=data_files/server7.key \
8495 mtu=512 force_version=dtls1_2" \
8496 "$O_CLI -dtls1_2" \
8497 0 \
8498 -s "fragmenting handshake message"
8499
8500requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8501requires_config_enabled MBEDTLS_RSA_C
8502requires_config_enabled MBEDTLS_ECDSA_C
8503requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8504run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8505 "$P_SRV dtls=1 debug_level=2 \
8506 crt_file=data_files/server7_int-ca.crt \
8507 key_file=data_files/server7.key \
8508 mtu=512 force_version=dtls1" \
8509 "$O_CLI -dtls1" \
8510 0 \
8511 -s "fragmenting handshake message"
8512
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008513# interop tests for DTLS fragmentating with unreliable connection
8514#
8515# again we just want to test that the we fragment in a way that
8516# pleases other implementations, so we don't need the peer to fragment
8517requires_gnutls_next
8518requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8519requires_config_enabled MBEDTLS_RSA_C
8520requires_config_enabled MBEDTLS_ECDSA_C
8521requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008522client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008523run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8524 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8525 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008526 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008527 crt_file=data_files/server8_int-ca2.crt \
8528 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008529 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008530 0 \
8531 -c "fragmenting handshake message" \
8532 -C "error"
8533
8534requires_gnutls_next
8535requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8536requires_config_enabled MBEDTLS_RSA_C
8537requires_config_enabled MBEDTLS_ECDSA_C
8538requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008539client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008540run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8541 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8542 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008543 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008544 crt_file=data_files/server8_int-ca2.crt \
8545 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008546 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008547 0 \
8548 -c "fragmenting handshake message" \
8549 -C "error"
8550
k-stachowiak17a38d32019-02-18 15:29:56 +01008551requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008552requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8553requires_config_enabled MBEDTLS_RSA_C
8554requires_config_enabled MBEDTLS_ECDSA_C
8555requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8556client_needs_more_time 4
8557run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8558 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8559 "$P_SRV dtls=1 debug_level=2 \
8560 crt_file=data_files/server7_int-ca.crt \
8561 key_file=data_files/server7.key \
8562 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008563 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008564 0 \
8565 -s "fragmenting handshake message"
8566
k-stachowiak17a38d32019-02-18 15:29:56 +01008567requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008568requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8569requires_config_enabled MBEDTLS_RSA_C
8570requires_config_enabled MBEDTLS_ECDSA_C
8571requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8572client_needs_more_time 4
8573run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8574 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8575 "$P_SRV dtls=1 debug_level=2 \
8576 crt_file=data_files/server7_int-ca.crt \
8577 key_file=data_files/server7.key \
8578 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008579 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008580 0 \
8581 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008582
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008583## Interop test with OpenSSL might trigger a bug in recent versions (including
8584## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008585## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008586## They should be re-enabled once a fixed version of OpenSSL is available
8587## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008588skip_next_test
8589requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8590requires_config_enabled MBEDTLS_RSA_C
8591requires_config_enabled MBEDTLS_ECDSA_C
8592requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8593client_needs_more_time 4
8594run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8595 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8596 "$O_SRV -dtls1_2 -verify 10" \
8597 "$P_CLI dtls=1 debug_level=2 \
8598 crt_file=data_files/server8_int-ca2.crt \
8599 key_file=data_files/server8.key \
8600 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8601 0 \
8602 -c "fragmenting handshake message" \
8603 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008604
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008605skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008606requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8607requires_config_enabled MBEDTLS_RSA_C
8608requires_config_enabled MBEDTLS_ECDSA_C
8609requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008610client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008611run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8612 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008613 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008614 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008615 crt_file=data_files/server8_int-ca2.crt \
8616 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008617 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008618 0 \
8619 -c "fragmenting handshake message" \
8620 -C "error"
8621
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008622skip_next_test
8623requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8624requires_config_enabled MBEDTLS_RSA_C
8625requires_config_enabled MBEDTLS_ECDSA_C
8626requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8627client_needs_more_time 4
8628run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8629 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8630 "$P_SRV dtls=1 debug_level=2 \
8631 crt_file=data_files/server7_int-ca.crt \
8632 key_file=data_files/server7.key \
8633 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8634 "$O_CLI -dtls1_2" \
8635 0 \
8636 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008637
8638# -nbio is added to prevent s_client from blocking in case of duplicated
8639# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008640skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008641requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8642requires_config_enabled MBEDTLS_RSA_C
8643requires_config_enabled MBEDTLS_ECDSA_C
8644requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008645client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008646run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8647 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008648 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008649 crt_file=data_files/server7_int-ca.crt \
8650 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008651 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008652 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008653 0 \
8654 -s "fragmenting handshake message"
8655
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008656# Tests for specific things with "unreliable" UDP connection
8657
8658not_with_valgrind # spurious resend due to timeout
8659run_test "DTLS proxy: reference" \
8660 -p "$P_PXY" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008661 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
8662 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008663 0 \
8664 -C "replayed record" \
8665 -S "replayed record" \
Hanno Beckerb2a86c32019-07-19 15:43:09 +01008666 -C "Buffer record from epoch" \
8667 -S "Buffer record from epoch" \
8668 -C "ssl_buffer_message" \
8669 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008670 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008671 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008672 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008673 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008674 -c "HTTP/1.0 200 OK"
8675
8676not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008677run_test "DTLS proxy: duplicate every packet" \
8678 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008679 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
8680 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008681 0 \
8682 -c "replayed record" \
8683 -s "replayed record" \
8684 -c "record from another epoch" \
8685 -s "record from another epoch" \
8686 -S "resend" \
8687 -s "Extra-header:" \
8688 -c "HTTP/1.0 200 OK"
8689
8690run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8691 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008692 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8693 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008694 0 \
8695 -c "replayed record" \
8696 -S "replayed record" \
8697 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008698 -s "record from another epoch" \
8699 -c "resend" \
8700 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008701 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008702 -c "HTTP/1.0 200 OK"
8703
8704run_test "DTLS proxy: multiple records in same datagram" \
8705 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008706 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8707 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008708 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008709 -c "next record in same datagram" \
8710 -s "next record in same datagram"
8711
8712run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8713 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008714 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8715 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008716 0 \
8717 -c "next record in same datagram" \
8718 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008719
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008720run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8721 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008722 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8723 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008724 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008725 -c "discarding invalid record (mac)" \
8726 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008727 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008728 -c "HTTP/1.0 200 OK" \
8729 -S "too many records with bad MAC" \
8730 -S "Verification of the message MAC failed"
8731
8732run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8733 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008734 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8735 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008736 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008737 -C "discarding invalid record (mac)" \
8738 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008739 -S "Extra-header:" \
8740 -C "HTTP/1.0 200 OK" \
8741 -s "too many records with bad MAC" \
8742 -s "Verification of the message MAC failed"
8743
8744run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8745 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008746 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8747 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008748 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008749 -c "discarding invalid record (mac)" \
8750 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008751 -s "Extra-header:" \
8752 -c "HTTP/1.0 200 OK" \
8753 -S "too many records with bad MAC" \
8754 -S "Verification of the message MAC failed"
8755
8756run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8757 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008758 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8759 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008760 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008761 -c "discarding invalid record (mac)" \
8762 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008763 -s "Extra-header:" \
8764 -c "HTTP/1.0 200 OK" \
8765 -s "too many records with bad MAC" \
8766 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008767
8768run_test "DTLS proxy: delay ChangeCipherSpec" \
8769 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008770 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8771 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008772 0 \
8773 -c "record from another epoch" \
8774 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008775 -s "Extra-header:" \
8776 -c "HTTP/1.0 200 OK"
8777
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008778# Tests for reordering support with DTLS
8779
Hanno Becker56cdfd12018-08-17 13:42:15 +01008780run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8781 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008782 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8783 hs_timeout=2500-60000" \
8784 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8785 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008786 0 \
8787 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008788 -c "Next handshake message has been buffered - load"\
8789 -S "Buffering HS message" \
8790 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008791 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008792 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008793 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008794 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008795
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008796run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8797 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008798 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8799 hs_timeout=2500-60000" \
8800 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8801 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008802 0 \
8803 -c "Buffering HS message" \
8804 -c "found fragmented DTLS handshake message"\
8805 -c "Next handshake message 1 not or only partially bufffered" \
8806 -c "Next handshake message has been buffered - load"\
8807 -S "Buffering HS message" \
8808 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008809 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008810 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008811 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008812 -S "Remember CCS message"
8813
Hanno Beckera1adcca2018-08-24 14:41:07 +01008814# The client buffers the ServerKeyExchange before receiving the fragmented
8815# Certificate message; at the time of writing, together these are aroudn 1200b
8816# in size, so that the bound below ensures that the certificate can be reassembled
8817# while keeping the ServerKeyExchange.
8818requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8819run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008820 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008821 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8822 hs_timeout=2500-60000" \
8823 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8824 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008825 0 \
8826 -c "Buffering HS message" \
8827 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008828 -C "attempt to make space by freeing buffered messages" \
8829 -S "Buffering HS message" \
8830 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008831 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008832 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008833 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008834 -S "Remember CCS message"
8835
8836# The size constraints ensure that the delayed certificate message can't
8837# be reassembled while keeping the ServerKeyExchange message, but it can
8838# when dropping it first.
8839requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8840requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8841run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8842 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008843 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8844 hs_timeout=2500-60000" \
8845 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8846 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008847 0 \
8848 -c "Buffering HS message" \
8849 -c "attempt to make space by freeing buffered future messages" \
8850 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008851 -S "Buffering HS message" \
8852 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008853 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008854 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008855 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008856 -S "Remember CCS message"
8857
Hanno Becker56cdfd12018-08-17 13:42:15 +01008858run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8859 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008860 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8861 hs_timeout=2500-60000" \
8862 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8863 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008864 0 \
8865 -C "Buffering HS message" \
8866 -C "Next handshake message has been buffered - load"\
8867 -s "Buffering HS message" \
8868 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008869 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008870 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008871 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008872 -S "Remember CCS message"
8873
8874run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8875 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008876 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8877 hs_timeout=2500-60000" \
8878 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8879 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008880 0 \
8881 -C "Buffering HS message" \
8882 -C "Next handshake message has been buffered - load"\
8883 -S "Buffering HS message" \
8884 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008885 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008886 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008887 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008888 -S "Remember CCS message"
8889
8890run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8891 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008892 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8893 hs_timeout=2500-60000" \
8894 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8895 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008896 0 \
8897 -C "Buffering HS message" \
8898 -C "Next handshake message has been buffered - load"\
8899 -S "Buffering HS message" \
8900 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008901 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008902 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008903 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008904 -s "Remember CCS message"
8905
Hanno Beckera1adcca2018-08-24 14:41:07 +01008906run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008907 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008908 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8909 hs_timeout=2500-60000" \
8910 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8911 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008912 0 \
8913 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008914 -s "Found buffered record from current epoch - load" \
8915 -c "Buffer record from epoch 1" \
8916 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008917
Hanno Beckera1adcca2018-08-24 14:41:07 +01008918# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8919# from the server are delayed, so that the encrypted Finished message
8920# is received and buffered. When the fragmented NewSessionTicket comes
8921# in afterwards, the encrypted Finished message must be freed in order
8922# to make space for the NewSessionTicket to be reassembled.
8923# This works only in very particular circumstances:
8924# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8925# of the NewSessionTicket, but small enough to also allow buffering of
8926# the encrypted Finished message.
8927# - The MTU setting on the server must be so small that the NewSessionTicket
8928# needs to be fragmented.
8929# - All messages sent by the server must be small enough to be either sent
8930# without fragmentation or be reassembled within the bounds of
8931# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8932# handshake, omitting CRTs.
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02008933requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8934requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008935run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8936 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02008937 "$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 +01008938 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8939 0 \
8940 -s "Buffer record from epoch 1" \
8941 -s "Found buffered record from current epoch - load" \
8942 -c "Buffer record from epoch 1" \
8943 -C "Found buffered record from current epoch - load" \
8944 -c "Enough space available after freeing future epoch record"
8945
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008946# Tests for "randomly unreliable connection": try a variety of flows and peers
8947
8948client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008949run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8950 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008951 "$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 +02008952 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008953 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008954 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8955 0 \
8956 -s "Extra-header:" \
8957 -c "HTTP/1.0 200 OK"
8958
Janos Follath74537a62016-09-02 13:45:28 +01008959client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008960run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8961 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008962 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8963 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008964 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8965 0 \
8966 -s "Extra-header:" \
8967 -c "HTTP/1.0 200 OK"
8968
Janos Follath74537a62016-09-02 13:45:28 +01008969client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008970run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8971 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008972 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8973 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008974 0 \
8975 -s "Extra-header:" \
8976 -c "HTTP/1.0 200 OK"
8977
Janos Follath74537a62016-09-02 13:45:28 +01008978client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008979run_test "DTLS proxy: 3d, FS, client auth" \
8980 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008981 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8982 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008983 0 \
8984 -s "Extra-header:" \
8985 -c "HTTP/1.0 200 OK"
8986
Janos Follath74537a62016-09-02 13:45:28 +01008987client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008988run_test "DTLS proxy: 3d, FS, ticket" \
8989 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008990 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8991 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008992 0 \
8993 -s "Extra-header:" \
8994 -c "HTTP/1.0 200 OK"
8995
Janos Follath74537a62016-09-02 13:45:28 +01008996client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008997run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8998 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008999 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
9000 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02009001 0 \
9002 -s "Extra-header:" \
9003 -c "HTTP/1.0 200 OK"
9004
Janos Follath74537a62016-09-02 13:45:28 +01009005client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009006run_test "DTLS proxy: 3d, max handshake, nbio" \
9007 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009008 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009009 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009010 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009011 0 \
9012 -s "Extra-header:" \
9013 -c "HTTP/1.0 200 OK"
9014
Janos Follath74537a62016-09-02 13:45:28 +01009015client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02009016run_test "DTLS proxy: 3d, min handshake, resumption" \
9017 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009018 "$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 +02009019 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009020 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01009021 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02009022 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9023 0 \
9024 -s "a session has been resumed" \
9025 -c "a session has been resumed" \
9026 -s "Extra-header:" \
9027 -c "HTTP/1.0 200 OK"
9028
Janos Follath74537a62016-09-02 13:45:28 +01009029client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02009030run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
9031 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009032 "$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 +02009033 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009034 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01009035 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02009036 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
9037 0 \
9038 -s "a session has been resumed" \
9039 -c "a session has been resumed" \
9040 -s "Extra-header:" \
9041 -c "HTTP/1.0 200 OK"
9042
Janos Follath74537a62016-09-02 13:45:28 +01009043client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009044requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009045run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02009046 -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é-Gonnard37a4de22014-10-01 16:38:03 +02009048 psk=abc123 renegotiation=1 debug_level=2" \
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é-Gonnard37a4de22014-10-01 16:38:03 +02009050 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02009051 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9052 0 \
9053 -c "=> renegotiate" \
9054 -s "=> renegotiate" \
9055 -s "Extra-header:" \
9056 -c "HTTP/1.0 200 OK"
9057
Janos Follath74537a62016-09-02 13:45:28 +01009058client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009059requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009060run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
9061 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009062 "$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 +02009063 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009064 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009065 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009066 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9067 0 \
9068 -c "=> renegotiate" \
9069 -s "=> renegotiate" \
9070 -s "Extra-header:" \
9071 -c "HTTP/1.0 200 OK"
9072
Janos Follath74537a62016-09-02 13:45:28 +01009073client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009074requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009075run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009076 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009077 "$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 +02009078 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009079 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009080 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009081 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009082 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9083 0 \
9084 -c "=> renegotiate" \
9085 -s "=> renegotiate" \
9086 -s "Extra-header:" \
9087 -c "HTTP/1.0 200 OK"
9088
Janos Follath74537a62016-09-02 13:45:28 +01009089client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009090requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009091run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009092 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009093 "$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 +02009094 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009095 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009096 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009097 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009098 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9099 0 \
9100 -c "=> renegotiate" \
9101 -s "=> renegotiate" \
9102 -s "Extra-header:" \
9103 -c "HTTP/1.0 200 OK"
9104
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009105## Interop tests with OpenSSL might trigger a bug in recent versions (including
9106## all versions installed on the CI machines), reported here:
9107## Bug report: https://github.com/openssl/openssl/issues/6902
9108## They should be re-enabled once a fixed version of OpenSSL is available
9109## (this should happen in some 1.1.1_ release according to the ticket).
9110skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01009111client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009112not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009113run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009114 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9115 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009116 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009117 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009118 -c "HTTP/1.0 200 OK"
9119
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009120skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01009121client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009122not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009123run_test "DTLS proxy: 3d, openssl server, fragmentation" \
9124 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9125 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009126 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009127 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009128 -c "HTTP/1.0 200 OK"
9129
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009130skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01009131client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009132not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009133run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
9134 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9135 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009136 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009137 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009138 -c "HTTP/1.0 200 OK"
9139
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00009140requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01009141client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009142not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009143run_test "DTLS proxy: 3d, gnutls server" \
9144 -p "$P_PXY drop=5 delay=5 duplicate=5" \
9145 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009146 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009147 0 \
9148 -s "Extra-header:" \
9149 -c "Extra-header:"
9150
k-stachowiak17a38d32019-02-18 15:29:56 +01009151requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01009152client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009153not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009154run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
9155 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01009156 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009157 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009158 0 \
9159 -s "Extra-header:" \
9160 -c "Extra-header:"
9161
k-stachowiak17a38d32019-02-18 15:29:56 +01009162requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01009163client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009164not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009165run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
9166 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01009167 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009168 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009169 0 \
9170 -s "Extra-header:" \
9171 -c "Extra-header:"
9172
Ron Eldorf75e2522019-05-14 20:38:49 +03009173requires_config_enabled MBEDTLS_SSL_EXPORT_KEYS
9174run_test "export keys functionality" \
9175 "$P_SRV eap_tls=1 debug_level=3" \
9176 "$P_CLI eap_tls=1 debug_level=3" \
9177 0 \
9178 -s "exported maclen is " \
9179 -s "exported keylen is " \
9180 -s "exported ivlen is " \
9181 -c "exported maclen is " \
9182 -c "exported keylen is " \
Ron Eldor65d8c262019-06-04 13:05:36 +03009183 -c "exported ivlen is " \
9184 -c "EAP-TLS key material is:"\
9185 -s "EAP-TLS key material is:"\
9186 -c "EAP-TLS IV is:" \
9187 -s "EAP-TLS IV is:"
Ron Eldorf75e2522019-05-14 20:38:49 +03009188
Piotr Nowicki0937ed22019-11-26 16:32:40 +01009189# Test heap memory usage after handshake
9190requires_config_enabled MBEDTLS_MEMORY_DEBUG
9191requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C
9192requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
9193run_tests_memory_after_hanshake
9194
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01009195# Final report
9196
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009197echo "------------------------------------------------------------------------"
9198
9199if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01009200 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009201else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01009202 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009203fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02009204PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02009205echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009206
9207exit $FAILS