blob: f5a3d4af5acacce87d70e918498ad2b1484fcc07 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Bence Szépkúti44bfbe32020-08-19 16:54:51 +02005# Copyright The Mbed TLS Contributors
Bence Szépkúti4e9f7122020-06-05 13:02:18 +02006# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7#
8# This file is provided under the Apache License 2.0, or the
9# GNU General Public License v2.0 or later.
10#
11# **********
12# Apache License 2.0:
Bence Szépkúti09b4f192020-05-26 01:54:15 +020013#
14# Licensed under the Apache License, Version 2.0 (the "License"); you may
15# not use this file except in compliance with the License.
16# You may obtain a copy of the License at
17#
18# http://www.apache.org/licenses/LICENSE-2.0
19#
20# Unless required by applicable law or agreed to in writing, software
21# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23# See the License for the specific language governing permissions and
24# limitations under the License.
25#
Bence Szépkúti4e9f7122020-06-05 13:02:18 +020026# **********
27#
28# **********
29# GNU General Public License v2.0 or later:
30#
31# This program is free software; you can redistribute it and/or modify
32# it under the terms of the GNU General Public License as published by
33# the Free Software Foundation; either version 2 of the License, or
34# (at your option) any later version.
35#
36# This program is distributed in the hope that it will be useful,
37# but WITHOUT ANY WARRANTY; without even the implied warranty of
38# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39# GNU General Public License for more details.
40#
41# You should have received a copy of the GNU General Public License along
42# with this program; if not, write to the Free Software Foundation, Inc.,
43# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
44#
45# **********
46#
Simon Butcher58eddef2016-05-19 23:43:11 +010047# Purpose
48#
49# Executes tests to prove various TLS/SSL options and extensions.
50#
51# The goal is not to cover every ciphersuite/version, but instead to cover
52# specific options (max fragment length, truncated hmac, etc) or procedures
53# (session resumption from cache or ticket, renego, etc).
54#
55# The tests assume a build with default options, with exceptions expressed
56# with a dependency. The tests focus on functionality and do not consider
57# performance.
58#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010059
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010060set -u
61
Jaeden Amero34730912019-07-03 13:51:04 +010062# Limit the size of each log to 10 GiB, in case of failures with this script
63# where it may output seemingly unlimited length error logs.
64ulimit -f 20971520
65
Antonin Décimo8fd91562019-01-23 15:24:37 +010066# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010067: ${P_SRV:=../programs/ssl/ssl_server2}
68: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020069: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010070: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020071: ${GNUTLS_CLI:=gnutls-cli}
72: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020073: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010074
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020075O_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 +010076O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020077G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard179c2272020-02-03 15:37:47 +010078G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12u.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020079TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010080
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010081TESTS=0
82FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020083SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010084
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000085CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020086
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010087MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010088FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020089EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010090
Paul Bakkere20310a2016-05-10 11:18:17 +010091SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010092RUN_TEST_NUMBER=''
93
Paul Bakkeracaac852016-05-10 11:47:13 +010094PRESERVE_LOGS=0
95
Gilles Peskinef93c7d32017-04-14 17:55:28 +020096# Pick a "unique" server port in the range 10000-19999, and a proxy
97# port which is this plus 10000. Each port number may be independently
98# overridden by a command line option.
99SRV_PORT=$(($$ % 10000 + 10000))
100PXY_PORT=$((SRV_PORT + 10000))
101
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100102print_usage() {
103 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100104 printf " -h|--help\tPrint this help.\n"
105 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinee7a9c3a2020-08-26 22:50:38 +0200106 printf " -f|--filter\tOnly matching tests are executed (BRE)\n"
107 printf " -e|--exclude\tMatching tests are excluded (BRE)\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100108 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100109 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100110 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200111 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
112 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100113 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100114}
115
116get_options() {
117 while [ $# -gt 0 ]; do
118 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100119 -f|--filter)
120 shift; FILTER=$1
121 ;;
122 -e|--exclude)
123 shift; EXCLUDE=$1
124 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100125 -m|--memcheck)
126 MEMCHECK=1
127 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100128 -n|--number)
129 shift; RUN_TEST_NUMBER=$1
130 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100131 -s|--show-numbers)
132 SHOW_TEST_NUMBER=1
133 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100134 -p|--preserve-logs)
135 PRESERVE_LOGS=1
136 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200137 --port)
138 shift; SRV_PORT=$1
139 ;;
140 --proxy-port)
141 shift; PXY_PORT=$1
142 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100143 --seed)
144 shift; SEED="$1"
145 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100146 -h|--help)
147 print_usage
148 exit 0
149 ;;
150 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200151 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100152 print_usage
153 exit 1
154 ;;
155 esac
156 shift
157 done
158}
159
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100160# skip next test if the flag is not enabled in config.h
161requires_config_enabled() {
162 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
163 SKIP_NEXT="YES"
164 fi
165}
166
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200167# skip next test if the flag is enabled in config.h
168requires_config_disabled() {
169 if grep "^#define $1" $CONFIG_H > /dev/null; then
170 SKIP_NEXT="YES"
171 fi
172}
173
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200174# skip next test if OpenSSL doesn't support FALLBACK_SCSV
175requires_openssl_with_fallback_scsv() {
176 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
177 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
178 then
179 OPENSSL_HAS_FBSCSV="YES"
180 else
181 OPENSSL_HAS_FBSCSV="NO"
182 fi
183 fi
184 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
185 SKIP_NEXT="YES"
186 fi
187}
188
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200189# skip next test if GnuTLS isn't available
190requires_gnutls() {
191 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200192 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200193 GNUTLS_AVAILABLE="YES"
194 else
195 GNUTLS_AVAILABLE="NO"
196 fi
197 fi
198 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
199 SKIP_NEXT="YES"
200 fi
201}
202
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200203# skip next test if IPv6 isn't available on this host
204requires_ipv6() {
205 if [ -z "${HAS_IPV6:-}" ]; then
206 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
207 SRV_PID=$!
208 sleep 1
209 kill $SRV_PID >/dev/null 2>&1
210 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
211 HAS_IPV6="NO"
212 else
213 HAS_IPV6="YES"
214 fi
215 rm -r $SRV_OUT
216 fi
217
218 if [ "$HAS_IPV6" = "NO" ]; then
219 SKIP_NEXT="YES"
220 fi
221}
222
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200223# skip the next test if valgrind is in use
224not_with_valgrind() {
225 if [ "$MEMCHECK" -gt 0 ]; then
226 SKIP_NEXT="YES"
227 fi
228}
229
Paul Bakker362689d2016-05-13 10:33:25 +0100230# skip the next test if valgrind is NOT in use
231only_with_valgrind() {
232 if [ "$MEMCHECK" -eq 0 ]; then
233 SKIP_NEXT="YES"
234 fi
235}
236
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200237# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100238client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200239 CLI_DELAY_FACTOR=$1
240}
241
Janos Follath74537a62016-09-02 13:45:28 +0100242# wait for the given seconds after the client finished in the next test
243server_needs_more_time() {
244 SRV_DELAY_SECONDS=$1
245}
246
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100247# print_name <name>
248print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100249 TESTS=$(( $TESTS + 1 ))
250 LINE=""
251
252 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
253 LINE="$TESTS "
254 fi
255
256 LINE="$LINE$1"
Gilles Peskine352a7cf2020-08-26 20:05:11 +0200257 printf "%s " "$LINE"
Paul Bakkere20310a2016-05-10 11:18:17 +0100258 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100259 for i in `seq 1 $LEN`; do printf '.'; done
260 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100261
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100262}
263
264# fail <message>
265fail() {
266 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100267 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100268
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200269 mv $SRV_OUT o-srv-${TESTS}.log
270 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200271 if [ -n "$PXY_CMD" ]; then
272 mv $PXY_OUT o-pxy-${TESTS}.log
273 fi
274 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100275
Manuel Pégourié-Gonnardbc079e22020-06-08 11:49:05 +0200276 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200277 echo " ! server output:"
278 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200279 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200280 echo " ! client output:"
281 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200282 if [ -n "$PXY_CMD" ]; then
283 echo " ! ========================================================"
284 echo " ! proxy output:"
285 cat o-pxy-${TESTS}.log
286 fi
287 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200288 fi
289
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200290 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100291}
292
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100293# is_polar <cmd_line>
294is_polar() {
295 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
296}
297
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200298# openssl s_server doesn't have -www with DTLS
299check_osrv_dtls() {
300 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
301 NEEDS_INPUT=1
302 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
303 else
304 NEEDS_INPUT=0
305 fi
306}
307
308# provide input to commands that need it
309provide_input() {
310 if [ $NEEDS_INPUT -eq 0 ]; then
311 return
312 fi
313
314 while true; do
315 echo "HTTP/1.0 200 OK"
316 sleep 1
317 done
318}
319
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100320# has_mem_err <log_file_name>
321has_mem_err() {
322 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
323 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
324 then
325 return 1 # false: does not have errors
326 else
327 return 0 # true: has errors
328 fi
329}
330
Unknownb86bcb42019-09-02 10:42:57 -0400331# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100332if type lsof >/dev/null 2>/dev/null; then
Unknownb86bcb42019-09-02 10:42:57 -0400333 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100334 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200335 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100336 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200337 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100338 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200339 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100340 # Make a tight loop, server normally takes less than 1s to start.
341 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
342 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknownb86bcb42019-09-02 10:42:57 -0400343 echo "$3 START TIMEOUT"
344 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100345 break
346 fi
347 # Linux and *BSD support decimal arguments to sleep. On other
348 # OSes this may be a tight loop.
349 sleep 0.1 2>/dev/null || true
350 done
351 }
352else
Unknownb86bcb42019-09-02 10:42:57 -0400353 echo "Warning: lsof not available, wait_app_start = sleep"
354 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200355 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100356 }
357fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200358
Unknownb86bcb42019-09-02 10:42:57 -0400359# Wait for server process $2 to be listening on port $1.
360wait_server_start() {
361 wait_app_start $1 $2 "SERVER" $SRV_OUT
362}
363
364# Wait for proxy process $2 to be listening on port $1.
365wait_proxy_start() {
366 wait_app_start $1 $2 "PROXY" $PXY_OUT
367}
368
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100369# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100370# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100371# acceptable bounds
372check_server_hello_time() {
373 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100374 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100375 # Get the Unix timestamp for now
376 CUR_TIME=$(date +'%s')
377 THRESHOLD_IN_SECS=300
378
379 # Check if the ServerHello time was printed
380 if [ -z "$SERVER_HELLO_TIME" ]; then
381 return 1
382 fi
383
384 # Check the time in ServerHello is within acceptable bounds
385 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
386 # The time in ServerHello is at least 5 minutes before now
387 return 1
388 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100389 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100390 return 1
391 else
392 return 0
393 fi
394}
395
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200396# wait for client to terminate and set CLI_EXIT
397# must be called right after starting the client
398wait_client_done() {
399 CLI_PID=$!
400
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200401 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
402 CLI_DELAY_FACTOR=1
403
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200404 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200405 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200406
407 wait $CLI_PID
408 CLI_EXIT=$?
409
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200410 kill $DOG_PID >/dev/null 2>&1
411 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200412
413 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100414
415 sleep $SRV_DELAY_SECONDS
416 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200417}
418
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200419# check if the given command uses dtls and sets global variable DTLS
420detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200421 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200422 DTLS=1
423 else
424 DTLS=0
425 fi
426}
427
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200428# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100429# Options: -s pattern pattern that must be present in server output
430# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100431# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100432# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100433# -S pattern pattern that must be absent in server output
434# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100435# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100436# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100437run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100438 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200439 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100440
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100441 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
442 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200443 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100444 return
445 fi
446
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100447 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100448
Paul Bakkerb7584a52016-05-10 10:50:43 +0100449 # Do we only run numbered tests?
450 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
451 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
452 else
453 SKIP_NEXT="YES"
454 fi
455
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200456 # should we skip?
457 if [ "X$SKIP_NEXT" = "XYES" ]; then
458 SKIP_NEXT="NO"
459 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200460 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200461 return
462 fi
463
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200464 # does this test use a proxy?
465 if [ "X$1" = "X-p" ]; then
466 PXY_CMD="$2"
467 shift 2
468 else
469 PXY_CMD=""
470 fi
471
472 # get commands and client output
473 SRV_CMD="$1"
474 CLI_CMD="$2"
475 CLI_EXPECT="$3"
476 shift 3
477
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200478 # update DTLS variable
479 detect_dtls "$SRV_CMD"
480
Manuel Pégourié-Gonnard1fcb1a12020-06-08 11:40:06 +0200481 # if the test uses DTLS but no custom proxy, add a simple proxy
482 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnardc5ae9c82020-06-25 09:54:46 +0200483 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard1fcb1a12020-06-08 11:40:06 +0200484 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnarded0aaf42020-07-16 10:19:32 +0200485 case " $SRV_CMD " in
486 *' server_addr=::1 '*)
487 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
488 esac
Manuel Pégourié-Gonnard1fcb1a12020-06-08 11:40:06 +0200489 fi
490
Manuel Pégourié-Gonnard57e328e2020-06-25 09:52:54 +0200491 # fix client port
492 if [ -n "$PXY_CMD" ]; then
493 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
494 else
495 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
496 fi
497
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100498 # prepend valgrind to our commands if active
499 if [ "$MEMCHECK" -gt 0 ]; then
500 if is_polar "$SRV_CMD"; then
501 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
502 fi
503 if is_polar "$CLI_CMD"; then
504 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
505 fi
506 fi
507
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200508 TIMES_LEFT=2
509 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200510 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200511
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200512 # run the commands
513 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnard33659702020-07-27 09:45:32 +0200514 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200515 $PXY_CMD >> $PXY_OUT 2>&1 &
516 PXY_PID=$!
Unknownb86bcb42019-09-02 10:42:57 -0400517 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200518 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200519
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200520 check_osrv_dtls
Gilles Peskine352a7cf2020-08-26 20:05:11 +0200521 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200522 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
523 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100524 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200525
Gilles Peskine352a7cf2020-08-26 20:05:11 +0200526 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200527 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
528 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100529
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200530 # terminate the server (and the proxy)
531 kill $SRV_PID
532 wait $SRV_PID
Gilles Peskine028ca782021-02-02 23:29:03 +0100533 SRV_RET=$?
534
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200535 if [ -n "$PXY_CMD" ]; then
536 kill $PXY_PID >/dev/null 2>&1
537 wait $PXY_PID
538 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100539
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200540 # retry only on timeouts
541 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
542 printf "RETRY "
543 else
544 TIMES_LEFT=0
545 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200546 done
547
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100548 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200549 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100550 # expected client exit to incorrectly succeed in case of catastrophic
551 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100552 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200553 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100554 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100555 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100556 return
557 fi
558 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100559 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200560 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100561 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100562 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100563 return
564 fi
565 fi
566
Gilles Peskine8607f062021-02-09 21:01:33 +0100567 # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
568 # exit with status 0 when interrupted by a signal, and we don't really
569 # care anyway), in case e.g. the server reports a memory leak.
570 if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then
Gilles Peskine028ca782021-02-02 23:29:03 +0100571 fail "Server exited with status $SRV_RET"
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100572 return
573 fi
574
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100575 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100576 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
577 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100578 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200579 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100580 return
581 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100582
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100583 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200584 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100585 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100586 while [ $# -gt 0 ]
587 do
588 case $1 in
589 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100590 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 +0100591 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100592 return
593 fi
594 ;;
595
596 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100597 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 +0100598 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100599 return
600 fi
601 ;;
602
603 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100604 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 +0100605 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100606 return
607 fi
608 ;;
609
610 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100611 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 +0100612 fail "pattern '$2' MUST NOT be present in the Client output"
613 return
614 fi
615 ;;
616
617 # The filtering in the following two options (-u and -U) do the following
618 # - ignore valgrind output
Antonin Décimo8fd91562019-01-23 15:24:37 +0100619 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100620 # - keep one of each non-unique line
621 # - count how many lines remain
622 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
623 # if there were no duplicates.
624 "-U")
625 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
626 fail "lines following pattern '$2' must be unique in Server output"
627 return
628 fi
629 ;;
630
631 "-u")
632 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
633 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100634 return
635 fi
636 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100637 "-F")
638 if ! $2 "$SRV_OUT"; then
639 fail "function call to '$2' failed on Server output"
640 return
641 fi
642 ;;
643 "-f")
644 if ! $2 "$CLI_OUT"; then
645 fail "function call to '$2' failed on Client output"
646 return
647 fi
648 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100649
650 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200651 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100652 exit 1
653 esac
654 shift 2
655 done
656
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100657 # check valgrind's results
658 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200659 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100660 fail "Server has memory errors"
661 return
662 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200663 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100664 fail "Client has memory errors"
665 return
666 fi
667 fi
668
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100669 # if we're here, everything is ok
670 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100671 if [ "$PRESERVE_LOGS" -gt 0 ]; then
672 mv $SRV_OUT o-srv-${TESTS}.log
673 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Beckerdc6c0e42018-08-20 12:21:35 +0100674 if [ -n "$PXY_CMD" ]; then
675 mv $PXY_OUT o-pxy-${TESTS}.log
676 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100677 fi
678
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200679 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100680}
681
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100682cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200683 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200684 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
685 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
686 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
687 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100688 exit 1
689}
690
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100691#
692# MAIN
693#
694
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000695if cd $( dirname $0 ); then :; else
696 echo "cd $( dirname $0 ) failed" >&2
697 exit 1
698fi
699
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100700get_options "$@"
701
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100702# sanity checks, avoid an avalanche of errors
703if [ ! -x "$P_SRV" ]; then
704 echo "Command '$P_SRV' is not an executable file"
705 exit 1
706fi
707if [ ! -x "$P_CLI" ]; then
708 echo "Command '$P_CLI' is not an executable file"
709 exit 1
710fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200711if [ ! -x "$P_PXY" ]; then
712 echo "Command '$P_PXY' is not an executable file"
713 exit 1
714fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100715if [ "$MEMCHECK" -gt 0 ]; then
716 if which valgrind >/dev/null 2>&1; then :; else
717 echo "Memcheck not possible. Valgrind not found"
718 exit 1
719 fi
720fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100721if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
722 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100723 exit 1
724fi
725
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200726# used by watchdog
727MAIN_PID="$$"
728
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100729# We use somewhat arbitrary delays for tests:
730# - how long do we wait for the server to start (when lsof not available)?
731# - how long do we allow for the client to finish?
732# (not to check performance, just to avoid waiting indefinitely)
733# Things are slower with valgrind, so give extra time here.
734#
735# Note: without lsof, there is a trade-off between the running time of this
736# script and the risk of spurious errors because we didn't wait long enough.
737# The watchdog delay on the other hand doesn't affect normal running time of
738# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200739if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100740 START_DELAY=6
741 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200742else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100743 START_DELAY=2
744 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200745fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100746
747# some particular tests need more time:
748# - for the client, we multiply the usual watchdog limit by a factor
749# - for the server, we sleep for a number of seconds after the client exits
750# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200751CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100752SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200753
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200754# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000755# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200756P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
757P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100758P_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 +0200759O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200760O_CLI="$O_CLI -connect localhost:+SRV_PORT"
761G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000762G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200763
Gilles Peskine62469d92017-05-10 10:13:59 +0200764# Allow SHA-1, because many of our test certificates use it
765P_SRV="$P_SRV allow_sha1=1"
766P_CLI="$P_CLI allow_sha1=1"
767
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200768# Also pick a unique name for intermediate files
769SRV_OUT="srv_out.$$"
770CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200771PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200772SESSION="session.$$"
773
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200774SKIP_NEXT="NO"
775
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100776trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100777
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200778# Basic test
779
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200780# Checks that:
781# - things work with all ciphersuites active (used with config-full in all.sh)
782# - the expected (highest security) parameters are selected
783# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200784run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200785 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200786 "$P_CLI" \
787 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200788 -s "Protocol is TLSv1.2" \
789 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
790 -s "client hello v3, signature_algorithm ext: 6" \
791 -s "ECDHE curve: secp521r1" \
792 -S "error" \
793 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200794
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000795run_test "Default, DTLS" \
796 "$P_SRV dtls=1" \
797 "$P_CLI dtls=1" \
798 0 \
799 -s "Protocol is DTLSv1.2" \
800 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
801
Manuel Pégourié-Gonnard45575512020-01-02 11:58:00 +0100802requires_config_enabled MBEDTLS_ZLIB_SUPPORT
803run_test "Default (compression enabled)" \
804 "$P_SRV debug_level=3" \
805 "$P_CLI debug_level=3" \
806 0 \
807 -s "Allocating compression buffer" \
808 -c "Allocating compression buffer" \
809 -s "Record expansion is unknown (compression)" \
810 -c "Record expansion is unknown (compression)" \
811 -S "error" \
812 -C "error"
813
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100814# Test current time in ServerHello
815requires_config_enabled MBEDTLS_HAVE_TIME
816run_test "Default, ServerHello contains gmt_unix_time" \
817 "$P_SRV debug_level=3" \
818 "$P_CLI debug_level=3" \
819 0 \
820 -s "Protocol is TLSv1.2" \
821 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
822 -s "client hello v3, signature_algorithm ext: 6" \
823 -s "ECDHE curve: secp521r1" \
824 -S "error" \
825 -C "error" \
826 -f "check_server_hello_time" \
827 -F "check_server_hello_time"
828
Simon Butcher8e004102016-10-14 00:48:33 +0100829# Test for uniqueness of IVs in AEAD ciphersuites
830run_test "Unique IV in GCM" \
831 "$P_SRV exchanges=20 debug_level=4" \
832 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
833 0 \
834 -u "IV used" \
835 -U "IV used"
836
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100837# Tests for rc4 option
838
Simon Butchera410af52016-05-19 22:12:18 +0100839requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100840run_test "RC4: server disabled, client enabled" \
841 "$P_SRV" \
842 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
843 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100844 -s "SSL - The server has no ciphersuites in common"
845
Simon Butchera410af52016-05-19 22:12:18 +0100846requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100847run_test "RC4: server half, client enabled" \
848 "$P_SRV arc4=1" \
849 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
850 1 \
851 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100852
853run_test "RC4: server enabled, client disabled" \
854 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
855 "$P_CLI" \
856 1 \
857 -s "SSL - The server has no ciphersuites in common"
858
859run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100860 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100861 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
862 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100863 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100864 -S "SSL - The server has no ciphersuites in common"
865
Hanno Becker3a333a52018-08-17 09:54:10 +0100866# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
867
868requires_gnutls
869requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
870run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
871 "$G_SRV"\
872 "$P_CLI force_version=tls1_1" \
873 0
874
875requires_gnutls
876requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
877run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
878 "$G_SRV"\
879 "$P_CLI force_version=tls1" \
880 0
881
Gilles Peskinebc70a182017-05-09 15:59:24 +0200882# Tests for SHA-1 support
883
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200884requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200885run_test "SHA-1 forbidden by default in server certificate" \
886 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
887 "$P_CLI debug_level=2 allow_sha1=0" \
888 1 \
889 -c "The certificate is signed with an unacceptable hash"
890
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200891requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
892run_test "SHA-1 forbidden by default in server certificate" \
893 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
894 "$P_CLI debug_level=2 allow_sha1=0" \
895 0
896
Gilles Peskinebc70a182017-05-09 15:59:24 +0200897run_test "SHA-1 explicitly allowed in server certificate" \
898 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
899 "$P_CLI allow_sha1=1" \
900 0
901
902run_test "SHA-256 allowed by default in server certificate" \
903 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
904 "$P_CLI allow_sha1=0" \
905 0
906
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200907requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200908run_test "SHA-1 forbidden by default in client certificate" \
909 "$P_SRV auth_mode=required allow_sha1=0" \
910 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
911 1 \
912 -s "The certificate is signed with an unacceptable hash"
913
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200914requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
915run_test "SHA-1 forbidden by default in client certificate" \
916 "$P_SRV auth_mode=required allow_sha1=0" \
917 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
918 0
919
Gilles Peskinebc70a182017-05-09 15:59:24 +0200920run_test "SHA-1 explicitly allowed in client certificate" \
921 "$P_SRV auth_mode=required allow_sha1=1" \
922 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
923 0
924
925run_test "SHA-256 allowed by default in client certificate" \
926 "$P_SRV auth_mode=required allow_sha1=0" \
927 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
928 0
929
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100930# Tests for Truncated HMAC extension
931
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100932run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200933 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100934 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100935 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000936 -s "dumping 'expected mac' (20 bytes)" \
937 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100938
Hanno Becker32c55012017-11-10 08:42:54 +0000939requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100940run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200941 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000942 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100943 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000944 -s "dumping 'expected mac' (20 bytes)" \
945 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100946
Hanno Becker32c55012017-11-10 08:42:54 +0000947requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100948run_test "Truncated HMAC: client enabled, server default" \
949 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000950 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100951 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000952 -s "dumping 'expected mac' (20 bytes)" \
953 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100954
Hanno Becker32c55012017-11-10 08:42:54 +0000955requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100956run_test "Truncated HMAC: client enabled, server disabled" \
957 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000958 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100959 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000960 -s "dumping 'expected mac' (20 bytes)" \
961 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100962
Hanno Becker32c55012017-11-10 08:42:54 +0000963requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000964run_test "Truncated HMAC: client disabled, server enabled" \
965 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000966 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000967 0 \
968 -s "dumping 'expected mac' (20 bytes)" \
969 -S "dumping 'expected mac' (10 bytes)"
970
971requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100972run_test "Truncated HMAC: client enabled, server enabled" \
973 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000974 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100975 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000976 -S "dumping 'expected mac' (20 bytes)" \
977 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100978
Hanno Becker4c4f4102017-11-10 09:16:05 +0000979run_test "Truncated HMAC, DTLS: client default, server default" \
980 "$P_SRV dtls=1 debug_level=4" \
981 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
982 0 \
983 -s "dumping 'expected mac' (20 bytes)" \
984 -S "dumping 'expected mac' (10 bytes)"
985
986requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
987run_test "Truncated HMAC, DTLS: client disabled, server default" \
988 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000989 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000990 0 \
991 -s "dumping 'expected mac' (20 bytes)" \
992 -S "dumping 'expected mac' (10 bytes)"
993
994requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
995run_test "Truncated HMAC, DTLS: client enabled, server default" \
996 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000997 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000998 0 \
999 -s "dumping 'expected mac' (20 bytes)" \
1000 -S "dumping 'expected mac' (10 bytes)"
1001
1002requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1003run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1004 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001005 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001006 0 \
1007 -s "dumping 'expected mac' (20 bytes)" \
1008 -S "dumping 'expected mac' (10 bytes)"
1009
1010requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1011run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1012 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001013 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001014 0 \
1015 -s "dumping 'expected mac' (20 bytes)" \
1016 -S "dumping 'expected mac' (10 bytes)"
1017
1018requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1019run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1020 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001021 "$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 +01001022 0 \
1023 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001024 -s "dumping 'expected mac' (10 bytes)"
1025
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001026# Tests for Encrypt-then-MAC extension
1027
1028run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001029 "$P_SRV debug_level=3 \
1030 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001031 "$P_CLI debug_level=3" \
1032 0 \
1033 -c "client hello, adding encrypt_then_mac extension" \
1034 -s "found encrypt then mac extension" \
1035 -s "server hello, adding encrypt then mac extension" \
1036 -c "found encrypt_then_mac extension" \
1037 -c "using encrypt then mac" \
1038 -s "using encrypt then mac"
1039
1040run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001041 "$P_SRV debug_level=3 etm=0 \
1042 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001043 "$P_CLI debug_level=3 etm=1" \
1044 0 \
1045 -c "client hello, adding encrypt_then_mac extension" \
1046 -s "found encrypt then mac extension" \
1047 -S "server hello, adding encrypt then mac extension" \
1048 -C "found encrypt_then_mac extension" \
1049 -C "using encrypt then mac" \
1050 -S "using encrypt then mac"
1051
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001052run_test "Encrypt then MAC: client enabled, aead cipher" \
1053 "$P_SRV debug_level=3 etm=1 \
1054 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1055 "$P_CLI debug_level=3 etm=1" \
1056 0 \
1057 -c "client hello, adding encrypt_then_mac extension" \
1058 -s "found encrypt then mac extension" \
1059 -S "server hello, adding encrypt then mac extension" \
1060 -C "found encrypt_then_mac extension" \
1061 -C "using encrypt then mac" \
1062 -S "using encrypt then mac"
1063
1064run_test "Encrypt then MAC: client enabled, stream cipher" \
1065 "$P_SRV debug_level=3 etm=1 \
1066 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001067 "$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 +01001068 0 \
1069 -c "client hello, adding encrypt_then_mac extension" \
1070 -s "found encrypt then mac extension" \
1071 -S "server hello, adding encrypt then mac extension" \
1072 -C "found encrypt_then_mac extension" \
1073 -C "using encrypt then mac" \
1074 -S "using encrypt then mac"
1075
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001076run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001077 "$P_SRV debug_level=3 etm=1 \
1078 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001079 "$P_CLI debug_level=3 etm=0" \
1080 0 \
1081 -C "client hello, adding encrypt_then_mac extension" \
1082 -S "found encrypt then mac extension" \
1083 -S "server hello, adding encrypt then mac extension" \
1084 -C "found encrypt_then_mac extension" \
1085 -C "using encrypt then mac" \
1086 -S "using encrypt then mac"
1087
Janos Follathe2681a42016-03-07 15:57:05 +00001088requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001089run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001090 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001091 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001092 "$P_CLI debug_level=3 force_version=ssl3" \
1093 0 \
1094 -C "client hello, adding encrypt_then_mac extension" \
1095 -S "found encrypt then mac extension" \
1096 -S "server hello, adding encrypt then mac extension" \
1097 -C "found encrypt_then_mac extension" \
1098 -C "using encrypt then mac" \
1099 -S "using encrypt then mac"
1100
Janos Follathe2681a42016-03-07 15:57:05 +00001101requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001102run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001103 "$P_SRV debug_level=3 force_version=ssl3 \
1104 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001105 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001106 0 \
1107 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001108 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001109 -S "server hello, adding encrypt then mac extension" \
1110 -C "found encrypt_then_mac extension" \
1111 -C "using encrypt then mac" \
1112 -S "using encrypt then mac"
1113
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001114# Tests for Extended Master Secret extension
1115
1116run_test "Extended Master Secret: default" \
1117 "$P_SRV debug_level=3" \
1118 "$P_CLI debug_level=3" \
1119 0 \
1120 -c "client hello, adding extended_master_secret extension" \
1121 -s "found extended master secret extension" \
1122 -s "server hello, adding extended master secret extension" \
1123 -c "found extended_master_secret extension" \
1124 -c "using extended master secret" \
1125 -s "using extended master secret"
1126
1127run_test "Extended Master Secret: client enabled, server disabled" \
1128 "$P_SRV debug_level=3 extended_ms=0" \
1129 "$P_CLI debug_level=3 extended_ms=1" \
1130 0 \
1131 -c "client hello, adding extended_master_secret extension" \
1132 -s "found extended master secret extension" \
1133 -S "server hello, adding extended master secret extension" \
1134 -C "found extended_master_secret extension" \
1135 -C "using extended master secret" \
1136 -S "using extended master secret"
1137
1138run_test "Extended Master Secret: client disabled, server enabled" \
1139 "$P_SRV debug_level=3 extended_ms=1" \
1140 "$P_CLI debug_level=3 extended_ms=0" \
1141 0 \
1142 -C "client hello, adding extended_master_secret extension" \
1143 -S "found extended master secret extension" \
1144 -S "server hello, adding extended master secret extension" \
1145 -C "found extended_master_secret extension" \
1146 -C "using extended master secret" \
1147 -S "using extended master secret"
1148
Janos Follathe2681a42016-03-07 15:57:05 +00001149requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001150run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001151 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001152 "$P_CLI debug_level=3 force_version=ssl3" \
1153 0 \
1154 -C "client hello, adding extended_master_secret extension" \
1155 -S "found extended master secret extension" \
1156 -S "server hello, adding extended master secret extension" \
1157 -C "found extended_master_secret extension" \
1158 -C "using extended master secret" \
1159 -S "using extended master secret"
1160
Janos Follathe2681a42016-03-07 15:57:05 +00001161requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001162run_test "Extended Master Secret: client enabled, server SSLv3" \
1163 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001164 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001165 0 \
1166 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001167 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001168 -S "server hello, adding extended master secret extension" \
1169 -C "found extended_master_secret extension" \
1170 -C "using extended master secret" \
1171 -S "using extended master secret"
1172
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001173# Tests for FALLBACK_SCSV
1174
1175run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001176 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001177 "$P_CLI debug_level=3 force_version=tls1_1" \
1178 0 \
1179 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001180 -S "received FALLBACK_SCSV" \
1181 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001182 -C "is a fatal alert message (msg 86)"
1183
1184run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001185 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001186 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1187 0 \
1188 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001189 -S "received FALLBACK_SCSV" \
1190 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001191 -C "is a fatal alert message (msg 86)"
1192
1193run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001194 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001195 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001196 1 \
1197 -c "adding FALLBACK_SCSV" \
1198 -s "received FALLBACK_SCSV" \
1199 -s "inapropriate fallback" \
1200 -c "is a fatal alert message (msg 86)"
1201
1202run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001203 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001204 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001205 0 \
1206 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001207 -s "received FALLBACK_SCSV" \
1208 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001209 -C "is a fatal alert message (msg 86)"
1210
1211requires_openssl_with_fallback_scsv
1212run_test "Fallback SCSV: default, openssl server" \
1213 "$O_SRV" \
1214 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1215 0 \
1216 -C "adding FALLBACK_SCSV" \
1217 -C "is a fatal alert message (msg 86)"
1218
1219requires_openssl_with_fallback_scsv
1220run_test "Fallback SCSV: enabled, openssl server" \
1221 "$O_SRV" \
1222 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1223 1 \
1224 -c "adding FALLBACK_SCSV" \
1225 -c "is a fatal alert message (msg 86)"
1226
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001227requires_openssl_with_fallback_scsv
1228run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001229 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001230 "$O_CLI -tls1_1" \
1231 0 \
1232 -S "received FALLBACK_SCSV" \
1233 -S "inapropriate fallback"
1234
1235requires_openssl_with_fallback_scsv
1236run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001237 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001238 "$O_CLI -tls1_1 -fallback_scsv" \
1239 1 \
1240 -s "received FALLBACK_SCSV" \
1241 -s "inapropriate fallback"
1242
1243requires_openssl_with_fallback_scsv
1244run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001245 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001246 "$O_CLI -fallback_scsv" \
1247 0 \
1248 -s "received FALLBACK_SCSV" \
1249 -S "inapropriate fallback"
1250
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001251# Test sending and receiving empty application data records
1252
1253run_test "Encrypt then MAC: empty application data record" \
1254 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1255 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1256 0 \
1257 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1258 -s "dumping 'input payload after decrypt' (0 bytes)" \
1259 -c "0 bytes written in 1 fragments"
1260
Manuel Pégourié-Gonnardd6e44542020-03-24 10:53:39 +01001261run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001262 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1263 "$P_CLI auth_mode=none etm=0 request_size=0" \
1264 0 \
1265 -s "dumping 'input payload after decrypt' (0 bytes)" \
1266 -c "0 bytes written in 1 fragments"
1267
1268run_test "Encrypt then MAC, DTLS: empty application data record" \
1269 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1270 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1271 0 \
1272 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1273 -s "dumping 'input payload after decrypt' (0 bytes)" \
1274 -c "0 bytes written in 1 fragments"
1275
Manuel Pégourié-Gonnardd6e44542020-03-24 10:53:39 +01001276run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001277 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1278 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1279 0 \
1280 -s "dumping 'input payload after decrypt' (0 bytes)" \
1281 -c "0 bytes written in 1 fragments"
1282
Gilles Peskined50177f2017-05-16 17:53:03 +02001283## ClientHello generated with
1284## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1285## then manually twiddling the ciphersuite list.
1286## The ClientHello content is spelled out below as a hex string as
1287## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1288## The expected response is an inappropriate_fallback alert.
1289requires_openssl_with_fallback_scsv
1290run_test "Fallback SCSV: beginning of list" \
1291 "$P_SRV debug_level=2" \
1292 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1293 0 \
1294 -s "received FALLBACK_SCSV" \
1295 -s "inapropriate fallback"
1296
1297requires_openssl_with_fallback_scsv
1298run_test "Fallback SCSV: end of list" \
1299 "$P_SRV debug_level=2" \
1300 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1301 0 \
1302 -s "received FALLBACK_SCSV" \
1303 -s "inapropriate fallback"
1304
1305## Here the expected response is a valid ServerHello prefix, up to the random.
1306requires_openssl_with_fallback_scsv
1307run_test "Fallback SCSV: not in list" \
1308 "$P_SRV debug_level=2" \
1309 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1310 0 \
1311 -S "received FALLBACK_SCSV" \
1312 -S "inapropriate fallback"
1313
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001314# Tests for CBC 1/n-1 record splitting
1315
1316run_test "CBC Record splitting: TLS 1.2, no splitting" \
1317 "$P_SRV" \
1318 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1319 request_size=123 force_version=tls1_2" \
1320 0 \
1321 -s "Read from client: 123 bytes read" \
1322 -S "Read from client: 1 bytes read" \
1323 -S "122 bytes read"
1324
1325run_test "CBC Record splitting: TLS 1.1, no splitting" \
1326 "$P_SRV" \
1327 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1328 request_size=123 force_version=tls1_1" \
1329 0 \
1330 -s "Read from client: 123 bytes read" \
1331 -S "Read from client: 1 bytes read" \
1332 -S "122 bytes read"
1333
1334run_test "CBC Record splitting: TLS 1.0, splitting" \
1335 "$P_SRV" \
1336 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1337 request_size=123 force_version=tls1" \
1338 0 \
1339 -S "Read from client: 123 bytes read" \
1340 -s "Read from client: 1 bytes read" \
1341 -s "122 bytes read"
1342
Janos Follathe2681a42016-03-07 15:57:05 +00001343requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001344run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001345 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001346 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1347 request_size=123 force_version=ssl3" \
1348 0 \
1349 -S "Read from client: 123 bytes read" \
1350 -s "Read from client: 1 bytes read" \
1351 -s "122 bytes read"
1352
1353run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001354 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001355 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1356 request_size=123 force_version=tls1" \
1357 0 \
1358 -s "Read from client: 123 bytes read" \
1359 -S "Read from client: 1 bytes read" \
1360 -S "122 bytes read"
1361
1362run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1363 "$P_SRV" \
1364 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1365 request_size=123 force_version=tls1 recsplit=0" \
1366 0 \
1367 -s "Read from client: 123 bytes read" \
1368 -S "Read from client: 1 bytes read" \
1369 -S "122 bytes read"
1370
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001371run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1372 "$P_SRV nbio=2" \
1373 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1374 request_size=123 force_version=tls1" \
1375 0 \
1376 -S "Read from client: 123 bytes read" \
1377 -s "Read from client: 1 bytes read" \
1378 -s "122 bytes read"
1379
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001380# Tests for Session Tickets
1381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001382run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001383 "$P_SRV debug_level=3 tickets=1" \
1384 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001385 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001386 -c "client hello, adding session ticket extension" \
1387 -s "found session ticket extension" \
1388 -s "server hello, adding session ticket extension" \
1389 -c "found session_ticket extension" \
1390 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001391 -S "session successfully restored from cache" \
1392 -s "session successfully restored from ticket" \
1393 -s "a session has been resumed" \
1394 -c "a session has been resumed"
1395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001396run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001397 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1398 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001399 0 \
1400 -c "client hello, adding session ticket extension" \
1401 -s "found session ticket extension" \
1402 -s "server hello, adding session ticket extension" \
1403 -c "found session_ticket extension" \
1404 -c "parse new session ticket" \
1405 -S "session successfully restored from cache" \
1406 -s "session successfully restored from ticket" \
1407 -s "a session has been resumed" \
1408 -c "a session has been resumed"
1409
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001410run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001411 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1412 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001413 0 \
1414 -c "client hello, adding session ticket extension" \
1415 -s "found session ticket extension" \
1416 -s "server hello, adding session ticket extension" \
1417 -c "found session_ticket extension" \
1418 -c "parse new session ticket" \
1419 -S "session successfully restored from cache" \
1420 -S "session successfully restored from ticket" \
1421 -S "a session has been resumed" \
1422 -C "a session has been resumed"
1423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001424run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001425 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001426 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001427 0 \
1428 -c "client hello, adding session ticket extension" \
1429 -c "found session_ticket extension" \
1430 -c "parse new session ticket" \
1431 -c "a session has been resumed"
1432
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001433run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001434 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001435 "( $O_CLI -sess_out $SESSION; \
1436 $O_CLI -sess_in $SESSION; \
1437 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001438 0 \
1439 -s "found session ticket extension" \
1440 -s "server hello, adding session ticket extension" \
1441 -S "session successfully restored from cache" \
1442 -s "session successfully restored from ticket" \
1443 -s "a session has been resumed"
1444
Hanno Beckerb5546362018-08-21 13:55:22 +01001445# Tests for Session Tickets with DTLS
1446
1447run_test "Session resume using tickets, DTLS: basic" \
1448 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001449 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001450 0 \
1451 -c "client hello, adding session ticket extension" \
1452 -s "found session ticket extension" \
1453 -s "server hello, adding session ticket extension" \
1454 -c "found session_ticket extension" \
1455 -c "parse new session ticket" \
1456 -S "session successfully restored from cache" \
1457 -s "session successfully restored from ticket" \
1458 -s "a session has been resumed" \
1459 -c "a session has been resumed"
1460
1461run_test "Session resume using tickets, DTLS: cache disabled" \
1462 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001463 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001464 0 \
1465 -c "client hello, adding session ticket extension" \
1466 -s "found session ticket extension" \
1467 -s "server hello, adding session ticket extension" \
1468 -c "found session_ticket extension" \
1469 -c "parse new session ticket" \
1470 -S "session successfully restored from cache" \
1471 -s "session successfully restored from ticket" \
1472 -s "a session has been resumed" \
1473 -c "a session has been resumed"
1474
1475run_test "Session resume using tickets, DTLS: timeout" \
1476 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001477 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001478 0 \
1479 -c "client hello, adding session ticket extension" \
1480 -s "found session ticket extension" \
1481 -s "server hello, adding session ticket extension" \
1482 -c "found session_ticket extension" \
1483 -c "parse new session ticket" \
1484 -S "session successfully restored from cache" \
1485 -S "session successfully restored from ticket" \
1486 -S "a session has been resumed" \
1487 -C "a session has been resumed"
1488
1489run_test "Session resume using tickets, DTLS: openssl server" \
1490 "$O_SRV -dtls1" \
1491 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1492 0 \
1493 -c "client hello, adding session ticket extension" \
1494 -c "found session_ticket extension" \
1495 -c "parse new session ticket" \
1496 -c "a session has been resumed"
1497
1498run_test "Session resume using tickets, DTLS: openssl client" \
1499 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1500 "( $O_CLI -dtls1 -sess_out $SESSION; \
1501 $O_CLI -dtls1 -sess_in $SESSION; \
1502 rm -f $SESSION )" \
1503 0 \
1504 -s "found session ticket extension" \
1505 -s "server hello, adding session ticket extension" \
1506 -S "session successfully restored from cache" \
1507 -s "session successfully restored from ticket" \
1508 -s "a session has been resumed"
1509
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001510# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001512run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001513 "$P_SRV debug_level=3 tickets=0" \
1514 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001515 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001516 -c "client hello, adding session ticket extension" \
1517 -s "found session ticket extension" \
1518 -S "server hello, adding session ticket extension" \
1519 -C "found session_ticket extension" \
1520 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001521 -s "session successfully restored from cache" \
1522 -S "session successfully restored from ticket" \
1523 -s "a session has been resumed" \
1524 -c "a session has been resumed"
1525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001526run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001527 "$P_SRV debug_level=3 tickets=1" \
1528 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001529 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001530 -C "client hello, adding session ticket extension" \
1531 -S "found session ticket extension" \
1532 -S "server hello, adding session ticket extension" \
1533 -C "found session_ticket extension" \
1534 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001535 -s "session successfully restored from cache" \
1536 -S "session successfully restored from ticket" \
1537 -s "a session has been resumed" \
1538 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001540run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001541 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1542 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001543 0 \
1544 -S "session successfully restored from cache" \
1545 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001546 -S "a session has been resumed" \
1547 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001549run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001550 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1551 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001552 0 \
1553 -s "session successfully restored from cache" \
1554 -S "session successfully restored from ticket" \
1555 -s "a session has been resumed" \
1556 -c "a session has been resumed"
1557
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001558run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001559 "$P_SRV debug_level=3 tickets=0" \
1560 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001561 0 \
1562 -s "session successfully restored from cache" \
1563 -S "session successfully restored from ticket" \
1564 -s "a session has been resumed" \
1565 -c "a session has been resumed"
1566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001567run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001568 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1569 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001570 0 \
1571 -S "session successfully restored from cache" \
1572 -S "session successfully restored from ticket" \
1573 -S "a session has been resumed" \
1574 -C "a session has been resumed"
1575
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001576run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001577 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1578 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001579 0 \
1580 -s "session successfully restored from cache" \
1581 -S "session successfully restored from ticket" \
1582 -s "a session has been resumed" \
1583 -c "a session has been resumed"
1584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001585run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001586 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001587 "( $O_CLI -sess_out $SESSION; \
1588 $O_CLI -sess_in $SESSION; \
1589 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001590 0 \
1591 -s "found session ticket extension" \
1592 -S "server hello, adding session ticket extension" \
1593 -s "session successfully restored from cache" \
1594 -S "session successfully restored from ticket" \
1595 -s "a session has been resumed"
1596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001597run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001598 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001599 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001600 0 \
1601 -C "found session_ticket extension" \
1602 -C "parse new session ticket" \
1603 -c "a session has been resumed"
1604
Hanno Beckerb5546362018-08-21 13:55:22 +01001605# Tests for Session Resume based on session-ID and cache, DTLS
1606
1607run_test "Session resume using cache, DTLS: tickets enabled on client" \
1608 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001609 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001610 0 \
1611 -c "client hello, adding session ticket extension" \
1612 -s "found session ticket extension" \
1613 -S "server hello, adding session ticket extension" \
1614 -C "found session_ticket extension" \
1615 -C "parse new session ticket" \
1616 -s "session successfully restored from cache" \
1617 -S "session successfully restored from ticket" \
1618 -s "a session has been resumed" \
1619 -c "a session has been resumed"
1620
1621run_test "Session resume using cache, DTLS: tickets enabled on server" \
1622 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001623 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001624 0 \
1625 -C "client hello, adding session ticket extension" \
1626 -S "found session ticket extension" \
1627 -S "server hello, adding session ticket extension" \
1628 -C "found session_ticket extension" \
1629 -C "parse new session ticket" \
1630 -s "session successfully restored from cache" \
1631 -S "session successfully restored from ticket" \
1632 -s "a session has been resumed" \
1633 -c "a session has been resumed"
1634
1635run_test "Session resume using cache, DTLS: cache_max=0" \
1636 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001637 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001638 0 \
1639 -S "session successfully restored from cache" \
1640 -S "session successfully restored from ticket" \
1641 -S "a session has been resumed" \
1642 -C "a session has been resumed"
1643
1644run_test "Session resume using cache, DTLS: cache_max=1" \
1645 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001646 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001647 0 \
1648 -s "session successfully restored from cache" \
1649 -S "session successfully restored from ticket" \
1650 -s "a session has been resumed" \
1651 -c "a session has been resumed"
1652
1653run_test "Session resume using cache, DTLS: timeout > delay" \
1654 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001655 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=0" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001656 0 \
1657 -s "session successfully restored from cache" \
1658 -S "session successfully restored from ticket" \
1659 -s "a session has been resumed" \
1660 -c "a session has been resumed"
1661
1662run_test "Session resume using cache, DTLS: timeout < delay" \
1663 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001664 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001665 0 \
1666 -S "session successfully restored from cache" \
1667 -S "session successfully restored from ticket" \
1668 -S "a session has been resumed" \
1669 -C "a session has been resumed"
1670
1671run_test "Session resume using cache, DTLS: no timeout" \
1672 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001673 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001674 0 \
1675 -s "session successfully restored from cache" \
1676 -S "session successfully restored from ticket" \
1677 -s "a session has been resumed" \
1678 -c "a session has been resumed"
1679
1680run_test "Session resume using cache, DTLS: openssl client" \
1681 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1682 "( $O_CLI -dtls1 -sess_out $SESSION; \
1683 $O_CLI -dtls1 -sess_in $SESSION; \
1684 rm -f $SESSION )" \
1685 0 \
1686 -s "found session ticket extension" \
1687 -S "server hello, adding session ticket extension" \
1688 -s "session successfully restored from cache" \
1689 -S "session successfully restored from ticket" \
1690 -s "a session has been resumed"
1691
1692run_test "Session resume using cache, DTLS: openssl server" \
1693 "$O_SRV -dtls1" \
1694 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1695 0 \
1696 -C "found session_ticket extension" \
1697 -C "parse new session ticket" \
1698 -c "a session has been resumed"
1699
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001700# Tests for Max Fragment Length extension
1701
Hanno Becker6428f8d2017-09-22 16:58:50 +01001702MAX_CONTENT_LEN_EXPECT='16384'
1703MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1704
1705if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
Gilles Peskine352a7cf2020-08-26 20:05:11 +02001706 cat <<EOF
1707The ${CONFIG_H} file contains a value for the configuration of
1708MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s
1709test value of ${MAX_CONTENT_LEN_EXPECT}.
Hanno Becker6428f8d2017-09-22 16:58:50 +01001710
Gilles Peskine352a7cf2020-08-26 20:05:11 +02001711The tests assume this value and if it changes, the tests in this
1712script should also be adjusted.
1713EOF
Hanno Becker6428f8d2017-09-22 16:58:50 +01001714 exit 1
1715fi
1716
Hanno Becker4aed27e2017-09-18 15:00:34 +01001717requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001718run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001719 "$P_SRV debug_level=3" \
1720 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001721 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001722 -c "Maximum fragment length is 16384" \
1723 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001724 -C "client hello, adding max_fragment_length extension" \
1725 -S "found max fragment length extension" \
1726 -S "server hello, max_fragment_length extension" \
1727 -C "found max_fragment_length extension"
1728
Hanno Becker4aed27e2017-09-18 15:00:34 +01001729requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001730run_test "Max fragment length: enabled, default, larger message" \
1731 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001732 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001733 0 \
1734 -c "Maximum fragment length is 16384" \
1735 -s "Maximum fragment length is 16384" \
1736 -C "client hello, adding max_fragment_length extension" \
1737 -S "found max fragment length extension" \
1738 -S "server hello, max_fragment_length extension" \
1739 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001740 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001741 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001742 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001743
1744requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1745run_test "Max fragment length, DTLS: enabled, default, larger message" \
1746 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001747 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001748 1 \
1749 -c "Maximum fragment length is 16384" \
1750 -s "Maximum fragment length is 16384" \
1751 -C "client hello, adding max_fragment_length extension" \
1752 -S "found max fragment length extension" \
1753 -S "server hello, max_fragment_length extension" \
1754 -C "found max_fragment_length extension" \
1755 -c "fragment larger than.*maximum "
1756
1757requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1758run_test "Max fragment length: disabled, larger message" \
1759 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001760 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001761 0 \
1762 -C "Maximum fragment length is 16384" \
1763 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001764 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001765 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001766 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001767
1768requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1769run_test "Max fragment length DTLS: disabled, larger message" \
1770 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001771 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001772 1 \
1773 -C "Maximum fragment length is 16384" \
1774 -S "Maximum fragment length is 16384" \
1775 -c "fragment larger than.*maximum "
1776
1777requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001778run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001779 "$P_SRV debug_level=3" \
1780 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001781 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001782 -c "Maximum fragment length is 4096" \
1783 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001784 -c "client hello, adding max_fragment_length extension" \
1785 -s "found max fragment length extension" \
1786 -s "server hello, max_fragment_length extension" \
1787 -c "found max_fragment_length extension"
1788
Hanno Becker4aed27e2017-09-18 15:00:34 +01001789requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001790run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001791 "$P_SRV debug_level=3 max_frag_len=4096" \
1792 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001793 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001794 -c "Maximum fragment length is 16384" \
1795 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001796 -C "client hello, adding max_fragment_length extension" \
1797 -S "found max fragment length extension" \
1798 -S "server hello, max_fragment_length extension" \
1799 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001800
Hanno Becker4aed27e2017-09-18 15:00:34 +01001801requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001802requires_gnutls
1803run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001804 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001805 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001806 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001807 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001808 -c "client hello, adding max_fragment_length extension" \
1809 -c "found max_fragment_length extension"
1810
Hanno Becker4aed27e2017-09-18 15:00:34 +01001811requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001812run_test "Max fragment length: client, message just fits" \
1813 "$P_SRV debug_level=3" \
1814 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1815 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001816 -c "Maximum fragment length is 2048" \
1817 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001818 -c "client hello, adding max_fragment_length extension" \
1819 -s "found max fragment length extension" \
1820 -s "server hello, max_fragment_length extension" \
1821 -c "found max_fragment_length extension" \
1822 -c "2048 bytes written in 1 fragments" \
1823 -s "2048 bytes read"
1824
Hanno Becker4aed27e2017-09-18 15:00:34 +01001825requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001826run_test "Max fragment length: client, larger message" \
1827 "$P_SRV debug_level=3" \
1828 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1829 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001830 -c "Maximum fragment length is 2048" \
1831 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001832 -c "client hello, adding max_fragment_length extension" \
1833 -s "found max fragment length extension" \
1834 -s "server hello, max_fragment_length extension" \
1835 -c "found max_fragment_length extension" \
1836 -c "2345 bytes written in 2 fragments" \
1837 -s "2048 bytes read" \
1838 -s "297 bytes read"
1839
Hanno Becker4aed27e2017-09-18 15:00:34 +01001840requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001841run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001842 "$P_SRV debug_level=3 dtls=1" \
1843 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1844 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001845 -c "Maximum fragment length is 2048" \
1846 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001847 -c "client hello, adding max_fragment_length extension" \
1848 -s "found max fragment length extension" \
1849 -s "server hello, max_fragment_length extension" \
1850 -c "found max_fragment_length extension" \
1851 -c "fragment larger than.*maximum"
1852
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001853# Tests for renegotiation
1854
Hanno Becker6a243642017-10-12 15:18:45 +01001855# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001856run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001857 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001859 0 \
1860 -C "client hello, adding renegotiation extension" \
1861 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1862 -S "found renegotiation extension" \
1863 -s "server hello, secure renegotiation extension" \
1864 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001865 -C "=> renegotiate" \
1866 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001867 -S "write hello request"
1868
Hanno Becker6a243642017-10-12 15:18:45 +01001869requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001870run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001871 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001872 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001873 0 \
1874 -c "client hello, adding renegotiation extension" \
1875 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1876 -s "found renegotiation extension" \
1877 -s "server hello, secure renegotiation extension" \
1878 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001879 -c "=> renegotiate" \
1880 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001881 -S "write hello request"
1882
Hanno Becker6a243642017-10-12 15:18:45 +01001883requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001884run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001885 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001886 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001887 0 \
1888 -c "client hello, adding renegotiation extension" \
1889 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1890 -s "found renegotiation extension" \
1891 -s "server hello, secure renegotiation extension" \
1892 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001893 -c "=> renegotiate" \
1894 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001895 -s "write hello request"
1896
Janos Follathb0f148c2017-10-05 12:29:42 +01001897# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1898# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1899# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001900requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001901run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1902 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1903 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1904 0 \
1905 -c "client hello, adding renegotiation extension" \
1906 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1907 -s "found renegotiation extension" \
1908 -s "server hello, secure renegotiation extension" \
1909 -c "found renegotiation extension" \
1910 -c "=> renegotiate" \
1911 -s "=> renegotiate" \
1912 -S "write hello request" \
1913 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1914
1915# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1916# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1917# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001918requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001919run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1920 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1921 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1922 0 \
1923 -c "client hello, adding renegotiation extension" \
1924 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1925 -s "found renegotiation extension" \
1926 -s "server hello, secure renegotiation extension" \
1927 -c "found renegotiation extension" \
1928 -c "=> renegotiate" \
1929 -s "=> renegotiate" \
1930 -s "write hello request" \
1931 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1932
Hanno Becker6a243642017-10-12 15:18:45 +01001933requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001934run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001935 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001936 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001937 0 \
1938 -c "client hello, adding renegotiation extension" \
1939 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1940 -s "found renegotiation extension" \
1941 -s "server hello, secure renegotiation extension" \
1942 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001943 -c "=> renegotiate" \
1944 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001945 -s "write hello request"
1946
Hanno Becker6a243642017-10-12 15:18:45 +01001947requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001948run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001949 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001950 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001951 1 \
1952 -c "client hello, adding renegotiation extension" \
1953 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1954 -S "found renegotiation extension" \
1955 -s "server hello, secure renegotiation extension" \
1956 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001957 -c "=> renegotiate" \
1958 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001959 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001960 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001961 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001962
Hanno Becker6a243642017-10-12 15:18:45 +01001963requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001964run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001965 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001966 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001967 0 \
1968 -C "client hello, adding renegotiation extension" \
1969 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1970 -S "found renegotiation extension" \
1971 -s "server hello, secure renegotiation extension" \
1972 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001973 -C "=> renegotiate" \
1974 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001975 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001976 -S "SSL - An unexpected message was received from our peer" \
1977 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001978
Hanno Becker6a243642017-10-12 15:18:45 +01001979requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001980run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001981 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001982 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001983 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001984 0 \
1985 -C "client hello, adding renegotiation extension" \
1986 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1987 -S "found renegotiation extension" \
1988 -s "server hello, secure renegotiation extension" \
1989 -c "found renegotiation extension" \
1990 -C "=> renegotiate" \
1991 -S "=> renegotiate" \
1992 -s "write hello request" \
1993 -S "SSL - An unexpected message was received from our peer" \
1994 -S "failed"
1995
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001996# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001997requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001998run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001999 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002000 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002001 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002002 0 \
2003 -C "client hello, adding renegotiation extension" \
2004 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2005 -S "found renegotiation extension" \
2006 -s "server hello, secure renegotiation extension" \
2007 -c "found renegotiation extension" \
2008 -C "=> renegotiate" \
2009 -S "=> renegotiate" \
2010 -s "write hello request" \
2011 -S "SSL - An unexpected message was received from our peer" \
2012 -S "failed"
2013
Hanno Becker6a243642017-10-12 15:18:45 +01002014requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002015run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002016 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002017 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002018 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002019 0 \
2020 -C "client hello, adding renegotiation extension" \
2021 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2022 -S "found renegotiation extension" \
2023 -s "server hello, secure renegotiation extension" \
2024 -c "found renegotiation extension" \
2025 -C "=> renegotiate" \
2026 -S "=> renegotiate" \
2027 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002028 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002029
Hanno Becker6a243642017-10-12 15:18:45 +01002030requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002031run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002032 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002033 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002034 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002035 0 \
2036 -c "client hello, adding renegotiation extension" \
2037 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2038 -s "found renegotiation extension" \
2039 -s "server hello, secure renegotiation extension" \
2040 -c "found renegotiation extension" \
2041 -c "=> renegotiate" \
2042 -s "=> renegotiate" \
2043 -s "write hello request" \
2044 -S "SSL - An unexpected message was received from our peer" \
2045 -S "failed"
2046
Hanno Becker6a243642017-10-12 15:18:45 +01002047requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002048run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002049 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002050 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2051 0 \
2052 -C "client hello, adding renegotiation extension" \
2053 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2054 -S "found renegotiation extension" \
2055 -s "server hello, secure renegotiation extension" \
2056 -c "found renegotiation extension" \
2057 -S "record counter limit reached: renegotiate" \
2058 -C "=> renegotiate" \
2059 -S "=> renegotiate" \
2060 -S "write hello request" \
2061 -S "SSL - An unexpected message was received from our peer" \
2062 -S "failed"
2063
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002064# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002065requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002066run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002067 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002068 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002069 0 \
2070 -c "client hello, adding renegotiation extension" \
2071 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2072 -s "found renegotiation extension" \
2073 -s "server hello, secure renegotiation extension" \
2074 -c "found renegotiation extension" \
2075 -s "record counter limit reached: renegotiate" \
2076 -c "=> renegotiate" \
2077 -s "=> renegotiate" \
2078 -s "write hello request" \
2079 -S "SSL - An unexpected message was received from our peer" \
2080 -S "failed"
2081
Hanno Becker6a243642017-10-12 15:18:45 +01002082requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002083run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002084 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002085 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002086 0 \
2087 -c "client hello, adding renegotiation extension" \
2088 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2089 -s "found renegotiation extension" \
2090 -s "server hello, secure renegotiation extension" \
2091 -c "found renegotiation extension" \
2092 -s "record counter limit reached: renegotiate" \
2093 -c "=> renegotiate" \
2094 -s "=> renegotiate" \
2095 -s "write hello request" \
2096 -S "SSL - An unexpected message was received from our peer" \
2097 -S "failed"
2098
Hanno Becker6a243642017-10-12 15:18:45 +01002099requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002100run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002101 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002102 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2103 0 \
2104 -C "client hello, adding renegotiation extension" \
2105 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2106 -S "found renegotiation extension" \
2107 -s "server hello, secure renegotiation extension" \
2108 -c "found renegotiation extension" \
2109 -S "record counter limit reached: renegotiate" \
2110 -C "=> renegotiate" \
2111 -S "=> renegotiate" \
2112 -S "write hello request" \
2113 -S "SSL - An unexpected message was received from our peer" \
2114 -S "failed"
2115
Hanno Becker6a243642017-10-12 15:18:45 +01002116requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002117run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002118 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002119 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002120 0 \
2121 -c "client hello, adding renegotiation extension" \
2122 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2123 -s "found renegotiation extension" \
2124 -s "server hello, secure renegotiation extension" \
2125 -c "found renegotiation extension" \
2126 -c "=> renegotiate" \
2127 -s "=> renegotiate" \
2128 -S "write hello request"
2129
Hanno Becker6a243642017-10-12 15:18:45 +01002130requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002131run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002132 "$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 +02002133 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002134 0 \
2135 -c "client hello, adding renegotiation extension" \
2136 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2137 -s "found renegotiation extension" \
2138 -s "server hello, secure renegotiation extension" \
2139 -c "found renegotiation extension" \
2140 -c "=> renegotiate" \
2141 -s "=> renegotiate" \
2142 -s "write hello request"
2143
Hanno Becker6a243642017-10-12 15:18:45 +01002144requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002145run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002146 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002147 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002148 0 \
2149 -c "client hello, adding renegotiation extension" \
2150 -c "found renegotiation extension" \
2151 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002152 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002153 -C "error" \
2154 -c "HTTP/1.0 200 [Oo][Kk]"
2155
Paul Bakker539d9722015-02-08 16:18:35 +01002156requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002157requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002158run_test "Renegotiation: gnutls server strict, client-initiated" \
2159 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002160 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002161 0 \
2162 -c "client hello, adding renegotiation extension" \
2163 -c "found renegotiation extension" \
2164 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002165 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002166 -C "error" \
2167 -c "HTTP/1.0 200 [Oo][Kk]"
2168
Paul Bakker539d9722015-02-08 16:18:35 +01002169requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002170requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002171run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2172 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2173 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2174 1 \
2175 -c "client hello, adding renegotiation extension" \
2176 -C "found renegotiation extension" \
2177 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002178 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002179 -c "error" \
2180 -C "HTTP/1.0 200 [Oo][Kk]"
2181
Paul Bakker539d9722015-02-08 16:18:35 +01002182requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002183requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002184run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2185 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2186 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2187 allow_legacy=0" \
2188 1 \
2189 -c "client hello, adding renegotiation extension" \
2190 -C "found renegotiation extension" \
2191 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002192 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002193 -c "error" \
2194 -C "HTTP/1.0 200 [Oo][Kk]"
2195
Paul Bakker539d9722015-02-08 16:18:35 +01002196requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002197requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002198run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2199 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2200 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2201 allow_legacy=1" \
2202 0 \
2203 -c "client hello, adding renegotiation extension" \
2204 -C "found renegotiation extension" \
2205 -c "=> renegotiate" \
2206 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002207 -C "error" \
2208 -c "HTTP/1.0 200 [Oo][Kk]"
2209
Hanno Becker6a243642017-10-12 15:18:45 +01002210requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002211run_test "Renegotiation: DTLS, client-initiated" \
2212 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2213 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2214 0 \
2215 -c "client hello, adding renegotiation extension" \
2216 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2217 -s "found renegotiation extension" \
2218 -s "server hello, secure renegotiation extension" \
2219 -c "found renegotiation extension" \
2220 -c "=> renegotiate" \
2221 -s "=> renegotiate" \
2222 -S "write hello request"
2223
Hanno Becker6a243642017-10-12 15:18:45 +01002224requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002225run_test "Renegotiation: DTLS, server-initiated" \
2226 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002227 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2228 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002229 0 \
2230 -c "client hello, adding renegotiation extension" \
2231 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2232 -s "found renegotiation extension" \
2233 -s "server hello, secure renegotiation extension" \
2234 -c "found renegotiation extension" \
2235 -c "=> renegotiate" \
2236 -s "=> renegotiate" \
2237 -s "write hello request"
2238
Hanno Becker6a243642017-10-12 15:18:45 +01002239requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002240run_test "Renegotiation: DTLS, renego_period overflow" \
2241 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2242 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2243 0 \
2244 -c "client hello, adding renegotiation extension" \
2245 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2246 -s "found renegotiation extension" \
2247 -s "server hello, secure renegotiation extension" \
2248 -s "record counter limit reached: renegotiate" \
2249 -c "=> renegotiate" \
2250 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002251 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002252
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002253requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002254requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002255run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2256 "$G_SRV -u --mtu 4096" \
2257 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2258 0 \
2259 -c "client hello, adding renegotiation extension" \
2260 -c "found renegotiation extension" \
2261 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002262 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002263 -C "error" \
2264 -s "Extra-header:"
2265
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002266# Test for the "secure renegotation" extension only (no actual renegotiation)
2267
Paul Bakker539d9722015-02-08 16:18:35 +01002268requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002269run_test "Renego ext: gnutls server strict, client default" \
2270 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2271 "$P_CLI debug_level=3" \
2272 0 \
2273 -c "found renegotiation extension" \
2274 -C "error" \
2275 -c "HTTP/1.0 200 [Oo][Kk]"
2276
Paul Bakker539d9722015-02-08 16:18:35 +01002277requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002278run_test "Renego ext: gnutls server unsafe, client default" \
2279 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2280 "$P_CLI debug_level=3" \
2281 0 \
2282 -C "found renegotiation extension" \
2283 -C "error" \
2284 -c "HTTP/1.0 200 [Oo][Kk]"
2285
Paul Bakker539d9722015-02-08 16:18:35 +01002286requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002287run_test "Renego ext: gnutls server unsafe, client break legacy" \
2288 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2289 "$P_CLI debug_level=3 allow_legacy=-1" \
2290 1 \
2291 -C "found renegotiation extension" \
2292 -c "error" \
2293 -C "HTTP/1.0 200 [Oo][Kk]"
2294
Paul Bakker539d9722015-02-08 16:18:35 +01002295requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002296run_test "Renego ext: gnutls client strict, server default" \
2297 "$P_SRV debug_level=3" \
2298 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2299 0 \
2300 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2301 -s "server hello, secure renegotiation extension"
2302
Paul Bakker539d9722015-02-08 16:18:35 +01002303requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002304run_test "Renego ext: gnutls client unsafe, server default" \
2305 "$P_SRV debug_level=3" \
2306 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2307 0 \
2308 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2309 -S "server hello, secure renegotiation extension"
2310
Paul Bakker539d9722015-02-08 16:18:35 +01002311requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002312run_test "Renego ext: gnutls client unsafe, server break legacy" \
2313 "$P_SRV debug_level=3 allow_legacy=-1" \
2314 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2315 1 \
2316 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2317 -S "server hello, secure renegotiation extension"
2318
Janos Follath0b242342016-02-17 10:11:21 +00002319# Tests for silently dropping trailing extra bytes in .der certificates
2320
2321requires_gnutls
2322run_test "DER format: no trailing bytes" \
2323 "$P_SRV crt_file=data_files/server5-der0.crt \
2324 key_file=data_files/server5.key" \
2325 "$G_CLI " \
2326 0 \
2327 -c "Handshake was completed" \
2328
2329requires_gnutls
2330run_test "DER format: with a trailing zero byte" \
2331 "$P_SRV crt_file=data_files/server5-der1a.crt \
2332 key_file=data_files/server5.key" \
2333 "$G_CLI " \
2334 0 \
2335 -c "Handshake was completed" \
2336
2337requires_gnutls
2338run_test "DER format: with a trailing random byte" \
2339 "$P_SRV crt_file=data_files/server5-der1b.crt \
2340 key_file=data_files/server5.key" \
2341 "$G_CLI " \
2342 0 \
2343 -c "Handshake was completed" \
2344
2345requires_gnutls
2346run_test "DER format: with 2 trailing random bytes" \
2347 "$P_SRV crt_file=data_files/server5-der2.crt \
2348 key_file=data_files/server5.key" \
2349 "$G_CLI " \
2350 0 \
2351 -c "Handshake was completed" \
2352
2353requires_gnutls
2354run_test "DER format: with 4 trailing random bytes" \
2355 "$P_SRV crt_file=data_files/server5-der4.crt \
2356 key_file=data_files/server5.key" \
2357 "$G_CLI " \
2358 0 \
2359 -c "Handshake was completed" \
2360
2361requires_gnutls
2362run_test "DER format: with 8 trailing random bytes" \
2363 "$P_SRV crt_file=data_files/server5-der8.crt \
2364 key_file=data_files/server5.key" \
2365 "$G_CLI " \
2366 0 \
2367 -c "Handshake was completed" \
2368
2369requires_gnutls
2370run_test "DER format: with 9 trailing random bytes" \
2371 "$P_SRV crt_file=data_files/server5-der9.crt \
2372 key_file=data_files/server5.key" \
2373 "$G_CLI " \
2374 0 \
2375 -c "Handshake was completed" \
2376
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002377# Tests for auth_mode
2378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002379run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002380 "$P_SRV crt_file=data_files/server5-badsign.crt \
2381 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002382 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002383 1 \
2384 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002385 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002386 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002387 -c "X509 - Certificate verification failed"
2388
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002389run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002390 "$P_SRV crt_file=data_files/server5-badsign.crt \
2391 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002392 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002393 0 \
2394 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002395 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002396 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002397 -C "X509 - Certificate verification failed"
2398
Hanno Beckere6706e62017-05-15 16:05:15 +01002399run_test "Authentication: server goodcert, client optional, no trusted CA" \
2400 "$P_SRV" \
2401 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2402 0 \
2403 -c "x509_verify_cert() returned" \
2404 -c "! The certificate is not correctly signed by the trusted CA" \
2405 -c "! Certificate verification flags"\
2406 -C "! mbedtls_ssl_handshake returned" \
2407 -C "X509 - Certificate verification failed" \
2408 -C "SSL - No CA Chain is set, but required to operate"
2409
2410run_test "Authentication: server goodcert, client required, no trusted CA" \
2411 "$P_SRV" \
2412 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2413 1 \
2414 -c "x509_verify_cert() returned" \
2415 -c "! The certificate is not correctly signed by the trusted CA" \
2416 -c "! Certificate verification flags"\
2417 -c "! mbedtls_ssl_handshake returned" \
2418 -c "SSL - No CA Chain is set, but required to operate"
2419
2420# The purpose of the next two tests is to test the client's behaviour when receiving a server
2421# certificate with an unsupported elliptic curve. This should usually not happen because
2422# the client informs the server about the supported curves - it does, though, in the
2423# corner case of a static ECDH suite, because the server doesn't check the curve on that
2424# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2425# different means to have the server ignoring the client's supported curve list.
2426
2427requires_config_enabled MBEDTLS_ECP_C
2428run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2429 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2430 crt_file=data_files/server5.ku-ka.crt" \
2431 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2432 1 \
2433 -c "bad certificate (EC key curve)"\
2434 -c "! Certificate verification flags"\
2435 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2436
2437requires_config_enabled MBEDTLS_ECP_C
2438run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2439 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2440 crt_file=data_files/server5.ku-ka.crt" \
2441 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2442 1 \
2443 -c "bad certificate (EC key curve)"\
2444 -c "! Certificate verification flags"\
2445 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002447run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002448 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002449 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002450 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002451 0 \
2452 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002453 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002454 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002455 -C "X509 - Certificate verification failed"
2456
Simon Butcher99000142016-10-13 17:21:01 +01002457run_test "Authentication: client SHA256, server required" \
2458 "$P_SRV auth_mode=required" \
2459 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2460 key_file=data_files/server6.key \
2461 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2462 0 \
2463 -c "Supported Signature Algorithm found: 4," \
2464 -c "Supported Signature Algorithm found: 5,"
2465
2466run_test "Authentication: client SHA384, server required" \
2467 "$P_SRV auth_mode=required" \
2468 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2469 key_file=data_files/server6.key \
2470 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2471 0 \
2472 -c "Supported Signature Algorithm found: 4," \
2473 -c "Supported Signature Algorithm found: 5,"
2474
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002475requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2476run_test "Authentication: client has no cert, server required (SSLv3)" \
2477 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2478 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2479 key_file=data_files/server5.key" \
2480 1 \
2481 -S "skip write certificate request" \
2482 -C "skip parse certificate request" \
2483 -c "got a certificate request" \
2484 -c "got no certificate to send" \
2485 -S "x509_verify_cert() returned" \
2486 -s "client has no certificate" \
2487 -s "! mbedtls_ssl_handshake returned" \
2488 -c "! mbedtls_ssl_handshake returned" \
2489 -s "No client certification received from the client, but required by the authentication mode"
2490
2491run_test "Authentication: client has no cert, server required (TLS)" \
2492 "$P_SRV debug_level=3 auth_mode=required" \
2493 "$P_CLI debug_level=3 crt_file=none \
2494 key_file=data_files/server5.key" \
2495 1 \
2496 -S "skip write certificate request" \
2497 -C "skip parse certificate request" \
2498 -c "got a certificate request" \
2499 -c "= write certificate$" \
2500 -C "skip write certificate$" \
2501 -S "x509_verify_cert() returned" \
2502 -s "client has no certificate" \
2503 -s "! mbedtls_ssl_handshake returned" \
2504 -c "! mbedtls_ssl_handshake returned" \
2505 -s "No client certification received from the client, but required by the authentication mode"
2506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002507run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002508 "$P_SRV debug_level=3 auth_mode=required" \
2509 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002510 key_file=data_files/server5.key" \
2511 1 \
2512 -S "skip write certificate request" \
2513 -C "skip parse certificate request" \
2514 -c "got a certificate request" \
2515 -C "skip write certificate" \
2516 -C "skip write certificate verify" \
2517 -S "skip parse certificate verify" \
2518 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002519 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002520 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002521 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002522 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002523 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002524# We don't check that the client receives the alert because it might
2525# detect that its write end of the connection is closed and abort
2526# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002527
Janos Follath89baba22017-04-10 14:34:35 +01002528run_test "Authentication: client cert not trusted, server required" \
2529 "$P_SRV debug_level=3 auth_mode=required" \
2530 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2531 key_file=data_files/server5.key" \
2532 1 \
2533 -S "skip write certificate request" \
2534 -C "skip parse certificate request" \
2535 -c "got a certificate request" \
2536 -C "skip write certificate" \
2537 -C "skip write certificate verify" \
2538 -S "skip parse certificate verify" \
2539 -s "x509_verify_cert() returned" \
2540 -s "! The certificate is not correctly signed by the trusted CA" \
2541 -s "! mbedtls_ssl_handshake returned" \
2542 -c "! mbedtls_ssl_handshake returned" \
2543 -s "X509 - Certificate verification failed"
2544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002545run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002546 "$P_SRV debug_level=3 auth_mode=optional" \
2547 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002548 key_file=data_files/server5.key" \
2549 0 \
2550 -S "skip write certificate request" \
2551 -C "skip parse certificate request" \
2552 -c "got a certificate request" \
2553 -C "skip write certificate" \
2554 -C "skip write certificate verify" \
2555 -S "skip parse certificate verify" \
2556 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002557 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002558 -S "! mbedtls_ssl_handshake returned" \
2559 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002560 -S "X509 - Certificate verification failed"
2561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002562run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002563 "$P_SRV debug_level=3 auth_mode=none" \
2564 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002565 key_file=data_files/server5.key" \
2566 0 \
2567 -s "skip write certificate request" \
2568 -C "skip parse certificate request" \
2569 -c "got no certificate request" \
2570 -c "skip write certificate" \
2571 -c "skip write certificate verify" \
2572 -s "skip parse certificate verify" \
2573 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002574 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002575 -S "! mbedtls_ssl_handshake returned" \
2576 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002577 -S "X509 - Certificate verification failed"
2578
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002579run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002580 "$P_SRV debug_level=3 auth_mode=optional" \
2581 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002582 0 \
2583 -S "skip write certificate request" \
2584 -C "skip parse certificate request" \
2585 -c "got a certificate request" \
2586 -C "skip write certificate$" \
2587 -C "got no certificate to send" \
2588 -S "SSLv3 client has no certificate" \
2589 -c "skip write certificate verify" \
2590 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002591 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002592 -S "! mbedtls_ssl_handshake returned" \
2593 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002594 -S "X509 - Certificate verification failed"
2595
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002596run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002597 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002598 "$O_CLI" \
2599 0 \
2600 -S "skip write certificate request" \
2601 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002602 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002603 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002604 -S "X509 - Certificate verification failed"
2605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002606run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002607 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002608 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002609 0 \
2610 -C "skip parse certificate request" \
2611 -c "got a certificate request" \
2612 -C "skip write certificate$" \
2613 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002614 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002615
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002616run_test "Authentication: client no cert, openssl server required" \
2617 "$O_SRV -Verify 10" \
2618 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2619 1 \
2620 -C "skip parse certificate request" \
2621 -c "got a certificate request" \
2622 -C "skip write certificate$" \
2623 -c "skip write certificate verify" \
2624 -c "! mbedtls_ssl_handshake returned"
2625
Janos Follathe2681a42016-03-07 15:57:05 +00002626requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002627run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002628 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002629 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002630 0 \
2631 -S "skip write certificate request" \
2632 -C "skip parse certificate request" \
2633 -c "got a certificate request" \
2634 -C "skip write certificate$" \
2635 -c "skip write certificate verify" \
2636 -c "got no certificate to send" \
2637 -s "SSLv3 client has no certificate" \
2638 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002639 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002640 -S "! mbedtls_ssl_handshake returned" \
2641 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002642 -S "X509 - Certificate verification failed"
2643
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002644# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2645# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002646
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002647MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002648MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002649
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002650if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Gilles Peskine352a7cf2020-08-26 20:05:11 +02002651 cat <<EOF
2652${CONFIG_H} contains a value for the configuration of
2653MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script's
2654test value of ${MAX_IM_CA}.
Simon Butcher06b78632017-07-28 01:00:17 +01002655
Gilles Peskine352a7cf2020-08-26 20:05:11 +02002656The tests assume this value and if it changes, the tests in this
2657script should also be adjusted.
2658EOF
Simon Butcher06b78632017-07-28 01:00:17 +01002659 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002660fi
2661
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002662run_test "Authentication: server max_int chain, client default" \
2663 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2664 key_file=data_files/dir-maxpath/09.key" \
2665 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2666 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002667 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002668
2669run_test "Authentication: server max_int+1 chain, client default" \
2670 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2671 key_file=data_files/dir-maxpath/10.key" \
2672 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2673 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002674 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002675
2676run_test "Authentication: server max_int+1 chain, client optional" \
2677 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2678 key_file=data_files/dir-maxpath/10.key" \
2679 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2680 auth_mode=optional" \
2681 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002682 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002683
2684run_test "Authentication: server max_int+1 chain, client none" \
2685 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2686 key_file=data_files/dir-maxpath/10.key" \
2687 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2688 auth_mode=none" \
2689 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002690 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002691
2692run_test "Authentication: client max_int+1 chain, server default" \
2693 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2694 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2695 key_file=data_files/dir-maxpath/10.key" \
2696 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002697 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002698
2699run_test "Authentication: client max_int+1 chain, server optional" \
2700 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2701 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2702 key_file=data_files/dir-maxpath/10.key" \
2703 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002704 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002705
2706run_test "Authentication: client max_int+1 chain, server required" \
2707 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2708 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2709 key_file=data_files/dir-maxpath/10.key" \
2710 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002711 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002712
2713run_test "Authentication: client max_int chain, server required" \
2714 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2715 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2716 key_file=data_files/dir-maxpath/09.key" \
2717 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002718 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002719
Janos Follath89baba22017-04-10 14:34:35 +01002720# Tests for CA list in CertificateRequest messages
2721
2722run_test "Authentication: send CA list in CertificateRequest (default)" \
2723 "$P_SRV debug_level=3 auth_mode=required" \
2724 "$P_CLI crt_file=data_files/server6.crt \
2725 key_file=data_files/server6.key" \
2726 0 \
2727 -s "requested DN"
2728
2729run_test "Authentication: do not send CA list in CertificateRequest" \
2730 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2731 "$P_CLI crt_file=data_files/server6.crt \
2732 key_file=data_files/server6.key" \
2733 0 \
2734 -S "requested DN"
2735
2736run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2737 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2738 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2739 key_file=data_files/server5.key" \
2740 1 \
2741 -S "requested DN" \
2742 -s "x509_verify_cert() returned" \
2743 -s "! The certificate is not correctly signed by the trusted CA" \
2744 -s "! mbedtls_ssl_handshake returned" \
2745 -c "! mbedtls_ssl_handshake returned" \
2746 -s "X509 - Certificate verification failed"
2747
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002748# Tests for certificate selection based on SHA verson
2749
2750run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2751 "$P_SRV crt_file=data_files/server5.crt \
2752 key_file=data_files/server5.key \
2753 crt_file2=data_files/server5-sha1.crt \
2754 key_file2=data_files/server5.key" \
2755 "$P_CLI force_version=tls1_2" \
2756 0 \
2757 -c "signed using.*ECDSA with SHA256" \
2758 -C "signed using.*ECDSA with SHA1"
2759
2760run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2761 "$P_SRV crt_file=data_files/server5.crt \
2762 key_file=data_files/server5.key \
2763 crt_file2=data_files/server5-sha1.crt \
2764 key_file2=data_files/server5.key" \
2765 "$P_CLI force_version=tls1_1" \
2766 0 \
2767 -C "signed using.*ECDSA with SHA256" \
2768 -c "signed using.*ECDSA with SHA1"
2769
2770run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2771 "$P_SRV crt_file=data_files/server5.crt \
2772 key_file=data_files/server5.key \
2773 crt_file2=data_files/server5-sha1.crt \
2774 key_file2=data_files/server5.key" \
2775 "$P_CLI force_version=tls1" \
2776 0 \
2777 -C "signed using.*ECDSA with SHA256" \
2778 -c "signed using.*ECDSA with SHA1"
2779
2780run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2781 "$P_SRV crt_file=data_files/server5.crt \
2782 key_file=data_files/server5.key \
2783 crt_file2=data_files/server6.crt \
2784 key_file2=data_files/server6.key" \
2785 "$P_CLI force_version=tls1_1" \
2786 0 \
2787 -c "serial number.*09" \
2788 -c "signed using.*ECDSA with SHA256" \
2789 -C "signed using.*ECDSA with SHA1"
2790
2791run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2792 "$P_SRV crt_file=data_files/server6.crt \
2793 key_file=data_files/server6.key \
2794 crt_file2=data_files/server5.crt \
2795 key_file2=data_files/server5.key" \
2796 "$P_CLI force_version=tls1_1" \
2797 0 \
2798 -c "serial number.*0A" \
2799 -c "signed using.*ECDSA with SHA256" \
2800 -C "signed using.*ECDSA with SHA1"
2801
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002802# tests for SNI
2803
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002804run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002805 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002806 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002807 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002808 0 \
2809 -S "parse ServerName extension" \
2810 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2811 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002812
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002813run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002814 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002815 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002816 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 +02002817 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002818 0 \
2819 -s "parse ServerName extension" \
2820 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2821 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002823run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002824 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002825 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002826 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 +02002827 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002828 0 \
2829 -s "parse ServerName extension" \
2830 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2831 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002833run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002834 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002835 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002836 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 +02002837 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002838 1 \
2839 -s "parse ServerName extension" \
2840 -s "ssl_sni_wrapper() returned" \
2841 -s "mbedtls_ssl_handshake returned" \
2842 -c "mbedtls_ssl_handshake returned" \
2843 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002844
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002845run_test "SNI: client auth no override: optional" \
2846 "$P_SRV debug_level=3 auth_mode=optional \
2847 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2848 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2849 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002850 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002851 -S "skip write certificate request" \
2852 -C "skip parse certificate request" \
2853 -c "got a certificate request" \
2854 -C "skip write certificate" \
2855 -C "skip write certificate verify" \
2856 -S "skip parse certificate verify"
2857
2858run_test "SNI: client auth override: none -> optional" \
2859 "$P_SRV debug_level=3 auth_mode=none \
2860 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2861 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2862 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002863 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002864 -S "skip write certificate request" \
2865 -C "skip parse certificate request" \
2866 -c "got a certificate request" \
2867 -C "skip write certificate" \
2868 -C "skip write certificate verify" \
2869 -S "skip parse certificate verify"
2870
2871run_test "SNI: client auth override: optional -> none" \
2872 "$P_SRV debug_level=3 auth_mode=optional \
2873 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2874 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2875 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002876 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002877 -s "skip write certificate request" \
2878 -C "skip parse certificate request" \
2879 -c "got no certificate request" \
2880 -c "skip write certificate" \
2881 -c "skip write certificate verify" \
2882 -s "skip parse certificate verify"
2883
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002884run_test "SNI: CA no override" \
2885 "$P_SRV debug_level=3 auth_mode=optional \
2886 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2887 ca_file=data_files/test-ca.crt \
2888 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2889 "$P_CLI debug_level=3 server_name=localhost \
2890 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2891 1 \
2892 -S "skip write certificate request" \
2893 -C "skip parse certificate request" \
2894 -c "got a certificate request" \
2895 -C "skip write certificate" \
2896 -C "skip write certificate verify" \
2897 -S "skip parse certificate verify" \
2898 -s "x509_verify_cert() returned" \
2899 -s "! The certificate is not correctly signed by the trusted CA" \
2900 -S "The certificate has been revoked (is on a CRL)"
2901
2902run_test "SNI: CA override" \
2903 "$P_SRV debug_level=3 auth_mode=optional \
2904 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2905 ca_file=data_files/test-ca.crt \
2906 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2907 "$P_CLI debug_level=3 server_name=localhost \
2908 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2909 0 \
2910 -S "skip write certificate request" \
2911 -C "skip parse certificate request" \
2912 -c "got a certificate request" \
2913 -C "skip write certificate" \
2914 -C "skip write certificate verify" \
2915 -S "skip parse certificate verify" \
2916 -S "x509_verify_cert() returned" \
2917 -S "! The certificate is not correctly signed by the trusted CA" \
2918 -S "The certificate has been revoked (is on a CRL)"
2919
2920run_test "SNI: CA override with CRL" \
2921 "$P_SRV debug_level=3 auth_mode=optional \
2922 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2923 ca_file=data_files/test-ca.crt \
2924 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2925 "$P_CLI debug_level=3 server_name=localhost \
2926 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2927 1 \
2928 -S "skip write certificate request" \
2929 -C "skip parse certificate request" \
2930 -c "got a certificate request" \
2931 -C "skip write certificate" \
2932 -C "skip write certificate verify" \
2933 -S "skip parse certificate verify" \
2934 -s "x509_verify_cert() returned" \
2935 -S "! The certificate is not correctly signed by the trusted CA" \
2936 -s "The certificate has been revoked (is on a CRL)"
2937
Andres AGe8b07742016-12-07 10:01:30 +00002938# Tests for SNI and DTLS
2939
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002940run_test "SNI: DTLS, no SNI callback" \
2941 "$P_SRV debug_level=3 dtls=1 \
2942 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2943 "$P_CLI server_name=localhost dtls=1" \
2944 0 \
2945 -S "parse ServerName extension" \
2946 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2947 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2948
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002949run_test "SNI: DTLS, matching cert 1" \
Andres AGe8b07742016-12-07 10:01:30 +00002950 "$P_SRV debug_level=3 dtls=1 \
2951 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2952 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2953 "$P_CLI server_name=localhost dtls=1" \
2954 0 \
2955 -s "parse ServerName extension" \
2956 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2957 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2958
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002959run_test "SNI: DTLS, matching cert 2" \
2960 "$P_SRV debug_level=3 dtls=1 \
2961 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2962 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2963 "$P_CLI server_name=polarssl.example dtls=1" \
2964 0 \
2965 -s "parse ServerName extension" \
2966 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2967 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2968
2969run_test "SNI: DTLS, no matching cert" \
2970 "$P_SRV debug_level=3 dtls=1 \
2971 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2972 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2973 "$P_CLI server_name=nonesuch.example dtls=1" \
2974 1 \
2975 -s "parse ServerName extension" \
2976 -s "ssl_sni_wrapper() returned" \
2977 -s "mbedtls_ssl_handshake returned" \
2978 -c "mbedtls_ssl_handshake returned" \
2979 -c "SSL - A fatal alert message was received from our peer"
2980
2981run_test "SNI: DTLS, client auth no override: optional" \
2982 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2983 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2984 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2985 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2986 0 \
2987 -S "skip write certificate request" \
2988 -C "skip parse certificate request" \
2989 -c "got a certificate request" \
2990 -C "skip write certificate" \
2991 -C "skip write certificate verify" \
2992 -S "skip parse certificate verify"
2993
2994run_test "SNI: DTLS, client auth override: none -> optional" \
2995 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2996 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2997 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2998 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2999 0 \
3000 -S "skip write certificate request" \
3001 -C "skip parse certificate request" \
3002 -c "got a certificate request" \
3003 -C "skip write certificate" \
3004 -C "skip write certificate verify" \
3005 -S "skip parse certificate verify"
3006
3007run_test "SNI: DTLS, client auth override: optional -> none" \
3008 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3009 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3010 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3011 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3012 0 \
3013 -s "skip write certificate request" \
3014 -C "skip parse certificate request" \
3015 -c "got no certificate request" \
3016 -c "skip write certificate" \
3017 -c "skip write certificate verify" \
3018 -s "skip parse certificate verify"
3019
3020run_test "SNI: DTLS, CA no override" \
3021 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3022 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3023 ca_file=data_files/test-ca.crt \
3024 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3025 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3026 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3027 1 \
3028 -S "skip write certificate request" \
3029 -C "skip parse certificate request" \
3030 -c "got a certificate request" \
3031 -C "skip write certificate" \
3032 -C "skip write certificate verify" \
3033 -S "skip parse certificate verify" \
3034 -s "x509_verify_cert() returned" \
3035 -s "! The certificate is not correctly signed by the trusted CA" \
3036 -S "The certificate has been revoked (is on a CRL)"
3037
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01003038run_test "SNI: DTLS, CA override" \
Andres AGe8b07742016-12-07 10:01:30 +00003039 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3040 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3041 ca_file=data_files/test-ca.crt \
3042 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3043 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3044 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3045 0 \
3046 -S "skip write certificate request" \
3047 -C "skip parse certificate request" \
3048 -c "got a certificate request" \
3049 -C "skip write certificate" \
3050 -C "skip write certificate verify" \
3051 -S "skip parse certificate verify" \
3052 -S "x509_verify_cert() returned" \
3053 -S "! The certificate is not correctly signed by the trusted CA" \
3054 -S "The certificate has been revoked (is on a CRL)"
3055
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01003056run_test "SNI: DTLS, CA override with CRL" \
Andres AGe8b07742016-12-07 10:01:30 +00003057 "$P_SRV debug_level=3 auth_mode=optional \
3058 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3059 ca_file=data_files/test-ca.crt \
3060 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3061 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3062 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3063 1 \
3064 -S "skip write certificate request" \
3065 -C "skip parse certificate request" \
3066 -c "got a certificate request" \
3067 -C "skip write certificate" \
3068 -C "skip write certificate verify" \
3069 -S "skip parse certificate verify" \
3070 -s "x509_verify_cert() returned" \
3071 -S "! The certificate is not correctly signed by the trusted CA" \
3072 -s "The certificate has been revoked (is on a CRL)"
3073
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003074# Tests for non-blocking I/O: exercise a variety of handshake flows
3075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003076run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003077 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3078 "$P_CLI nbio=2 tickets=0" \
3079 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003080 -S "mbedtls_ssl_handshake returned" \
3081 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003082 -c "Read from server: .* bytes read"
3083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003084run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003085 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3086 "$P_CLI nbio=2 tickets=0" \
3087 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003088 -S "mbedtls_ssl_handshake returned" \
3089 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003090 -c "Read from server: .* bytes read"
3091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003092run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003093 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3094 "$P_CLI nbio=2 tickets=1" \
3095 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003096 -S "mbedtls_ssl_handshake returned" \
3097 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003098 -c "Read from server: .* bytes read"
3099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003100run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003101 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3102 "$P_CLI nbio=2 tickets=1" \
3103 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003104 -S "mbedtls_ssl_handshake returned" \
3105 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003106 -c "Read from server: .* bytes read"
3107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003108run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003109 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3110 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3111 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003112 -S "mbedtls_ssl_handshake returned" \
3113 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003114 -c "Read from server: .* bytes read"
3115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003116run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003117 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3118 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3119 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003120 -S "mbedtls_ssl_handshake returned" \
3121 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003122 -c "Read from server: .* bytes read"
3123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003124run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003125 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3126 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3127 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003128 -S "mbedtls_ssl_handshake returned" \
3129 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003130 -c "Read from server: .* bytes read"
3131
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003132# Tests for version negotiation
3133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003134run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003135 "$P_SRV" \
3136 "$P_CLI" \
3137 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003138 -S "mbedtls_ssl_handshake returned" \
3139 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003140 -s "Protocol is TLSv1.2" \
3141 -c "Protocol is TLSv1.2"
3142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003143run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003144 "$P_SRV" \
3145 "$P_CLI max_version=tls1_1" \
3146 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003147 -S "mbedtls_ssl_handshake returned" \
3148 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003149 -s "Protocol is TLSv1.1" \
3150 -c "Protocol is TLSv1.1"
3151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003152run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003153 "$P_SRV max_version=tls1_1" \
3154 "$P_CLI" \
3155 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003156 -S "mbedtls_ssl_handshake returned" \
3157 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003158 -s "Protocol is TLSv1.1" \
3159 -c "Protocol is TLSv1.1"
3160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003161run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003162 "$P_SRV max_version=tls1_1" \
3163 "$P_CLI max_version=tls1_1" \
3164 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003165 -S "mbedtls_ssl_handshake returned" \
3166 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003167 -s "Protocol is TLSv1.1" \
3168 -c "Protocol is TLSv1.1"
3169
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003170run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003171 "$P_SRV min_version=tls1_1" \
3172 "$P_CLI max_version=tls1_1" \
3173 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003174 -S "mbedtls_ssl_handshake returned" \
3175 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003176 -s "Protocol is TLSv1.1" \
3177 -c "Protocol is TLSv1.1"
3178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003179run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003180 "$P_SRV max_version=tls1_1" \
3181 "$P_CLI min_version=tls1_1" \
3182 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003183 -S "mbedtls_ssl_handshake returned" \
3184 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003185 -s "Protocol is TLSv1.1" \
3186 -c "Protocol is TLSv1.1"
3187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003188run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003189 "$P_SRV max_version=tls1_1" \
3190 "$P_CLI min_version=tls1_2" \
3191 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003192 -s "mbedtls_ssl_handshake returned" \
3193 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003194 -c "SSL - Handshake protocol not within min/max boundaries"
3195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003196run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003197 "$P_SRV min_version=tls1_2" \
3198 "$P_CLI max_version=tls1_1" \
3199 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003200 -s "mbedtls_ssl_handshake returned" \
3201 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003202 -s "SSL - Handshake protocol not within min/max boundaries"
3203
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003204# Tests for ALPN extension
3205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003206run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003207 "$P_SRV debug_level=3" \
3208 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003209 0 \
3210 -C "client hello, adding alpn extension" \
3211 -S "found alpn extension" \
3212 -C "got an alert message, type: \\[2:120]" \
3213 -S "server hello, adding alpn extension" \
3214 -C "found alpn extension " \
3215 -C "Application Layer Protocol is" \
3216 -S "Application Layer Protocol is"
3217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003218run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003219 "$P_SRV debug_level=3" \
3220 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003221 0 \
3222 -c "client hello, adding alpn extension" \
3223 -s "found alpn extension" \
3224 -C "got an alert message, type: \\[2:120]" \
3225 -S "server hello, adding alpn extension" \
3226 -C "found alpn extension " \
3227 -c "Application Layer Protocol is (none)" \
3228 -S "Application Layer Protocol is"
3229
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003230run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003231 "$P_SRV debug_level=3 alpn=abc,1234" \
3232 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003233 0 \
3234 -C "client hello, adding alpn extension" \
3235 -S "found alpn extension" \
3236 -C "got an alert message, type: \\[2:120]" \
3237 -S "server hello, adding alpn extension" \
3238 -C "found alpn extension " \
3239 -C "Application Layer Protocol is" \
3240 -s "Application Layer Protocol is (none)"
3241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003242run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003243 "$P_SRV debug_level=3 alpn=abc,1234" \
3244 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003245 0 \
3246 -c "client hello, adding alpn extension" \
3247 -s "found alpn extension" \
3248 -C "got an alert message, type: \\[2:120]" \
3249 -s "server hello, adding alpn extension" \
3250 -c "found alpn extension" \
3251 -c "Application Layer Protocol is abc" \
3252 -s "Application Layer Protocol is abc"
3253
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003254run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003255 "$P_SRV debug_level=3 alpn=abc,1234" \
3256 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003257 0 \
3258 -c "client hello, adding alpn extension" \
3259 -s "found alpn extension" \
3260 -C "got an alert message, type: \\[2:120]" \
3261 -s "server hello, adding alpn extension" \
3262 -c "found alpn extension" \
3263 -c "Application Layer Protocol is abc" \
3264 -s "Application Layer Protocol is abc"
3265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003266run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003267 "$P_SRV debug_level=3 alpn=abc,1234" \
3268 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003269 0 \
3270 -c "client hello, adding alpn extension" \
3271 -s "found alpn extension" \
3272 -C "got an alert message, type: \\[2:120]" \
3273 -s "server hello, adding alpn extension" \
3274 -c "found alpn extension" \
3275 -c "Application Layer Protocol is 1234" \
3276 -s "Application Layer Protocol is 1234"
3277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003278run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003279 "$P_SRV debug_level=3 alpn=abc,123" \
3280 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003281 1 \
3282 -c "client hello, adding alpn extension" \
3283 -s "found alpn extension" \
3284 -c "got an alert message, type: \\[2:120]" \
3285 -S "server hello, adding alpn extension" \
3286 -C "found alpn extension" \
3287 -C "Application Layer Protocol is 1234" \
3288 -S "Application Layer Protocol is 1234"
3289
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003290
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003291# Tests for keyUsage in leaf certificates, part 1:
3292# server-side certificate/suite selection
3293
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003294run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003295 "$P_SRV key_file=data_files/server2.key \
3296 crt_file=data_files/server2.ku-ds.crt" \
3297 "$P_CLI" \
3298 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003299 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003300
3301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003302run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003303 "$P_SRV key_file=data_files/server2.key \
3304 crt_file=data_files/server2.ku-ke.crt" \
3305 "$P_CLI" \
3306 0 \
3307 -c "Ciphersuite is TLS-RSA-WITH-"
3308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003309run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003310 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003311 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003312 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003313 1 \
3314 -C "Ciphersuite is "
3315
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003316run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003317 "$P_SRV key_file=data_files/server5.key \
3318 crt_file=data_files/server5.ku-ds.crt" \
3319 "$P_CLI" \
3320 0 \
3321 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3322
3323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003324run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003325 "$P_SRV key_file=data_files/server5.key \
3326 crt_file=data_files/server5.ku-ka.crt" \
3327 "$P_CLI" \
3328 0 \
3329 -c "Ciphersuite is TLS-ECDH-"
3330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003331run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003332 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003333 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003334 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003335 1 \
3336 -C "Ciphersuite is "
3337
3338# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003339# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003341run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003342 "$O_SRV -key data_files/server2.key \
3343 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003344 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003345 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3346 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003347 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003348 -C "Processing of the Certificate handshake message failed" \
3349 -c "Ciphersuite is TLS-"
3350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003351run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003352 "$O_SRV -key data_files/server2.key \
3353 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003354 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003355 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3356 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003357 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003358 -C "Processing of the Certificate handshake message failed" \
3359 -c "Ciphersuite is TLS-"
3360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003361run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003362 "$O_SRV -key data_files/server2.key \
3363 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003364 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003365 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3366 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003367 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003368 -C "Processing of the Certificate handshake message failed" \
3369 -c "Ciphersuite is TLS-"
3370
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003371run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003372 "$O_SRV -key data_files/server2.key \
3373 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003374 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003375 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3376 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003377 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003378 -c "Processing of the Certificate handshake message failed" \
3379 -C "Ciphersuite is TLS-"
3380
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003381run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3382 "$O_SRV -key data_files/server2.key \
3383 -cert data_files/server2.ku-ke.crt" \
3384 "$P_CLI debug_level=1 auth_mode=optional \
3385 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3386 0 \
3387 -c "bad certificate (usage extensions)" \
3388 -C "Processing of the Certificate handshake message failed" \
3389 -c "Ciphersuite is TLS-" \
3390 -c "! Usage does not match the keyUsage extension"
3391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003392run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003393 "$O_SRV -key data_files/server2.key \
3394 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003395 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003396 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3397 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003398 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003399 -C "Processing of the Certificate handshake message failed" \
3400 -c "Ciphersuite is TLS-"
3401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003402run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003403 "$O_SRV -key data_files/server2.key \
3404 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003405 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003406 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3407 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003408 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003409 -c "Processing of the Certificate handshake message failed" \
3410 -C "Ciphersuite is TLS-"
3411
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003412run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3413 "$O_SRV -key data_files/server2.key \
3414 -cert data_files/server2.ku-ds.crt" \
3415 "$P_CLI debug_level=1 auth_mode=optional \
3416 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3417 0 \
3418 -c "bad certificate (usage extensions)" \
3419 -C "Processing of the Certificate handshake message failed" \
3420 -c "Ciphersuite is TLS-" \
3421 -c "! Usage does not match the keyUsage extension"
3422
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003423# Tests for keyUsage in leaf certificates, part 3:
3424# server-side checking of client cert
3425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003426run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003427 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003428 "$O_CLI -key data_files/server2.key \
3429 -cert data_files/server2.ku-ds.crt" \
3430 0 \
3431 -S "bad certificate (usage extensions)" \
3432 -S "Processing of the Certificate handshake message failed"
3433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003434run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003435 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003436 "$O_CLI -key data_files/server2.key \
3437 -cert data_files/server2.ku-ke.crt" \
3438 0 \
3439 -s "bad certificate (usage extensions)" \
3440 -S "Processing of the Certificate handshake message failed"
3441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003442run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003443 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003444 "$O_CLI -key data_files/server2.key \
3445 -cert data_files/server2.ku-ke.crt" \
3446 1 \
3447 -s "bad certificate (usage extensions)" \
3448 -s "Processing of the Certificate handshake message failed"
3449
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003450run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003451 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003452 "$O_CLI -key data_files/server5.key \
3453 -cert data_files/server5.ku-ds.crt" \
3454 0 \
3455 -S "bad certificate (usage extensions)" \
3456 -S "Processing of the Certificate handshake message failed"
3457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003458run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003459 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003460 "$O_CLI -key data_files/server5.key \
3461 -cert data_files/server5.ku-ka.crt" \
3462 0 \
3463 -s "bad certificate (usage extensions)" \
3464 -S "Processing of the Certificate handshake message failed"
3465
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003466# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003468run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003469 "$P_SRV key_file=data_files/server5.key \
3470 crt_file=data_files/server5.eku-srv.crt" \
3471 "$P_CLI" \
3472 0
3473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003474run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003475 "$P_SRV key_file=data_files/server5.key \
3476 crt_file=data_files/server5.eku-srv.crt" \
3477 "$P_CLI" \
3478 0
3479
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003480run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003481 "$P_SRV key_file=data_files/server5.key \
3482 crt_file=data_files/server5.eku-cs_any.crt" \
3483 "$P_CLI" \
3484 0
3485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003486run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003487 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003488 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003489 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003490 1
3491
3492# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003494run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003495 "$O_SRV -key data_files/server5.key \
3496 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003497 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003498 0 \
3499 -C "bad certificate (usage extensions)" \
3500 -C "Processing of the Certificate handshake message failed" \
3501 -c "Ciphersuite is TLS-"
3502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003503run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003504 "$O_SRV -key data_files/server5.key \
3505 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003506 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003507 0 \
3508 -C "bad certificate (usage extensions)" \
3509 -C "Processing of the Certificate handshake message failed" \
3510 -c "Ciphersuite is TLS-"
3511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003512run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003513 "$O_SRV -key data_files/server5.key \
3514 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003515 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003516 0 \
3517 -C "bad certificate (usage extensions)" \
3518 -C "Processing of the Certificate handshake message failed" \
3519 -c "Ciphersuite is TLS-"
3520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003521run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003522 "$O_SRV -key data_files/server5.key \
3523 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003524 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003525 1 \
3526 -c "bad certificate (usage extensions)" \
3527 -c "Processing of the Certificate handshake message failed" \
3528 -C "Ciphersuite is TLS-"
3529
3530# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003532run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003533 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003534 "$O_CLI -key data_files/server5.key \
3535 -cert data_files/server5.eku-cli.crt" \
3536 0 \
3537 -S "bad certificate (usage extensions)" \
3538 -S "Processing of the Certificate handshake message failed"
3539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003540run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003541 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003542 "$O_CLI -key data_files/server5.key \
3543 -cert data_files/server5.eku-srv_cli.crt" \
3544 0 \
3545 -S "bad certificate (usage extensions)" \
3546 -S "Processing of the Certificate handshake message failed"
3547
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003548run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003549 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003550 "$O_CLI -key data_files/server5.key \
3551 -cert data_files/server5.eku-cs_any.crt" \
3552 0 \
3553 -S "bad certificate (usage extensions)" \
3554 -S "Processing of the Certificate handshake message failed"
3555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003556run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003557 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003558 "$O_CLI -key data_files/server5.key \
3559 -cert data_files/server5.eku-cs.crt" \
3560 0 \
3561 -s "bad certificate (usage extensions)" \
3562 -S "Processing of the Certificate handshake message failed"
3563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003564run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003565 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003566 "$O_CLI -key data_files/server5.key \
3567 -cert data_files/server5.eku-cs.crt" \
3568 1 \
3569 -s "bad certificate (usage extensions)" \
3570 -s "Processing of the Certificate handshake message failed"
3571
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003572# Tests for DHM parameters loading
3573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003574run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003575 "$P_SRV" \
3576 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3577 debug_level=3" \
3578 0 \
3579 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003580 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003582run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003583 "$P_SRV dhm_file=data_files/dhparams.pem" \
3584 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3585 debug_level=3" \
3586 0 \
3587 -c "value of 'DHM: P ' (1024 bits)" \
3588 -c "value of 'DHM: G ' (2 bits)"
3589
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003590# Tests for DHM client-side size checking
3591
3592run_test "DHM size: server default, client default, OK" \
3593 "$P_SRV" \
3594 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3595 debug_level=1" \
3596 0 \
3597 -C "DHM prime too short:"
3598
3599run_test "DHM size: server default, client 2048, OK" \
3600 "$P_SRV" \
3601 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3602 debug_level=1 dhmlen=2048" \
3603 0 \
3604 -C "DHM prime too short:"
3605
3606run_test "DHM size: server 1024, client default, OK" \
3607 "$P_SRV dhm_file=data_files/dhparams.pem" \
3608 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3609 debug_level=1" \
3610 0 \
3611 -C "DHM prime too short:"
3612
3613run_test "DHM size: server 1000, client default, rejected" \
3614 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3615 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3616 debug_level=1" \
3617 1 \
3618 -c "DHM prime too short:"
3619
3620run_test "DHM size: server default, client 2049, rejected" \
3621 "$P_SRV" \
3622 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3623 debug_level=1 dhmlen=2049" \
3624 1 \
3625 -c "DHM prime too short:"
3626
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003627# Tests for PSK callback
3628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003629run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003630 "$P_SRV psk=abc123 psk_identity=foo" \
3631 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3632 psk_identity=foo psk=abc123" \
3633 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003634 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003635 -S "SSL - Unknown identity received" \
3636 -S "SSL - Verification of the message MAC failed"
3637
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003638run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003639 "$P_SRV" \
3640 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3641 psk_identity=foo psk=abc123" \
3642 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003643 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003644 -S "SSL - Unknown identity received" \
3645 -S "SSL - Verification of the message MAC failed"
3646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003647run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003648 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3649 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3650 psk_identity=foo psk=abc123" \
3651 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003652 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003653 -s "SSL - Unknown identity received" \
3654 -S "SSL - Verification of the message MAC failed"
3655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003656run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003657 "$P_SRV psk_list=abc,dead,def,beef" \
3658 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3659 psk_identity=abc psk=dead" \
3660 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003661 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003662 -S "SSL - Unknown identity received" \
3663 -S "SSL - Verification of the message MAC failed"
3664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003665run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003666 "$P_SRV psk_list=abc,dead,def,beef" \
3667 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3668 psk_identity=def psk=beef" \
3669 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003670 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003671 -S "SSL - Unknown identity received" \
3672 -S "SSL - Verification of the message MAC failed"
3673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003674run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003675 "$P_SRV psk_list=abc,dead,def,beef" \
3676 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3677 psk_identity=ghi psk=beef" \
3678 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003679 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003680 -s "SSL - Unknown identity received" \
3681 -S "SSL - Verification of the message MAC failed"
3682
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003683run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003684 "$P_SRV psk_list=abc,dead,def,beef" \
3685 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3686 psk_identity=abc psk=beef" \
3687 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003688 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003689 -S "SSL - Unknown identity received" \
3690 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003691
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003692# Tests for EC J-PAKE
3693
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003694requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003695run_test "ECJPAKE: client not configured" \
3696 "$P_SRV debug_level=3" \
3697 "$P_CLI debug_level=3" \
3698 0 \
3699 -C "add ciphersuite: c0ff" \
3700 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003701 -S "found ecjpake kkpp extension" \
3702 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003703 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003704 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003705 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003706 -S "None of the common ciphersuites is usable"
3707
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003708requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003709run_test "ECJPAKE: server not configured" \
3710 "$P_SRV debug_level=3" \
3711 "$P_CLI debug_level=3 ecjpake_pw=bla \
3712 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3713 1 \
3714 -c "add ciphersuite: c0ff" \
3715 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003716 -s "found ecjpake kkpp extension" \
3717 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003718 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003719 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003720 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003721 -s "None of the common ciphersuites is usable"
3722
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003723requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003724run_test "ECJPAKE: working, TLS" \
3725 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3726 "$P_CLI debug_level=3 ecjpake_pw=bla \
3727 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003728 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003729 -c "add ciphersuite: c0ff" \
3730 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003731 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003732 -s "found ecjpake kkpp extension" \
3733 -S "skip ecjpake kkpp extension" \
3734 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003735 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003736 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003737 -S "None of the common ciphersuites is usable" \
3738 -S "SSL - Verification of the message MAC failed"
3739
Janos Follath74537a62016-09-02 13:45:28 +01003740server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003741requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003742run_test "ECJPAKE: password mismatch, TLS" \
3743 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3744 "$P_CLI debug_level=3 ecjpake_pw=bad \
3745 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3746 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003747 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003748 -s "SSL - Verification of the message MAC failed"
3749
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003750requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003751run_test "ECJPAKE: working, DTLS" \
3752 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3753 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3754 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3755 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003756 -c "re-using cached ecjpake parameters" \
3757 -S "SSL - Verification of the message MAC failed"
3758
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003759requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003760run_test "ECJPAKE: working, DTLS, no cookie" \
3761 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3762 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3763 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3764 0 \
3765 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003766 -S "SSL - Verification of the message MAC failed"
3767
Janos Follath74537a62016-09-02 13:45:28 +01003768server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003769requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003770run_test "ECJPAKE: password mismatch, DTLS" \
3771 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3772 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3773 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3774 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003775 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003776 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003777
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003778# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003779requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003780run_test "ECJPAKE: working, DTLS, nolog" \
3781 "$P_SRV dtls=1 ecjpake_pw=bla" \
3782 "$P_CLI dtls=1 ecjpake_pw=bla \
3783 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3784 0
3785
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003786# Tests for ciphersuites per version
3787
Janos Follathe2681a42016-03-07 15:57:05 +00003788requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003789requires_config_enabled MBEDTLS_CAMELLIA_C
3790requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003791run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003792 "$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 +02003793 "$P_CLI force_version=ssl3" \
3794 0 \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003795 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003796
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003797requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
3798requires_config_enabled MBEDTLS_CAMELLIA_C
3799requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003800run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003801 "$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 +01003802 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003803 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003804 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003805
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003806requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
3807requires_config_enabled MBEDTLS_CAMELLIA_C
3808requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003809run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003810 "$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 +02003811 "$P_CLI force_version=tls1_1" \
3812 0 \
3813 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3814
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003815requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
3816requires_config_enabled MBEDTLS_CAMELLIA_C
3817requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003818run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003819 "$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 +02003820 "$P_CLI force_version=tls1_2" \
3821 0 \
3822 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3823
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003824# Test for ClientHello without extensions
3825
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003826requires_gnutls
Manuel Pégourié-Gonnard37abf122020-01-30 12:45:14 +01003827run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnarda92990a2020-01-30 11:19:45 +01003828 "$P_SRV debug_level=3" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003829 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3830 0 \
3831 -s "dumping 'client hello extensions' (0 bytes)"
3832
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003833# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003834
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003835run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003836 "$P_SRV" \
3837 "$P_CLI request_size=100" \
3838 0 \
3839 -s "Read from client: 100 bytes read$"
3840
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003841run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003842 "$P_SRV" \
3843 "$P_CLI request_size=500" \
3844 0 \
3845 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003846
Andrzej Kurekd731a632018-06-19 09:37:30 -04003847# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003848
Janos Follathe2681a42016-03-07 15:57:05 +00003849requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekd731a632018-06-19 09:37:30 -04003850run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003851 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003852 "$P_CLI request_size=1 force_version=ssl3 \
3853 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3854 0 \
3855 -s "Read from client: 1 bytes read"
3856
Janos Follathe2681a42016-03-07 15:57:05 +00003857requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekd731a632018-06-19 09:37:30 -04003858run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003859 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003860 "$P_CLI request_size=1 force_version=ssl3 \
3861 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3862 0 \
3863 -s "Read from client: 1 bytes read"
3864
Andrzej Kurekd731a632018-06-19 09:37:30 -04003865run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003866 "$P_SRV" \
3867 "$P_CLI request_size=1 force_version=tls1 \
3868 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3869 0 \
3870 -s "Read from client: 1 bytes read"
3871
Andrzej Kurekd731a632018-06-19 09:37:30 -04003872run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003873 "$P_SRV" \
3874 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3875 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3876 0 \
3877 -s "Read from client: 1 bytes read"
3878
Hanno Becker32c55012017-11-10 08:42:54 +00003879requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003880run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003881 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003882 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003883 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003884 0 \
3885 -s "Read from client: 1 bytes read"
3886
Hanno Becker32c55012017-11-10 08:42:54 +00003887requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003888run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003889 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003890 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003891 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003892 0 \
3893 -s "Read from client: 1 bytes read"
3894
Andrzej Kurekd731a632018-06-19 09:37:30 -04003895run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003896 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003897 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003898 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3899 0 \
3900 -s "Read from client: 1 bytes read"
3901
Andrzej Kurekd731a632018-06-19 09:37:30 -04003902run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003903 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3904 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003905 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003906 0 \
3907 -s "Read from client: 1 bytes read"
3908
3909requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003910run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003911 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003912 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003913 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003914 0 \
3915 -s "Read from client: 1 bytes read"
3916
Hanno Becker8501f982017-11-10 08:59:04 +00003917requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003918run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003919 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3920 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3921 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003922 0 \
3923 -s "Read from client: 1 bytes read"
3924
Andrzej Kurekd731a632018-06-19 09:37:30 -04003925run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003926 "$P_SRV" \
3927 "$P_CLI request_size=1 force_version=tls1_1 \
3928 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3929 0 \
3930 -s "Read from client: 1 bytes read"
3931
Andrzej Kurekd731a632018-06-19 09:37:30 -04003932run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003933 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003934 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003935 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003936 0 \
3937 -s "Read from client: 1 bytes read"
3938
3939requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003940run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003941 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003942 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003943 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003944 0 \
3945 -s "Read from client: 1 bytes read"
3946
3947requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003948run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003949 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003950 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003951 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003952 0 \
3953 -s "Read from client: 1 bytes read"
3954
Andrzej Kurekd731a632018-06-19 09:37:30 -04003955run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003956 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003957 "$P_CLI request_size=1 force_version=tls1_1 \
3958 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3959 0 \
3960 -s "Read from client: 1 bytes read"
3961
Andrzej Kurekd731a632018-06-19 09:37:30 -04003962run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003963 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003964 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003965 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003966 0 \
3967 -s "Read from client: 1 bytes read"
3968
Hanno Becker8501f982017-11-10 08:59:04 +00003969requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003970run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003971 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003972 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003973 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003974 0 \
3975 -s "Read from client: 1 bytes read"
3976
Hanno Becker32c55012017-11-10 08:42:54 +00003977requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003978run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003979 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003980 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003981 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003982 0 \
3983 -s "Read from client: 1 bytes read"
3984
Andrzej Kurekd731a632018-06-19 09:37:30 -04003985run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003986 "$P_SRV" \
3987 "$P_CLI request_size=1 force_version=tls1_2 \
3988 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3989 0 \
3990 -s "Read from client: 1 bytes read"
3991
Andrzej Kurekd731a632018-06-19 09:37:30 -04003992run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003993 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003994 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003995 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003996 0 \
3997 -s "Read from client: 1 bytes read"
3998
Andrzej Kurekd731a632018-06-19 09:37:30 -04003999run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004000 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004001 "$P_CLI request_size=1 force_version=tls1_2 \
4002 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004003 0 \
4004 -s "Read from client: 1 bytes read"
4005
Hanno Becker32c55012017-11-10 08:42:54 +00004006requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004007run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004008 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004009 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004010 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004011 0 \
4012 -s "Read from client: 1 bytes read"
4013
Hanno Becker8501f982017-11-10 08:59:04 +00004014requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004015run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004016 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004017 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004018 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004019 0 \
4020 -s "Read from client: 1 bytes read"
4021
Andrzej Kurekd731a632018-06-19 09:37:30 -04004022run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004023 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004024 "$P_CLI request_size=1 force_version=tls1_2 \
4025 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4026 0 \
4027 -s "Read from client: 1 bytes read"
4028
Andrzej Kurekd731a632018-06-19 09:37:30 -04004029run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004030 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004031 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004032 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004033 0 \
4034 -s "Read from client: 1 bytes read"
4035
Hanno Becker32c55012017-11-10 08:42:54 +00004036requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004037run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004038 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004039 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004040 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004041 0 \
4042 -s "Read from client: 1 bytes read"
4043
Hanno Becker8501f982017-11-10 08:59:04 +00004044requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004045run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004046 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004047 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004048 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004049 0 \
4050 -s "Read from client: 1 bytes read"
4051
Andrzej Kurekd731a632018-06-19 09:37:30 -04004052run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004053 "$P_SRV" \
4054 "$P_CLI request_size=1 force_version=tls1_2 \
4055 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4056 0 \
4057 -s "Read from client: 1 bytes read"
4058
Andrzej Kurekd731a632018-06-19 09:37:30 -04004059run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004060 "$P_SRV" \
4061 "$P_CLI request_size=1 force_version=tls1_2 \
4062 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4063 0 \
4064 -s "Read from client: 1 bytes read"
4065
Andrzej Kurekd731a632018-06-19 09:37:30 -04004066# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004067
4068requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004069run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004070 "$P_SRV dtls=1 force_version=dtls1" \
4071 "$P_CLI dtls=1 request_size=1 \
4072 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4073 0 \
4074 -s "Read from client: 1 bytes read"
4075
4076requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004077run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004078 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4079 "$P_CLI dtls=1 request_size=1 \
4080 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4081 0 \
4082 -s "Read from client: 1 bytes read"
4083
4084requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4085requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004086run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004087 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4088 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004089 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4090 0 \
4091 -s "Read from client: 1 bytes read"
4092
4093requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4094requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004095run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004096 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004097 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004098 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004099 0 \
4100 -s "Read from client: 1 bytes read"
4101
4102requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004103run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004104 "$P_SRV dtls=1 force_version=dtls1_2" \
4105 "$P_CLI dtls=1 request_size=1 \
4106 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4107 0 \
4108 -s "Read from client: 1 bytes read"
4109
4110requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004111run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004112 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004113 "$P_CLI dtls=1 request_size=1 \
4114 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4115 0 \
4116 -s "Read from client: 1 bytes read"
4117
4118requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4119requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004120run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004121 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004122 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004123 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004124 0 \
4125 -s "Read from client: 1 bytes read"
4126
4127requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4128requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004129run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004130 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004131 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004132 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004133 0 \
4134 -s "Read from client: 1 bytes read"
4135
Andrzej Kurekd731a632018-06-19 09:37:30 -04004136# Tests for small server packets
4137
4138requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4139run_test "Small server packet SSLv3 BlockCipher" \
4140 "$P_SRV response_size=1 min_version=ssl3" \
4141 "$P_CLI force_version=ssl3 \
4142 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4143 0 \
4144 -c "Read from server: 1 bytes read"
4145
4146requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4147run_test "Small server packet SSLv3 StreamCipher" \
4148 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4149 "$P_CLI force_version=ssl3 \
4150 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4151 0 \
4152 -c "Read from server: 1 bytes read"
4153
4154run_test "Small server packet TLS 1.0 BlockCipher" \
4155 "$P_SRV response_size=1" \
4156 "$P_CLI force_version=tls1 \
4157 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4158 0 \
4159 -c "Read from server: 1 bytes read"
4160
4161run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4162 "$P_SRV response_size=1" \
4163 "$P_CLI force_version=tls1 etm=0 \
4164 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4165 0 \
4166 -c "Read from server: 1 bytes read"
4167
4168requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4169run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4170 "$P_SRV response_size=1 trunc_hmac=1" \
4171 "$P_CLI force_version=tls1 \
4172 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4173 0 \
4174 -c "Read from server: 1 bytes read"
4175
4176requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4177run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4178 "$P_SRV response_size=1 trunc_hmac=1" \
4179 "$P_CLI force_version=tls1 \
4180 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4181 0 \
4182 -c "Read from server: 1 bytes read"
4183
4184run_test "Small server packet TLS 1.0 StreamCipher" \
4185 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4186 "$P_CLI force_version=tls1 \
4187 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4188 0 \
4189 -c "Read from server: 1 bytes read"
4190
4191run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4192 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4193 "$P_CLI force_version=tls1 \
4194 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4195 0 \
4196 -c "Read from server: 1 bytes read"
4197
4198requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4199run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4200 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4201 "$P_CLI force_version=tls1 \
4202 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4203 0 \
4204 -c "Read from server: 1 bytes read"
4205
4206requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4207run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4208 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4209 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4210 trunc_hmac=1 etm=0" \
4211 0 \
4212 -c "Read from server: 1 bytes read"
4213
4214run_test "Small server packet TLS 1.1 BlockCipher" \
4215 "$P_SRV response_size=1" \
4216 "$P_CLI force_version=tls1_1 \
4217 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4218 0 \
4219 -c "Read from server: 1 bytes read"
4220
4221run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4222 "$P_SRV response_size=1" \
4223 "$P_CLI force_version=tls1_1 \
4224 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4225 0 \
4226 -c "Read from server: 1 bytes read"
4227
4228requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4229run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4230 "$P_SRV response_size=1 trunc_hmac=1" \
4231 "$P_CLI force_version=tls1_1 \
4232 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4233 0 \
4234 -c "Read from server: 1 bytes read"
4235
4236requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4237run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4238 "$P_SRV response_size=1 trunc_hmac=1" \
4239 "$P_CLI force_version=tls1_1 \
4240 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4241 0 \
4242 -c "Read from server: 1 bytes read"
4243
4244run_test "Small server packet TLS 1.1 StreamCipher" \
4245 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4246 "$P_CLI force_version=tls1_1 \
4247 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4248 0 \
4249 -c "Read from server: 1 bytes read"
4250
4251run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4252 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4253 "$P_CLI force_version=tls1_1 \
4254 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4255 0 \
4256 -c "Read from server: 1 bytes read"
4257
4258requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4259run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4260 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4261 "$P_CLI force_version=tls1_1 \
4262 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4263 0 \
4264 -c "Read from server: 1 bytes read"
4265
4266requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4267run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4268 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4269 "$P_CLI force_version=tls1_1 \
4270 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4271 0 \
4272 -c "Read from server: 1 bytes read"
4273
4274run_test "Small server packet TLS 1.2 BlockCipher" \
4275 "$P_SRV response_size=1" \
4276 "$P_CLI force_version=tls1_2 \
4277 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4278 0 \
4279 -c "Read from server: 1 bytes read"
4280
4281run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4282 "$P_SRV response_size=1" \
4283 "$P_CLI force_version=tls1_2 \
4284 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4285 0 \
4286 -c "Read from server: 1 bytes read"
4287
4288run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4289 "$P_SRV response_size=1" \
4290 "$P_CLI force_version=tls1_2 \
4291 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4292 0 \
4293 -c "Read from server: 1 bytes read"
4294
4295requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4296run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4297 "$P_SRV response_size=1 trunc_hmac=1" \
4298 "$P_CLI force_version=tls1_2 \
4299 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4300 0 \
4301 -c "Read from server: 1 bytes read"
4302
4303requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4304run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4305 "$P_SRV response_size=1 trunc_hmac=1" \
4306 "$P_CLI force_version=tls1_2 \
4307 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4308 0 \
4309 -c "Read from server: 1 bytes read"
4310
4311run_test "Small server packet TLS 1.2 StreamCipher" \
4312 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4313 "$P_CLI force_version=tls1_2 \
4314 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4315 0 \
4316 -c "Read from server: 1 bytes read"
4317
4318run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4319 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4320 "$P_CLI force_version=tls1_2 \
4321 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4322 0 \
4323 -c "Read from server: 1 bytes read"
4324
4325requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4326run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4327 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4328 "$P_CLI force_version=tls1_2 \
4329 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4330 0 \
4331 -c "Read from server: 1 bytes read"
4332
4333requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4334run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4335 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4336 "$P_CLI force_version=tls1_2 \
4337 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4338 0 \
4339 -c "Read from server: 1 bytes read"
4340
4341run_test "Small server packet TLS 1.2 AEAD" \
4342 "$P_SRV response_size=1" \
4343 "$P_CLI force_version=tls1_2 \
4344 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4345 0 \
4346 -c "Read from server: 1 bytes read"
4347
4348run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4349 "$P_SRV response_size=1" \
4350 "$P_CLI force_version=tls1_2 \
4351 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4352 0 \
4353 -c "Read from server: 1 bytes read"
4354
4355# Tests for small server packets in DTLS
4356
4357requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4358run_test "Small server packet DTLS 1.0" \
4359 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4360 "$P_CLI dtls=1 \
4361 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4362 0 \
4363 -c "Read from server: 1 bytes read"
4364
4365requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4366run_test "Small server packet DTLS 1.0, without EtM" \
4367 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4368 "$P_CLI dtls=1 \
4369 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4370 0 \
4371 -c "Read from server: 1 bytes read"
4372
4373requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4374requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4375run_test "Small server packet DTLS 1.0, truncated hmac" \
4376 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4377 "$P_CLI dtls=1 trunc_hmac=1 \
4378 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4379 0 \
4380 -c "Read from server: 1 bytes read"
4381
4382requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4383requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4384run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4385 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4386 "$P_CLI dtls=1 \
4387 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4388 0 \
4389 -c "Read from server: 1 bytes read"
4390
4391requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4392run_test "Small server packet DTLS 1.2" \
4393 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4394 "$P_CLI dtls=1 \
4395 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4396 0 \
4397 -c "Read from server: 1 bytes read"
4398
4399requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4400run_test "Small server packet DTLS 1.2, without EtM" \
4401 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4402 "$P_CLI dtls=1 \
4403 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4404 0 \
4405 -c "Read from server: 1 bytes read"
4406
4407requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4408requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4409run_test "Small server packet DTLS 1.2, truncated hmac" \
4410 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4411 "$P_CLI dtls=1 \
4412 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4413 0 \
4414 -c "Read from server: 1 bytes read"
4415
4416requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4417requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4418run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4419 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4420 "$P_CLI dtls=1 \
4421 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4422 0 \
4423 -c "Read from server: 1 bytes read"
4424
Janos Follath00efff72016-05-06 13:48:23 +01004425# A test for extensions in SSLv3
4426
4427requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4428run_test "SSLv3 with extensions, server side" \
4429 "$P_SRV min_version=ssl3 debug_level=3" \
4430 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4431 0 \
4432 -S "dumping 'client hello extensions'" \
4433 -S "server hello, total extension length:"
4434
Andrzej Kurek557335e2018-06-28 04:03:10 -04004435# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004436
Janos Follathe2681a42016-03-07 15:57:05 +00004437requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek557335e2018-06-28 04:03:10 -04004438run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004439 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004440 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004441 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4442 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004443 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004444 -s "Read from client: 16384 bytes read"
4445
Janos Follathe2681a42016-03-07 15:57:05 +00004446requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek557335e2018-06-28 04:03:10 -04004447run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004448 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004449 "$P_CLI request_size=16384 force_version=ssl3 \
4450 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4451 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004452 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004453 -s "Read from client: 16384 bytes read"
4454
Andrzej Kurek557335e2018-06-28 04:03:10 -04004455run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004456 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004457 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004458 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4459 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004460 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004461 -s "Read from client: 16384 bytes read"
4462
Andrzej Kurek557335e2018-06-28 04:03:10 -04004463run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004464 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004465 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4466 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4467 0 \
4468 -s "Read from client: 16384 bytes read"
4469
Hanno Becker32c55012017-11-10 08:42:54 +00004470requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004471run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004472 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004473 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004474 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004475 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004476 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004477 -s "Read from client: 16384 bytes read"
4478
Hanno Becker32c55012017-11-10 08:42:54 +00004479requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004480run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004481 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004482 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004483 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004484 0 \
4485 -s "Read from client: 16384 bytes read"
4486
Andrzej Kurek557335e2018-06-28 04:03:10 -04004487run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004488 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004489 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004490 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4491 0 \
4492 -s "Read from client: 16384 bytes read"
4493
Andrzej Kurek557335e2018-06-28 04:03:10 -04004494run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004495 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4496 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004497 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004498 0 \
4499 -s "Read from client: 16384 bytes read"
4500
4501requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004502run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004503 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004504 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004505 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004506 0 \
4507 -s "Read from client: 16384 bytes read"
4508
Hanno Becker278fc7a2017-11-10 09:16:28 +00004509requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004510run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004511 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004512 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004513 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004514 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004515 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004516 -s "Read from client: 16384 bytes read"
4517
Andrzej Kurek557335e2018-06-28 04:03:10 -04004518run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004519 "$P_SRV" \
4520 "$P_CLI request_size=16384 force_version=tls1_1 \
4521 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4522 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004523 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004524 -s "Read from client: 16384 bytes read"
4525
Andrzej Kurek557335e2018-06-28 04:03:10 -04004526run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004527 "$P_SRV" \
4528 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4529 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004530 0 \
4531 -s "Read from client: 16384 bytes read"
4532
Hanno Becker32c55012017-11-10 08:42:54 +00004533requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004534run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004535 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004536 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004537 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004538 0 \
4539 -s "Read from client: 16384 bytes read"
4540
Hanno Becker32c55012017-11-10 08:42:54 +00004541requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004542run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004543 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004544 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004545 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004546 0 \
4547 -s "Read from client: 16384 bytes read"
4548
Andrzej Kurek557335e2018-06-28 04:03:10 -04004549run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004550 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4551 "$P_CLI request_size=16384 force_version=tls1_1 \
4552 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4553 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004554 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004555 -s "Read from client: 16384 bytes read"
4556
Andrzej Kurek557335e2018-06-28 04:03:10 -04004557run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004558 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004559 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004560 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004561 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004562 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004563 -s "Read from client: 16384 bytes read"
4564
Hanno Becker278fc7a2017-11-10 09:16:28 +00004565requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004566run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004567 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004568 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004569 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004570 0 \
4571 -s "Read from client: 16384 bytes read"
4572
Hanno Becker278fc7a2017-11-10 09:16:28 +00004573requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004574run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004575 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004576 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004577 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004578 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004579 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004580 -s "Read from client: 16384 bytes read"
4581
Andrzej Kurek557335e2018-06-28 04:03:10 -04004582run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004583 "$P_SRV" \
4584 "$P_CLI request_size=16384 force_version=tls1_2 \
4585 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4586 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004587 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004588 -s "Read from client: 16384 bytes read"
4589
Andrzej Kurek557335e2018-06-28 04:03:10 -04004590run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004591 "$P_SRV" \
4592 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4593 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4594 0 \
4595 -s "Read from client: 16384 bytes read"
4596
Andrzej Kurek557335e2018-06-28 04:03:10 -04004597run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004598 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004599 "$P_CLI request_size=16384 force_version=tls1_2 \
4600 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004601 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004602 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004603 -s "Read from client: 16384 bytes read"
4604
Hanno Becker32c55012017-11-10 08:42:54 +00004605requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004606run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004607 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004608 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004609 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004610 0 \
4611 -s "Read from client: 16384 bytes read"
4612
Hanno Becker278fc7a2017-11-10 09:16:28 +00004613requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004614run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004615 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004616 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004617 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004618 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004619 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004620 -s "Read from client: 16384 bytes read"
4621
Andrzej Kurek557335e2018-06-28 04:03:10 -04004622run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004623 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004624 "$P_CLI request_size=16384 force_version=tls1_2 \
4625 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4626 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004627 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004628 -s "Read from client: 16384 bytes read"
4629
Andrzej Kurek557335e2018-06-28 04:03:10 -04004630run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004631 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004632 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004633 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4634 0 \
4635 -s "Read from client: 16384 bytes read"
4636
Hanno Becker32c55012017-11-10 08:42:54 +00004637requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004638run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004639 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004640 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004641 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004642 0 \
4643 -s "Read from client: 16384 bytes read"
4644
Hanno Becker278fc7a2017-11-10 09:16:28 +00004645requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004646run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004647 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004648 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004649 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004650 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004651 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004652 -s "Read from client: 16384 bytes read"
4653
Andrzej Kurek557335e2018-06-28 04:03:10 -04004654run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004655 "$P_SRV" \
4656 "$P_CLI request_size=16384 force_version=tls1_2 \
4657 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4658 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004659 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004660 -s "Read from client: 16384 bytes read"
4661
Andrzej Kurek557335e2018-06-28 04:03:10 -04004662run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004663 "$P_SRV" \
4664 "$P_CLI request_size=16384 force_version=tls1_2 \
4665 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4666 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004667 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004668 -s "Read from client: 16384 bytes read"
4669
Ron Eldorc7f15232018-06-28 13:22:05 +03004670# Tests for ECC extensions (rfc 4492)
4671
Ron Eldor94226d82018-06-28 16:17:00 +03004672requires_config_enabled MBEDTLS_AES_C
4673requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4674requires_config_enabled MBEDTLS_SHA256_C
4675requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004676run_test "Force a non ECC ciphersuite in the client side" \
4677 "$P_SRV debug_level=3" \
Ron Eldor94226d82018-06-28 16:17:00 +03004678 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004679 0 \
4680 -C "client hello, adding supported_elliptic_curves extension" \
4681 -C "client hello, adding supported_point_formats extension" \
4682 -S "found supported elliptic curves extension" \
4683 -S "found supported point formats extension"
4684
Ron Eldor94226d82018-06-28 16:17:00 +03004685requires_config_enabled MBEDTLS_AES_C
4686requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4687requires_config_enabled MBEDTLS_SHA256_C
4688requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004689run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor94226d82018-06-28 16:17:00 +03004690 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004691 "$P_CLI debug_level=3" \
4692 0 \
4693 -C "found supported_point_formats extension" \
4694 -S "server hello, supported_point_formats extension"
4695
Ron Eldor94226d82018-06-28 16:17:00 +03004696requires_config_enabled MBEDTLS_AES_C
4697requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4698requires_config_enabled MBEDTLS_SHA256_C
4699requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004700run_test "Force an ECC ciphersuite in the client side" \
4701 "$P_SRV debug_level=3" \
4702 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4703 0 \
4704 -c "client hello, adding supported_elliptic_curves extension" \
4705 -c "client hello, adding supported_point_formats extension" \
4706 -s "found supported elliptic curves extension" \
4707 -s "found supported point formats extension"
4708
Ron Eldor94226d82018-06-28 16:17:00 +03004709requires_config_enabled MBEDTLS_AES_C
4710requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4711requires_config_enabled MBEDTLS_SHA256_C
4712requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004713run_test "Force an ECC ciphersuite in the server side" \
4714 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4715 "$P_CLI debug_level=3" \
4716 0 \
4717 -c "found supported_point_formats extension" \
4718 -s "server hello, supported_point_formats extension"
4719
Andrzej Kurek557335e2018-06-28 04:03:10 -04004720# Test for large server packets
Andrzej Kurek557335e2018-06-28 04:03:10 -04004721requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4722run_test "Large server packet SSLv3 StreamCipher" \
4723 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4724 "$P_CLI force_version=ssl3 \
4725 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4726 0 \
4727 -c "Read from server: 16384 bytes read"
4728
Andrzej Kurekc8958212018-08-27 08:00:13 -04004729# Checking next 4 tests logs for 1n-1 split against BEAST too
4730requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4731run_test "Large server packet SSLv3 BlockCipher" \
4732 "$P_SRV response_size=16384 min_version=ssl3" \
4733 "$P_CLI force_version=ssl3 recsplit=0 \
4734 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4735 0 \
4736 -c "Read from server: 1 bytes read"\
4737 -c "16383 bytes read"\
4738 -C "Read from server: 16384 bytes read"
4739
Andrzej Kurek557335e2018-06-28 04:03:10 -04004740run_test "Large server packet TLS 1.0 BlockCipher" \
4741 "$P_SRV response_size=16384" \
4742 "$P_CLI force_version=tls1 recsplit=0 \
4743 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4744 0 \
4745 -c "Read from server: 1 bytes read"\
4746 -c "16383 bytes read"\
4747 -C "Read from server: 16384 bytes read"
4748
Andrzej Kurekd731a632018-06-19 09:37:30 -04004749run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
4750 "$P_SRV response_size=16384" \
4751 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
4752 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4753 0 \
4754 -c "Read from server: 1 bytes read"\
4755 -c "16383 bytes read"\
4756 -C "Read from server: 16384 bytes read"
4757
Andrzej Kurek557335e2018-06-28 04:03:10 -04004758requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4759run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
4760 "$P_SRV response_size=16384" \
4761 "$P_CLI force_version=tls1 recsplit=0 \
4762 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4763 trunc_hmac=1" \
4764 0 \
4765 -c "Read from server: 1 bytes read"\
4766 -c "16383 bytes read"\
4767 -C "Read from server: 16384 bytes read"
4768
4769requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4770run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
4771 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4772 "$P_CLI force_version=tls1 \
4773 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4774 trunc_hmac=1" \
4775 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004776 -s "16384 bytes written in 1 fragments" \
4777 -c "Read from server: 16384 bytes read"
4778
4779run_test "Large server packet TLS 1.0 StreamCipher" \
4780 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4781 "$P_CLI force_version=tls1 \
4782 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4783 0 \
4784 -s "16384 bytes written in 1 fragments" \
4785 -c "Read from server: 16384 bytes read"
4786
4787run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
4788 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4789 "$P_CLI force_version=tls1 \
4790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4791 0 \
4792 -s "16384 bytes written in 1 fragments" \
4793 -c "Read from server: 16384 bytes read"
4794
4795requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4796run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
4797 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4798 "$P_CLI force_version=tls1 \
4799 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4800 0 \
4801 -s "16384 bytes written in 1 fragments" \
4802 -c "Read from server: 16384 bytes read"
4803
4804requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4805run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4806 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4807 "$P_CLI force_version=tls1 \
4808 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4809 0 \
4810 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004811 -c "Read from server: 16384 bytes read"
4812
4813run_test "Large server packet TLS 1.1 BlockCipher" \
4814 "$P_SRV response_size=16384" \
4815 "$P_CLI force_version=tls1_1 \
4816 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4817 0 \
4818 -c "Read from server: 16384 bytes read"
4819
Andrzej Kurekd731a632018-06-19 09:37:30 -04004820run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
4821 "$P_SRV response_size=16384" \
4822 "$P_CLI force_version=tls1_1 etm=0 \
4823 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004824 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004825 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004826 -c "Read from server: 16384 bytes read"
4827
4828requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4829run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
4830 "$P_SRV response_size=16384" \
4831 "$P_CLI force_version=tls1_1 \
4832 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4833 trunc_hmac=1" \
4834 0 \
4835 -c "Read from server: 16384 bytes read"
4836
4837requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004838run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4839 "$P_SRV response_size=16384 trunc_hmac=1" \
4840 "$P_CLI force_version=tls1_1 \
4841 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4842 0 \
4843 -s "16384 bytes written in 1 fragments" \
4844 -c "Read from server: 16384 bytes read"
4845
4846run_test "Large server packet TLS 1.1 StreamCipher" \
4847 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4848 "$P_CLI force_version=tls1_1 \
4849 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4850 0 \
4851 -c "Read from server: 16384 bytes read"
4852
4853run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
4854 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4855 "$P_CLI force_version=tls1_1 \
4856 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4857 0 \
4858 -s "16384 bytes written in 1 fragments" \
4859 -c "Read from server: 16384 bytes read"
4860
4861requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004862run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
4863 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4864 "$P_CLI force_version=tls1_1 \
4865 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4866 trunc_hmac=1" \
4867 0 \
4868 -c "Read from server: 16384 bytes read"
4869
Andrzej Kurekd731a632018-06-19 09:37:30 -04004870run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4871 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4872 "$P_CLI force_version=tls1_1 \
4873 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4874 0 \
4875 -s "16384 bytes written in 1 fragments" \
4876 -c "Read from server: 16384 bytes read"
4877
Andrzej Kurek557335e2018-06-28 04:03:10 -04004878run_test "Large server packet TLS 1.2 BlockCipher" \
4879 "$P_SRV response_size=16384" \
4880 "$P_CLI force_version=tls1_2 \
4881 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4882 0 \
4883 -c "Read from server: 16384 bytes read"
4884
Andrzej Kurekd731a632018-06-19 09:37:30 -04004885run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
4886 "$P_SRV response_size=16384" \
4887 "$P_CLI force_version=tls1_2 etm=0 \
4888 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4889 0 \
4890 -s "16384 bytes written in 1 fragments" \
4891 -c "Read from server: 16384 bytes read"
4892
Andrzej Kurek557335e2018-06-28 04:03:10 -04004893run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
4894 "$P_SRV response_size=16384" \
4895 "$P_CLI force_version=tls1_2 \
4896 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4897 0 \
4898 -c "Read from server: 16384 bytes read"
4899
4900requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4901run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
4902 "$P_SRV response_size=16384" \
4903 "$P_CLI force_version=tls1_2 \
4904 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4905 trunc_hmac=1" \
4906 0 \
4907 -c "Read from server: 16384 bytes read"
4908
Andrzej Kurekd731a632018-06-19 09:37:30 -04004909run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4910 "$P_SRV response_size=16384 trunc_hmac=1" \
4911 "$P_CLI force_version=tls1_2 \
4912 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4913 0 \
4914 -s "16384 bytes written in 1 fragments" \
4915 -c "Read from server: 16384 bytes read"
4916
Andrzej Kurek557335e2018-06-28 04:03:10 -04004917run_test "Large server packet TLS 1.2 StreamCipher" \
4918 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4919 "$P_CLI force_version=tls1_2 \
4920 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4921 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004922 -s "16384 bytes written in 1 fragments" \
4923 -c "Read from server: 16384 bytes read"
4924
4925run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
4926 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4927 "$P_CLI force_version=tls1_2 \
4928 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4929 0 \
4930 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004931 -c "Read from server: 16384 bytes read"
4932
4933requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4934run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
4935 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4936 "$P_CLI force_version=tls1_2 \
4937 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4938 trunc_hmac=1" \
4939 0 \
4940 -c "Read from server: 16384 bytes read"
4941
Andrzej Kurekd731a632018-06-19 09:37:30 -04004942requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4943run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4944 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4945 "$P_CLI force_version=tls1_2 \
4946 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4947 0 \
4948 -s "16384 bytes written in 1 fragments" \
4949 -c "Read from server: 16384 bytes read"
4950
Andrzej Kurek557335e2018-06-28 04:03:10 -04004951run_test "Large server packet TLS 1.2 AEAD" \
4952 "$P_SRV response_size=16384" \
4953 "$P_CLI force_version=tls1_2 \
4954 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4955 0 \
4956 -c "Read from server: 16384 bytes read"
4957
4958run_test "Large server packet TLS 1.2 AEAD shorter tag" \
4959 "$P_SRV response_size=16384" \
4960 "$P_CLI force_version=tls1_2 \
4961 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4962 0 \
4963 -c "Read from server: 16384 bytes read"
4964
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004965# Tests for DTLS HelloVerifyRequest
4966
4967run_test "DTLS cookie: enabled" \
4968 "$P_SRV dtls=1 debug_level=2" \
4969 "$P_CLI dtls=1 debug_level=2" \
4970 0 \
4971 -s "cookie verification failed" \
4972 -s "cookie verification passed" \
4973 -S "cookie verification skipped" \
4974 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004975 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004976 -S "SSL - The requested feature is not available"
4977
4978run_test "DTLS cookie: disabled" \
4979 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4980 "$P_CLI dtls=1 debug_level=2" \
4981 0 \
4982 -S "cookie verification failed" \
4983 -S "cookie verification passed" \
4984 -s "cookie verification skipped" \
4985 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004986 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004987 -S "SSL - The requested feature is not available"
4988
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004989run_test "DTLS cookie: default (failing)" \
4990 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4991 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4992 1 \
4993 -s "cookie verification failed" \
4994 -S "cookie verification passed" \
4995 -S "cookie verification skipped" \
4996 -C "received hello verify request" \
4997 -S "hello verification requested" \
4998 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004999
5000requires_ipv6
5001run_test "DTLS cookie: enabled, IPv6" \
5002 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5003 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5004 0 \
5005 -s "cookie verification failed" \
5006 -s "cookie verification passed" \
5007 -S "cookie verification skipped" \
5008 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005009 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005010 -S "SSL - The requested feature is not available"
5011
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005012run_test "DTLS cookie: enabled, nbio" \
5013 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5014 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5015 0 \
5016 -s "cookie verification failed" \
5017 -s "cookie verification passed" \
5018 -S "cookie verification skipped" \
5019 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005020 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005021 -S "SSL - The requested feature is not available"
5022
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005023# Tests for client reconnecting from the same port with DTLS
5024
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005025not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005026run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnardb1ee30b2019-09-09 11:14:37 +02005027 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5028 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005029 0 \
5030 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005031 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005032 -S "Client initiated reconnection from same port"
5033
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005034not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005035run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnardb1ee30b2019-09-09 11:14:37 +02005036 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5037 "$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 +02005038 0 \
5039 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005040 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005041 -s "Client initiated reconnection from same port"
5042
Paul Bakker362689d2016-05-13 10:33:25 +01005043not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5044run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005045 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5046 "$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 +02005047 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005048 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005049 -s "Client initiated reconnection from same port"
5050
Paul Bakker362689d2016-05-13 10:33:25 +01005051only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5052run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5053 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5054 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5055 0 \
5056 -S "The operation timed out" \
5057 -s "Client initiated reconnection from same port"
5058
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005059run_test "DTLS client reconnect from same port: no cookies" \
5060 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005061 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5062 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005063 -s "The operation timed out" \
5064 -S "Client initiated reconnection from same port"
5065
Manuel Pégourié-Gonnarda58b0462020-03-13 11:11:02 +01005066run_test "DTLS client reconnect from same port: attacker-injected" \
5067 -p "$P_PXY inject_clihlo=1" \
5068 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5069 "$P_CLI dtls=1 exchanges=2" \
5070 0 \
5071 -s "possible client reconnect from the same port" \
5072 -S "Client initiated reconnection from same port"
5073
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005074# Tests for various cases of client authentication with DTLS
5075# (focused on handshake flows and message parsing)
5076
5077run_test "DTLS client auth: required" \
5078 "$P_SRV dtls=1 auth_mode=required" \
5079 "$P_CLI dtls=1" \
5080 0 \
5081 -s "Verifying peer X.509 certificate... ok"
5082
5083run_test "DTLS client auth: optional, client has no cert" \
5084 "$P_SRV dtls=1 auth_mode=optional" \
5085 "$P_CLI dtls=1 crt_file=none key_file=none" \
5086 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005087 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005088
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005089run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005090 "$P_SRV dtls=1 auth_mode=none" \
5091 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5092 0 \
5093 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005094 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005095
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005096run_test "DTLS wrong PSK: badmac alert" \
5097 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5098 "$P_CLI dtls=1 psk=abc124" \
5099 1 \
5100 -s "SSL - Verification of the message MAC failed" \
5101 -c "SSL - A fatal alert message was received from our peer"
5102
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005103# Tests for receiving fragmented handshake messages with DTLS
5104
5105requires_gnutls
5106run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5107 "$G_SRV -u --mtu 2048 -a" \
5108 "$P_CLI dtls=1 debug_level=2" \
5109 0 \
5110 -C "found fragmented DTLS handshake message" \
5111 -C "error"
5112
5113requires_gnutls
5114run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5115 "$G_SRV -u --mtu 512" \
5116 "$P_CLI dtls=1 debug_level=2" \
5117 0 \
5118 -c "found fragmented DTLS handshake message" \
5119 -C "error"
5120
5121requires_gnutls
5122run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5123 "$G_SRV -u --mtu 128" \
5124 "$P_CLI dtls=1 debug_level=2" \
5125 0 \
5126 -c "found fragmented DTLS handshake message" \
5127 -C "error"
5128
5129requires_gnutls
5130run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5131 "$G_SRV -u --mtu 128" \
5132 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5133 0 \
5134 -c "found fragmented DTLS handshake message" \
5135 -C "error"
5136
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005137requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005138requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005139run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5140 "$G_SRV -u --mtu 256" \
5141 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5142 0 \
5143 -c "found fragmented DTLS handshake message" \
5144 -c "client hello, adding renegotiation extension" \
5145 -c "found renegotiation extension" \
5146 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005147 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005148 -C "error" \
5149 -s "Extra-header:"
5150
5151requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005152requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005153run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5154 "$G_SRV -u --mtu 256" \
5155 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5156 0 \
5157 -c "found fragmented DTLS handshake message" \
5158 -c "client hello, adding renegotiation extension" \
5159 -c "found renegotiation extension" \
5160 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005161 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005162 -C "error" \
5163 -s "Extra-header:"
5164
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005165run_test "DTLS reassembly: no fragmentation (openssl server)" \
5166 "$O_SRV -dtls1 -mtu 2048" \
5167 "$P_CLI dtls=1 debug_level=2" \
5168 0 \
5169 -C "found fragmented DTLS handshake message" \
5170 -C "error"
5171
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005172run_test "DTLS reassembly: some fragmentation (openssl server)" \
5173 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005174 "$P_CLI dtls=1 debug_level=2" \
5175 0 \
5176 -c "found fragmented DTLS handshake message" \
5177 -C "error"
5178
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005179run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005180 "$O_SRV -dtls1 -mtu 256" \
5181 "$P_CLI dtls=1 debug_level=2" \
5182 0 \
5183 -c "found fragmented DTLS handshake message" \
5184 -C "error"
5185
5186run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5187 "$O_SRV -dtls1 -mtu 256" \
5188 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5189 0 \
5190 -c "found fragmented DTLS handshake message" \
5191 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005192
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005193# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005194
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005195not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005196run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005197 -p "$P_PXY" \
Manuel Pégourié-Gonnardb1ee30b2019-09-09 11:14:37 +02005198 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
5199 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005200 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005201 -C "replayed record" \
5202 -S "replayed record" \
5203 -C "record from another epoch" \
5204 -S "record from another epoch" \
5205 -C "discarding invalid record" \
5206 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005207 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005208 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005209 -c "HTTP/1.0 200 OK"
5210
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005211not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005212run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005213 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnardb1ee30b2019-09-09 11:14:37 +02005214 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
5215 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005216 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005217 -c "replayed record" \
5218 -s "replayed record" \
Hanno Beckera34cc6b2017-05-26 16:07:36 +01005219 -c "record from another epoch" \
5220 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005221 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005222 -s "Extra-header:" \
5223 -c "HTTP/1.0 200 OK"
5224
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005225run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
5226 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005227 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
5228 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005229 0 \
5230 -c "replayed record" \
5231 -S "replayed record" \
Hanno Beckera34cc6b2017-05-26 16:07:36 +01005232 -c "record from another epoch" \
5233 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005234 -c "resend" \
5235 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005236 -s "Extra-header:" \
5237 -c "HTTP/1.0 200 OK"
5238
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005239run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005240 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005241 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005242 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005243 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005244 -c "discarding invalid record (mac)" \
5245 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005246 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005247 -c "HTTP/1.0 200 OK" \
5248 -S "too many records with bad MAC" \
5249 -S "Verification of the message MAC failed"
5250
5251run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
5252 -p "$P_PXY bad_ad=1" \
5253 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
5254 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5255 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005256 -C "discarding invalid record (mac)" \
5257 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005258 -S "Extra-header:" \
5259 -C "HTTP/1.0 200 OK" \
5260 -s "too many records with bad MAC" \
5261 -s "Verification of the message MAC failed"
5262
5263run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
5264 -p "$P_PXY bad_ad=1" \
5265 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
5266 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5267 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005268 -c "discarding invalid record (mac)" \
5269 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005270 -s "Extra-header:" \
5271 -c "HTTP/1.0 200 OK" \
5272 -S "too many records with bad MAC" \
5273 -S "Verification of the message MAC failed"
5274
5275run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
5276 -p "$P_PXY bad_ad=1" \
5277 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
5278 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
5279 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005280 -c "discarding invalid record (mac)" \
5281 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005282 -s "Extra-header:" \
5283 -c "HTTP/1.0 200 OK" \
5284 -s "too many records with bad MAC" \
5285 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005286
5287run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005288 -p "$P_PXY delay_ccs=1" \
5289 "$P_SRV dtls=1 debug_level=1" \
5290 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005291 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005292 -c "record from another epoch" \
5293 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005294 -s "Extra-header:" \
5295 -c "HTTP/1.0 200 OK"
5296
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005297# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005298
Janos Follath74537a62016-09-02 13:45:28 +01005299client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005300run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005301 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005302 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005303 psk=abc123" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005304 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005305 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5306 0 \
5307 -s "Extra-header:" \
5308 -c "HTTP/1.0 200 OK"
5309
Janos Follath74537a62016-09-02 13:45:28 +01005310client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005311run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
5312 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005313 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none" \
5314 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005315 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5316 0 \
5317 -s "Extra-header:" \
5318 -c "HTTP/1.0 200 OK"
5319
Janos Follath74537a62016-09-02 13:45:28 +01005320client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005321run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
5322 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005323 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none" \
5324 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005325 0 \
5326 -s "Extra-header:" \
5327 -c "HTTP/1.0 200 OK"
5328
Janos Follath74537a62016-09-02 13:45:28 +01005329client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005330run_test "DTLS proxy: 3d, FS, client auth" \
5331 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005332 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=required" \
5333 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005334 0 \
5335 -s "Extra-header:" \
5336 -c "HTTP/1.0 200 OK"
5337
Janos Follath74537a62016-09-02 13:45:28 +01005338client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005339run_test "DTLS proxy: 3d, FS, ticket" \
5340 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005341 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=1 auth_mode=none" \
5342 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005343 0 \
5344 -s "Extra-header:" \
5345 -c "HTTP/1.0 200 OK"
5346
Janos Follath74537a62016-09-02 13:45:28 +01005347client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005348run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
5349 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005350 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=1 auth_mode=required" \
5351 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005352 0 \
5353 -s "Extra-header:" \
5354 -c "HTTP/1.0 200 OK"
5355
Janos Follath74537a62016-09-02 13:45:28 +01005356client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005357run_test "DTLS proxy: 3d, max handshake, nbio" \
5358 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005359 "$P_SRV dtls=1 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005360 auth_mode=required" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005361 "$P_CLI dtls=1 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005362 0 \
5363 -s "Extra-header:" \
5364 -c "HTTP/1.0 200 OK"
5365
Janos Follath74537a62016-09-02 13:45:28 +01005366client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005367run_test "DTLS proxy: 3d, min handshake, resumption" \
5368 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005369 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005370 psk=abc123 debug_level=3" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005371 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01005372 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005373 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5374 0 \
5375 -s "a session has been resumed" \
5376 -c "a session has been resumed" \
5377 -s "Extra-header:" \
5378 -c "HTTP/1.0 200 OK"
5379
Janos Follath74537a62016-09-02 13:45:28 +01005380client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005381run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
5382 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005383 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005384 psk=abc123 debug_level=3 nbio=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005385 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01005386 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005387 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
5388 0 \
5389 -s "a session has been resumed" \
5390 -c "a session has been resumed" \
5391 -s "Extra-header:" \
5392 -c "HTTP/1.0 200 OK"
5393
Janos Follath74537a62016-09-02 13:45:28 +01005394client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005395requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005396run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005397 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005398 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005399 psk=abc123 renegotiation=1 debug_level=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005400 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005401 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005402 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5403 0 \
5404 -c "=> renegotiate" \
5405 -s "=> renegotiate" \
5406 -s "Extra-header:" \
5407 -c "HTTP/1.0 200 OK"
5408
Janos Follath74537a62016-09-02 13:45:28 +01005409client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005410requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005411run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
5412 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005413 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005414 psk=abc123 renegotiation=1 debug_level=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005415 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005416 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005417 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5418 0 \
5419 -c "=> renegotiate" \
5420 -s "=> renegotiate" \
5421 -s "Extra-header:" \
5422 -c "HTTP/1.0 200 OK"
5423
Janos Follath74537a62016-09-02 13:45:28 +01005424client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005425requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005426run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005427 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005428 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005429 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005430 debug_level=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005431 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005432 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005433 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5434 0 \
5435 -c "=> renegotiate" \
5436 -s "=> renegotiate" \
5437 -s "Extra-header:" \
5438 -c "HTTP/1.0 200 OK"
5439
Janos Follath74537a62016-09-02 13:45:28 +01005440client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005441requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005442run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005443 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005444 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005445 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005446 debug_level=2 nbio=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005447 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005448 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005449 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5450 0 \
5451 -c "=> renegotiate" \
5452 -s "=> renegotiate" \
5453 -s "Extra-header:" \
5454 -c "HTTP/1.0 200 OK"
5455
Janos Follath74537a62016-09-02 13:45:28 +01005456client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005457not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005458run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005459 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5460 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005461 "$P_CLI dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005462 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005463 -c "HTTP/1.0 200 OK"
5464
Janos Follath74537a62016-09-02 13:45:28 +01005465client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005466not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005467run_test "DTLS proxy: 3d, openssl server, fragmentation" \
5468 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5469 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005470 "$P_CLI dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005471 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005472 -c "HTTP/1.0 200 OK"
5473
Janos Follath74537a62016-09-02 13:45:28 +01005474client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005475not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005476run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
5477 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5478 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005479 "$P_CLI dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005480 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005481 -c "HTTP/1.0 200 OK"
5482
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005483requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005484client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005485not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005486run_test "DTLS proxy: 3d, gnutls server" \
5487 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5488 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005489 "$P_CLI dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005490 0 \
5491 -s "Extra-header:" \
5492 -c "Extra-header:"
5493
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005494requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005495client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005496not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005497run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
5498 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5499 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005500 "$P_CLI dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005501 0 \
5502 -s "Extra-header:" \
5503 -c "Extra-header:"
5504
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005505requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005506client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005507not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005508run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
5509 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5510 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005511 "$P_CLI dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005512 0 \
5513 -s "Extra-header:" \
5514 -c "Extra-header:"
5515
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01005516# Final report
5517
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005518echo "------------------------------------------------------------------------"
5519
5520if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005521 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005522else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005523 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005524fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02005525PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02005526echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005527
5528exit $FAILS