blob: 792cc6c02615819e7c34deb6fd9fdb1abaa91642 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# Copyright (c) 2016, ARM Limited, All Rights Reserved
Bence Szépkú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#
Bence Szépkúti09b4f192020-05-26 01:54:15 +020047# This file is part of Mbed TLS (https://tls.mbed.org)
Simon Butcher58eddef2016-05-19 23:43:11 +010048#
49# Purpose
50#
51# Executes tests to prove various TLS/SSL options and extensions.
52#
53# The goal is not to cover every ciphersuite/version, but instead to cover
54# specific options (max fragment length, truncated hmac, etc) or procedures
55# (session resumption from cache or ticket, renego, etc).
56#
57# The tests assume a build with default options, with exceptions expressed
58# with a dependency. The tests focus on functionality and do not consider
59# performance.
60#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010061
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010062set -u
63
Jaeden Amero34730912019-07-03 13:51:04 +010064# Limit the size of each log to 10 GiB, in case of failures with this script
65# where it may output seemingly unlimited length error logs.
66ulimit -f 20971520
67
Antonin Décimo8fd91562019-01-23 15:24:37 +010068# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010069: ${P_SRV:=../programs/ssl/ssl_server2}
70: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020071: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010072: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020073: ${GNUTLS_CLI:=gnutls-cli}
74: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020075: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010076
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020077O_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 +010078O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020079G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard179c2272020-02-03 15:37:47 +010080G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12u.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020081TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010082
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010083TESTS=0
84FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020085SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010086
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000087CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020088
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010089MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010090FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020091EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010092
Paul Bakkere20310a2016-05-10 11:18:17 +010093SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010094RUN_TEST_NUMBER=''
95
Paul Bakkeracaac852016-05-10 11:47:13 +010096PRESERVE_LOGS=0
97
Gilles Peskinef93c7d32017-04-14 17:55:28 +020098# Pick a "unique" server port in the range 10000-19999, and a proxy
99# port which is this plus 10000. Each port number may be independently
100# overridden by a command line option.
101SRV_PORT=$(($$ % 10000 + 10000))
102PXY_PORT=$((SRV_PORT + 10000))
103
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104print_usage() {
105 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100106 printf " -h|--help\tPrint this help.\n"
107 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200108 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
109 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100110 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100111 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100112 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200113 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
114 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100115 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100116}
117
118get_options() {
119 while [ $# -gt 0 ]; do
120 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100121 -f|--filter)
122 shift; FILTER=$1
123 ;;
124 -e|--exclude)
125 shift; EXCLUDE=$1
126 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100127 -m|--memcheck)
128 MEMCHECK=1
129 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100130 -n|--number)
131 shift; RUN_TEST_NUMBER=$1
132 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100133 -s|--show-numbers)
134 SHOW_TEST_NUMBER=1
135 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100136 -p|--preserve-logs)
137 PRESERVE_LOGS=1
138 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200139 --port)
140 shift; SRV_PORT=$1
141 ;;
142 --proxy-port)
143 shift; PXY_PORT=$1
144 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100145 --seed)
146 shift; SEED="$1"
147 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100148 -h|--help)
149 print_usage
150 exit 0
151 ;;
152 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200153 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100154 print_usage
155 exit 1
156 ;;
157 esac
158 shift
159 done
160}
161
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100162# skip next test if the flag is not enabled in config.h
163requires_config_enabled() {
164 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
165 SKIP_NEXT="YES"
166 fi
167}
168
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200169# skip next test if the flag is enabled in config.h
170requires_config_disabled() {
171 if grep "^#define $1" $CONFIG_H > /dev/null; then
172 SKIP_NEXT="YES"
173 fi
174}
175
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200176# skip next test if OpenSSL doesn't support FALLBACK_SCSV
177requires_openssl_with_fallback_scsv() {
178 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
179 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
180 then
181 OPENSSL_HAS_FBSCSV="YES"
182 else
183 OPENSSL_HAS_FBSCSV="NO"
184 fi
185 fi
186 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
187 SKIP_NEXT="YES"
188 fi
189}
190
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200191# skip next test if GnuTLS isn't available
192requires_gnutls() {
193 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200194 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200195 GNUTLS_AVAILABLE="YES"
196 else
197 GNUTLS_AVAILABLE="NO"
198 fi
199 fi
200 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
201 SKIP_NEXT="YES"
202 fi
203}
204
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200205# skip next test if IPv6 isn't available on this host
206requires_ipv6() {
207 if [ -z "${HAS_IPV6:-}" ]; then
208 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
209 SRV_PID=$!
210 sleep 1
211 kill $SRV_PID >/dev/null 2>&1
212 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
213 HAS_IPV6="NO"
214 else
215 HAS_IPV6="YES"
216 fi
217 rm -r $SRV_OUT
218 fi
219
220 if [ "$HAS_IPV6" = "NO" ]; then
221 SKIP_NEXT="YES"
222 fi
223}
224
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200225# skip the next test if valgrind is in use
226not_with_valgrind() {
227 if [ "$MEMCHECK" -gt 0 ]; then
228 SKIP_NEXT="YES"
229 fi
230}
231
Paul Bakker362689d2016-05-13 10:33:25 +0100232# skip the next test if valgrind is NOT in use
233only_with_valgrind() {
234 if [ "$MEMCHECK" -eq 0 ]; then
235 SKIP_NEXT="YES"
236 fi
237}
238
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200239# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100240client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200241 CLI_DELAY_FACTOR=$1
242}
243
Janos Follath74537a62016-09-02 13:45:28 +0100244# wait for the given seconds after the client finished in the next test
245server_needs_more_time() {
246 SRV_DELAY_SECONDS=$1
247}
248
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249# print_name <name>
250print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100251 TESTS=$(( $TESTS + 1 ))
252 LINE=""
253
254 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
255 LINE="$TESTS "
256 fi
257
258 LINE="$LINE$1"
259 printf "$LINE "
260 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100261 for i in `seq 1 $LEN`; do printf '.'; done
262 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100263
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100264}
265
266# fail <message>
267fail() {
268 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100269 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100270
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200271 mv $SRV_OUT o-srv-${TESTS}.log
272 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200273 if [ -n "$PXY_CMD" ]; then
274 mv $PXY_OUT o-pxy-${TESTS}.log
275 fi
276 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100277
Manuel Pégourié-Gonnardbc079e22020-06-08 11:49:05 +0200278 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200279 echo " ! server output:"
280 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200281 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200282 echo " ! client output:"
283 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200284 if [ -n "$PXY_CMD" ]; then
285 echo " ! ========================================================"
286 echo " ! proxy output:"
287 cat o-pxy-${TESTS}.log
288 fi
289 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200290 fi
291
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200292 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100293}
294
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100295# is_polar <cmd_line>
296is_polar() {
297 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
298}
299
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200300# openssl s_server doesn't have -www with DTLS
301check_osrv_dtls() {
302 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
303 NEEDS_INPUT=1
304 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
305 else
306 NEEDS_INPUT=0
307 fi
308}
309
310# provide input to commands that need it
311provide_input() {
312 if [ $NEEDS_INPUT -eq 0 ]; then
313 return
314 fi
315
316 while true; do
317 echo "HTTP/1.0 200 OK"
318 sleep 1
319 done
320}
321
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100322# has_mem_err <log_file_name>
323has_mem_err() {
324 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
325 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
326 then
327 return 1 # false: does not have errors
328 else
329 return 0 # true: has errors
330 fi
331}
332
Unknownb86bcb42019-09-02 10:42:57 -0400333# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100334if type lsof >/dev/null 2>/dev/null; then
Unknownb86bcb42019-09-02 10:42:57 -0400335 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100336 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200337 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100338 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200339 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100340 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200341 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100342 # Make a tight loop, server normally takes less than 1s to start.
343 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
344 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknownb86bcb42019-09-02 10:42:57 -0400345 echo "$3 START TIMEOUT"
346 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100347 break
348 fi
349 # Linux and *BSD support decimal arguments to sleep. On other
350 # OSes this may be a tight loop.
351 sleep 0.1 2>/dev/null || true
352 done
353 }
354else
Unknownb86bcb42019-09-02 10:42:57 -0400355 echo "Warning: lsof not available, wait_app_start = sleep"
356 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200357 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100358 }
359fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200360
Unknownb86bcb42019-09-02 10:42:57 -0400361# Wait for server process $2 to be listening on port $1.
362wait_server_start() {
363 wait_app_start $1 $2 "SERVER" $SRV_OUT
364}
365
366# Wait for proxy process $2 to be listening on port $1.
367wait_proxy_start() {
368 wait_app_start $1 $2 "PROXY" $PXY_OUT
369}
370
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100371# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100372# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100373# acceptable bounds
374check_server_hello_time() {
375 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100376 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100377 # Get the Unix timestamp for now
378 CUR_TIME=$(date +'%s')
379 THRESHOLD_IN_SECS=300
380
381 # Check if the ServerHello time was printed
382 if [ -z "$SERVER_HELLO_TIME" ]; then
383 return 1
384 fi
385
386 # Check the time in ServerHello is within acceptable bounds
387 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
388 # The time in ServerHello is at least 5 minutes before now
389 return 1
390 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100391 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100392 return 1
393 else
394 return 0
395 fi
396}
397
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200398# wait for client to terminate and set CLI_EXIT
399# must be called right after starting the client
400wait_client_done() {
401 CLI_PID=$!
402
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200403 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
404 CLI_DELAY_FACTOR=1
405
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200406 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200407 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200408
409 wait $CLI_PID
410 CLI_EXIT=$?
411
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200412 kill $DOG_PID >/dev/null 2>&1
413 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200414
415 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100416
417 sleep $SRV_DELAY_SECONDS
418 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200419}
420
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200421# check if the given command uses dtls and sets global variable DTLS
422detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200423 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200424 DTLS=1
425 else
426 DTLS=0
427 fi
428}
429
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200430# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100431# Options: -s pattern pattern that must be present in server output
432# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100433# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100434# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100435# -S pattern pattern that must be absent in server output
436# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100437# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100438# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100439run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100440 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200441 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100442
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100443 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
444 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200445 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100446 return
447 fi
448
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100449 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100450
Paul Bakkerb7584a52016-05-10 10:50:43 +0100451 # Do we only run numbered tests?
452 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
453 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
454 else
455 SKIP_NEXT="YES"
456 fi
457
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200458 # should we skip?
459 if [ "X$SKIP_NEXT" = "XYES" ]; then
460 SKIP_NEXT="NO"
461 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200462 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200463 return
464 fi
465
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200466 # does this test use a proxy?
467 if [ "X$1" = "X-p" ]; then
468 PXY_CMD="$2"
469 shift 2
470 else
471 PXY_CMD=""
472 fi
473
474 # get commands and client output
475 SRV_CMD="$1"
476 CLI_CMD="$2"
477 CLI_EXPECT="$3"
478 shift 3
479
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200480 # update DTLS variable
481 detect_dtls "$SRV_CMD"
482
Manuel Pégourié-Gonnard1fcb1a12020-06-08 11:40:06 +0200483 # if the test uses DTLS but no custom proxy, add a simple proxy
484 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnardc5ae9c82020-06-25 09:54:46 +0200485 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard1fcb1a12020-06-08 11:40:06 +0200486 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnarded0aaf42020-07-16 10:19:32 +0200487 case " $SRV_CMD " in
488 *' server_addr=::1 '*)
489 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
490 esac
Manuel Pégourié-Gonnard1fcb1a12020-06-08 11:40:06 +0200491 fi
492
Manuel Pégourié-Gonnard57e328e2020-06-25 09:52:54 +0200493 # fix client port
494 if [ -n "$PXY_CMD" ]; then
495 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
496 else
497 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
498 fi
499
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100500 # prepend valgrind to our commands if active
501 if [ "$MEMCHECK" -gt 0 ]; then
502 if is_polar "$SRV_CMD"; then
503 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
504 fi
505 if is_polar "$CLI_CMD"; then
506 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
507 fi
508 fi
509
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200510 TIMES_LEFT=2
511 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200512 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200513
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200514 # run the commands
515 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarde5201e42020-06-08 12:06:21 +0200516 printf "# $NAME\n$PXY_CMD\n" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200517 $PXY_CMD >> $PXY_OUT 2>&1 &
518 PXY_PID=$!
Unknownb86bcb42019-09-02 10:42:57 -0400519 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200520 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200521
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200522 check_osrv_dtls
Manuel Pégourié-Gonnarde5201e42020-06-08 12:06:21 +0200523 printf "# $NAME\n$SRV_CMD\n" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200524 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
525 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100526 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200527
Manuel Pégourié-Gonnarde5201e42020-06-08 12:06:21 +0200528 printf "# $NAME\n$CLI_CMD\n" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200529 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
530 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100531
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200532 # terminate the server (and the proxy)
533 kill $SRV_PID
534 wait $SRV_PID
535 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
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100567 # check server exit code
568 if [ $? != 0 ]; then
569 fail "server fail"
570 return
571 fi
572
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100573 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100574 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
575 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100576 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200577 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100578 return
579 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100580
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100581 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200582 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100583 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100584 while [ $# -gt 0 ]
585 do
586 case $1 in
587 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100588 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 +0100589 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100590 return
591 fi
592 ;;
593
594 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100595 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 +0100596 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100597 return
598 fi
599 ;;
600
601 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100602 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 +0100603 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100604 return
605 fi
606 ;;
607
608 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100609 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 +0100610 fail "pattern '$2' MUST NOT be present in the Client output"
611 return
612 fi
613 ;;
614
615 # The filtering in the following two options (-u and -U) do the following
616 # - ignore valgrind output
Antonin Décimo8fd91562019-01-23 15:24:37 +0100617 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100618 # - keep one of each non-unique line
619 # - count how many lines remain
620 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
621 # if there were no duplicates.
622 "-U")
623 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
624 fail "lines following pattern '$2' must be unique in Server output"
625 return
626 fi
627 ;;
628
629 "-u")
630 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
631 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100632 return
633 fi
634 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100635 "-F")
636 if ! $2 "$SRV_OUT"; then
637 fail "function call to '$2' failed on Server output"
638 return
639 fi
640 ;;
641 "-f")
642 if ! $2 "$CLI_OUT"; then
643 fail "function call to '$2' failed on Client output"
644 return
645 fi
646 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100647
648 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200649 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100650 exit 1
651 esac
652 shift 2
653 done
654
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100655 # check valgrind's results
656 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200657 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100658 fail "Server has memory errors"
659 return
660 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200661 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100662 fail "Client has memory errors"
663 return
664 fi
665 fi
666
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100667 # if we're here, everything is ok
668 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100669 if [ "$PRESERVE_LOGS" -gt 0 ]; then
670 mv $SRV_OUT o-srv-${TESTS}.log
671 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Beckerdc6c0e42018-08-20 12:21:35 +0100672 if [ -n "$PXY_CMD" ]; then
673 mv $PXY_OUT o-pxy-${TESTS}.log
674 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100675 fi
676
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200677 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100678}
679
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100680cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200681 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200682 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
683 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
684 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
685 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100686 exit 1
687}
688
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100689#
690# MAIN
691#
692
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000693if cd $( dirname $0 ); then :; else
694 echo "cd $( dirname $0 ) failed" >&2
695 exit 1
696fi
697
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100698get_options "$@"
699
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100700# sanity checks, avoid an avalanche of errors
701if [ ! -x "$P_SRV" ]; then
702 echo "Command '$P_SRV' is not an executable file"
703 exit 1
704fi
705if [ ! -x "$P_CLI" ]; then
706 echo "Command '$P_CLI' is not an executable file"
707 exit 1
708fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200709if [ ! -x "$P_PXY" ]; then
710 echo "Command '$P_PXY' is not an executable file"
711 exit 1
712fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100713if [ "$MEMCHECK" -gt 0 ]; then
714 if which valgrind >/dev/null 2>&1; then :; else
715 echo "Memcheck not possible. Valgrind not found"
716 exit 1
717 fi
718fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100719if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
720 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100721 exit 1
722fi
723
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200724# used by watchdog
725MAIN_PID="$$"
726
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100727# We use somewhat arbitrary delays for tests:
728# - how long do we wait for the server to start (when lsof not available)?
729# - how long do we allow for the client to finish?
730# (not to check performance, just to avoid waiting indefinitely)
731# Things are slower with valgrind, so give extra time here.
732#
733# Note: without lsof, there is a trade-off between the running time of this
734# script and the risk of spurious errors because we didn't wait long enough.
735# The watchdog delay on the other hand doesn't affect normal running time of
736# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200737if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100738 START_DELAY=6
739 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200740else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100741 START_DELAY=2
742 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200743fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100744
745# some particular tests need more time:
746# - for the client, we multiply the usual watchdog limit by a factor
747# - for the server, we sleep for a number of seconds after the client exits
748# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200749CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100750SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200751
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200752# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000753# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200754P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
755P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100756P_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 +0200757O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200758O_CLI="$O_CLI -connect localhost:+SRV_PORT"
759G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000760G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200761
Gilles Peskine62469d92017-05-10 10:13:59 +0200762# Allow SHA-1, because many of our test certificates use it
763P_SRV="$P_SRV allow_sha1=1"
764P_CLI="$P_CLI allow_sha1=1"
765
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200766# Also pick a unique name for intermediate files
767SRV_OUT="srv_out.$$"
768CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200769PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200770SESSION="session.$$"
771
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200772SKIP_NEXT="NO"
773
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100774trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100775
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200776# Basic test
777
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200778# Checks that:
779# - things work with all ciphersuites active (used with config-full in all.sh)
780# - the expected (highest security) parameters are selected
781# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200782run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200783 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200784 "$P_CLI" \
785 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200786 -s "Protocol is TLSv1.2" \
787 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
788 -s "client hello v3, signature_algorithm ext: 6" \
789 -s "ECDHE curve: secp521r1" \
790 -S "error" \
791 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200792
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000793run_test "Default, DTLS" \
794 "$P_SRV dtls=1" \
795 "$P_CLI dtls=1" \
796 0 \
797 -s "Protocol is DTLSv1.2" \
798 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
799
Manuel Pégourié-Gonnard45575512020-01-02 11:58:00 +0100800requires_config_enabled MBEDTLS_ZLIB_SUPPORT
801run_test "Default (compression enabled)" \
802 "$P_SRV debug_level=3" \
803 "$P_CLI debug_level=3" \
804 0 \
805 -s "Allocating compression buffer" \
806 -c "Allocating compression buffer" \
807 -s "Record expansion is unknown (compression)" \
808 -c "Record expansion is unknown (compression)" \
809 -S "error" \
810 -C "error"
811
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100812# Test current time in ServerHello
813requires_config_enabled MBEDTLS_HAVE_TIME
814run_test "Default, ServerHello contains gmt_unix_time" \
815 "$P_SRV debug_level=3" \
816 "$P_CLI debug_level=3" \
817 0 \
818 -s "Protocol is TLSv1.2" \
819 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
820 -s "client hello v3, signature_algorithm ext: 6" \
821 -s "ECDHE curve: secp521r1" \
822 -S "error" \
823 -C "error" \
824 -f "check_server_hello_time" \
825 -F "check_server_hello_time"
826
Simon Butcher8e004102016-10-14 00:48:33 +0100827# Test for uniqueness of IVs in AEAD ciphersuites
828run_test "Unique IV in GCM" \
829 "$P_SRV exchanges=20 debug_level=4" \
830 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
831 0 \
832 -u "IV used" \
833 -U "IV used"
834
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100835# Tests for rc4 option
836
Simon Butchera410af52016-05-19 22:12:18 +0100837requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100838run_test "RC4: server disabled, client enabled" \
839 "$P_SRV" \
840 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
841 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100842 -s "SSL - The server has no ciphersuites in common"
843
Simon Butchera410af52016-05-19 22:12:18 +0100844requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100845run_test "RC4: server half, client enabled" \
846 "$P_SRV arc4=1" \
847 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
848 1 \
849 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100850
851run_test "RC4: server enabled, client disabled" \
852 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
853 "$P_CLI" \
854 1 \
855 -s "SSL - The server has no ciphersuites in common"
856
857run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100858 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100859 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
860 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100861 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100862 -S "SSL - The server has no ciphersuites in common"
863
Hanno Becker3a333a52018-08-17 09:54:10 +0100864# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
865
866requires_gnutls
867requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
868run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
869 "$G_SRV"\
870 "$P_CLI force_version=tls1_1" \
871 0
872
873requires_gnutls
874requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
875run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
876 "$G_SRV"\
877 "$P_CLI force_version=tls1" \
878 0
879
Gilles Peskinebc70a182017-05-09 15:59:24 +0200880# Tests for SHA-1 support
881
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200882requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200883run_test "SHA-1 forbidden by default in server certificate" \
884 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
885 "$P_CLI debug_level=2 allow_sha1=0" \
886 1 \
887 -c "The certificate is signed with an unacceptable hash"
888
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200889requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
890run_test "SHA-1 forbidden by default in server certificate" \
891 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
892 "$P_CLI debug_level=2 allow_sha1=0" \
893 0
894
Gilles Peskinebc70a182017-05-09 15:59:24 +0200895run_test "SHA-1 explicitly allowed in server certificate" \
896 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
897 "$P_CLI allow_sha1=1" \
898 0
899
900run_test "SHA-256 allowed by default in server certificate" \
901 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
902 "$P_CLI allow_sha1=0" \
903 0
904
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200905requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200906run_test "SHA-1 forbidden by default in client certificate" \
907 "$P_SRV auth_mode=required allow_sha1=0" \
908 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
909 1 \
910 -s "The certificate is signed with an unacceptable hash"
911
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200912requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
913run_test "SHA-1 forbidden by default in client certificate" \
914 "$P_SRV auth_mode=required allow_sha1=0" \
915 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
916 0
917
Gilles Peskinebc70a182017-05-09 15:59:24 +0200918run_test "SHA-1 explicitly allowed in client certificate" \
919 "$P_SRV auth_mode=required allow_sha1=1" \
920 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
921 0
922
923run_test "SHA-256 allowed by default in client certificate" \
924 "$P_SRV auth_mode=required allow_sha1=0" \
925 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
926 0
927
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100928# Tests for Truncated HMAC extension
929
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100930run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200931 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100932 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100933 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000934 -s "dumping 'expected mac' (20 bytes)" \
935 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100936
Hanno Becker32c55012017-11-10 08:42:54 +0000937requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100938run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200939 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000940 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100941 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000942 -s "dumping 'expected mac' (20 bytes)" \
943 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100944
Hanno Becker32c55012017-11-10 08:42:54 +0000945requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100946run_test "Truncated HMAC: client enabled, server default" \
947 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000948 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100949 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000950 -s "dumping 'expected mac' (20 bytes)" \
951 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100952
Hanno Becker32c55012017-11-10 08:42:54 +0000953requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100954run_test "Truncated HMAC: client enabled, server disabled" \
955 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000956 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100957 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000958 -s "dumping 'expected mac' (20 bytes)" \
959 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100960
Hanno Becker32c55012017-11-10 08:42:54 +0000961requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000962run_test "Truncated HMAC: client disabled, server enabled" \
963 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000964 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000965 0 \
966 -s "dumping 'expected mac' (20 bytes)" \
967 -S "dumping 'expected mac' (10 bytes)"
968
969requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100970run_test "Truncated HMAC: client enabled, server enabled" \
971 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000972 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100973 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000974 -S "dumping 'expected mac' (20 bytes)" \
975 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100976
Hanno Becker4c4f4102017-11-10 09:16:05 +0000977run_test "Truncated HMAC, DTLS: client default, server default" \
978 "$P_SRV dtls=1 debug_level=4" \
979 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
980 0 \
981 -s "dumping 'expected mac' (20 bytes)" \
982 -S "dumping 'expected mac' (10 bytes)"
983
984requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
985run_test "Truncated HMAC, DTLS: client disabled, server default" \
986 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000987 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000988 0 \
989 -s "dumping 'expected mac' (20 bytes)" \
990 -S "dumping 'expected mac' (10 bytes)"
991
992requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
993run_test "Truncated HMAC, DTLS: client enabled, server default" \
994 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000995 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000996 0 \
997 -s "dumping 'expected mac' (20 bytes)" \
998 -S "dumping 'expected mac' (10 bytes)"
999
1000requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1001run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1002 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001003 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001004 0 \
1005 -s "dumping 'expected mac' (20 bytes)" \
1006 -S "dumping 'expected mac' (10 bytes)"
1007
1008requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1009run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1010 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001011 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001012 0 \
1013 -s "dumping 'expected mac' (20 bytes)" \
1014 -S "dumping 'expected mac' (10 bytes)"
1015
1016requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1017run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1018 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001019 "$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 +01001020 0 \
1021 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001022 -s "dumping 'expected mac' (10 bytes)"
1023
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001024# Tests for Encrypt-then-MAC extension
1025
1026run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001027 "$P_SRV debug_level=3 \
1028 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001029 "$P_CLI debug_level=3" \
1030 0 \
1031 -c "client hello, adding encrypt_then_mac extension" \
1032 -s "found encrypt then mac extension" \
1033 -s "server hello, adding encrypt then mac extension" \
1034 -c "found encrypt_then_mac extension" \
1035 -c "using encrypt then mac" \
1036 -s "using encrypt then mac"
1037
1038run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001039 "$P_SRV debug_level=3 etm=0 \
1040 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001041 "$P_CLI debug_level=3 etm=1" \
1042 0 \
1043 -c "client hello, adding encrypt_then_mac extension" \
1044 -s "found encrypt then mac extension" \
1045 -S "server hello, adding encrypt then mac extension" \
1046 -C "found encrypt_then_mac extension" \
1047 -C "using encrypt then mac" \
1048 -S "using encrypt then mac"
1049
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001050run_test "Encrypt then MAC: client enabled, aead cipher" \
1051 "$P_SRV debug_level=3 etm=1 \
1052 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1053 "$P_CLI debug_level=3 etm=1" \
1054 0 \
1055 -c "client hello, adding encrypt_then_mac extension" \
1056 -s "found encrypt then mac extension" \
1057 -S "server hello, adding encrypt then mac extension" \
1058 -C "found encrypt_then_mac extension" \
1059 -C "using encrypt then mac" \
1060 -S "using encrypt then mac"
1061
1062run_test "Encrypt then MAC: client enabled, stream cipher" \
1063 "$P_SRV debug_level=3 etm=1 \
1064 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001065 "$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 +01001066 0 \
1067 -c "client hello, adding encrypt_then_mac extension" \
1068 -s "found encrypt then mac extension" \
1069 -S "server hello, adding encrypt then mac extension" \
1070 -C "found encrypt_then_mac extension" \
1071 -C "using encrypt then mac" \
1072 -S "using encrypt then mac"
1073
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001074run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001075 "$P_SRV debug_level=3 etm=1 \
1076 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001077 "$P_CLI debug_level=3 etm=0" \
1078 0 \
1079 -C "client hello, adding encrypt_then_mac extension" \
1080 -S "found encrypt then mac extension" \
1081 -S "server hello, adding encrypt then mac extension" \
1082 -C "found encrypt_then_mac extension" \
1083 -C "using encrypt then mac" \
1084 -S "using encrypt then mac"
1085
Janos Follathe2681a42016-03-07 15:57:05 +00001086requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001087run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001088 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001089 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001090 "$P_CLI debug_level=3 force_version=ssl3" \
1091 0 \
1092 -C "client hello, adding encrypt_then_mac extension" \
1093 -S "found encrypt then mac extension" \
1094 -S "server hello, adding encrypt then mac extension" \
1095 -C "found encrypt_then_mac extension" \
1096 -C "using encrypt then mac" \
1097 -S "using encrypt then mac"
1098
Janos Follathe2681a42016-03-07 15:57:05 +00001099requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001100run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001101 "$P_SRV debug_level=3 force_version=ssl3 \
1102 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001103 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001104 0 \
1105 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001106 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001107 -S "server hello, adding encrypt then mac extension" \
1108 -C "found encrypt_then_mac extension" \
1109 -C "using encrypt then mac" \
1110 -S "using encrypt then mac"
1111
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001112# Tests for Extended Master Secret extension
1113
1114run_test "Extended Master Secret: default" \
1115 "$P_SRV debug_level=3" \
1116 "$P_CLI debug_level=3" \
1117 0 \
1118 -c "client hello, adding extended_master_secret extension" \
1119 -s "found extended master secret extension" \
1120 -s "server hello, adding extended master secret extension" \
1121 -c "found extended_master_secret extension" \
1122 -c "using extended master secret" \
1123 -s "using extended master secret"
1124
1125run_test "Extended Master Secret: client enabled, server disabled" \
1126 "$P_SRV debug_level=3 extended_ms=0" \
1127 "$P_CLI debug_level=3 extended_ms=1" \
1128 0 \
1129 -c "client hello, adding extended_master_secret extension" \
1130 -s "found extended master secret extension" \
1131 -S "server hello, adding extended master secret extension" \
1132 -C "found extended_master_secret extension" \
1133 -C "using extended master secret" \
1134 -S "using extended master secret"
1135
1136run_test "Extended Master Secret: client disabled, server enabled" \
1137 "$P_SRV debug_level=3 extended_ms=1" \
1138 "$P_CLI debug_level=3 extended_ms=0" \
1139 0 \
1140 -C "client hello, adding extended_master_secret extension" \
1141 -S "found extended master secret extension" \
1142 -S "server hello, adding extended master secret extension" \
1143 -C "found extended_master_secret extension" \
1144 -C "using extended master secret" \
1145 -S "using extended master secret"
1146
Janos Follathe2681a42016-03-07 15:57:05 +00001147requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001148run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001149 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001150 "$P_CLI debug_level=3 force_version=ssl3" \
1151 0 \
1152 -C "client hello, adding extended_master_secret extension" \
1153 -S "found extended master secret extension" \
1154 -S "server hello, adding extended master secret extension" \
1155 -C "found extended_master_secret extension" \
1156 -C "using extended master secret" \
1157 -S "using extended master secret"
1158
Janos Follathe2681a42016-03-07 15:57:05 +00001159requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001160run_test "Extended Master Secret: client enabled, server SSLv3" \
1161 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001162 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001163 0 \
1164 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001165 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001166 -S "server hello, adding extended master secret extension" \
1167 -C "found extended_master_secret extension" \
1168 -C "using extended master secret" \
1169 -S "using extended master secret"
1170
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001171# Tests for FALLBACK_SCSV
1172
1173run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001174 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001175 "$P_CLI debug_level=3 force_version=tls1_1" \
1176 0 \
1177 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001178 -S "received FALLBACK_SCSV" \
1179 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001180 -C "is a fatal alert message (msg 86)"
1181
1182run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001183 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001184 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1185 0 \
1186 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001187 -S "received FALLBACK_SCSV" \
1188 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001189 -C "is a fatal alert message (msg 86)"
1190
1191run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001192 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001193 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001194 1 \
1195 -c "adding FALLBACK_SCSV" \
1196 -s "received FALLBACK_SCSV" \
1197 -s "inapropriate fallback" \
1198 -c "is a fatal alert message (msg 86)"
1199
1200run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001201 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001202 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001203 0 \
1204 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001205 -s "received FALLBACK_SCSV" \
1206 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001207 -C "is a fatal alert message (msg 86)"
1208
1209requires_openssl_with_fallback_scsv
1210run_test "Fallback SCSV: default, openssl server" \
1211 "$O_SRV" \
1212 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1213 0 \
1214 -C "adding FALLBACK_SCSV" \
1215 -C "is a fatal alert message (msg 86)"
1216
1217requires_openssl_with_fallback_scsv
1218run_test "Fallback SCSV: enabled, openssl server" \
1219 "$O_SRV" \
1220 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1221 1 \
1222 -c "adding FALLBACK_SCSV" \
1223 -c "is a fatal alert message (msg 86)"
1224
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001225requires_openssl_with_fallback_scsv
1226run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001227 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001228 "$O_CLI -tls1_1" \
1229 0 \
1230 -S "received FALLBACK_SCSV" \
1231 -S "inapropriate fallback"
1232
1233requires_openssl_with_fallback_scsv
1234run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001235 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001236 "$O_CLI -tls1_1 -fallback_scsv" \
1237 1 \
1238 -s "received FALLBACK_SCSV" \
1239 -s "inapropriate fallback"
1240
1241requires_openssl_with_fallback_scsv
1242run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001243 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001244 "$O_CLI -fallback_scsv" \
1245 0 \
1246 -s "received FALLBACK_SCSV" \
1247 -S "inapropriate fallback"
1248
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001249# Test sending and receiving empty application data records
1250
1251run_test "Encrypt then MAC: empty application data record" \
1252 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1253 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1254 0 \
1255 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1256 -s "dumping 'input payload after decrypt' (0 bytes)" \
1257 -c "0 bytes written in 1 fragments"
1258
Manuel Pégourié-Gonnardd6e44542020-03-24 10:53:39 +01001259run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001260 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1261 "$P_CLI auth_mode=none etm=0 request_size=0" \
1262 0 \
1263 -s "dumping 'input payload after decrypt' (0 bytes)" \
1264 -c "0 bytes written in 1 fragments"
1265
1266run_test "Encrypt then MAC, DTLS: empty application data record" \
1267 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1268 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1269 0 \
1270 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1271 -s "dumping 'input payload after decrypt' (0 bytes)" \
1272 -c "0 bytes written in 1 fragments"
1273
Manuel Pégourié-Gonnardd6e44542020-03-24 10:53:39 +01001274run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001275 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1276 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1277 0 \
1278 -s "dumping 'input payload after decrypt' (0 bytes)" \
1279 -c "0 bytes written in 1 fragments"
1280
Gilles Peskined50177f2017-05-16 17:53:03 +02001281## ClientHello generated with
1282## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1283## then manually twiddling the ciphersuite list.
1284## The ClientHello content is spelled out below as a hex string as
1285## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1286## The expected response is an inappropriate_fallback alert.
1287requires_openssl_with_fallback_scsv
1288run_test "Fallback SCSV: beginning of list" \
1289 "$P_SRV debug_level=2" \
1290 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1291 0 \
1292 -s "received FALLBACK_SCSV" \
1293 -s "inapropriate fallback"
1294
1295requires_openssl_with_fallback_scsv
1296run_test "Fallback SCSV: end of list" \
1297 "$P_SRV debug_level=2" \
1298 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1299 0 \
1300 -s "received FALLBACK_SCSV" \
1301 -s "inapropriate fallback"
1302
1303## Here the expected response is a valid ServerHello prefix, up to the random.
1304requires_openssl_with_fallback_scsv
1305run_test "Fallback SCSV: not in list" \
1306 "$P_SRV debug_level=2" \
1307 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1308 0 \
1309 -S "received FALLBACK_SCSV" \
1310 -S "inapropriate fallback"
1311
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001312# Tests for CBC 1/n-1 record splitting
1313
1314run_test "CBC Record splitting: TLS 1.2, no splitting" \
1315 "$P_SRV" \
1316 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1317 request_size=123 force_version=tls1_2" \
1318 0 \
1319 -s "Read from client: 123 bytes read" \
1320 -S "Read from client: 1 bytes read" \
1321 -S "122 bytes read"
1322
1323run_test "CBC Record splitting: TLS 1.1, no splitting" \
1324 "$P_SRV" \
1325 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1326 request_size=123 force_version=tls1_1" \
1327 0 \
1328 -s "Read from client: 123 bytes read" \
1329 -S "Read from client: 1 bytes read" \
1330 -S "122 bytes read"
1331
1332run_test "CBC Record splitting: TLS 1.0, splitting" \
1333 "$P_SRV" \
1334 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1335 request_size=123 force_version=tls1" \
1336 0 \
1337 -S "Read from client: 123 bytes read" \
1338 -s "Read from client: 1 bytes read" \
1339 -s "122 bytes read"
1340
Janos Follathe2681a42016-03-07 15:57:05 +00001341requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001342run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001343 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001344 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1345 request_size=123 force_version=ssl3" \
1346 0 \
1347 -S "Read from client: 123 bytes read" \
1348 -s "Read from client: 1 bytes read" \
1349 -s "122 bytes read"
1350
1351run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001352 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001353 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1354 request_size=123 force_version=tls1" \
1355 0 \
1356 -s "Read from client: 123 bytes read" \
1357 -S "Read from client: 1 bytes read" \
1358 -S "122 bytes read"
1359
1360run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1361 "$P_SRV" \
1362 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1363 request_size=123 force_version=tls1 recsplit=0" \
1364 0 \
1365 -s "Read from client: 123 bytes read" \
1366 -S "Read from client: 1 bytes read" \
1367 -S "122 bytes read"
1368
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001369run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1370 "$P_SRV nbio=2" \
1371 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1372 request_size=123 force_version=tls1" \
1373 0 \
1374 -S "Read from client: 123 bytes read" \
1375 -s "Read from client: 1 bytes read" \
1376 -s "122 bytes read"
1377
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001378# Tests for Session Tickets
1379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001380run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_SRV debug_level=3 tickets=1" \
1382 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001383 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001384 -c "client hello, adding session ticket extension" \
1385 -s "found session ticket extension" \
1386 -s "server hello, adding session ticket extension" \
1387 -c "found session_ticket extension" \
1388 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001389 -S "session successfully restored from cache" \
1390 -s "session successfully restored from ticket" \
1391 -s "a session has been resumed" \
1392 -c "a session has been resumed"
1393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001394run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001395 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1396 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001397 0 \
1398 -c "client hello, adding session ticket extension" \
1399 -s "found session ticket extension" \
1400 -s "server hello, adding session ticket extension" \
1401 -c "found session_ticket extension" \
1402 -c "parse new session ticket" \
1403 -S "session successfully restored from cache" \
1404 -s "session successfully restored from ticket" \
1405 -s "a session has been resumed" \
1406 -c "a session has been resumed"
1407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001408run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001409 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1410 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001411 0 \
1412 -c "client hello, adding session ticket extension" \
1413 -s "found session ticket extension" \
1414 -s "server hello, adding session ticket extension" \
1415 -c "found session_ticket extension" \
1416 -c "parse new session ticket" \
1417 -S "session successfully restored from cache" \
1418 -S "session successfully restored from ticket" \
1419 -S "a session has been resumed" \
1420 -C "a session has been resumed"
1421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001422run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001423 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001424 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001425 0 \
1426 -c "client hello, adding session ticket extension" \
1427 -c "found session_ticket extension" \
1428 -c "parse new session ticket" \
1429 -c "a session has been resumed"
1430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001431run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001432 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001433 "( $O_CLI -sess_out $SESSION; \
1434 $O_CLI -sess_in $SESSION; \
1435 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001436 0 \
1437 -s "found session ticket extension" \
1438 -s "server hello, adding session ticket extension" \
1439 -S "session successfully restored from cache" \
1440 -s "session successfully restored from ticket" \
1441 -s "a session has been resumed"
1442
Hanno Beckerb5546362018-08-21 13:55:22 +01001443# Tests for Session Tickets with DTLS
1444
1445run_test "Session resume using tickets, DTLS: basic" \
1446 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001447 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001448 0 \
1449 -c "client hello, adding session ticket extension" \
1450 -s "found session ticket extension" \
1451 -s "server hello, adding session ticket extension" \
1452 -c "found session_ticket extension" \
1453 -c "parse new session ticket" \
1454 -S "session successfully restored from cache" \
1455 -s "session successfully restored from ticket" \
1456 -s "a session has been resumed" \
1457 -c "a session has been resumed"
1458
1459run_test "Session resume using tickets, DTLS: cache disabled" \
1460 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001461 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001462 0 \
1463 -c "client hello, adding session ticket extension" \
1464 -s "found session ticket extension" \
1465 -s "server hello, adding session ticket extension" \
1466 -c "found session_ticket extension" \
1467 -c "parse new session ticket" \
1468 -S "session successfully restored from cache" \
1469 -s "session successfully restored from ticket" \
1470 -s "a session has been resumed" \
1471 -c "a session has been resumed"
1472
1473run_test "Session resume using tickets, DTLS: timeout" \
1474 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001475 "$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 +01001476 0 \
1477 -c "client hello, adding session ticket extension" \
1478 -s "found session ticket extension" \
1479 -s "server hello, adding session ticket extension" \
1480 -c "found session_ticket extension" \
1481 -c "parse new session ticket" \
1482 -S "session successfully restored from cache" \
1483 -S "session successfully restored from ticket" \
1484 -S "a session has been resumed" \
1485 -C "a session has been resumed"
1486
1487run_test "Session resume using tickets, DTLS: openssl server" \
1488 "$O_SRV -dtls1" \
1489 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1490 0 \
1491 -c "client hello, adding session ticket extension" \
1492 -c "found session_ticket extension" \
1493 -c "parse new session ticket" \
1494 -c "a session has been resumed"
1495
1496run_test "Session resume using tickets, DTLS: openssl client" \
1497 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1498 "( $O_CLI -dtls1 -sess_out $SESSION; \
1499 $O_CLI -dtls1 -sess_in $SESSION; \
1500 rm -f $SESSION )" \
1501 0 \
1502 -s "found session ticket extension" \
1503 -s "server hello, adding session ticket extension" \
1504 -S "session successfully restored from cache" \
1505 -s "session successfully restored from ticket" \
1506 -s "a session has been resumed"
1507
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001508# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001510run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001511 "$P_SRV debug_level=3 tickets=0" \
1512 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001513 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001514 -c "client hello, adding session ticket extension" \
1515 -s "found session ticket extension" \
1516 -S "server hello, adding session ticket extension" \
1517 -C "found session_ticket extension" \
1518 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001519 -s "session successfully restored from cache" \
1520 -S "session successfully restored from ticket" \
1521 -s "a session has been resumed" \
1522 -c "a session has been resumed"
1523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001524run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_SRV debug_level=3 tickets=1" \
1526 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001527 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001528 -C "client hello, adding session ticket extension" \
1529 -S "found session ticket extension" \
1530 -S "server hello, adding session ticket extension" \
1531 -C "found session_ticket extension" \
1532 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001533 -s "session successfully restored from cache" \
1534 -S "session successfully restored from ticket" \
1535 -s "a session has been resumed" \
1536 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001538run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001539 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1540 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001541 0 \
1542 -S "session successfully restored from cache" \
1543 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001544 -S "a session has been resumed" \
1545 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001547run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001548 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1549 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001550 0 \
1551 -s "session successfully restored from cache" \
1552 -S "session successfully restored from ticket" \
1553 -s "a session has been resumed" \
1554 -c "a session has been resumed"
1555
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001556run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001557 "$P_SRV debug_level=3 tickets=0" \
1558 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001559 0 \
1560 -s "session successfully restored from cache" \
1561 -S "session successfully restored from ticket" \
1562 -s "a session has been resumed" \
1563 -c "a session has been resumed"
1564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001565run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001566 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1567 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001568 0 \
1569 -S "session successfully restored from cache" \
1570 -S "session successfully restored from ticket" \
1571 -S "a session has been resumed" \
1572 -C "a session has been resumed"
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001575 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1576 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001577 0 \
1578 -s "session successfully restored from cache" \
1579 -S "session successfully restored from ticket" \
1580 -s "a session has been resumed" \
1581 -c "a session has been resumed"
1582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001583run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001584 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001585 "( $O_CLI -sess_out $SESSION; \
1586 $O_CLI -sess_in $SESSION; \
1587 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001588 0 \
1589 -s "found session ticket extension" \
1590 -S "server hello, adding session ticket extension" \
1591 -s "session successfully restored from cache" \
1592 -S "session successfully restored from ticket" \
1593 -s "a session has been resumed"
1594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001595run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001596 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001597 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001598 0 \
1599 -C "found session_ticket extension" \
1600 -C "parse new session ticket" \
1601 -c "a session has been resumed"
1602
Hanno Beckerb5546362018-08-21 13:55:22 +01001603# Tests for Session Resume based on session-ID and cache, DTLS
1604
1605run_test "Session resume using cache, DTLS: tickets enabled on client" \
1606 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001607 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001608 0 \
1609 -c "client hello, adding session ticket extension" \
1610 -s "found session ticket extension" \
1611 -S "server hello, adding session ticket extension" \
1612 -C "found session_ticket extension" \
1613 -C "parse new session ticket" \
1614 -s "session successfully restored from cache" \
1615 -S "session successfully restored from ticket" \
1616 -s "a session has been resumed" \
1617 -c "a session has been resumed"
1618
1619run_test "Session resume using cache, DTLS: tickets enabled on server" \
1620 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001621 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001622 0 \
1623 -C "client hello, adding session ticket extension" \
1624 -S "found session ticket extension" \
1625 -S "server hello, adding session ticket extension" \
1626 -C "found session_ticket extension" \
1627 -C "parse new session ticket" \
1628 -s "session successfully restored from cache" \
1629 -S "session successfully restored from ticket" \
1630 -s "a session has been resumed" \
1631 -c "a session has been resumed"
1632
1633run_test "Session resume using cache, DTLS: cache_max=0" \
1634 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001635 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001636 0 \
1637 -S "session successfully restored from cache" \
1638 -S "session successfully restored from ticket" \
1639 -S "a session has been resumed" \
1640 -C "a session has been resumed"
1641
1642run_test "Session resume using cache, DTLS: cache_max=1" \
1643 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001644 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001645 0 \
1646 -s "session successfully restored from cache" \
1647 -S "session successfully restored from ticket" \
1648 -s "a session has been resumed" \
1649 -c "a session has been resumed"
1650
1651run_test "Session resume using cache, DTLS: timeout > delay" \
1652 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001653 "$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 +01001654 0 \
1655 -s "session successfully restored from cache" \
1656 -S "session successfully restored from ticket" \
1657 -s "a session has been resumed" \
1658 -c "a session has been resumed"
1659
1660run_test "Session resume using cache, DTLS: timeout < delay" \
1661 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001662 "$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 +01001663 0 \
1664 -S "session successfully restored from cache" \
1665 -S "session successfully restored from ticket" \
1666 -S "a session has been resumed" \
1667 -C "a session has been resumed"
1668
1669run_test "Session resume using cache, DTLS: no timeout" \
1670 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001671 "$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 +01001672 0 \
1673 -s "session successfully restored from cache" \
1674 -S "session successfully restored from ticket" \
1675 -s "a session has been resumed" \
1676 -c "a session has been resumed"
1677
1678run_test "Session resume using cache, DTLS: openssl client" \
1679 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1680 "( $O_CLI -dtls1 -sess_out $SESSION; \
1681 $O_CLI -dtls1 -sess_in $SESSION; \
1682 rm -f $SESSION )" \
1683 0 \
1684 -s "found session ticket extension" \
1685 -S "server hello, adding session ticket extension" \
1686 -s "session successfully restored from cache" \
1687 -S "session successfully restored from ticket" \
1688 -s "a session has been resumed"
1689
1690run_test "Session resume using cache, DTLS: openssl server" \
1691 "$O_SRV -dtls1" \
1692 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1693 0 \
1694 -C "found session_ticket extension" \
1695 -C "parse new session ticket" \
1696 -c "a session has been resumed"
1697
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001698# Tests for Max Fragment Length extension
1699
Hanno Becker6428f8d2017-09-22 16:58:50 +01001700MAX_CONTENT_LEN_EXPECT='16384'
1701MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1702
1703if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1704 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1705 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1706 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1707 printf "\n"
1708 printf "The tests assume this value and if it changes, the tests in this\n"
1709 printf "script should also be adjusted.\n"
1710 printf "\n"
1711
1712 exit 1
1713fi
1714
Hanno Becker4aed27e2017-09-18 15:00:34 +01001715requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001716run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001717 "$P_SRV debug_level=3" \
1718 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001719 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001720 -c "Maximum fragment length is 16384" \
1721 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001722 -C "client hello, adding max_fragment_length extension" \
1723 -S "found max fragment length extension" \
1724 -S "server hello, max_fragment_length extension" \
1725 -C "found max_fragment_length extension"
1726
Hanno Becker4aed27e2017-09-18 15:00:34 +01001727requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001728run_test "Max fragment length: enabled, default, larger message" \
1729 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001730 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001731 0 \
1732 -c "Maximum fragment length is 16384" \
1733 -s "Maximum fragment length is 16384" \
1734 -C "client hello, adding max_fragment_length extension" \
1735 -S "found max fragment length extension" \
1736 -S "server hello, max_fragment_length extension" \
1737 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001738 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001739 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001740 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001741
1742requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1743run_test "Max fragment length, DTLS: enabled, default, larger message" \
1744 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001745 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001746 1 \
1747 -c "Maximum fragment length is 16384" \
1748 -s "Maximum fragment length is 16384" \
1749 -C "client hello, adding max_fragment_length extension" \
1750 -S "found max fragment length extension" \
1751 -S "server hello, max_fragment_length extension" \
1752 -C "found max_fragment_length extension" \
1753 -c "fragment larger than.*maximum "
1754
1755requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1756run_test "Max fragment length: disabled, larger message" \
1757 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001758 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001759 0 \
1760 -C "Maximum fragment length is 16384" \
1761 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001762 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001763 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001764 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001765
1766requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1767run_test "Max fragment length DTLS: disabled, larger message" \
1768 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001769 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001770 1 \
1771 -C "Maximum fragment length is 16384" \
1772 -S "Maximum fragment length is 16384" \
1773 -c "fragment larger than.*maximum "
1774
1775requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001776run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001777 "$P_SRV debug_level=3" \
1778 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001779 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001780 -c "Maximum fragment length is 4096" \
1781 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001782 -c "client hello, adding max_fragment_length extension" \
1783 -s "found max fragment length extension" \
1784 -s "server hello, max_fragment_length extension" \
1785 -c "found max_fragment_length extension"
1786
Hanno Becker4aed27e2017-09-18 15:00:34 +01001787requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001788run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001789 "$P_SRV debug_level=3 max_frag_len=4096" \
1790 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001791 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001792 -c "Maximum fragment length is 16384" \
1793 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001794 -C "client hello, adding max_fragment_length extension" \
1795 -S "found max fragment length extension" \
1796 -S "server hello, max_fragment_length extension" \
1797 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001798
Hanno Becker4aed27e2017-09-18 15:00:34 +01001799requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001800requires_gnutls
1801run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001802 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001803 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001804 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001805 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001806 -c "client hello, adding max_fragment_length extension" \
1807 -c "found max_fragment_length extension"
1808
Hanno Becker4aed27e2017-09-18 15:00:34 +01001809requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001810run_test "Max fragment length: client, message just fits" \
1811 "$P_SRV debug_level=3" \
1812 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1813 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001814 -c "Maximum fragment length is 2048" \
1815 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001816 -c "client hello, adding max_fragment_length extension" \
1817 -s "found max fragment length extension" \
1818 -s "server hello, max_fragment_length extension" \
1819 -c "found max_fragment_length extension" \
1820 -c "2048 bytes written in 1 fragments" \
1821 -s "2048 bytes read"
1822
Hanno Becker4aed27e2017-09-18 15:00:34 +01001823requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001824run_test "Max fragment length: client, larger message" \
1825 "$P_SRV debug_level=3" \
1826 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1827 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001828 -c "Maximum fragment length is 2048" \
1829 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001830 -c "client hello, adding max_fragment_length extension" \
1831 -s "found max fragment length extension" \
1832 -s "server hello, max_fragment_length extension" \
1833 -c "found max_fragment_length extension" \
1834 -c "2345 bytes written in 2 fragments" \
1835 -s "2048 bytes read" \
1836 -s "297 bytes read"
1837
Hanno Becker4aed27e2017-09-18 15:00:34 +01001838requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001839run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001840 "$P_SRV debug_level=3 dtls=1" \
1841 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1842 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001843 -c "Maximum fragment length is 2048" \
1844 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001845 -c "client hello, adding max_fragment_length extension" \
1846 -s "found max fragment length extension" \
1847 -s "server hello, max_fragment_length extension" \
1848 -c "found max_fragment_length extension" \
1849 -c "fragment larger than.*maximum"
1850
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001851# Tests for renegotiation
1852
Hanno Becker6a243642017-10-12 15:18:45 +01001853# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001854run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001855 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001856 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001857 0 \
1858 -C "client hello, adding renegotiation extension" \
1859 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1860 -S "found renegotiation extension" \
1861 -s "server hello, secure renegotiation extension" \
1862 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001863 -C "=> renegotiate" \
1864 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001865 -S "write hello request"
1866
Hanno Becker6a243642017-10-12 15:18:45 +01001867requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001868run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001869 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001870 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001871 0 \
1872 -c "client hello, adding renegotiation extension" \
1873 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1874 -s "found renegotiation extension" \
1875 -s "server hello, secure renegotiation extension" \
1876 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001877 -c "=> renegotiate" \
1878 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001879 -S "write hello request"
1880
Hanno Becker6a243642017-10-12 15:18:45 +01001881requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001882run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001883 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001884 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001885 0 \
1886 -c "client hello, adding renegotiation extension" \
1887 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1888 -s "found renegotiation extension" \
1889 -s "server hello, secure renegotiation extension" \
1890 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001891 -c "=> renegotiate" \
1892 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001893 -s "write hello request"
1894
Janos Follathb0f148c2017-10-05 12:29:42 +01001895# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1896# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1897# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001898requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001899run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1900 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1901 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1902 0 \
1903 -c "client hello, adding renegotiation extension" \
1904 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1905 -s "found renegotiation extension" \
1906 -s "server hello, secure renegotiation extension" \
1907 -c "found renegotiation extension" \
1908 -c "=> renegotiate" \
1909 -s "=> renegotiate" \
1910 -S "write hello request" \
1911 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1912
1913# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1914# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1915# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001916requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001917run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1918 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1919 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1920 0 \
1921 -c "client hello, adding renegotiation extension" \
1922 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1923 -s "found renegotiation extension" \
1924 -s "server hello, secure renegotiation extension" \
1925 -c "found renegotiation extension" \
1926 -c "=> renegotiate" \
1927 -s "=> renegotiate" \
1928 -s "write hello request" \
1929 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1930
Hanno Becker6a243642017-10-12 15:18:45 +01001931requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001932run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001933 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001934 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001935 0 \
1936 -c "client hello, adding renegotiation extension" \
1937 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1938 -s "found renegotiation extension" \
1939 -s "server hello, secure renegotiation extension" \
1940 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001941 -c "=> renegotiate" \
1942 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001943 -s "write hello request"
1944
Hanno Becker6a243642017-10-12 15:18:45 +01001945requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001946run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001947 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001948 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001949 1 \
1950 -c "client hello, adding renegotiation extension" \
1951 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1952 -S "found renegotiation extension" \
1953 -s "server hello, secure renegotiation extension" \
1954 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001955 -c "=> renegotiate" \
1956 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001957 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001958 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001959 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001960
Hanno Becker6a243642017-10-12 15:18:45 +01001961requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001962run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001963 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001964 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001965 0 \
1966 -C "client hello, adding renegotiation extension" \
1967 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1968 -S "found renegotiation extension" \
1969 -s "server hello, secure renegotiation extension" \
1970 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001971 -C "=> renegotiate" \
1972 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001973 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001974 -S "SSL - An unexpected message was received from our peer" \
1975 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001976
Hanno Becker6a243642017-10-12 15:18:45 +01001977requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001978run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001979 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001980 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001981 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001982 0 \
1983 -C "client hello, adding renegotiation extension" \
1984 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1985 -S "found renegotiation extension" \
1986 -s "server hello, secure renegotiation extension" \
1987 -c "found renegotiation extension" \
1988 -C "=> renegotiate" \
1989 -S "=> renegotiate" \
1990 -s "write hello request" \
1991 -S "SSL - An unexpected message was received from our peer" \
1992 -S "failed"
1993
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001994# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001995requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001996run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001997 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001998 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001999 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002000 0 \
2001 -C "client hello, adding renegotiation extension" \
2002 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2003 -S "found renegotiation extension" \
2004 -s "server hello, secure renegotiation extension" \
2005 -c "found renegotiation extension" \
2006 -C "=> renegotiate" \
2007 -S "=> renegotiate" \
2008 -s "write hello request" \
2009 -S "SSL - An unexpected message was received from our peer" \
2010 -S "failed"
2011
Hanno Becker6a243642017-10-12 15:18:45 +01002012requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002013run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002014 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002015 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002016 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002017 0 \
2018 -C "client hello, adding renegotiation extension" \
2019 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2020 -S "found renegotiation extension" \
2021 -s "server hello, secure renegotiation extension" \
2022 -c "found renegotiation extension" \
2023 -C "=> renegotiate" \
2024 -S "=> renegotiate" \
2025 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002026 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002027
Hanno Becker6a243642017-10-12 15:18:45 +01002028requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002029run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002030 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002031 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002032 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002033 0 \
2034 -c "client hello, adding renegotiation extension" \
2035 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2036 -s "found renegotiation extension" \
2037 -s "server hello, secure renegotiation extension" \
2038 -c "found renegotiation extension" \
2039 -c "=> renegotiate" \
2040 -s "=> renegotiate" \
2041 -s "write hello request" \
2042 -S "SSL - An unexpected message was received from our peer" \
2043 -S "failed"
2044
Hanno Becker6a243642017-10-12 15:18:45 +01002045requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002046run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002047 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002048 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2049 0 \
2050 -C "client hello, adding renegotiation extension" \
2051 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2052 -S "found renegotiation extension" \
2053 -s "server hello, secure renegotiation extension" \
2054 -c "found renegotiation extension" \
2055 -S "record counter limit reached: renegotiate" \
2056 -C "=> renegotiate" \
2057 -S "=> renegotiate" \
2058 -S "write hello request" \
2059 -S "SSL - An unexpected message was received from our peer" \
2060 -S "failed"
2061
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002062# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002063requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002064run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002065 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002066 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002067 0 \
2068 -c "client hello, adding renegotiation extension" \
2069 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2070 -s "found renegotiation extension" \
2071 -s "server hello, secure renegotiation extension" \
2072 -c "found renegotiation extension" \
2073 -s "record counter limit reached: renegotiate" \
2074 -c "=> renegotiate" \
2075 -s "=> renegotiate" \
2076 -s "write hello request" \
2077 -S "SSL - An unexpected message was received from our peer" \
2078 -S "failed"
2079
Hanno Becker6a243642017-10-12 15:18:45 +01002080requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002081run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002082 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002083 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002084 0 \
2085 -c "client hello, adding renegotiation extension" \
2086 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2087 -s "found renegotiation extension" \
2088 -s "server hello, secure renegotiation extension" \
2089 -c "found renegotiation extension" \
2090 -s "record counter limit reached: renegotiate" \
2091 -c "=> renegotiate" \
2092 -s "=> renegotiate" \
2093 -s "write hello request" \
2094 -S "SSL - An unexpected message was received from our peer" \
2095 -S "failed"
2096
Hanno Becker6a243642017-10-12 15:18:45 +01002097requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002098run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002099 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002100 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2101 0 \
2102 -C "client hello, adding renegotiation extension" \
2103 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2104 -S "found renegotiation extension" \
2105 -s "server hello, secure renegotiation extension" \
2106 -c "found renegotiation extension" \
2107 -S "record counter limit reached: renegotiate" \
2108 -C "=> renegotiate" \
2109 -S "=> renegotiate" \
2110 -S "write hello request" \
2111 -S "SSL - An unexpected message was received from our peer" \
2112 -S "failed"
2113
Hanno Becker6a243642017-10-12 15:18:45 +01002114requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002115run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002116 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002117 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002118 0 \
2119 -c "client hello, adding renegotiation extension" \
2120 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2121 -s "found renegotiation extension" \
2122 -s "server hello, secure renegotiation extension" \
2123 -c "found renegotiation extension" \
2124 -c "=> renegotiate" \
2125 -s "=> renegotiate" \
2126 -S "write hello request"
2127
Hanno Becker6a243642017-10-12 15:18:45 +01002128requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002129run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002130 "$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 +02002131 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002132 0 \
2133 -c "client hello, adding renegotiation extension" \
2134 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2135 -s "found renegotiation extension" \
2136 -s "server hello, secure renegotiation extension" \
2137 -c "found renegotiation extension" \
2138 -c "=> renegotiate" \
2139 -s "=> renegotiate" \
2140 -s "write hello request"
2141
Hanno Becker6a243642017-10-12 15:18:45 +01002142requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002143run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002144 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002145 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002146 0 \
2147 -c "client hello, adding renegotiation extension" \
2148 -c "found renegotiation extension" \
2149 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002150 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002151 -C "error" \
2152 -c "HTTP/1.0 200 [Oo][Kk]"
2153
Paul Bakker539d9722015-02-08 16:18:35 +01002154requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002155requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002156run_test "Renegotiation: gnutls server strict, client-initiated" \
2157 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002158 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002159 0 \
2160 -c "client hello, adding renegotiation extension" \
2161 -c "found renegotiation extension" \
2162 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002163 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002164 -C "error" \
2165 -c "HTTP/1.0 200 [Oo][Kk]"
2166
Paul Bakker539d9722015-02-08 16:18:35 +01002167requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002168requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002169run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2170 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2171 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2172 1 \
2173 -c "client hello, adding renegotiation extension" \
2174 -C "found renegotiation extension" \
2175 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002176 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002177 -c "error" \
2178 -C "HTTP/1.0 200 [Oo][Kk]"
2179
Paul Bakker539d9722015-02-08 16:18:35 +01002180requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002181requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002182run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2183 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2184 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2185 allow_legacy=0" \
2186 1 \
2187 -c "client hello, adding renegotiation extension" \
2188 -C "found renegotiation extension" \
2189 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002190 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002191 -c "error" \
2192 -C "HTTP/1.0 200 [Oo][Kk]"
2193
Paul Bakker539d9722015-02-08 16:18:35 +01002194requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002195requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002196run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2197 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2198 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2199 allow_legacy=1" \
2200 0 \
2201 -c "client hello, adding renegotiation extension" \
2202 -C "found renegotiation extension" \
2203 -c "=> renegotiate" \
2204 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002205 -C "error" \
2206 -c "HTTP/1.0 200 [Oo][Kk]"
2207
Hanno Becker6a243642017-10-12 15:18:45 +01002208requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002209run_test "Renegotiation: DTLS, client-initiated" \
2210 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2211 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2212 0 \
2213 -c "client hello, adding renegotiation extension" \
2214 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2215 -s "found renegotiation extension" \
2216 -s "server hello, secure renegotiation extension" \
2217 -c "found renegotiation extension" \
2218 -c "=> renegotiate" \
2219 -s "=> renegotiate" \
2220 -S "write hello request"
2221
Hanno Becker6a243642017-10-12 15:18:45 +01002222requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002223run_test "Renegotiation: DTLS, server-initiated" \
2224 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002225 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2226 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002227 0 \
2228 -c "client hello, adding renegotiation extension" \
2229 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2230 -s "found renegotiation extension" \
2231 -s "server hello, secure renegotiation extension" \
2232 -c "found renegotiation extension" \
2233 -c "=> renegotiate" \
2234 -s "=> renegotiate" \
2235 -s "write hello request"
2236
Hanno Becker6a243642017-10-12 15:18:45 +01002237requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002238run_test "Renegotiation: DTLS, renego_period overflow" \
2239 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2240 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2241 0 \
2242 -c "client hello, adding renegotiation extension" \
2243 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2244 -s "found renegotiation extension" \
2245 -s "server hello, secure renegotiation extension" \
2246 -s "record counter limit reached: renegotiate" \
2247 -c "=> renegotiate" \
2248 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002249 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002250
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002251requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002252requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002253run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2254 "$G_SRV -u --mtu 4096" \
2255 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2256 0 \
2257 -c "client hello, adding renegotiation extension" \
2258 -c "found renegotiation extension" \
2259 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002260 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002261 -C "error" \
2262 -s "Extra-header:"
2263
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002264# Test for the "secure renegotation" extension only (no actual renegotiation)
2265
Paul Bakker539d9722015-02-08 16:18:35 +01002266requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002267run_test "Renego ext: gnutls server strict, client default" \
2268 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2269 "$P_CLI debug_level=3" \
2270 0 \
2271 -c "found renegotiation extension" \
2272 -C "error" \
2273 -c "HTTP/1.0 200 [Oo][Kk]"
2274
Paul Bakker539d9722015-02-08 16:18:35 +01002275requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002276run_test "Renego ext: gnutls server unsafe, client default" \
2277 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2278 "$P_CLI debug_level=3" \
2279 0 \
2280 -C "found renegotiation extension" \
2281 -C "error" \
2282 -c "HTTP/1.0 200 [Oo][Kk]"
2283
Paul Bakker539d9722015-02-08 16:18:35 +01002284requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002285run_test "Renego ext: gnutls server unsafe, client break legacy" \
2286 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2287 "$P_CLI debug_level=3 allow_legacy=-1" \
2288 1 \
2289 -C "found renegotiation extension" \
2290 -c "error" \
2291 -C "HTTP/1.0 200 [Oo][Kk]"
2292
Paul Bakker539d9722015-02-08 16:18:35 +01002293requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002294run_test "Renego ext: gnutls client strict, server default" \
2295 "$P_SRV debug_level=3" \
2296 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2297 0 \
2298 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2299 -s "server hello, secure renegotiation extension"
2300
Paul Bakker539d9722015-02-08 16:18:35 +01002301requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002302run_test "Renego ext: gnutls client unsafe, server default" \
2303 "$P_SRV debug_level=3" \
2304 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2305 0 \
2306 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2307 -S "server hello, secure renegotiation extension"
2308
Paul Bakker539d9722015-02-08 16:18:35 +01002309requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002310run_test "Renego ext: gnutls client unsafe, server break legacy" \
2311 "$P_SRV debug_level=3 allow_legacy=-1" \
2312 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2313 1 \
2314 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2315 -S "server hello, secure renegotiation extension"
2316
Janos Follath0b242342016-02-17 10:11:21 +00002317# Tests for silently dropping trailing extra bytes in .der certificates
2318
2319requires_gnutls
2320run_test "DER format: no trailing bytes" \
2321 "$P_SRV crt_file=data_files/server5-der0.crt \
2322 key_file=data_files/server5.key" \
2323 "$G_CLI " \
2324 0 \
2325 -c "Handshake was completed" \
2326
2327requires_gnutls
2328run_test "DER format: with a trailing zero byte" \
2329 "$P_SRV crt_file=data_files/server5-der1a.crt \
2330 key_file=data_files/server5.key" \
2331 "$G_CLI " \
2332 0 \
2333 -c "Handshake was completed" \
2334
2335requires_gnutls
2336run_test "DER format: with a trailing random byte" \
2337 "$P_SRV crt_file=data_files/server5-der1b.crt \
2338 key_file=data_files/server5.key" \
2339 "$G_CLI " \
2340 0 \
2341 -c "Handshake was completed" \
2342
2343requires_gnutls
2344run_test "DER format: with 2 trailing random bytes" \
2345 "$P_SRV crt_file=data_files/server5-der2.crt \
2346 key_file=data_files/server5.key" \
2347 "$G_CLI " \
2348 0 \
2349 -c "Handshake was completed" \
2350
2351requires_gnutls
2352run_test "DER format: with 4 trailing random bytes" \
2353 "$P_SRV crt_file=data_files/server5-der4.crt \
2354 key_file=data_files/server5.key" \
2355 "$G_CLI " \
2356 0 \
2357 -c "Handshake was completed" \
2358
2359requires_gnutls
2360run_test "DER format: with 8 trailing random bytes" \
2361 "$P_SRV crt_file=data_files/server5-der8.crt \
2362 key_file=data_files/server5.key" \
2363 "$G_CLI " \
2364 0 \
2365 -c "Handshake was completed" \
2366
2367requires_gnutls
2368run_test "DER format: with 9 trailing random bytes" \
2369 "$P_SRV crt_file=data_files/server5-der9.crt \
2370 key_file=data_files/server5.key" \
2371 "$G_CLI " \
2372 0 \
2373 -c "Handshake was completed" \
2374
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002375# Tests for auth_mode
2376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002377run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002378 "$P_SRV crt_file=data_files/server5-badsign.crt \
2379 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002380 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002381 1 \
2382 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002383 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002384 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002385 -c "X509 - Certificate verification failed"
2386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002387run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002388 "$P_SRV crt_file=data_files/server5-badsign.crt \
2389 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002390 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002391 0 \
2392 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002393 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002394 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002395 -C "X509 - Certificate verification failed"
2396
Hanno Beckere6706e62017-05-15 16:05:15 +01002397run_test "Authentication: server goodcert, client optional, no trusted CA" \
2398 "$P_SRV" \
2399 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2400 0 \
2401 -c "x509_verify_cert() returned" \
2402 -c "! The certificate is not correctly signed by the trusted CA" \
2403 -c "! Certificate verification flags"\
2404 -C "! mbedtls_ssl_handshake returned" \
2405 -C "X509 - Certificate verification failed" \
2406 -C "SSL - No CA Chain is set, but required to operate"
2407
2408run_test "Authentication: server goodcert, client required, no trusted CA" \
2409 "$P_SRV" \
2410 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2411 1 \
2412 -c "x509_verify_cert() returned" \
2413 -c "! The certificate is not correctly signed by the trusted CA" \
2414 -c "! Certificate verification flags"\
2415 -c "! mbedtls_ssl_handshake returned" \
2416 -c "SSL - No CA Chain is set, but required to operate"
2417
2418# The purpose of the next two tests is to test the client's behaviour when receiving a server
2419# certificate with an unsupported elliptic curve. This should usually not happen because
2420# the client informs the server about the supported curves - it does, though, in the
2421# corner case of a static ECDH suite, because the server doesn't check the curve on that
2422# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2423# different means to have the server ignoring the client's supported curve list.
2424
2425requires_config_enabled MBEDTLS_ECP_C
2426run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2427 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2428 crt_file=data_files/server5.ku-ka.crt" \
2429 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2430 1 \
2431 -c "bad certificate (EC key curve)"\
2432 -c "! Certificate verification flags"\
2433 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2434
2435requires_config_enabled MBEDTLS_ECP_C
2436run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2437 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2438 crt_file=data_files/server5.ku-ka.crt" \
2439 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2440 1 \
2441 -c "bad certificate (EC key curve)"\
2442 -c "! Certificate verification flags"\
2443 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002445run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002446 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002447 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002448 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002449 0 \
2450 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002451 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002452 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002453 -C "X509 - Certificate verification failed"
2454
Simon Butcher99000142016-10-13 17:21:01 +01002455run_test "Authentication: client SHA256, server required" \
2456 "$P_SRV auth_mode=required" \
2457 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2458 key_file=data_files/server6.key \
2459 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2460 0 \
2461 -c "Supported Signature Algorithm found: 4," \
2462 -c "Supported Signature Algorithm found: 5,"
2463
2464run_test "Authentication: client SHA384, server required" \
2465 "$P_SRV auth_mode=required" \
2466 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2467 key_file=data_files/server6.key \
2468 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2469 0 \
2470 -c "Supported Signature Algorithm found: 4," \
2471 -c "Supported Signature Algorithm found: 5,"
2472
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002473requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2474run_test "Authentication: client has no cert, server required (SSLv3)" \
2475 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2476 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2477 key_file=data_files/server5.key" \
2478 1 \
2479 -S "skip write certificate request" \
2480 -C "skip parse certificate request" \
2481 -c "got a certificate request" \
2482 -c "got no certificate to send" \
2483 -S "x509_verify_cert() returned" \
2484 -s "client has no certificate" \
2485 -s "! mbedtls_ssl_handshake returned" \
2486 -c "! mbedtls_ssl_handshake returned" \
2487 -s "No client certification received from the client, but required by the authentication mode"
2488
2489run_test "Authentication: client has no cert, server required (TLS)" \
2490 "$P_SRV debug_level=3 auth_mode=required" \
2491 "$P_CLI debug_level=3 crt_file=none \
2492 key_file=data_files/server5.key" \
2493 1 \
2494 -S "skip write certificate request" \
2495 -C "skip parse certificate request" \
2496 -c "got a certificate request" \
2497 -c "= write certificate$" \
2498 -C "skip write certificate$" \
2499 -S "x509_verify_cert() returned" \
2500 -s "client has no certificate" \
2501 -s "! mbedtls_ssl_handshake returned" \
2502 -c "! mbedtls_ssl_handshake returned" \
2503 -s "No client certification received from the client, but required by the authentication mode"
2504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002505run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002506 "$P_SRV debug_level=3 auth_mode=required" \
2507 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002508 key_file=data_files/server5.key" \
2509 1 \
2510 -S "skip write certificate request" \
2511 -C "skip parse certificate request" \
2512 -c "got a certificate request" \
2513 -C "skip write certificate" \
2514 -C "skip write certificate verify" \
2515 -S "skip parse certificate verify" \
2516 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002517 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002518 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002519 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002520 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002521 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002522# We don't check that the client receives the alert because it might
2523# detect that its write end of the connection is closed and abort
2524# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002525
Janos Follath89baba22017-04-10 14:34:35 +01002526run_test "Authentication: client cert not trusted, server required" \
2527 "$P_SRV debug_level=3 auth_mode=required" \
2528 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2529 key_file=data_files/server5.key" \
2530 1 \
2531 -S "skip write certificate request" \
2532 -C "skip parse certificate request" \
2533 -c "got a certificate request" \
2534 -C "skip write certificate" \
2535 -C "skip write certificate verify" \
2536 -S "skip parse certificate verify" \
2537 -s "x509_verify_cert() returned" \
2538 -s "! The certificate is not correctly signed by the trusted CA" \
2539 -s "! mbedtls_ssl_handshake returned" \
2540 -c "! mbedtls_ssl_handshake returned" \
2541 -s "X509 - Certificate verification failed"
2542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002543run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002544 "$P_SRV debug_level=3 auth_mode=optional" \
2545 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002546 key_file=data_files/server5.key" \
2547 0 \
2548 -S "skip write certificate request" \
2549 -C "skip parse certificate request" \
2550 -c "got a certificate request" \
2551 -C "skip write certificate" \
2552 -C "skip write certificate verify" \
2553 -S "skip parse certificate verify" \
2554 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002555 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002556 -S "! mbedtls_ssl_handshake returned" \
2557 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002558 -S "X509 - Certificate verification failed"
2559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002560run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002561 "$P_SRV debug_level=3 auth_mode=none" \
2562 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002563 key_file=data_files/server5.key" \
2564 0 \
2565 -s "skip write certificate request" \
2566 -C "skip parse certificate request" \
2567 -c "got no certificate request" \
2568 -c "skip write certificate" \
2569 -c "skip write certificate verify" \
2570 -s "skip parse certificate verify" \
2571 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002572 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002573 -S "! mbedtls_ssl_handshake returned" \
2574 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002575 -S "X509 - Certificate verification failed"
2576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002577run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002578 "$P_SRV debug_level=3 auth_mode=optional" \
2579 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002580 0 \
2581 -S "skip write certificate request" \
2582 -C "skip parse certificate request" \
2583 -c "got a certificate request" \
2584 -C "skip write certificate$" \
2585 -C "got no certificate to send" \
2586 -S "SSLv3 client has no certificate" \
2587 -c "skip write certificate verify" \
2588 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002589 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002590 -S "! mbedtls_ssl_handshake returned" \
2591 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002592 -S "X509 - Certificate verification failed"
2593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002594run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002595 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002596 "$O_CLI" \
2597 0 \
2598 -S "skip write certificate request" \
2599 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002600 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002601 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002602 -S "X509 - Certificate verification failed"
2603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002604run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002605 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002606 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002607 0 \
2608 -C "skip parse certificate request" \
2609 -c "got a certificate request" \
2610 -C "skip write certificate$" \
2611 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002612 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002613
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002614run_test "Authentication: client no cert, openssl server required" \
2615 "$O_SRV -Verify 10" \
2616 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2617 1 \
2618 -C "skip parse certificate request" \
2619 -c "got a certificate request" \
2620 -C "skip write certificate$" \
2621 -c "skip write certificate verify" \
2622 -c "! mbedtls_ssl_handshake returned"
2623
Janos Follathe2681a42016-03-07 15:57:05 +00002624requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002625run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002626 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002627 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002628 0 \
2629 -S "skip write certificate request" \
2630 -C "skip parse certificate request" \
2631 -c "got a certificate request" \
2632 -C "skip write certificate$" \
2633 -c "skip write certificate verify" \
2634 -c "got no certificate to send" \
2635 -s "SSLv3 client has no certificate" \
2636 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002637 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002638 -S "! mbedtls_ssl_handshake returned" \
2639 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002640 -S "X509 - Certificate verification failed"
2641
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002642# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2643# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002644
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002645MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002646MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002647
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002648if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002649 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002650 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002651 printf "test value of ${MAX_IM_CA}. \n"
2652 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002653 printf "The tests assume this value and if it changes, the tests in this\n"
2654 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002655 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002656
2657 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002658fi
2659
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002660run_test "Authentication: server max_int chain, client default" \
2661 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2662 key_file=data_files/dir-maxpath/09.key" \
2663 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2664 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002665 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002666
2667run_test "Authentication: server max_int+1 chain, client default" \
2668 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2669 key_file=data_files/dir-maxpath/10.key" \
2670 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2671 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002672 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002673
2674run_test "Authentication: server max_int+1 chain, client optional" \
2675 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2676 key_file=data_files/dir-maxpath/10.key" \
2677 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2678 auth_mode=optional" \
2679 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002680 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002681
2682run_test "Authentication: server max_int+1 chain, client none" \
2683 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2684 key_file=data_files/dir-maxpath/10.key" \
2685 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2686 auth_mode=none" \
2687 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002688 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002689
2690run_test "Authentication: client max_int+1 chain, server default" \
2691 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2692 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2693 key_file=data_files/dir-maxpath/10.key" \
2694 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002695 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002696
2697run_test "Authentication: client max_int+1 chain, server optional" \
2698 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2699 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2700 key_file=data_files/dir-maxpath/10.key" \
2701 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002702 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002703
2704run_test "Authentication: client max_int+1 chain, server required" \
2705 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2706 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2707 key_file=data_files/dir-maxpath/10.key" \
2708 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002709 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002710
2711run_test "Authentication: client max_int chain, server required" \
2712 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2713 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2714 key_file=data_files/dir-maxpath/09.key" \
2715 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002716 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002717
Janos Follath89baba22017-04-10 14:34:35 +01002718# Tests for CA list in CertificateRequest messages
2719
2720run_test "Authentication: send CA list in CertificateRequest (default)" \
2721 "$P_SRV debug_level=3 auth_mode=required" \
2722 "$P_CLI crt_file=data_files/server6.crt \
2723 key_file=data_files/server6.key" \
2724 0 \
2725 -s "requested DN"
2726
2727run_test "Authentication: do not send CA list in CertificateRequest" \
2728 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2729 "$P_CLI crt_file=data_files/server6.crt \
2730 key_file=data_files/server6.key" \
2731 0 \
2732 -S "requested DN"
2733
2734run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2735 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2736 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2737 key_file=data_files/server5.key" \
2738 1 \
2739 -S "requested DN" \
2740 -s "x509_verify_cert() returned" \
2741 -s "! The certificate is not correctly signed by the trusted CA" \
2742 -s "! mbedtls_ssl_handshake returned" \
2743 -c "! mbedtls_ssl_handshake returned" \
2744 -s "X509 - Certificate verification failed"
2745
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002746# Tests for certificate selection based on SHA verson
2747
2748run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2749 "$P_SRV crt_file=data_files/server5.crt \
2750 key_file=data_files/server5.key \
2751 crt_file2=data_files/server5-sha1.crt \
2752 key_file2=data_files/server5.key" \
2753 "$P_CLI force_version=tls1_2" \
2754 0 \
2755 -c "signed using.*ECDSA with SHA256" \
2756 -C "signed using.*ECDSA with SHA1"
2757
2758run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2759 "$P_SRV crt_file=data_files/server5.crt \
2760 key_file=data_files/server5.key \
2761 crt_file2=data_files/server5-sha1.crt \
2762 key_file2=data_files/server5.key" \
2763 "$P_CLI force_version=tls1_1" \
2764 0 \
2765 -C "signed using.*ECDSA with SHA256" \
2766 -c "signed using.*ECDSA with SHA1"
2767
2768run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2769 "$P_SRV crt_file=data_files/server5.crt \
2770 key_file=data_files/server5.key \
2771 crt_file2=data_files/server5-sha1.crt \
2772 key_file2=data_files/server5.key" \
2773 "$P_CLI force_version=tls1" \
2774 0 \
2775 -C "signed using.*ECDSA with SHA256" \
2776 -c "signed using.*ECDSA with SHA1"
2777
2778run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2779 "$P_SRV crt_file=data_files/server5.crt \
2780 key_file=data_files/server5.key \
2781 crt_file2=data_files/server6.crt \
2782 key_file2=data_files/server6.key" \
2783 "$P_CLI force_version=tls1_1" \
2784 0 \
2785 -c "serial number.*09" \
2786 -c "signed using.*ECDSA with SHA256" \
2787 -C "signed using.*ECDSA with SHA1"
2788
2789run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2790 "$P_SRV crt_file=data_files/server6.crt \
2791 key_file=data_files/server6.key \
2792 crt_file2=data_files/server5.crt \
2793 key_file2=data_files/server5.key" \
2794 "$P_CLI force_version=tls1_1" \
2795 0 \
2796 -c "serial number.*0A" \
2797 -c "signed using.*ECDSA with SHA256" \
2798 -C "signed using.*ECDSA with SHA1"
2799
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002800# tests for SNI
2801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002802run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002803 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002804 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002805 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002806 0 \
2807 -S "parse ServerName extension" \
2808 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2809 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002811run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002812 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002813 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002814 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 +02002815 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002816 0 \
2817 -s "parse ServerName extension" \
2818 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2819 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002821run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002822 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002823 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002824 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 +02002825 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002826 0 \
2827 -s "parse ServerName extension" \
2828 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2829 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002831run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002832 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002833 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002834 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 +02002835 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002836 1 \
2837 -s "parse ServerName extension" \
2838 -s "ssl_sni_wrapper() returned" \
2839 -s "mbedtls_ssl_handshake returned" \
2840 -c "mbedtls_ssl_handshake returned" \
2841 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002842
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002843run_test "SNI: client auth no override: optional" \
2844 "$P_SRV debug_level=3 auth_mode=optional \
2845 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2846 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2847 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002848 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002849 -S "skip write certificate request" \
2850 -C "skip parse certificate request" \
2851 -c "got a certificate request" \
2852 -C "skip write certificate" \
2853 -C "skip write certificate verify" \
2854 -S "skip parse certificate verify"
2855
2856run_test "SNI: client auth override: none -> optional" \
2857 "$P_SRV debug_level=3 auth_mode=none \
2858 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2859 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2860 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002861 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002862 -S "skip write certificate request" \
2863 -C "skip parse certificate request" \
2864 -c "got a certificate request" \
2865 -C "skip write certificate" \
2866 -C "skip write certificate verify" \
2867 -S "skip parse certificate verify"
2868
2869run_test "SNI: client auth override: optional -> none" \
2870 "$P_SRV debug_level=3 auth_mode=optional \
2871 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2872 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2873 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002874 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002875 -s "skip write certificate request" \
2876 -C "skip parse certificate request" \
2877 -c "got no certificate request" \
2878 -c "skip write certificate" \
2879 -c "skip write certificate verify" \
2880 -s "skip parse certificate verify"
2881
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002882run_test "SNI: CA no override" \
2883 "$P_SRV debug_level=3 auth_mode=optional \
2884 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2885 ca_file=data_files/test-ca.crt \
2886 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2887 "$P_CLI debug_level=3 server_name=localhost \
2888 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2889 1 \
2890 -S "skip write certificate request" \
2891 -C "skip parse certificate request" \
2892 -c "got a certificate request" \
2893 -C "skip write certificate" \
2894 -C "skip write certificate verify" \
2895 -S "skip parse certificate verify" \
2896 -s "x509_verify_cert() returned" \
2897 -s "! The certificate is not correctly signed by the trusted CA" \
2898 -S "The certificate has been revoked (is on a CRL)"
2899
2900run_test "SNI: CA override" \
2901 "$P_SRV debug_level=3 auth_mode=optional \
2902 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2903 ca_file=data_files/test-ca.crt \
2904 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2905 "$P_CLI debug_level=3 server_name=localhost \
2906 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2907 0 \
2908 -S "skip write certificate request" \
2909 -C "skip parse certificate request" \
2910 -c "got a certificate request" \
2911 -C "skip write certificate" \
2912 -C "skip write certificate verify" \
2913 -S "skip parse certificate verify" \
2914 -S "x509_verify_cert() returned" \
2915 -S "! The certificate is not correctly signed by the trusted CA" \
2916 -S "The certificate has been revoked (is on a CRL)"
2917
2918run_test "SNI: CA override with CRL" \
2919 "$P_SRV debug_level=3 auth_mode=optional \
2920 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2921 ca_file=data_files/test-ca.crt \
2922 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2923 "$P_CLI debug_level=3 server_name=localhost \
2924 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2925 1 \
2926 -S "skip write certificate request" \
2927 -C "skip parse certificate request" \
2928 -c "got a certificate request" \
2929 -C "skip write certificate" \
2930 -C "skip write certificate verify" \
2931 -S "skip parse certificate verify" \
2932 -s "x509_verify_cert() returned" \
2933 -S "! The certificate is not correctly signed by the trusted CA" \
2934 -s "The certificate has been revoked (is on a CRL)"
2935
Andres AGe8b07742016-12-07 10:01:30 +00002936# Tests for SNI and DTLS
2937
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002938run_test "SNI: DTLS, no SNI callback" \
2939 "$P_SRV debug_level=3 dtls=1 \
2940 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2941 "$P_CLI server_name=localhost dtls=1" \
2942 0 \
2943 -S "parse ServerName extension" \
2944 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2945 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2946
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002947run_test "SNI: DTLS, matching cert 1" \
Andres AGe8b07742016-12-07 10:01:30 +00002948 "$P_SRV debug_level=3 dtls=1 \
2949 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2950 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2951 "$P_CLI server_name=localhost dtls=1" \
2952 0 \
2953 -s "parse ServerName extension" \
2954 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2955 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2956
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002957run_test "SNI: DTLS, matching cert 2" \
2958 "$P_SRV debug_level=3 dtls=1 \
2959 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2960 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2961 "$P_CLI server_name=polarssl.example dtls=1" \
2962 0 \
2963 -s "parse ServerName extension" \
2964 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2965 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2966
2967run_test "SNI: DTLS, no matching cert" \
2968 "$P_SRV debug_level=3 dtls=1 \
2969 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2970 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2971 "$P_CLI server_name=nonesuch.example dtls=1" \
2972 1 \
2973 -s "parse ServerName extension" \
2974 -s "ssl_sni_wrapper() returned" \
2975 -s "mbedtls_ssl_handshake returned" \
2976 -c "mbedtls_ssl_handshake returned" \
2977 -c "SSL - A fatal alert message was received from our peer"
2978
2979run_test "SNI: DTLS, client auth no override: optional" \
2980 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2981 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2982 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2983 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2984 0 \
2985 -S "skip write certificate request" \
2986 -C "skip parse certificate request" \
2987 -c "got a certificate request" \
2988 -C "skip write certificate" \
2989 -C "skip write certificate verify" \
2990 -S "skip parse certificate verify"
2991
2992run_test "SNI: DTLS, client auth override: none -> optional" \
2993 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2994 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2995 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2996 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2997 0 \
2998 -S "skip write certificate request" \
2999 -C "skip parse certificate request" \
3000 -c "got a certificate request" \
3001 -C "skip write certificate" \
3002 -C "skip write certificate verify" \
3003 -S "skip parse certificate verify"
3004
3005run_test "SNI: DTLS, client auth override: optional -> none" \
3006 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3007 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3008 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3009 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3010 0 \
3011 -s "skip write certificate request" \
3012 -C "skip parse certificate request" \
3013 -c "got no certificate request" \
3014 -c "skip write certificate" \
3015 -c "skip write certificate verify" \
3016 -s "skip parse certificate verify"
3017
3018run_test "SNI: DTLS, CA no override" \
3019 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3020 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3021 ca_file=data_files/test-ca.crt \
3022 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3023 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3024 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3025 1 \
3026 -S "skip write certificate request" \
3027 -C "skip parse certificate request" \
3028 -c "got a certificate request" \
3029 -C "skip write certificate" \
3030 -C "skip write certificate verify" \
3031 -S "skip parse certificate verify" \
3032 -s "x509_verify_cert() returned" \
3033 -s "! The certificate is not correctly signed by the trusted CA" \
3034 -S "The certificate has been revoked (is on a CRL)"
3035
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01003036run_test "SNI: DTLS, CA override" \
Andres AGe8b07742016-12-07 10:01:30 +00003037 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3038 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3039 ca_file=data_files/test-ca.crt \
3040 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3041 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3042 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3043 0 \
3044 -S "skip write certificate request" \
3045 -C "skip parse certificate request" \
3046 -c "got a certificate request" \
3047 -C "skip write certificate" \
3048 -C "skip write certificate verify" \
3049 -S "skip parse certificate verify" \
3050 -S "x509_verify_cert() returned" \
3051 -S "! The certificate is not correctly signed by the trusted CA" \
3052 -S "The certificate has been revoked (is on a CRL)"
3053
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01003054run_test "SNI: DTLS, CA override with CRL" \
Andres AGe8b07742016-12-07 10:01:30 +00003055 "$P_SRV debug_level=3 auth_mode=optional \
3056 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3057 ca_file=data_files/test-ca.crt \
3058 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3059 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3060 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3061 1 \
3062 -S "skip write certificate request" \
3063 -C "skip parse certificate request" \
3064 -c "got a certificate request" \
3065 -C "skip write certificate" \
3066 -C "skip write certificate verify" \
3067 -S "skip parse certificate verify" \
3068 -s "x509_verify_cert() returned" \
3069 -S "! The certificate is not correctly signed by the trusted CA" \
3070 -s "The certificate has been revoked (is on a CRL)"
3071
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003072# Tests for non-blocking I/O: exercise a variety of handshake flows
3073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003074run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003075 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3076 "$P_CLI nbio=2 tickets=0" \
3077 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003078 -S "mbedtls_ssl_handshake returned" \
3079 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003080 -c "Read from server: .* bytes read"
3081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003082run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003083 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3084 "$P_CLI nbio=2 tickets=0" \
3085 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003086 -S "mbedtls_ssl_handshake returned" \
3087 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003088 -c "Read from server: .* bytes read"
3089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003090run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003091 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3092 "$P_CLI nbio=2 tickets=1" \
3093 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003094 -S "mbedtls_ssl_handshake returned" \
3095 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003096 -c "Read from server: .* bytes read"
3097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003098run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003099 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3100 "$P_CLI nbio=2 tickets=1" \
3101 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003102 -S "mbedtls_ssl_handshake returned" \
3103 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003104 -c "Read from server: .* bytes read"
3105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003106run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003107 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3108 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3109 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003110 -S "mbedtls_ssl_handshake returned" \
3111 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003112 -c "Read from server: .* bytes read"
3113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003114run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003115 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3116 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3117 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003118 -S "mbedtls_ssl_handshake returned" \
3119 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003120 -c "Read from server: .* bytes read"
3121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003122run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003123 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3124 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3125 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003126 -S "mbedtls_ssl_handshake returned" \
3127 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003128 -c "Read from server: .* bytes read"
3129
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003130# Tests for version negotiation
3131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003132run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003133 "$P_SRV" \
3134 "$P_CLI" \
3135 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003136 -S "mbedtls_ssl_handshake returned" \
3137 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003138 -s "Protocol is TLSv1.2" \
3139 -c "Protocol is TLSv1.2"
3140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003141run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003142 "$P_SRV" \
3143 "$P_CLI max_version=tls1_1" \
3144 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003145 -S "mbedtls_ssl_handshake returned" \
3146 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003147 -s "Protocol is TLSv1.1" \
3148 -c "Protocol is TLSv1.1"
3149
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003150run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003151 "$P_SRV max_version=tls1_1" \
3152 "$P_CLI" \
3153 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003154 -S "mbedtls_ssl_handshake returned" \
3155 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003156 -s "Protocol is TLSv1.1" \
3157 -c "Protocol is TLSv1.1"
3158
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003159run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003160 "$P_SRV max_version=tls1_1" \
3161 "$P_CLI max_version=tls1_1" \
3162 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003163 -S "mbedtls_ssl_handshake returned" \
3164 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003165 -s "Protocol is TLSv1.1" \
3166 -c "Protocol is TLSv1.1"
3167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003168run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003169 "$P_SRV min_version=tls1_1" \
3170 "$P_CLI max_version=tls1_1" \
3171 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003172 -S "mbedtls_ssl_handshake returned" \
3173 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003174 -s "Protocol is TLSv1.1" \
3175 -c "Protocol is TLSv1.1"
3176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003177run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003178 "$P_SRV max_version=tls1_1" \
3179 "$P_CLI min_version=tls1_1" \
3180 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003181 -S "mbedtls_ssl_handshake returned" \
3182 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003183 -s "Protocol is TLSv1.1" \
3184 -c "Protocol is TLSv1.1"
3185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003186run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003187 "$P_SRV max_version=tls1_1" \
3188 "$P_CLI min_version=tls1_2" \
3189 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003190 -s "mbedtls_ssl_handshake returned" \
3191 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003192 -c "SSL - Handshake protocol not within min/max boundaries"
3193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003194run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003195 "$P_SRV min_version=tls1_2" \
3196 "$P_CLI max_version=tls1_1" \
3197 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003198 -s "mbedtls_ssl_handshake returned" \
3199 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003200 -s "SSL - Handshake protocol not within min/max boundaries"
3201
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003202# Tests for ALPN extension
3203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003204run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003205 "$P_SRV debug_level=3" \
3206 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003207 0 \
3208 -C "client hello, adding alpn extension" \
3209 -S "found alpn extension" \
3210 -C "got an alert message, type: \\[2:120]" \
3211 -S "server hello, adding alpn extension" \
3212 -C "found alpn extension " \
3213 -C "Application Layer Protocol is" \
3214 -S "Application Layer Protocol is"
3215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003216run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003217 "$P_SRV debug_level=3" \
3218 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003219 0 \
3220 -c "client hello, adding alpn extension" \
3221 -s "found alpn extension" \
3222 -C "got an alert message, type: \\[2:120]" \
3223 -S "server hello, adding alpn extension" \
3224 -C "found alpn extension " \
3225 -c "Application Layer Protocol is (none)" \
3226 -S "Application Layer Protocol is"
3227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003228run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003229 "$P_SRV debug_level=3 alpn=abc,1234" \
3230 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003231 0 \
3232 -C "client hello, adding alpn extension" \
3233 -S "found alpn extension" \
3234 -C "got an alert message, type: \\[2:120]" \
3235 -S "server hello, adding alpn extension" \
3236 -C "found alpn extension " \
3237 -C "Application Layer Protocol is" \
3238 -s "Application Layer Protocol is (none)"
3239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003240run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003241 "$P_SRV debug_level=3 alpn=abc,1234" \
3242 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003243 0 \
3244 -c "client hello, adding alpn extension" \
3245 -s "found alpn extension" \
3246 -C "got an alert message, type: \\[2:120]" \
3247 -s "server hello, adding alpn extension" \
3248 -c "found alpn extension" \
3249 -c "Application Layer Protocol is abc" \
3250 -s "Application Layer Protocol is abc"
3251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003252run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003253 "$P_SRV debug_level=3 alpn=abc,1234" \
3254 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003255 0 \
3256 -c "client hello, adding alpn extension" \
3257 -s "found alpn extension" \
3258 -C "got an alert message, type: \\[2:120]" \
3259 -s "server hello, adding alpn extension" \
3260 -c "found alpn extension" \
3261 -c "Application Layer Protocol is abc" \
3262 -s "Application Layer Protocol is abc"
3263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003264run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003265 "$P_SRV debug_level=3 alpn=abc,1234" \
3266 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003267 0 \
3268 -c "client hello, adding alpn extension" \
3269 -s "found alpn extension" \
3270 -C "got an alert message, type: \\[2:120]" \
3271 -s "server hello, adding alpn extension" \
3272 -c "found alpn extension" \
3273 -c "Application Layer Protocol is 1234" \
3274 -s "Application Layer Protocol is 1234"
3275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003276run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003277 "$P_SRV debug_level=3 alpn=abc,123" \
3278 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003279 1 \
3280 -c "client hello, adding alpn extension" \
3281 -s "found alpn extension" \
3282 -c "got an alert message, type: \\[2:120]" \
3283 -S "server hello, adding alpn extension" \
3284 -C "found alpn extension" \
3285 -C "Application Layer Protocol is 1234" \
3286 -S "Application Layer Protocol is 1234"
3287
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003288
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003289# Tests for keyUsage in leaf certificates, part 1:
3290# server-side certificate/suite selection
3291
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003292run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003293 "$P_SRV key_file=data_files/server2.key \
3294 crt_file=data_files/server2.ku-ds.crt" \
3295 "$P_CLI" \
3296 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003297 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003298
3299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003300run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003301 "$P_SRV key_file=data_files/server2.key \
3302 crt_file=data_files/server2.ku-ke.crt" \
3303 "$P_CLI" \
3304 0 \
3305 -c "Ciphersuite is TLS-RSA-WITH-"
3306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003307run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003308 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003309 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003310 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003311 1 \
3312 -C "Ciphersuite is "
3313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003314run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003315 "$P_SRV key_file=data_files/server5.key \
3316 crt_file=data_files/server5.ku-ds.crt" \
3317 "$P_CLI" \
3318 0 \
3319 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3320
3321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003322run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003323 "$P_SRV key_file=data_files/server5.key \
3324 crt_file=data_files/server5.ku-ka.crt" \
3325 "$P_CLI" \
3326 0 \
3327 -c "Ciphersuite is TLS-ECDH-"
3328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003329run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003330 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003331 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003332 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003333 1 \
3334 -C "Ciphersuite is "
3335
3336# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003337# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003339run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003340 "$O_SRV -key data_files/server2.key \
3341 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003342 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003343 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3344 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003345 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003346 -C "Processing of the Certificate handshake message failed" \
3347 -c "Ciphersuite is TLS-"
3348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003349run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003350 "$O_SRV -key data_files/server2.key \
3351 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003352 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003353 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3354 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003355 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003356 -C "Processing of the Certificate handshake message failed" \
3357 -c "Ciphersuite is TLS-"
3358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003359run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003360 "$O_SRV -key data_files/server2.key \
3361 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003362 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003363 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3364 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003365 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003366 -C "Processing of the Certificate handshake message failed" \
3367 -c "Ciphersuite is TLS-"
3368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003369run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003370 "$O_SRV -key data_files/server2.key \
3371 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003372 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003373 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3374 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003375 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003376 -c "Processing of the Certificate handshake message failed" \
3377 -C "Ciphersuite is TLS-"
3378
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003379run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3380 "$O_SRV -key data_files/server2.key \
3381 -cert data_files/server2.ku-ke.crt" \
3382 "$P_CLI debug_level=1 auth_mode=optional \
3383 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3384 0 \
3385 -c "bad certificate (usage extensions)" \
3386 -C "Processing of the Certificate handshake message failed" \
3387 -c "Ciphersuite is TLS-" \
3388 -c "! Usage does not match the keyUsage extension"
3389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003390run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003391 "$O_SRV -key data_files/server2.key \
3392 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003393 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003394 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3395 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003396 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003397 -C "Processing of the Certificate handshake message failed" \
3398 -c "Ciphersuite is TLS-"
3399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003400run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003401 "$O_SRV -key data_files/server2.key \
3402 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003403 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003404 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3405 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003406 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003407 -c "Processing of the Certificate handshake message failed" \
3408 -C "Ciphersuite is TLS-"
3409
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003410run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3411 "$O_SRV -key data_files/server2.key \
3412 -cert data_files/server2.ku-ds.crt" \
3413 "$P_CLI debug_level=1 auth_mode=optional \
3414 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3415 0 \
3416 -c "bad certificate (usage extensions)" \
3417 -C "Processing of the Certificate handshake message failed" \
3418 -c "Ciphersuite is TLS-" \
3419 -c "! Usage does not match the keyUsage extension"
3420
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003421# Tests for keyUsage in leaf certificates, part 3:
3422# server-side checking of client cert
3423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003424run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003425 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003426 "$O_CLI -key data_files/server2.key \
3427 -cert data_files/server2.ku-ds.crt" \
3428 0 \
3429 -S "bad certificate (usage extensions)" \
3430 -S "Processing of the Certificate handshake message failed"
3431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003432run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003433 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003434 "$O_CLI -key data_files/server2.key \
3435 -cert data_files/server2.ku-ke.crt" \
3436 0 \
3437 -s "bad certificate (usage extensions)" \
3438 -S "Processing of the Certificate handshake message failed"
3439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003440run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003441 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003442 "$O_CLI -key data_files/server2.key \
3443 -cert data_files/server2.ku-ke.crt" \
3444 1 \
3445 -s "bad certificate (usage extensions)" \
3446 -s "Processing of the Certificate handshake message failed"
3447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003448run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003449 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003450 "$O_CLI -key data_files/server5.key \
3451 -cert data_files/server5.ku-ds.crt" \
3452 0 \
3453 -S "bad certificate (usage extensions)" \
3454 -S "Processing of the Certificate handshake message failed"
3455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003456run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003457 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003458 "$O_CLI -key data_files/server5.key \
3459 -cert data_files/server5.ku-ka.crt" \
3460 0 \
3461 -s "bad certificate (usage extensions)" \
3462 -S "Processing of the Certificate handshake message failed"
3463
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003464# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003466run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003467 "$P_SRV key_file=data_files/server5.key \
3468 crt_file=data_files/server5.eku-srv.crt" \
3469 "$P_CLI" \
3470 0
3471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003472run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003473 "$P_SRV key_file=data_files/server5.key \
3474 crt_file=data_files/server5.eku-srv.crt" \
3475 "$P_CLI" \
3476 0
3477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003478run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003479 "$P_SRV key_file=data_files/server5.key \
3480 crt_file=data_files/server5.eku-cs_any.crt" \
3481 "$P_CLI" \
3482 0
3483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003484run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003485 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003486 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003487 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003488 1
3489
3490# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3491
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003492run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003493 "$O_SRV -key data_files/server5.key \
3494 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003495 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003496 0 \
3497 -C "bad certificate (usage extensions)" \
3498 -C "Processing of the Certificate handshake message failed" \
3499 -c "Ciphersuite is TLS-"
3500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003501run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003502 "$O_SRV -key data_files/server5.key \
3503 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003504 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003505 0 \
3506 -C "bad certificate (usage extensions)" \
3507 -C "Processing of the Certificate handshake message failed" \
3508 -c "Ciphersuite is TLS-"
3509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003510run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003511 "$O_SRV -key data_files/server5.key \
3512 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003513 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003514 0 \
3515 -C "bad certificate (usage extensions)" \
3516 -C "Processing of the Certificate handshake message failed" \
3517 -c "Ciphersuite is TLS-"
3518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003519run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003520 "$O_SRV -key data_files/server5.key \
3521 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003522 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003523 1 \
3524 -c "bad certificate (usage extensions)" \
3525 -c "Processing of the Certificate handshake message failed" \
3526 -C "Ciphersuite is TLS-"
3527
3528# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003530run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003531 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003532 "$O_CLI -key data_files/server5.key \
3533 -cert data_files/server5.eku-cli.crt" \
3534 0 \
3535 -S "bad certificate (usage extensions)" \
3536 -S "Processing of the Certificate handshake message failed"
3537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003538run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003539 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003540 "$O_CLI -key data_files/server5.key \
3541 -cert data_files/server5.eku-srv_cli.crt" \
3542 0 \
3543 -S "bad certificate (usage extensions)" \
3544 -S "Processing of the Certificate handshake message failed"
3545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003546run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003547 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003548 "$O_CLI -key data_files/server5.key \
3549 -cert data_files/server5.eku-cs_any.crt" \
3550 0 \
3551 -S "bad certificate (usage extensions)" \
3552 -S "Processing of the Certificate handshake message failed"
3553
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003554run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003555 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003556 "$O_CLI -key data_files/server5.key \
3557 -cert data_files/server5.eku-cs.crt" \
3558 0 \
3559 -s "bad certificate (usage extensions)" \
3560 -S "Processing of the Certificate handshake message failed"
3561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003562run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003563 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003564 "$O_CLI -key data_files/server5.key \
3565 -cert data_files/server5.eku-cs.crt" \
3566 1 \
3567 -s "bad certificate (usage extensions)" \
3568 -s "Processing of the Certificate handshake message failed"
3569
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003570# Tests for DHM parameters loading
3571
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003572run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003573 "$P_SRV" \
3574 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3575 debug_level=3" \
3576 0 \
3577 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003578 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003580run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003581 "$P_SRV dhm_file=data_files/dhparams.pem" \
3582 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3583 debug_level=3" \
3584 0 \
3585 -c "value of 'DHM: P ' (1024 bits)" \
3586 -c "value of 'DHM: G ' (2 bits)"
3587
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003588# Tests for DHM client-side size checking
3589
3590run_test "DHM size: server default, client default, OK" \
3591 "$P_SRV" \
3592 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3593 debug_level=1" \
3594 0 \
3595 -C "DHM prime too short:"
3596
3597run_test "DHM size: server default, client 2048, OK" \
3598 "$P_SRV" \
3599 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3600 debug_level=1 dhmlen=2048" \
3601 0 \
3602 -C "DHM prime too short:"
3603
3604run_test "DHM size: server 1024, client default, OK" \
3605 "$P_SRV dhm_file=data_files/dhparams.pem" \
3606 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3607 debug_level=1" \
3608 0 \
3609 -C "DHM prime too short:"
3610
3611run_test "DHM size: server 1000, client default, rejected" \
3612 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3613 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3614 debug_level=1" \
3615 1 \
3616 -c "DHM prime too short:"
3617
3618run_test "DHM size: server default, client 2049, rejected" \
3619 "$P_SRV" \
3620 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3621 debug_level=1 dhmlen=2049" \
3622 1 \
3623 -c "DHM prime too short:"
3624
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003625# Tests for PSK callback
3626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003627run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003628 "$P_SRV psk=abc123 psk_identity=foo" \
3629 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3630 psk_identity=foo psk=abc123" \
3631 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003632 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003633 -S "SSL - Unknown identity received" \
3634 -S "SSL - Verification of the message MAC failed"
3635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003636run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003637 "$P_SRV" \
3638 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3639 psk_identity=foo psk=abc123" \
3640 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003641 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003642 -S "SSL - Unknown identity received" \
3643 -S "SSL - Verification of the message MAC failed"
3644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003645run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003646 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3647 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3648 psk_identity=foo psk=abc123" \
3649 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003650 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003651 -s "SSL - Unknown identity received" \
3652 -S "SSL - Verification of the message MAC failed"
3653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003654run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003655 "$P_SRV psk_list=abc,dead,def,beef" \
3656 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3657 psk_identity=abc psk=dead" \
3658 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003659 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003660 -S "SSL - Unknown identity received" \
3661 -S "SSL - Verification of the message MAC failed"
3662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003663run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003664 "$P_SRV psk_list=abc,dead,def,beef" \
3665 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3666 psk_identity=def psk=beef" \
3667 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003668 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003669 -S "SSL - Unknown identity received" \
3670 -S "SSL - Verification of the message MAC failed"
3671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003672run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003673 "$P_SRV psk_list=abc,dead,def,beef" \
3674 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3675 psk_identity=ghi psk=beef" \
3676 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003677 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003678 -s "SSL - Unknown identity received" \
3679 -S "SSL - Verification of the message MAC failed"
3680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003681run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003682 "$P_SRV psk_list=abc,dead,def,beef" \
3683 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3684 psk_identity=abc psk=beef" \
3685 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003686 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003687 -S "SSL - Unknown identity received" \
3688 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003689
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003690# Tests for EC J-PAKE
3691
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003692requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003693run_test "ECJPAKE: client not configured" \
3694 "$P_SRV debug_level=3" \
3695 "$P_CLI debug_level=3" \
3696 0 \
3697 -C "add ciphersuite: c0ff" \
3698 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003699 -S "found ecjpake kkpp extension" \
3700 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003701 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003702 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003703 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003704 -S "None of the common ciphersuites is usable"
3705
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003706requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003707run_test "ECJPAKE: server not configured" \
3708 "$P_SRV debug_level=3" \
3709 "$P_CLI debug_level=3 ecjpake_pw=bla \
3710 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3711 1 \
3712 -c "add ciphersuite: c0ff" \
3713 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003714 -s "found ecjpake kkpp extension" \
3715 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003716 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003717 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003718 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003719 -s "None of the common ciphersuites is usable"
3720
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003721requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003722run_test "ECJPAKE: working, TLS" \
3723 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3724 "$P_CLI debug_level=3 ecjpake_pw=bla \
3725 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003726 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003727 -c "add ciphersuite: c0ff" \
3728 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003729 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003730 -s "found ecjpake kkpp extension" \
3731 -S "skip ecjpake kkpp extension" \
3732 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003733 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003734 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003735 -S "None of the common ciphersuites is usable" \
3736 -S "SSL - Verification of the message MAC failed"
3737
Janos Follath74537a62016-09-02 13:45:28 +01003738server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003739requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003740run_test "ECJPAKE: password mismatch, TLS" \
3741 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3742 "$P_CLI debug_level=3 ecjpake_pw=bad \
3743 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3744 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003745 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003746 -s "SSL - Verification of the message MAC failed"
3747
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003748requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003749run_test "ECJPAKE: working, DTLS" \
3750 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3751 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3752 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3753 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003754 -c "re-using cached ecjpake parameters" \
3755 -S "SSL - Verification of the message MAC failed"
3756
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003757requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003758run_test "ECJPAKE: working, DTLS, no cookie" \
3759 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3760 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3761 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3762 0 \
3763 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003764 -S "SSL - Verification of the message MAC failed"
3765
Janos Follath74537a62016-09-02 13:45:28 +01003766server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003767requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003768run_test "ECJPAKE: password mismatch, DTLS" \
3769 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3770 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3771 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3772 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003773 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003774 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003775
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003776# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003777requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003778run_test "ECJPAKE: working, DTLS, nolog" \
3779 "$P_SRV dtls=1 ecjpake_pw=bla" \
3780 "$P_CLI dtls=1 ecjpake_pw=bla \
3781 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3782 0
3783
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003784# Tests for ciphersuites per version
3785
Janos Follathe2681a42016-03-07 15:57:05 +00003786requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003787requires_config_enabled MBEDTLS_CAMELLIA_C
3788requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003789run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003790 "$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 +02003791 "$P_CLI force_version=ssl3" \
3792 0 \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003793 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003794
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003795requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
3796requires_config_enabled MBEDTLS_CAMELLIA_C
3797requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003798run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003799 "$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 +01003800 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003801 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003802 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003803
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003804requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
3805requires_config_enabled MBEDTLS_CAMELLIA_C
3806requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003807run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003808 "$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 +02003809 "$P_CLI force_version=tls1_1" \
3810 0 \
3811 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3812
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003813requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
3814requires_config_enabled MBEDTLS_CAMELLIA_C
3815requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003816run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003817 "$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 +02003818 "$P_CLI force_version=tls1_2" \
3819 0 \
3820 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3821
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003822# Test for ClientHello without extensions
3823
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003824requires_gnutls
Manuel Pégourié-Gonnard37abf122020-01-30 12:45:14 +01003825run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnarda92990a2020-01-30 11:19:45 +01003826 "$P_SRV debug_level=3" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003827 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3828 0 \
3829 -s "dumping 'client hello extensions' (0 bytes)"
3830
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003831# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003832
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003833run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003834 "$P_SRV" \
3835 "$P_CLI request_size=100" \
3836 0 \
3837 -s "Read from client: 100 bytes read$"
3838
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003839run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003840 "$P_SRV" \
3841 "$P_CLI request_size=500" \
3842 0 \
3843 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003844
Andrzej Kurekd731a632018-06-19 09:37:30 -04003845# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003846
Janos Follathe2681a42016-03-07 15:57:05 +00003847requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekd731a632018-06-19 09:37:30 -04003848run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003849 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003850 "$P_CLI request_size=1 force_version=ssl3 \
3851 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3852 0 \
3853 -s "Read from client: 1 bytes read"
3854
Janos Follathe2681a42016-03-07 15:57:05 +00003855requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekd731a632018-06-19 09:37:30 -04003856run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003857 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003858 "$P_CLI request_size=1 force_version=ssl3 \
3859 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3860 0 \
3861 -s "Read from client: 1 bytes read"
3862
Andrzej Kurekd731a632018-06-19 09:37:30 -04003863run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003864 "$P_SRV" \
3865 "$P_CLI request_size=1 force_version=tls1 \
3866 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3867 0 \
3868 -s "Read from client: 1 bytes read"
3869
Andrzej Kurekd731a632018-06-19 09:37:30 -04003870run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003871 "$P_SRV" \
3872 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3873 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3874 0 \
3875 -s "Read from client: 1 bytes read"
3876
Hanno Becker32c55012017-11-10 08:42:54 +00003877requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003878run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003879 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003880 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003881 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003882 0 \
3883 -s "Read from client: 1 bytes read"
3884
Hanno Becker32c55012017-11-10 08:42:54 +00003885requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003886run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003887 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003888 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003889 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003890 0 \
3891 -s "Read from client: 1 bytes read"
3892
Andrzej Kurekd731a632018-06-19 09:37:30 -04003893run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003894 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003895 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003896 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3897 0 \
3898 -s "Read from client: 1 bytes read"
3899
Andrzej Kurekd731a632018-06-19 09:37:30 -04003900run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003901 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3902 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003903 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003904 0 \
3905 -s "Read from client: 1 bytes read"
3906
3907requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003908run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003909 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003910 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003911 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003912 0 \
3913 -s "Read from client: 1 bytes read"
3914
Hanno Becker8501f982017-11-10 08:59:04 +00003915requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003916run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003917 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3918 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3919 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003920 0 \
3921 -s "Read from client: 1 bytes read"
3922
Andrzej Kurekd731a632018-06-19 09:37:30 -04003923run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003924 "$P_SRV" \
3925 "$P_CLI request_size=1 force_version=tls1_1 \
3926 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3927 0 \
3928 -s "Read from client: 1 bytes read"
3929
Andrzej Kurekd731a632018-06-19 09:37:30 -04003930run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003931 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003932 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003933 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003934 0 \
3935 -s "Read from client: 1 bytes read"
3936
3937requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003938run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003939 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003940 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003941 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003942 0 \
3943 -s "Read from client: 1 bytes read"
3944
3945requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003946run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003947 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003948 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003949 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003950 0 \
3951 -s "Read from client: 1 bytes read"
3952
Andrzej Kurekd731a632018-06-19 09:37:30 -04003953run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003954 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003955 "$P_CLI request_size=1 force_version=tls1_1 \
3956 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3957 0 \
3958 -s "Read from client: 1 bytes read"
3959
Andrzej Kurekd731a632018-06-19 09:37:30 -04003960run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003961 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003962 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003963 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003964 0 \
3965 -s "Read from client: 1 bytes read"
3966
Hanno Becker8501f982017-11-10 08:59:04 +00003967requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003968run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003969 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003970 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003971 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003972 0 \
3973 -s "Read from client: 1 bytes read"
3974
Hanno Becker32c55012017-11-10 08:42:54 +00003975requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003976run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003977 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003978 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003979 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003980 0 \
3981 -s "Read from client: 1 bytes read"
3982
Andrzej Kurekd731a632018-06-19 09:37:30 -04003983run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003984 "$P_SRV" \
3985 "$P_CLI request_size=1 force_version=tls1_2 \
3986 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3987 0 \
3988 -s "Read from client: 1 bytes read"
3989
Andrzej Kurekd731a632018-06-19 09:37:30 -04003990run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003991 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003992 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003993 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003994 0 \
3995 -s "Read from client: 1 bytes read"
3996
Andrzej Kurekd731a632018-06-19 09:37:30 -04003997run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003998 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003999 "$P_CLI request_size=1 force_version=tls1_2 \
4000 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004001 0 \
4002 -s "Read from client: 1 bytes read"
4003
Hanno Becker32c55012017-11-10 08:42:54 +00004004requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004005run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004006 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004007 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004008 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004009 0 \
4010 -s "Read from client: 1 bytes read"
4011
Hanno Becker8501f982017-11-10 08:59:04 +00004012requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004013run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004014 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004015 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004016 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004017 0 \
4018 -s "Read from client: 1 bytes read"
4019
Andrzej Kurekd731a632018-06-19 09:37:30 -04004020run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004021 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004022 "$P_CLI request_size=1 force_version=tls1_2 \
4023 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4024 0 \
4025 -s "Read from client: 1 bytes read"
4026
Andrzej Kurekd731a632018-06-19 09:37:30 -04004027run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004028 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004029 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004030 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004031 0 \
4032 -s "Read from client: 1 bytes read"
4033
Hanno Becker32c55012017-11-10 08:42:54 +00004034requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004035run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004036 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004037 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004038 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004039 0 \
4040 -s "Read from client: 1 bytes read"
4041
Hanno Becker8501f982017-11-10 08:59:04 +00004042requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004043run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004044 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004045 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004046 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004047 0 \
4048 -s "Read from client: 1 bytes read"
4049
Andrzej Kurekd731a632018-06-19 09:37:30 -04004050run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004051 "$P_SRV" \
4052 "$P_CLI request_size=1 force_version=tls1_2 \
4053 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4054 0 \
4055 -s "Read from client: 1 bytes read"
4056
Andrzej Kurekd731a632018-06-19 09:37:30 -04004057run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004058 "$P_SRV" \
4059 "$P_CLI request_size=1 force_version=tls1_2 \
4060 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4061 0 \
4062 -s "Read from client: 1 bytes read"
4063
Andrzej Kurekd731a632018-06-19 09:37:30 -04004064# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004065
4066requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004067run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004068 "$P_SRV dtls=1 force_version=dtls1" \
4069 "$P_CLI dtls=1 request_size=1 \
4070 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4071 0 \
4072 -s "Read from client: 1 bytes read"
4073
4074requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004075run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004076 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4077 "$P_CLI dtls=1 request_size=1 \
4078 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4079 0 \
4080 -s "Read from client: 1 bytes read"
4081
4082requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4083requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004084run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004085 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4086 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004087 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4088 0 \
4089 -s "Read from client: 1 bytes read"
4090
4091requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4092requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004093run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004094 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004095 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004096 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004097 0 \
4098 -s "Read from client: 1 bytes read"
4099
4100requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004101run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004102 "$P_SRV dtls=1 force_version=dtls1_2" \
4103 "$P_CLI dtls=1 request_size=1 \
4104 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4105 0 \
4106 -s "Read from client: 1 bytes read"
4107
4108requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004109run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004110 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004111 "$P_CLI dtls=1 request_size=1 \
4112 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4113 0 \
4114 -s "Read from client: 1 bytes read"
4115
4116requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4117requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004118run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004119 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004120 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004121 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004122 0 \
4123 -s "Read from client: 1 bytes read"
4124
4125requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4126requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004127run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004128 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004129 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004130 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004131 0 \
4132 -s "Read from client: 1 bytes read"
4133
Andrzej Kurekd731a632018-06-19 09:37:30 -04004134# Tests for small server packets
4135
4136requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4137run_test "Small server packet SSLv3 BlockCipher" \
4138 "$P_SRV response_size=1 min_version=ssl3" \
4139 "$P_CLI force_version=ssl3 \
4140 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4141 0 \
4142 -c "Read from server: 1 bytes read"
4143
4144requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4145run_test "Small server packet SSLv3 StreamCipher" \
4146 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4147 "$P_CLI force_version=ssl3 \
4148 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4149 0 \
4150 -c "Read from server: 1 bytes read"
4151
4152run_test "Small server packet TLS 1.0 BlockCipher" \
4153 "$P_SRV response_size=1" \
4154 "$P_CLI force_version=tls1 \
4155 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4156 0 \
4157 -c "Read from server: 1 bytes read"
4158
4159run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4160 "$P_SRV response_size=1" \
4161 "$P_CLI force_version=tls1 etm=0 \
4162 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4163 0 \
4164 -c "Read from server: 1 bytes read"
4165
4166requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4167run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4168 "$P_SRV response_size=1 trunc_hmac=1" \
4169 "$P_CLI force_version=tls1 \
4170 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4171 0 \
4172 -c "Read from server: 1 bytes read"
4173
4174requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4175run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4176 "$P_SRV response_size=1 trunc_hmac=1" \
4177 "$P_CLI force_version=tls1 \
4178 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4179 0 \
4180 -c "Read from server: 1 bytes read"
4181
4182run_test "Small server packet TLS 1.0 StreamCipher" \
4183 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4184 "$P_CLI force_version=tls1 \
4185 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4186 0 \
4187 -c "Read from server: 1 bytes read"
4188
4189run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4190 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4191 "$P_CLI force_version=tls1 \
4192 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4193 0 \
4194 -c "Read from server: 1 bytes read"
4195
4196requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4197run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4198 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4199 "$P_CLI force_version=tls1 \
4200 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4201 0 \
4202 -c "Read from server: 1 bytes read"
4203
4204requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4205run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4206 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4207 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4208 trunc_hmac=1 etm=0" \
4209 0 \
4210 -c "Read from server: 1 bytes read"
4211
4212run_test "Small server packet TLS 1.1 BlockCipher" \
4213 "$P_SRV response_size=1" \
4214 "$P_CLI force_version=tls1_1 \
4215 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4216 0 \
4217 -c "Read from server: 1 bytes read"
4218
4219run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4220 "$P_SRV response_size=1" \
4221 "$P_CLI force_version=tls1_1 \
4222 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4223 0 \
4224 -c "Read from server: 1 bytes read"
4225
4226requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4227run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4228 "$P_SRV response_size=1 trunc_hmac=1" \
4229 "$P_CLI force_version=tls1_1 \
4230 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4231 0 \
4232 -c "Read from server: 1 bytes read"
4233
4234requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4235run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4236 "$P_SRV response_size=1 trunc_hmac=1" \
4237 "$P_CLI force_version=tls1_1 \
4238 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4239 0 \
4240 -c "Read from server: 1 bytes read"
4241
4242run_test "Small server packet TLS 1.1 StreamCipher" \
4243 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4244 "$P_CLI force_version=tls1_1 \
4245 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4246 0 \
4247 -c "Read from server: 1 bytes read"
4248
4249run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4250 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4251 "$P_CLI force_version=tls1_1 \
4252 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4253 0 \
4254 -c "Read from server: 1 bytes read"
4255
4256requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4257run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4258 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4259 "$P_CLI force_version=tls1_1 \
4260 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4261 0 \
4262 -c "Read from server: 1 bytes read"
4263
4264requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4265run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4266 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4267 "$P_CLI force_version=tls1_1 \
4268 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4269 0 \
4270 -c "Read from server: 1 bytes read"
4271
4272run_test "Small server packet TLS 1.2 BlockCipher" \
4273 "$P_SRV response_size=1" \
4274 "$P_CLI force_version=tls1_2 \
4275 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4276 0 \
4277 -c "Read from server: 1 bytes read"
4278
4279run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4280 "$P_SRV response_size=1" \
4281 "$P_CLI force_version=tls1_2 \
4282 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4283 0 \
4284 -c "Read from server: 1 bytes read"
4285
4286run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4287 "$P_SRV response_size=1" \
4288 "$P_CLI force_version=tls1_2 \
4289 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4290 0 \
4291 -c "Read from server: 1 bytes read"
4292
4293requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4294run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4295 "$P_SRV response_size=1 trunc_hmac=1" \
4296 "$P_CLI force_version=tls1_2 \
4297 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4298 0 \
4299 -c "Read from server: 1 bytes read"
4300
4301requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4302run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4303 "$P_SRV response_size=1 trunc_hmac=1" \
4304 "$P_CLI force_version=tls1_2 \
4305 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4306 0 \
4307 -c "Read from server: 1 bytes read"
4308
4309run_test "Small server packet TLS 1.2 StreamCipher" \
4310 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4311 "$P_CLI force_version=tls1_2 \
4312 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4313 0 \
4314 -c "Read from server: 1 bytes read"
4315
4316run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4317 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4318 "$P_CLI force_version=tls1_2 \
4319 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4320 0 \
4321 -c "Read from server: 1 bytes read"
4322
4323requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4324run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4325 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4326 "$P_CLI force_version=tls1_2 \
4327 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4328 0 \
4329 -c "Read from server: 1 bytes read"
4330
4331requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4332run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4333 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4334 "$P_CLI force_version=tls1_2 \
4335 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4336 0 \
4337 -c "Read from server: 1 bytes read"
4338
4339run_test "Small server packet TLS 1.2 AEAD" \
4340 "$P_SRV response_size=1" \
4341 "$P_CLI force_version=tls1_2 \
4342 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4343 0 \
4344 -c "Read from server: 1 bytes read"
4345
4346run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4347 "$P_SRV response_size=1" \
4348 "$P_CLI force_version=tls1_2 \
4349 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4350 0 \
4351 -c "Read from server: 1 bytes read"
4352
4353# Tests for small server packets in DTLS
4354
4355requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4356run_test "Small server packet DTLS 1.0" \
4357 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4358 "$P_CLI dtls=1 \
4359 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4360 0 \
4361 -c "Read from server: 1 bytes read"
4362
4363requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4364run_test "Small server packet DTLS 1.0, without EtM" \
4365 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4366 "$P_CLI dtls=1 \
4367 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4368 0 \
4369 -c "Read from server: 1 bytes read"
4370
4371requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4372requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4373run_test "Small server packet DTLS 1.0, truncated hmac" \
4374 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4375 "$P_CLI dtls=1 trunc_hmac=1 \
4376 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4377 0 \
4378 -c "Read from server: 1 bytes read"
4379
4380requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4381requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4382run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4383 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4384 "$P_CLI dtls=1 \
4385 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4386 0 \
4387 -c "Read from server: 1 bytes read"
4388
4389requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4390run_test "Small server packet DTLS 1.2" \
4391 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4392 "$P_CLI dtls=1 \
4393 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4394 0 \
4395 -c "Read from server: 1 bytes read"
4396
4397requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4398run_test "Small server packet DTLS 1.2, without EtM" \
4399 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4400 "$P_CLI dtls=1 \
4401 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4402 0 \
4403 -c "Read from server: 1 bytes read"
4404
4405requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4406requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4407run_test "Small server packet DTLS 1.2, truncated hmac" \
4408 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4409 "$P_CLI dtls=1 \
4410 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4411 0 \
4412 -c "Read from server: 1 bytes read"
4413
4414requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4415requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4416run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4417 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4418 "$P_CLI dtls=1 \
4419 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4420 0 \
4421 -c "Read from server: 1 bytes read"
4422
Janos Follath00efff72016-05-06 13:48:23 +01004423# A test for extensions in SSLv3
4424
4425requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4426run_test "SSLv3 with extensions, server side" \
4427 "$P_SRV min_version=ssl3 debug_level=3" \
4428 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4429 0 \
4430 -S "dumping 'client hello extensions'" \
4431 -S "server hello, total extension length:"
4432
Andrzej Kurek557335e2018-06-28 04:03:10 -04004433# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004434
Janos Follathe2681a42016-03-07 15:57:05 +00004435requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek557335e2018-06-28 04:03:10 -04004436run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004437 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004438 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004439 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4440 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004441 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004442 -s "Read from client: 16384 bytes read"
4443
Janos Follathe2681a42016-03-07 15:57:05 +00004444requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek557335e2018-06-28 04:03:10 -04004445run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004446 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004447 "$P_CLI request_size=16384 force_version=ssl3 \
4448 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4449 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004450 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004451 -s "Read from client: 16384 bytes read"
4452
Andrzej Kurek557335e2018-06-28 04:03:10 -04004453run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004454 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004455 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004456 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4457 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004458 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004459 -s "Read from client: 16384 bytes read"
4460
Andrzej Kurek557335e2018-06-28 04:03:10 -04004461run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004462 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004463 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4464 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4465 0 \
4466 -s "Read from client: 16384 bytes read"
4467
Hanno Becker32c55012017-11-10 08:42:54 +00004468requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004469run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004470 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004471 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004472 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004473 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004474 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004475 -s "Read from client: 16384 bytes read"
4476
Hanno Becker32c55012017-11-10 08:42:54 +00004477requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004478run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004479 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004480 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004481 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004482 0 \
4483 -s "Read from client: 16384 bytes read"
4484
Andrzej Kurek557335e2018-06-28 04:03:10 -04004485run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004486 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004487 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004488 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4489 0 \
4490 -s "Read from client: 16384 bytes read"
4491
Andrzej Kurek557335e2018-06-28 04:03:10 -04004492run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004493 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4494 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004495 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004496 0 \
4497 -s "Read from client: 16384 bytes read"
4498
4499requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004500run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004501 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004502 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004503 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004504 0 \
4505 -s "Read from client: 16384 bytes read"
4506
Hanno Becker278fc7a2017-11-10 09:16:28 +00004507requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004508run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004509 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004510 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004511 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004512 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004513 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004514 -s "Read from client: 16384 bytes read"
4515
Andrzej Kurek557335e2018-06-28 04:03:10 -04004516run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004517 "$P_SRV" \
4518 "$P_CLI request_size=16384 force_version=tls1_1 \
4519 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4520 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004521 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004522 -s "Read from client: 16384 bytes read"
4523
Andrzej Kurek557335e2018-06-28 04:03:10 -04004524run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004525 "$P_SRV" \
4526 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4527 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004528 0 \
4529 -s "Read from client: 16384 bytes read"
4530
Hanno Becker32c55012017-11-10 08:42:54 +00004531requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004532run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004533 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004534 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004535 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004536 0 \
4537 -s "Read from client: 16384 bytes read"
4538
Hanno Becker32c55012017-11-10 08:42:54 +00004539requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004540run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004541 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004542 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004543 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004544 0 \
4545 -s "Read from client: 16384 bytes read"
4546
Andrzej Kurek557335e2018-06-28 04:03:10 -04004547run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004548 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4549 "$P_CLI request_size=16384 force_version=tls1_1 \
4550 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4551 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004552 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004553 -s "Read from client: 16384 bytes read"
4554
Andrzej Kurek557335e2018-06-28 04:03:10 -04004555run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004556 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004557 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004558 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004559 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004560 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004561 -s "Read from client: 16384 bytes read"
4562
Hanno Becker278fc7a2017-11-10 09:16:28 +00004563requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004564run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004565 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004566 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004567 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004568 0 \
4569 -s "Read from client: 16384 bytes read"
4570
Hanno Becker278fc7a2017-11-10 09:16:28 +00004571requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004572run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004573 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004574 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004575 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004576 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004577 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004578 -s "Read from client: 16384 bytes read"
4579
Andrzej Kurek557335e2018-06-28 04:03:10 -04004580run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004581 "$P_SRV" \
4582 "$P_CLI request_size=16384 force_version=tls1_2 \
4583 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4584 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004585 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004586 -s "Read from client: 16384 bytes read"
4587
Andrzej Kurek557335e2018-06-28 04:03:10 -04004588run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004589 "$P_SRV" \
4590 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4591 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4592 0 \
4593 -s "Read from client: 16384 bytes read"
4594
Andrzej Kurek557335e2018-06-28 04:03:10 -04004595run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004596 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004597 "$P_CLI request_size=16384 force_version=tls1_2 \
4598 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004599 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004600 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004601 -s "Read from client: 16384 bytes read"
4602
Hanno Becker32c55012017-11-10 08:42:54 +00004603requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004604run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004605 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004606 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004607 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004608 0 \
4609 -s "Read from client: 16384 bytes read"
4610
Hanno Becker278fc7a2017-11-10 09:16:28 +00004611requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004612run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004613 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004614 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004615 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004616 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004617 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004618 -s "Read from client: 16384 bytes read"
4619
Andrzej Kurek557335e2018-06-28 04:03:10 -04004620run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004621 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004622 "$P_CLI request_size=16384 force_version=tls1_2 \
4623 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4624 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004625 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004626 -s "Read from client: 16384 bytes read"
4627
Andrzej Kurek557335e2018-06-28 04:03:10 -04004628run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004629 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004630 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004631 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4632 0 \
4633 -s "Read from client: 16384 bytes read"
4634
Hanno Becker32c55012017-11-10 08:42:54 +00004635requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004636run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004637 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004638 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004639 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004640 0 \
4641 -s "Read from client: 16384 bytes read"
4642
Hanno Becker278fc7a2017-11-10 09:16:28 +00004643requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004644run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004645 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004646 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004647 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004648 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004649 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004650 -s "Read from client: 16384 bytes read"
4651
Andrzej Kurek557335e2018-06-28 04:03:10 -04004652run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004653 "$P_SRV" \
4654 "$P_CLI request_size=16384 force_version=tls1_2 \
4655 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4656 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004657 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004658 -s "Read from client: 16384 bytes read"
4659
Andrzej Kurek557335e2018-06-28 04:03:10 -04004660run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004661 "$P_SRV" \
4662 "$P_CLI request_size=16384 force_version=tls1_2 \
4663 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4664 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004665 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004666 -s "Read from client: 16384 bytes read"
4667
Ron Eldorc7f15232018-06-28 13:22:05 +03004668# Tests for ECC extensions (rfc 4492)
4669
Ron Eldor94226d82018-06-28 16:17:00 +03004670requires_config_enabled MBEDTLS_AES_C
4671requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4672requires_config_enabled MBEDTLS_SHA256_C
4673requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004674run_test "Force a non ECC ciphersuite in the client side" \
4675 "$P_SRV debug_level=3" \
Ron Eldor94226d82018-06-28 16:17:00 +03004676 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004677 0 \
4678 -C "client hello, adding supported_elliptic_curves extension" \
4679 -C "client hello, adding supported_point_formats extension" \
4680 -S "found supported elliptic curves extension" \
4681 -S "found supported point formats extension"
4682
Ron Eldor94226d82018-06-28 16:17:00 +03004683requires_config_enabled MBEDTLS_AES_C
4684requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4685requires_config_enabled MBEDTLS_SHA256_C
4686requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004687run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor94226d82018-06-28 16:17:00 +03004688 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004689 "$P_CLI debug_level=3" \
4690 0 \
4691 -C "found supported_point_formats extension" \
4692 -S "server hello, supported_point_formats extension"
4693
Ron Eldor94226d82018-06-28 16:17:00 +03004694requires_config_enabled MBEDTLS_AES_C
4695requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4696requires_config_enabled MBEDTLS_SHA256_C
4697requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004698run_test "Force an ECC ciphersuite in the client side" \
4699 "$P_SRV debug_level=3" \
4700 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4701 0 \
4702 -c "client hello, adding supported_elliptic_curves extension" \
4703 -c "client hello, adding supported_point_formats extension" \
4704 -s "found supported elliptic curves extension" \
4705 -s "found supported point formats extension"
4706
Ron Eldor94226d82018-06-28 16:17:00 +03004707requires_config_enabled MBEDTLS_AES_C
4708requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4709requires_config_enabled MBEDTLS_SHA256_C
4710requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004711run_test "Force an ECC ciphersuite in the server side" \
4712 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4713 "$P_CLI debug_level=3" \
4714 0 \
4715 -c "found supported_point_formats extension" \
4716 -s "server hello, supported_point_formats extension"
4717
Andrzej Kurek557335e2018-06-28 04:03:10 -04004718# Test for large server packets
Andrzej Kurek557335e2018-06-28 04:03:10 -04004719requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4720run_test "Large server packet SSLv3 StreamCipher" \
4721 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4722 "$P_CLI force_version=ssl3 \
4723 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4724 0 \
4725 -c "Read from server: 16384 bytes read"
4726
Andrzej Kurekc8958212018-08-27 08:00:13 -04004727# Checking next 4 tests logs for 1n-1 split against BEAST too
4728requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4729run_test "Large server packet SSLv3 BlockCipher" \
4730 "$P_SRV response_size=16384 min_version=ssl3" \
4731 "$P_CLI force_version=ssl3 recsplit=0 \
4732 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4733 0 \
4734 -c "Read from server: 1 bytes read"\
4735 -c "16383 bytes read"\
4736 -C "Read from server: 16384 bytes read"
4737
Andrzej Kurek557335e2018-06-28 04:03:10 -04004738run_test "Large server packet TLS 1.0 BlockCipher" \
4739 "$P_SRV response_size=16384" \
4740 "$P_CLI force_version=tls1 recsplit=0 \
4741 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4742 0 \
4743 -c "Read from server: 1 bytes read"\
4744 -c "16383 bytes read"\
4745 -C "Read from server: 16384 bytes read"
4746
Andrzej Kurekd731a632018-06-19 09:37:30 -04004747run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
4748 "$P_SRV response_size=16384" \
4749 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
4750 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4751 0 \
4752 -c "Read from server: 1 bytes read"\
4753 -c "16383 bytes read"\
4754 -C "Read from server: 16384 bytes read"
4755
Andrzej Kurek557335e2018-06-28 04:03:10 -04004756requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4757run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
4758 "$P_SRV response_size=16384" \
4759 "$P_CLI force_version=tls1 recsplit=0 \
4760 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4761 trunc_hmac=1" \
4762 0 \
4763 -c "Read from server: 1 bytes read"\
4764 -c "16383 bytes read"\
4765 -C "Read from server: 16384 bytes read"
4766
4767requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4768run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
4769 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4770 "$P_CLI force_version=tls1 \
4771 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4772 trunc_hmac=1" \
4773 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004774 -s "16384 bytes written in 1 fragments" \
4775 -c "Read from server: 16384 bytes read"
4776
4777run_test "Large server packet TLS 1.0 StreamCipher" \
4778 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4779 "$P_CLI force_version=tls1 \
4780 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4781 0 \
4782 -s "16384 bytes written in 1 fragments" \
4783 -c "Read from server: 16384 bytes read"
4784
4785run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
4786 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4787 "$P_CLI force_version=tls1 \
4788 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4789 0 \
4790 -s "16384 bytes written in 1 fragments" \
4791 -c "Read from server: 16384 bytes read"
4792
4793requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4794run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
4795 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4796 "$P_CLI force_version=tls1 \
4797 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4798 0 \
4799 -s "16384 bytes written in 1 fragments" \
4800 -c "Read from server: 16384 bytes read"
4801
4802requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4803run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4804 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4805 "$P_CLI force_version=tls1 \
4806 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4807 0 \
4808 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004809 -c "Read from server: 16384 bytes read"
4810
4811run_test "Large server packet TLS 1.1 BlockCipher" \
4812 "$P_SRV response_size=16384" \
4813 "$P_CLI force_version=tls1_1 \
4814 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4815 0 \
4816 -c "Read from server: 16384 bytes read"
4817
Andrzej Kurekd731a632018-06-19 09:37:30 -04004818run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
4819 "$P_SRV response_size=16384" \
4820 "$P_CLI force_version=tls1_1 etm=0 \
4821 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004822 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004823 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004824 -c "Read from server: 16384 bytes read"
4825
4826requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4827run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
4828 "$P_SRV response_size=16384" \
4829 "$P_CLI force_version=tls1_1 \
4830 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4831 trunc_hmac=1" \
4832 0 \
4833 -c "Read from server: 16384 bytes read"
4834
4835requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004836run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4837 "$P_SRV response_size=16384 trunc_hmac=1" \
4838 "$P_CLI force_version=tls1_1 \
4839 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4840 0 \
4841 -s "16384 bytes written in 1 fragments" \
4842 -c "Read from server: 16384 bytes read"
4843
4844run_test "Large server packet TLS 1.1 StreamCipher" \
4845 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4846 "$P_CLI force_version=tls1_1 \
4847 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4848 0 \
4849 -c "Read from server: 16384 bytes read"
4850
4851run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
4852 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4853 "$P_CLI force_version=tls1_1 \
4854 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4855 0 \
4856 -s "16384 bytes written in 1 fragments" \
4857 -c "Read from server: 16384 bytes read"
4858
4859requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004860run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
4861 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4862 "$P_CLI force_version=tls1_1 \
4863 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4864 trunc_hmac=1" \
4865 0 \
4866 -c "Read from server: 16384 bytes read"
4867
Andrzej Kurekd731a632018-06-19 09:37:30 -04004868run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4869 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4870 "$P_CLI force_version=tls1_1 \
4871 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4872 0 \
4873 -s "16384 bytes written in 1 fragments" \
4874 -c "Read from server: 16384 bytes read"
4875
Andrzej Kurek557335e2018-06-28 04:03:10 -04004876run_test "Large server packet TLS 1.2 BlockCipher" \
4877 "$P_SRV response_size=16384" \
4878 "$P_CLI force_version=tls1_2 \
4879 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4880 0 \
4881 -c "Read from server: 16384 bytes read"
4882
Andrzej Kurekd731a632018-06-19 09:37:30 -04004883run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
4884 "$P_SRV response_size=16384" \
4885 "$P_CLI force_version=tls1_2 etm=0 \
4886 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4887 0 \
4888 -s "16384 bytes written in 1 fragments" \
4889 -c "Read from server: 16384 bytes read"
4890
Andrzej Kurek557335e2018-06-28 04:03:10 -04004891run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
4892 "$P_SRV response_size=16384" \
4893 "$P_CLI force_version=tls1_2 \
4894 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4895 0 \
4896 -c "Read from server: 16384 bytes read"
4897
4898requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4899run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
4900 "$P_SRV response_size=16384" \
4901 "$P_CLI force_version=tls1_2 \
4902 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4903 trunc_hmac=1" \
4904 0 \
4905 -c "Read from server: 16384 bytes read"
4906
Andrzej Kurekd731a632018-06-19 09:37:30 -04004907run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4908 "$P_SRV response_size=16384 trunc_hmac=1" \
4909 "$P_CLI force_version=tls1_2 \
4910 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4911 0 \
4912 -s "16384 bytes written in 1 fragments" \
4913 -c "Read from server: 16384 bytes read"
4914
Andrzej Kurek557335e2018-06-28 04:03:10 -04004915run_test "Large server packet TLS 1.2 StreamCipher" \
4916 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4917 "$P_CLI force_version=tls1_2 \
4918 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4919 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004920 -s "16384 bytes written in 1 fragments" \
4921 -c "Read from server: 16384 bytes read"
4922
4923run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
4924 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4925 "$P_CLI force_version=tls1_2 \
4926 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4927 0 \
4928 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004929 -c "Read from server: 16384 bytes read"
4930
4931requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4932run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
4933 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4934 "$P_CLI force_version=tls1_2 \
4935 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4936 trunc_hmac=1" \
4937 0 \
4938 -c "Read from server: 16384 bytes read"
4939
Andrzej Kurekd731a632018-06-19 09:37:30 -04004940requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4941run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4942 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4943 "$P_CLI force_version=tls1_2 \
4944 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4945 0 \
4946 -s "16384 bytes written in 1 fragments" \
4947 -c "Read from server: 16384 bytes read"
4948
Andrzej Kurek557335e2018-06-28 04:03:10 -04004949run_test "Large server packet TLS 1.2 AEAD" \
4950 "$P_SRV response_size=16384" \
4951 "$P_CLI force_version=tls1_2 \
4952 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4953 0 \
4954 -c "Read from server: 16384 bytes read"
4955
4956run_test "Large server packet TLS 1.2 AEAD shorter tag" \
4957 "$P_SRV response_size=16384" \
4958 "$P_CLI force_version=tls1_2 \
4959 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4960 0 \
4961 -c "Read from server: 16384 bytes read"
4962
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004963# Tests for DTLS HelloVerifyRequest
4964
4965run_test "DTLS cookie: enabled" \
4966 "$P_SRV dtls=1 debug_level=2" \
4967 "$P_CLI dtls=1 debug_level=2" \
4968 0 \
4969 -s "cookie verification failed" \
4970 -s "cookie verification passed" \
4971 -S "cookie verification skipped" \
4972 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004973 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004974 -S "SSL - The requested feature is not available"
4975
4976run_test "DTLS cookie: disabled" \
4977 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4978 "$P_CLI dtls=1 debug_level=2" \
4979 0 \
4980 -S "cookie verification failed" \
4981 -S "cookie verification passed" \
4982 -s "cookie verification skipped" \
4983 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004984 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004985 -S "SSL - The requested feature is not available"
4986
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004987run_test "DTLS cookie: default (failing)" \
4988 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4989 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4990 1 \
4991 -s "cookie verification failed" \
4992 -S "cookie verification passed" \
4993 -S "cookie verification skipped" \
4994 -C "received hello verify request" \
4995 -S "hello verification requested" \
4996 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004997
4998requires_ipv6
4999run_test "DTLS cookie: enabled, IPv6" \
5000 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5001 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5002 0 \
5003 -s "cookie verification failed" \
5004 -s "cookie verification passed" \
5005 -S "cookie verification skipped" \
5006 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005007 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005008 -S "SSL - The requested feature is not available"
5009
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005010run_test "DTLS cookie: enabled, nbio" \
5011 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5012 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5013 0 \
5014 -s "cookie verification failed" \
5015 -s "cookie verification passed" \
5016 -S "cookie verification skipped" \
5017 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005018 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005019 -S "SSL - The requested feature is not available"
5020
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005021# Tests for client reconnecting from the same port with DTLS
5022
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005023not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005024run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnardb1ee30b2019-09-09 11:14:37 +02005025 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5026 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005027 0 \
5028 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005029 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005030 -S "Client initiated reconnection from same port"
5031
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005032not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005033run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnardb1ee30b2019-09-09 11:14:37 +02005034 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5035 "$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 +02005036 0 \
5037 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005038 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005039 -s "Client initiated reconnection from same port"
5040
Paul Bakker362689d2016-05-13 10:33:25 +01005041not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5042run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005043 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5044 "$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 +02005045 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005046 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005047 -s "Client initiated reconnection from same port"
5048
Paul Bakker362689d2016-05-13 10:33:25 +01005049only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5050run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5051 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5052 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5053 0 \
5054 -S "The operation timed out" \
5055 -s "Client initiated reconnection from same port"
5056
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005057run_test "DTLS client reconnect from same port: no cookies" \
5058 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005059 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5060 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005061 -s "The operation timed out" \
5062 -S "Client initiated reconnection from same port"
5063
Manuel Pégourié-Gonnarda58b0462020-03-13 11:11:02 +01005064run_test "DTLS client reconnect from same port: attacker-injected" \
5065 -p "$P_PXY inject_clihlo=1" \
5066 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5067 "$P_CLI dtls=1 exchanges=2" \
5068 0 \
5069 -s "possible client reconnect from the same port" \
5070 -S "Client initiated reconnection from same port"
5071
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005072# Tests for various cases of client authentication with DTLS
5073# (focused on handshake flows and message parsing)
5074
5075run_test "DTLS client auth: required" \
5076 "$P_SRV dtls=1 auth_mode=required" \
5077 "$P_CLI dtls=1" \
5078 0 \
5079 -s "Verifying peer X.509 certificate... ok"
5080
5081run_test "DTLS client auth: optional, client has no cert" \
5082 "$P_SRV dtls=1 auth_mode=optional" \
5083 "$P_CLI dtls=1 crt_file=none key_file=none" \
5084 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005085 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005086
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005087run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005088 "$P_SRV dtls=1 auth_mode=none" \
5089 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5090 0 \
5091 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005092 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005093
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005094run_test "DTLS wrong PSK: badmac alert" \
5095 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5096 "$P_CLI dtls=1 psk=abc124" \
5097 1 \
5098 -s "SSL - Verification of the message MAC failed" \
5099 -c "SSL - A fatal alert message was received from our peer"
5100
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005101# Tests for receiving fragmented handshake messages with DTLS
5102
5103requires_gnutls
5104run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5105 "$G_SRV -u --mtu 2048 -a" \
5106 "$P_CLI dtls=1 debug_level=2" \
5107 0 \
5108 -C "found fragmented DTLS handshake message" \
5109 -C "error"
5110
5111requires_gnutls
5112run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5113 "$G_SRV -u --mtu 512" \
5114 "$P_CLI dtls=1 debug_level=2" \
5115 0 \
5116 -c "found fragmented DTLS handshake message" \
5117 -C "error"
5118
5119requires_gnutls
5120run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5121 "$G_SRV -u --mtu 128" \
5122 "$P_CLI dtls=1 debug_level=2" \
5123 0 \
5124 -c "found fragmented DTLS handshake message" \
5125 -C "error"
5126
5127requires_gnutls
5128run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5129 "$G_SRV -u --mtu 128" \
5130 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5131 0 \
5132 -c "found fragmented DTLS handshake message" \
5133 -C "error"
5134
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005135requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005136requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005137run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5138 "$G_SRV -u --mtu 256" \
5139 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5140 0 \
5141 -c "found fragmented DTLS handshake message" \
5142 -c "client hello, adding renegotiation extension" \
5143 -c "found renegotiation extension" \
5144 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005145 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005146 -C "error" \
5147 -s "Extra-header:"
5148
5149requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005150requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005151run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5152 "$G_SRV -u --mtu 256" \
5153 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5154 0 \
5155 -c "found fragmented DTLS handshake message" \
5156 -c "client hello, adding renegotiation extension" \
5157 -c "found renegotiation extension" \
5158 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005159 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005160 -C "error" \
5161 -s "Extra-header:"
5162
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005163run_test "DTLS reassembly: no fragmentation (openssl server)" \
5164 "$O_SRV -dtls1 -mtu 2048" \
5165 "$P_CLI dtls=1 debug_level=2" \
5166 0 \
5167 -C "found fragmented DTLS handshake message" \
5168 -C "error"
5169
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005170run_test "DTLS reassembly: some fragmentation (openssl server)" \
5171 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005172 "$P_CLI dtls=1 debug_level=2" \
5173 0 \
5174 -c "found fragmented DTLS handshake message" \
5175 -C "error"
5176
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005177run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005178 "$O_SRV -dtls1 -mtu 256" \
5179 "$P_CLI dtls=1 debug_level=2" \
5180 0 \
5181 -c "found fragmented DTLS handshake message" \
5182 -C "error"
5183
5184run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5185 "$O_SRV -dtls1 -mtu 256" \
5186 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5187 0 \
5188 -c "found fragmented DTLS handshake message" \
5189 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005190
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005191# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005192
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005193not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005194run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005195 -p "$P_PXY" \
Manuel Pégourié-Gonnardb1ee30b2019-09-09 11:14:37 +02005196 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
5197 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005198 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005199 -C "replayed record" \
5200 -S "replayed record" \
5201 -C "record from another epoch" \
5202 -S "record from another epoch" \
5203 -C "discarding invalid record" \
5204 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005205 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005206 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005207 -c "HTTP/1.0 200 OK"
5208
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005209not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005210run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005211 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnardb1ee30b2019-09-09 11:14:37 +02005212 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
5213 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005214 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005215 -c "replayed record" \
5216 -s "replayed record" \
Hanno Beckera34cc6b2017-05-26 16:07:36 +01005217 -c "record from another epoch" \
5218 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005219 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005220 -s "Extra-header:" \
5221 -c "HTTP/1.0 200 OK"
5222
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005223run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
5224 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005225 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
5226 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005227 0 \
5228 -c "replayed record" \
5229 -S "replayed record" \
Hanno Beckera34cc6b2017-05-26 16:07:36 +01005230 -c "record from another epoch" \
5231 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005232 -c "resend" \
5233 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005234 -s "Extra-header:" \
5235 -c "HTTP/1.0 200 OK"
5236
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005237run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005238 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005239 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005240 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005241 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005242 -c "discarding invalid record (mac)" \
5243 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005244 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005245 -c "HTTP/1.0 200 OK" \
5246 -S "too many records with bad MAC" \
5247 -S "Verification of the message MAC failed"
5248
5249run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
5250 -p "$P_PXY bad_ad=1" \
5251 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
5252 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5253 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005254 -C "discarding invalid record (mac)" \
5255 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005256 -S "Extra-header:" \
5257 -C "HTTP/1.0 200 OK" \
5258 -s "too many records with bad MAC" \
5259 -s "Verification of the message MAC failed"
5260
5261run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
5262 -p "$P_PXY bad_ad=1" \
5263 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
5264 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5265 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005266 -c "discarding invalid record (mac)" \
5267 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005268 -s "Extra-header:" \
5269 -c "HTTP/1.0 200 OK" \
5270 -S "too many records with bad MAC" \
5271 -S "Verification of the message MAC failed"
5272
5273run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
5274 -p "$P_PXY bad_ad=1" \
5275 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
5276 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
5277 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005278 -c "discarding invalid record (mac)" \
5279 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005280 -s "Extra-header:" \
5281 -c "HTTP/1.0 200 OK" \
5282 -s "too many records with bad MAC" \
5283 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005284
5285run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005286 -p "$P_PXY delay_ccs=1" \
5287 "$P_SRV dtls=1 debug_level=1" \
5288 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005289 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005290 -c "record from another epoch" \
5291 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005292 -s "Extra-header:" \
5293 -c "HTTP/1.0 200 OK"
5294
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005295# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005296
Janos Follath74537a62016-09-02 13:45:28 +01005297client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005298run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005299 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005300 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005301 psk=abc123" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005302 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005303 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5304 0 \
5305 -s "Extra-header:" \
5306 -c "HTTP/1.0 200 OK"
5307
Janos Follath74537a62016-09-02 13:45:28 +01005308client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005309run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
5310 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005311 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none" \
5312 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005313 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5314 0 \
5315 -s "Extra-header:" \
5316 -c "HTTP/1.0 200 OK"
5317
Janos Follath74537a62016-09-02 13:45:28 +01005318client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005319run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
5320 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005321 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none" \
5322 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005323 0 \
5324 -s "Extra-header:" \
5325 -c "HTTP/1.0 200 OK"
5326
Janos Follath74537a62016-09-02 13:45:28 +01005327client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005328run_test "DTLS proxy: 3d, FS, client auth" \
5329 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005330 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=required" \
5331 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005332 0 \
5333 -s "Extra-header:" \
5334 -c "HTTP/1.0 200 OK"
5335
Janos Follath74537a62016-09-02 13:45:28 +01005336client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005337run_test "DTLS proxy: 3d, FS, ticket" \
5338 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005339 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=1 auth_mode=none" \
5340 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005341 0 \
5342 -s "Extra-header:" \
5343 -c "HTTP/1.0 200 OK"
5344
Janos Follath74537a62016-09-02 13:45:28 +01005345client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005346run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
5347 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005348 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=1 auth_mode=required" \
5349 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005350 0 \
5351 -s "Extra-header:" \
5352 -c "HTTP/1.0 200 OK"
5353
Janos Follath74537a62016-09-02 13:45:28 +01005354client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005355run_test "DTLS proxy: 3d, max handshake, nbio" \
5356 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005357 "$P_SRV dtls=1 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005358 auth_mode=required" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005359 "$P_CLI dtls=1 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005360 0 \
5361 -s "Extra-header:" \
5362 -c "HTTP/1.0 200 OK"
5363
Janos Follath74537a62016-09-02 13:45:28 +01005364client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005365run_test "DTLS proxy: 3d, min handshake, resumption" \
5366 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005367 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005368 psk=abc123 debug_level=3" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005369 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01005370 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005371 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5372 0 \
5373 -s "a session has been resumed" \
5374 -c "a session has been resumed" \
5375 -s "Extra-header:" \
5376 -c "HTTP/1.0 200 OK"
5377
Janos Follath74537a62016-09-02 13:45:28 +01005378client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005379run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
5380 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005381 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005382 psk=abc123 debug_level=3 nbio=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005383 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01005384 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005385 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
5386 0 \
5387 -s "a session has been resumed" \
5388 -c "a session has been resumed" \
5389 -s "Extra-header:" \
5390 -c "HTTP/1.0 200 OK"
5391
Janos Follath74537a62016-09-02 13:45:28 +01005392client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005393requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005394run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005395 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005396 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005397 psk=abc123 renegotiation=1 debug_level=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005398 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005399 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005400 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5401 0 \
5402 -c "=> renegotiate" \
5403 -s "=> renegotiate" \
5404 -s "Extra-header:" \
5405 -c "HTTP/1.0 200 OK"
5406
Janos Follath74537a62016-09-02 13:45:28 +01005407client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005408requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005409run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
5410 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005411 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005412 psk=abc123 renegotiation=1 debug_level=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005413 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005414 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005415 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5416 0 \
5417 -c "=> renegotiate" \
5418 -s "=> renegotiate" \
5419 -s "Extra-header:" \
5420 -c "HTTP/1.0 200 OK"
5421
Janos Follath74537a62016-09-02 13:45:28 +01005422client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005423requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005424run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005425 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005426 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005427 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005428 debug_level=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005429 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005430 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005431 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5432 0 \
5433 -c "=> renegotiate" \
5434 -s "=> renegotiate" \
5435 -s "Extra-header:" \
5436 -c "HTTP/1.0 200 OK"
5437
Janos Follath74537a62016-09-02 13:45:28 +01005438client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005439requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005440run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005441 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005442 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005443 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005444 debug_level=2 nbio=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005445 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005446 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005447 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5448 0 \
5449 -c "=> renegotiate" \
5450 -s "=> renegotiate" \
5451 -s "Extra-header:" \
5452 -c "HTTP/1.0 200 OK"
5453
Janos Follath74537a62016-09-02 13:45:28 +01005454client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005455not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005456run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005457 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5458 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005459 "$P_CLI dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005460 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005461 -c "HTTP/1.0 200 OK"
5462
Janos Follath74537a62016-09-02 13:45:28 +01005463client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005464not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005465run_test "DTLS proxy: 3d, openssl server, fragmentation" \
5466 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5467 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005468 "$P_CLI dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005469 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005470 -c "HTTP/1.0 200 OK"
5471
Janos Follath74537a62016-09-02 13:45:28 +01005472client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005473not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005474run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
5475 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5476 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005477 "$P_CLI dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005478 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005479 -c "HTTP/1.0 200 OK"
5480
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005481requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005482client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005483not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005484run_test "DTLS proxy: 3d, gnutls server" \
5485 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5486 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005487 "$P_CLI dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005488 0 \
5489 -s "Extra-header:" \
5490 -c "Extra-header:"
5491
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005492requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005493client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005494not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005495run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
5496 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5497 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005498 "$P_CLI dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005499 0 \
5500 -s "Extra-header:" \
5501 -c "Extra-header:"
5502
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005503requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005504client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005505not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005506run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
5507 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5508 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005509 "$P_CLI dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005510 0 \
5511 -s "Extra-header:" \
5512 -c "Extra-header:"
5513
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01005514# Final report
5515
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005516echo "------------------------------------------------------------------------"
5517
5518if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005519 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005520else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005521 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005522fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02005523PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02005524echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005525
5526exit $FAILS