blob: eaac52de3dfa99470f34889fcdf54ac8411ef183 [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# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_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 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200125# skip next test if the flag is enabled in config.h
126requires_config_disabled() {
127 if grep "^#define $1" $CONFIG_H > /dev/null; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200132# skip next test if OpenSSL doesn't support FALLBACK_SCSV
133requires_openssl_with_fallback_scsv() {
134 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
135 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
136 then
137 OPENSSL_HAS_FBSCSV="YES"
138 else
139 OPENSSL_HAS_FBSCSV="NO"
140 fi
141 fi
142 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
143 SKIP_NEXT="YES"
144 fi
145}
146
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200147# skip next test if GnuTLS isn't available
148requires_gnutls() {
149 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200150 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151 GNUTLS_AVAILABLE="YES"
152 else
153 GNUTLS_AVAILABLE="NO"
154 fi
155 fi
156 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200161# skip next test if IPv6 isn't available on this host
162requires_ipv6() {
163 if [ -z "${HAS_IPV6:-}" ]; then
164 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
165 SRV_PID=$!
166 sleep 1
167 kill $SRV_PID >/dev/null 2>&1
168 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
169 HAS_IPV6="NO"
170 else
171 HAS_IPV6="YES"
172 fi
173 rm -r $SRV_OUT
174 fi
175
176 if [ "$HAS_IPV6" = "NO" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200181# skip the next test if valgrind is in use
182not_with_valgrind() {
183 if [ "$MEMCHECK" -gt 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Paul Bakker362689d2016-05-13 10:33:25 +0100188# skip the next test if valgrind is NOT in use
189only_with_valgrind() {
190 if [ "$MEMCHECK" -eq 0 ]; then
191 SKIP_NEXT="YES"
192 fi
193}
194
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200195# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100196client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200197 CLI_DELAY_FACTOR=$1
198}
199
Janos Follath74537a62016-09-02 13:45:28 +0100200# wait for the given seconds after the client finished in the next test
201server_needs_more_time() {
202 SRV_DELAY_SECONDS=$1
203}
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205# print_name <name>
206print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100207 TESTS=$(( $TESTS + 1 ))
208 LINE=""
209
210 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
211 LINE="$TESTS "
212 fi
213
214 LINE="$LINE$1"
215 printf "$LINE "
216 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100217 for i in `seq 1 $LEN`; do printf '.'; done
218 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100220}
221
222# fail <message>
223fail() {
224 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100225 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200227 mv $SRV_OUT o-srv-${TESTS}.log
228 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if [ -n "$PXY_CMD" ]; then
230 mv $PXY_OUT o-pxy-${TESTS}.log
231 fi
232 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100233
Azim Khan03da1212018-03-29 11:04:20 +0100234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot -o "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200235 echo " ! server output:"
236 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200237 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200238 echo " ! client output:"
239 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200240 if [ -n "$PXY_CMD" ]; then
241 echo " ! ========================================================"
242 echo " ! proxy output:"
243 cat o-pxy-${TESTS}.log
244 fi
245 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200246 fi
247
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200248 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249}
250
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251# is_polar <cmd_line>
252is_polar() {
253 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
254}
255
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200256# openssl s_server doesn't have -www with DTLS
257check_osrv_dtls() {
258 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
259 NEEDS_INPUT=1
260 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
261 else
262 NEEDS_INPUT=0
263 fi
264}
265
266# provide input to commands that need it
267provide_input() {
268 if [ $NEEDS_INPUT -eq 0 ]; then
269 return
270 fi
271
272 while true; do
273 echo "HTTP/1.0 200 OK"
274 sleep 1
275 done
276}
277
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100278# has_mem_err <log_file_name>
279has_mem_err() {
280 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
281 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
282 then
283 return 1 # false: does not have errors
284 else
285 return 0 # true: has errors
286 fi
287}
288
Gilles Peskine418b5362017-12-14 18:58:42 +0100289# Wait for process $2 to be listening on port $1
290if type lsof >/dev/null 2>/dev/null; then
291 wait_server_start() {
292 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200293 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100294 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200295 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100296 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200297 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100298 # Make a tight loop, server normally takes less than 1s to start.
299 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
300 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
301 echo "SERVERSTART TIMEOUT"
302 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
303 break
304 fi
305 # Linux and *BSD support decimal arguments to sleep. On other
306 # OSes this may be a tight loop.
307 sleep 0.1 2>/dev/null || true
308 done
309 }
310else
Gilles Peskine7163a6a2018-06-29 15:48:13 +0200311 echo "Warning: lsof not available, wait_server_start = sleep"
Gilles Peskine418b5362017-12-14 18:58:42 +0100312 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200313 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100314 }
315fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200316
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100317# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100318# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100319# acceptable bounds
320check_server_hello_time() {
321 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100322 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100323 # Get the Unix timestamp for now
324 CUR_TIME=$(date +'%s')
325 THRESHOLD_IN_SECS=300
326
327 # Check if the ServerHello time was printed
328 if [ -z "$SERVER_HELLO_TIME" ]; then
329 return 1
330 fi
331
332 # Check the time in ServerHello is within acceptable bounds
333 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
334 # The time in ServerHello is at least 5 minutes before now
335 return 1
336 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100337 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100338 return 1
339 else
340 return 0
341 fi
342}
343
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200344# wait for client to terminate and set CLI_EXIT
345# must be called right after starting the client
346wait_client_done() {
347 CLI_PID=$!
348
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200349 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
350 CLI_DELAY_FACTOR=1
351
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200352 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200353 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200354
355 wait $CLI_PID
356 CLI_EXIT=$?
357
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200358 kill $DOG_PID >/dev/null 2>&1
359 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200360
361 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100362
363 sleep $SRV_DELAY_SECONDS
364 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200365}
366
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200367# check if the given command uses dtls and sets global variable DTLS
368detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200369 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200370 DTLS=1
371 else
372 DTLS=0
373 fi
374}
375
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200376# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100377# Options: -s pattern pattern that must be present in server output
378# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100379# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100380# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100381# -S pattern pattern that must be absent in server output
382# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100383# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100384# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100385run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100386 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200387 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100388
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100389 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
390 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200391 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100392 return
393 fi
394
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100396
Paul Bakkerb7584a52016-05-10 10:50:43 +0100397 # Do we only run numbered tests?
398 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
399 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
400 else
401 SKIP_NEXT="YES"
402 fi
403
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200404 # should we skip?
405 if [ "X$SKIP_NEXT" = "XYES" ]; then
406 SKIP_NEXT="NO"
407 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200408 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200409 return
410 fi
411
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200412 # does this test use a proxy?
413 if [ "X$1" = "X-p" ]; then
414 PXY_CMD="$2"
415 shift 2
416 else
417 PXY_CMD=""
418 fi
419
420 # get commands and client output
421 SRV_CMD="$1"
422 CLI_CMD="$2"
423 CLI_EXPECT="$3"
424 shift 3
425
426 # fix client port
427 if [ -n "$PXY_CMD" ]; then
428 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
429 else
430 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
431 fi
432
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200433 # update DTLS variable
434 detect_dtls "$SRV_CMD"
435
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100436 # prepend valgrind to our commands if active
437 if [ "$MEMCHECK" -gt 0 ]; then
438 if is_polar "$SRV_CMD"; then
439 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
440 fi
441 if is_polar "$CLI_CMD"; then
442 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
443 fi
444 fi
445
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200446 TIMES_LEFT=2
447 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200448 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200449
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200450 # run the commands
451 if [ -n "$PXY_CMD" ]; then
452 echo "$PXY_CMD" > $PXY_OUT
453 $PXY_CMD >> $PXY_OUT 2>&1 &
454 PXY_PID=$!
455 # assume proxy starts faster than server
456 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200457
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200458 check_osrv_dtls
459 echo "$SRV_CMD" > $SRV_OUT
460 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
461 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100462 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200463
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200464 echo "$CLI_CMD" > $CLI_OUT
465 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
466 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100467
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200468 # terminate the server (and the proxy)
469 kill $SRV_PID
470 wait $SRV_PID
471 if [ -n "$PXY_CMD" ]; then
472 kill $PXY_PID >/dev/null 2>&1
473 wait $PXY_PID
474 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100475
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200476 # retry only on timeouts
477 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
478 printf "RETRY "
479 else
480 TIMES_LEFT=0
481 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200482 done
483
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100484 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200485 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100486 # expected client exit to incorrectly succeed in case of catastrophic
487 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100488 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200489 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100490 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100491 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100492 return
493 fi
494 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100495 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200496 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100497 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100498 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100499 return
500 fi
501 fi
502
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100503 # check server exit code
504 if [ $? != 0 ]; then
505 fail "server fail"
506 return
507 fi
508
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100509 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100510 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
511 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100512 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200513 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100514 return
515 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100516
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100517 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200518 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100519 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100520 while [ $# -gt 0 ]
521 do
522 case $1 in
523 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100524 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 +0100525 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100526 return
527 fi
528 ;;
529
530 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100531 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 +0100532 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100533 return
534 fi
535 ;;
536
537 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100538 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 +0100539 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100540 return
541 fi
542 ;;
543
544 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100545 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 +0100546 fail "pattern '$2' MUST NOT be present in the Client output"
547 return
548 fi
549 ;;
550
551 # The filtering in the following two options (-u and -U) do the following
552 # - ignore valgrind output
553 # - filter out everything but lines right after the pattern occurances
554 # - keep one of each non-unique line
555 # - count how many lines remain
556 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
557 # if there were no duplicates.
558 "-U")
559 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
560 fail "lines following pattern '$2' must be unique in Server output"
561 return
562 fi
563 ;;
564
565 "-u")
566 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
567 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100568 return
569 fi
570 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100571 "-F")
572 if ! $2 "$SRV_OUT"; then
573 fail "function call to '$2' failed on Server output"
574 return
575 fi
576 ;;
577 "-f")
578 if ! $2 "$CLI_OUT"; then
579 fail "function call to '$2' failed on Client output"
580 return
581 fi
582 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100583
584 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200585 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100586 exit 1
587 esac
588 shift 2
589 done
590
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100591 # check valgrind's results
592 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200593 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100594 fail "Server has memory errors"
595 return
596 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200597 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100598 fail "Client has memory errors"
599 return
600 fi
601 fi
602
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100603 # if we're here, everything is ok
604 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100605 if [ "$PRESERVE_LOGS" -gt 0 ]; then
606 mv $SRV_OUT o-srv-${TESTS}.log
607 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Beckerdc6c0e42018-08-20 12:21:35 +0100608 if [ -n "$PXY_CMD" ]; then
609 mv $PXY_OUT o-pxy-${TESTS}.log
610 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100611 fi
612
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200613 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100614}
615
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100616cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200618 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
619 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
620 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
621 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100622 exit 1
623}
624
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100625#
626# MAIN
627#
628
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000629if cd $( dirname $0 ); then :; else
630 echo "cd $( dirname $0 ) failed" >&2
631 exit 1
632fi
633
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100634get_options "$@"
635
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100636# sanity checks, avoid an avalanche of errors
637if [ ! -x "$P_SRV" ]; then
638 echo "Command '$P_SRV' is not an executable file"
639 exit 1
640fi
641if [ ! -x "$P_CLI" ]; then
642 echo "Command '$P_CLI' is not an executable file"
643 exit 1
644fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200645if [ ! -x "$P_PXY" ]; then
646 echo "Command '$P_PXY' is not an executable file"
647 exit 1
648fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100649if [ "$MEMCHECK" -gt 0 ]; then
650 if which valgrind >/dev/null 2>&1; then :; else
651 echo "Memcheck not possible. Valgrind not found"
652 exit 1
653 fi
654fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100655if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
656 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100657 exit 1
658fi
659
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200660# used by watchdog
661MAIN_PID="$$"
662
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100663# We use somewhat arbitrary delays for tests:
664# - how long do we wait for the server to start (when lsof not available)?
665# - how long do we allow for the client to finish?
666# (not to check performance, just to avoid waiting indefinitely)
667# Things are slower with valgrind, so give extra time here.
668#
669# Note: without lsof, there is a trade-off between the running time of this
670# script and the risk of spurious errors because we didn't wait long enough.
671# The watchdog delay on the other hand doesn't affect normal running time of
672# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200673if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100674 START_DELAY=6
675 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200676else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100677 START_DELAY=2
678 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200679fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100680
681# some particular tests need more time:
682# - for the client, we multiply the usual watchdog limit by a factor
683# - for the server, we sleep for a number of seconds after the client exits
684# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200685CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100686SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200687
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200688# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000689# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200690P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
691P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100692P_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 +0200693O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200694O_CLI="$O_CLI -connect localhost:+SRV_PORT"
695G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000696G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200697
Gilles Peskine62469d92017-05-10 10:13:59 +0200698# Allow SHA-1, because many of our test certificates use it
699P_SRV="$P_SRV allow_sha1=1"
700P_CLI="$P_CLI allow_sha1=1"
701
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200702# Also pick a unique name for intermediate files
703SRV_OUT="srv_out.$$"
704CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200705PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200706SESSION="session.$$"
707
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200708SKIP_NEXT="NO"
709
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100710trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100711
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200712# Basic test
713
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200714# Checks that:
715# - things work with all ciphersuites active (used with config-full in all.sh)
716# - the expected (highest security) parameters are selected
717# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200718run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200719 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200720 "$P_CLI" \
721 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200722 -s "Protocol is TLSv1.2" \
723 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
724 -s "client hello v3, signature_algorithm ext: 6" \
725 -s "ECDHE curve: secp521r1" \
726 -S "error" \
727 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200728
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000729run_test "Default, DTLS" \
730 "$P_SRV dtls=1" \
731 "$P_CLI dtls=1" \
732 0 \
733 -s "Protocol is DTLSv1.2" \
734 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
735
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100736# Test current time in ServerHello
737requires_config_enabled MBEDTLS_HAVE_TIME
738run_test "Default, ServerHello contains gmt_unix_time" \
739 "$P_SRV debug_level=3" \
740 "$P_CLI debug_level=3" \
741 0 \
742 -s "Protocol is TLSv1.2" \
743 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
744 -s "client hello v3, signature_algorithm ext: 6" \
745 -s "ECDHE curve: secp521r1" \
746 -S "error" \
747 -C "error" \
748 -f "check_server_hello_time" \
749 -F "check_server_hello_time"
750
Simon Butcher8e004102016-10-14 00:48:33 +0100751# Test for uniqueness of IVs in AEAD ciphersuites
752run_test "Unique IV in GCM" \
753 "$P_SRV exchanges=20 debug_level=4" \
754 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
755 0 \
756 -u "IV used" \
757 -U "IV used"
758
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100759# Tests for rc4 option
760
Simon Butchera410af52016-05-19 22:12:18 +0100761requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100762run_test "RC4: server disabled, client enabled" \
763 "$P_SRV" \
764 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
765 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100766 -s "SSL - The server has no ciphersuites in common"
767
Simon Butchera410af52016-05-19 22:12:18 +0100768requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100769run_test "RC4: server half, client enabled" \
770 "$P_SRV arc4=1" \
771 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
772 1 \
773 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100774
775run_test "RC4: server enabled, client disabled" \
776 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
777 "$P_CLI" \
778 1 \
779 -s "SSL - The server has no ciphersuites in common"
780
781run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100782 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100783 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
784 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100785 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100786 -S "SSL - The server has no ciphersuites in common"
787
Hanno Becker3a333a52018-08-17 09:54:10 +0100788# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
789
790requires_gnutls
791requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
792run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
793 "$G_SRV"\
794 "$P_CLI force_version=tls1_1" \
795 0
796
797requires_gnutls
798requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
799run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
800 "$G_SRV"\
801 "$P_CLI force_version=tls1" \
802 0
803
Gilles Peskinebc70a182017-05-09 15:59:24 +0200804# Tests for SHA-1 support
805
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200806requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200807run_test "SHA-1 forbidden by default in server certificate" \
808 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
809 "$P_CLI debug_level=2 allow_sha1=0" \
810 1 \
811 -c "The certificate is signed with an unacceptable hash"
812
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200813requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
814run_test "SHA-1 forbidden by default in server certificate" \
815 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
816 "$P_CLI debug_level=2 allow_sha1=0" \
817 0
818
Gilles Peskinebc70a182017-05-09 15:59:24 +0200819run_test "SHA-1 explicitly allowed in server certificate" \
820 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
821 "$P_CLI allow_sha1=1" \
822 0
823
824run_test "SHA-256 allowed by default in server certificate" \
825 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
826 "$P_CLI allow_sha1=0" \
827 0
828
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200829requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200830run_test "SHA-1 forbidden by default in client certificate" \
831 "$P_SRV auth_mode=required allow_sha1=0" \
832 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
833 1 \
834 -s "The certificate is signed with an unacceptable hash"
835
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200836requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
837run_test "SHA-1 forbidden by default in client certificate" \
838 "$P_SRV auth_mode=required allow_sha1=0" \
839 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
840 0
841
Gilles Peskinebc70a182017-05-09 15:59:24 +0200842run_test "SHA-1 explicitly allowed in client certificate" \
843 "$P_SRV auth_mode=required allow_sha1=1" \
844 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
845 0
846
847run_test "SHA-256 allowed by default in client certificate" \
848 "$P_SRV auth_mode=required allow_sha1=0" \
849 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
850 0
851
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100852# Tests for Truncated HMAC extension
853
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100854run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200855 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100856 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100857 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000858 -s "dumping 'expected mac' (20 bytes)" \
859 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100860
Hanno Becker32c55012017-11-10 08:42:54 +0000861requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100862run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200863 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000864 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100865 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000866 -s "dumping 'expected mac' (20 bytes)" \
867 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100868
Hanno Becker32c55012017-11-10 08:42:54 +0000869requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100870run_test "Truncated HMAC: client enabled, server default" \
871 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000872 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100873 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000874 -s "dumping 'expected mac' (20 bytes)" \
875 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100876
Hanno Becker32c55012017-11-10 08:42:54 +0000877requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100878run_test "Truncated HMAC: client enabled, server disabled" \
879 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000880 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100881 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000882 -s "dumping 'expected mac' (20 bytes)" \
883 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100884
Hanno Becker32c55012017-11-10 08:42:54 +0000885requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000886run_test "Truncated HMAC: client disabled, server enabled" \
887 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000888 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000889 0 \
890 -s "dumping 'expected mac' (20 bytes)" \
891 -S "dumping 'expected mac' (10 bytes)"
892
893requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100894run_test "Truncated HMAC: client enabled, server enabled" \
895 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000896 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100897 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000898 -S "dumping 'expected mac' (20 bytes)" \
899 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100900
Hanno Becker4c4f4102017-11-10 09:16:05 +0000901run_test "Truncated HMAC, DTLS: client default, server default" \
902 "$P_SRV dtls=1 debug_level=4" \
903 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
904 0 \
905 -s "dumping 'expected mac' (20 bytes)" \
906 -S "dumping 'expected mac' (10 bytes)"
907
908requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
909run_test "Truncated HMAC, DTLS: client disabled, server default" \
910 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000911 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000912 0 \
913 -s "dumping 'expected mac' (20 bytes)" \
914 -S "dumping 'expected mac' (10 bytes)"
915
916requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
917run_test "Truncated HMAC, DTLS: client enabled, server default" \
918 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000919 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000920 0 \
921 -s "dumping 'expected mac' (20 bytes)" \
922 -S "dumping 'expected mac' (10 bytes)"
923
924requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
925run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
926 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000927 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000928 0 \
929 -s "dumping 'expected mac' (20 bytes)" \
930 -S "dumping 'expected mac' (10 bytes)"
931
932requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
933run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
934 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000935 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000936 0 \
937 -s "dumping 'expected mac' (20 bytes)" \
938 -S "dumping 'expected mac' (10 bytes)"
939
940requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
941run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
942 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000943 "$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 +0100944 0 \
945 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100946 -s "dumping 'expected mac' (10 bytes)"
947
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100948# Tests for Encrypt-then-MAC extension
949
950run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100951 "$P_SRV debug_level=3 \
952 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100953 "$P_CLI debug_level=3" \
954 0 \
955 -c "client hello, adding encrypt_then_mac extension" \
956 -s "found encrypt then mac extension" \
957 -s "server hello, adding encrypt then mac extension" \
958 -c "found encrypt_then_mac extension" \
959 -c "using encrypt then mac" \
960 -s "using encrypt then mac"
961
962run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100963 "$P_SRV debug_level=3 etm=0 \
964 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100965 "$P_CLI debug_level=3 etm=1" \
966 0 \
967 -c "client hello, adding encrypt_then_mac extension" \
968 -s "found encrypt then mac extension" \
969 -S "server hello, adding encrypt then mac extension" \
970 -C "found encrypt_then_mac extension" \
971 -C "using encrypt then mac" \
972 -S "using encrypt then mac"
973
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100974run_test "Encrypt then MAC: client enabled, aead cipher" \
975 "$P_SRV debug_level=3 etm=1 \
976 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
977 "$P_CLI debug_level=3 etm=1" \
978 0 \
979 -c "client hello, adding encrypt_then_mac extension" \
980 -s "found encrypt then mac extension" \
981 -S "server hello, adding encrypt then mac extension" \
982 -C "found encrypt_then_mac extension" \
983 -C "using encrypt then mac" \
984 -S "using encrypt then mac"
985
986run_test "Encrypt then MAC: client enabled, stream cipher" \
987 "$P_SRV debug_level=3 etm=1 \
988 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100989 "$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 +0100990 0 \
991 -c "client hello, adding encrypt_then_mac extension" \
992 -s "found encrypt then mac extension" \
993 -S "server hello, adding encrypt then mac extension" \
994 -C "found encrypt_then_mac extension" \
995 -C "using encrypt then mac" \
996 -S "using encrypt then mac"
997
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100998run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100999 "$P_SRV debug_level=3 etm=1 \
1000 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001001 "$P_CLI debug_level=3 etm=0" \
1002 0 \
1003 -C "client hello, adding encrypt_then_mac extension" \
1004 -S "found encrypt then mac extension" \
1005 -S "server hello, adding encrypt then mac extension" \
1006 -C "found encrypt_then_mac extension" \
1007 -C "using encrypt then mac" \
1008 -S "using encrypt then mac"
1009
Janos Follathe2681a42016-03-07 15:57:05 +00001010requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001011run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001012 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001013 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001014 "$P_CLI debug_level=3 force_version=ssl3" \
1015 0 \
1016 -C "client hello, adding encrypt_then_mac extension" \
1017 -S "found encrypt then mac extension" \
1018 -S "server hello, adding encrypt then mac extension" \
1019 -C "found encrypt_then_mac extension" \
1020 -C "using encrypt then mac" \
1021 -S "using encrypt then mac"
1022
Janos Follathe2681a42016-03-07 15:57:05 +00001023requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001024run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001025 "$P_SRV debug_level=3 force_version=ssl3 \
1026 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001027 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001028 0 \
1029 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001030 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001031 -S "server hello, adding encrypt then mac extension" \
1032 -C "found encrypt_then_mac extension" \
1033 -C "using encrypt then mac" \
1034 -S "using encrypt then mac"
1035
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001036# Tests for Extended Master Secret extension
1037
1038run_test "Extended Master Secret: default" \
1039 "$P_SRV debug_level=3" \
1040 "$P_CLI debug_level=3" \
1041 0 \
1042 -c "client hello, adding extended_master_secret extension" \
1043 -s "found extended master secret extension" \
1044 -s "server hello, adding extended master secret extension" \
1045 -c "found extended_master_secret extension" \
1046 -c "using extended master secret" \
1047 -s "using extended master secret"
1048
1049run_test "Extended Master Secret: client enabled, server disabled" \
1050 "$P_SRV debug_level=3 extended_ms=0" \
1051 "$P_CLI debug_level=3 extended_ms=1" \
1052 0 \
1053 -c "client hello, adding extended_master_secret extension" \
1054 -s "found extended master secret extension" \
1055 -S "server hello, adding extended master secret extension" \
1056 -C "found extended_master_secret extension" \
1057 -C "using extended master secret" \
1058 -S "using extended master secret"
1059
1060run_test "Extended Master Secret: client disabled, server enabled" \
1061 "$P_SRV debug_level=3 extended_ms=1" \
1062 "$P_CLI debug_level=3 extended_ms=0" \
1063 0 \
1064 -C "client hello, adding extended_master_secret extension" \
1065 -S "found extended master secret extension" \
1066 -S "server hello, adding extended master secret extension" \
1067 -C "found extended_master_secret extension" \
1068 -C "using extended master secret" \
1069 -S "using extended master secret"
1070
Janos Follathe2681a42016-03-07 15:57:05 +00001071requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001072run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001073 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001074 "$P_CLI debug_level=3 force_version=ssl3" \
1075 0 \
1076 -C "client hello, adding extended_master_secret extension" \
1077 -S "found extended master secret extension" \
1078 -S "server hello, adding extended master secret extension" \
1079 -C "found extended_master_secret extension" \
1080 -C "using extended master secret" \
1081 -S "using extended master secret"
1082
Janos Follathe2681a42016-03-07 15:57:05 +00001083requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001084run_test "Extended Master Secret: client enabled, server SSLv3" \
1085 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001086 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001087 0 \
1088 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001089 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001090 -S "server hello, adding extended master secret extension" \
1091 -C "found extended_master_secret extension" \
1092 -C "using extended master secret" \
1093 -S "using extended master secret"
1094
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001095# Tests for FALLBACK_SCSV
1096
1097run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001098 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001099 "$P_CLI debug_level=3 force_version=tls1_1" \
1100 0 \
1101 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001102 -S "received FALLBACK_SCSV" \
1103 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001104 -C "is a fatal alert message (msg 86)"
1105
1106run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001107 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001108 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1109 0 \
1110 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001111 -S "received FALLBACK_SCSV" \
1112 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001113 -C "is a fatal alert message (msg 86)"
1114
1115run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001116 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001117 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001118 1 \
1119 -c "adding FALLBACK_SCSV" \
1120 -s "received FALLBACK_SCSV" \
1121 -s "inapropriate fallback" \
1122 -c "is a fatal alert message (msg 86)"
1123
1124run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001125 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001126 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001127 0 \
1128 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001129 -s "received FALLBACK_SCSV" \
1130 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001131 -C "is a fatal alert message (msg 86)"
1132
1133requires_openssl_with_fallback_scsv
1134run_test "Fallback SCSV: default, openssl server" \
1135 "$O_SRV" \
1136 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1137 0 \
1138 -C "adding FALLBACK_SCSV" \
1139 -C "is a fatal alert message (msg 86)"
1140
1141requires_openssl_with_fallback_scsv
1142run_test "Fallback SCSV: enabled, openssl server" \
1143 "$O_SRV" \
1144 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1145 1 \
1146 -c "adding FALLBACK_SCSV" \
1147 -c "is a fatal alert message (msg 86)"
1148
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001149requires_openssl_with_fallback_scsv
1150run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001151 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001152 "$O_CLI -tls1_1" \
1153 0 \
1154 -S "received FALLBACK_SCSV" \
1155 -S "inapropriate fallback"
1156
1157requires_openssl_with_fallback_scsv
1158run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001159 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001160 "$O_CLI -tls1_1 -fallback_scsv" \
1161 1 \
1162 -s "received FALLBACK_SCSV" \
1163 -s "inapropriate fallback"
1164
1165requires_openssl_with_fallback_scsv
1166run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001167 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001168 "$O_CLI -fallback_scsv" \
1169 0 \
1170 -s "received FALLBACK_SCSV" \
1171 -S "inapropriate fallback"
1172
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001173# Test sending and receiving empty application data records
1174
1175run_test "Encrypt then MAC: empty application data record" \
1176 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1177 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1178 0 \
1179 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1180 -s "dumping 'input payload after decrypt' (0 bytes)" \
1181 -c "0 bytes written in 1 fragments"
1182
1183run_test "Default, no Encrypt then MAC: empty application data record" \
1184 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1185 "$P_CLI auth_mode=none etm=0 request_size=0" \
1186 0 \
1187 -s "dumping 'input payload after decrypt' (0 bytes)" \
1188 -c "0 bytes written in 1 fragments"
1189
1190run_test "Encrypt then MAC, DTLS: empty application data record" \
1191 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1192 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1193 0 \
1194 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1195 -s "dumping 'input payload after decrypt' (0 bytes)" \
1196 -c "0 bytes written in 1 fragments"
1197
1198run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
1199 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1200 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1201 0 \
1202 -s "dumping 'input payload after decrypt' (0 bytes)" \
1203 -c "0 bytes written in 1 fragments"
1204
Gilles Peskined50177f2017-05-16 17:53:03 +02001205## ClientHello generated with
1206## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1207## then manually twiddling the ciphersuite list.
1208## The ClientHello content is spelled out below as a hex string as
1209## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1210## The expected response is an inappropriate_fallback alert.
1211requires_openssl_with_fallback_scsv
1212run_test "Fallback SCSV: beginning of list" \
1213 "$P_SRV debug_level=2" \
1214 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1215 0 \
1216 -s "received FALLBACK_SCSV" \
1217 -s "inapropriate fallback"
1218
1219requires_openssl_with_fallback_scsv
1220run_test "Fallback SCSV: end of list" \
1221 "$P_SRV debug_level=2" \
1222 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1223 0 \
1224 -s "received FALLBACK_SCSV" \
1225 -s "inapropriate fallback"
1226
1227## Here the expected response is a valid ServerHello prefix, up to the random.
1228requires_openssl_with_fallback_scsv
1229run_test "Fallback SCSV: not in list" \
1230 "$P_SRV debug_level=2" \
1231 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1232 0 \
1233 -S "received FALLBACK_SCSV" \
1234 -S "inapropriate fallback"
1235
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001236# Tests for CBC 1/n-1 record splitting
1237
1238run_test "CBC Record splitting: TLS 1.2, no splitting" \
1239 "$P_SRV" \
1240 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1241 request_size=123 force_version=tls1_2" \
1242 0 \
1243 -s "Read from client: 123 bytes read" \
1244 -S "Read from client: 1 bytes read" \
1245 -S "122 bytes read"
1246
1247run_test "CBC Record splitting: TLS 1.1, no splitting" \
1248 "$P_SRV" \
1249 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1250 request_size=123 force_version=tls1_1" \
1251 0 \
1252 -s "Read from client: 123 bytes read" \
1253 -S "Read from client: 1 bytes read" \
1254 -S "122 bytes read"
1255
1256run_test "CBC Record splitting: TLS 1.0, splitting" \
1257 "$P_SRV" \
1258 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1259 request_size=123 force_version=tls1" \
1260 0 \
1261 -S "Read from client: 123 bytes read" \
1262 -s "Read from client: 1 bytes read" \
1263 -s "122 bytes read"
1264
Janos Follathe2681a42016-03-07 15:57:05 +00001265requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001266run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001267 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001268 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1269 request_size=123 force_version=ssl3" \
1270 0 \
1271 -S "Read from client: 123 bytes read" \
1272 -s "Read from client: 1 bytes read" \
1273 -s "122 bytes read"
1274
1275run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001276 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001277 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1278 request_size=123 force_version=tls1" \
1279 0 \
1280 -s "Read from client: 123 bytes read" \
1281 -S "Read from client: 1 bytes read" \
1282 -S "122 bytes read"
1283
1284run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1285 "$P_SRV" \
1286 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1287 request_size=123 force_version=tls1 recsplit=0" \
1288 0 \
1289 -s "Read from client: 123 bytes read" \
1290 -S "Read from client: 1 bytes read" \
1291 -S "122 bytes read"
1292
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001293run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1294 "$P_SRV nbio=2" \
1295 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1296 request_size=123 force_version=tls1" \
1297 0 \
1298 -S "Read from client: 123 bytes read" \
1299 -s "Read from client: 1 bytes read" \
1300 -s "122 bytes read"
1301
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001302# Tests for Session Tickets
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001305 "$P_SRV debug_level=3 tickets=1" \
1306 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001307 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001308 -c "client hello, adding session ticket extension" \
1309 -s "found session ticket extension" \
1310 -s "server hello, adding session ticket extension" \
1311 -c "found session_ticket extension" \
1312 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001313 -S "session successfully restored from cache" \
1314 -s "session successfully restored from ticket" \
1315 -s "a session has been resumed" \
1316 -c "a session has been resumed"
1317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001318run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001319 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1320 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001321 0 \
1322 -c "client hello, adding session ticket extension" \
1323 -s "found session ticket extension" \
1324 -s "server hello, adding session ticket extension" \
1325 -c "found session_ticket extension" \
1326 -c "parse new session ticket" \
1327 -S "session successfully restored from cache" \
1328 -s "session successfully restored from ticket" \
1329 -s "a session has been resumed" \
1330 -c "a session has been resumed"
1331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001332run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1334 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001335 0 \
1336 -c "client hello, adding session ticket extension" \
1337 -s "found session ticket extension" \
1338 -s "server hello, adding session ticket extension" \
1339 -c "found session_ticket extension" \
1340 -c "parse new session ticket" \
1341 -S "session successfully restored from cache" \
1342 -S "session successfully restored from ticket" \
1343 -S "a session has been resumed" \
1344 -C "a session has been resumed"
1345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001347 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001348 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001349 0 \
1350 -c "client hello, adding session ticket extension" \
1351 -c "found session_ticket extension" \
1352 -c "parse new session ticket" \
1353 -c "a session has been resumed"
1354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001355run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001356 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001357 "( $O_CLI -sess_out $SESSION; \
1358 $O_CLI -sess_in $SESSION; \
1359 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001360 0 \
1361 -s "found session ticket extension" \
1362 -s "server hello, adding session ticket extension" \
1363 -S "session successfully restored from cache" \
1364 -s "session successfully restored from ticket" \
1365 -s "a session has been resumed"
1366
Hanno Beckerb5546362018-08-21 13:55:22 +01001367# Tests for Session Tickets with DTLS
1368
1369run_test "Session resume using tickets, DTLS: basic" \
1370 "$P_SRV debug_level=3 dtls=1 tickets=1" \
1371 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
1372 0 \
1373 -c "client hello, adding session ticket extension" \
1374 -s "found session ticket extension" \
1375 -s "server hello, adding session ticket extension" \
1376 -c "found session_ticket extension" \
1377 -c "parse new session ticket" \
1378 -S "session successfully restored from cache" \
1379 -s "session successfully restored from ticket" \
1380 -s "a session has been resumed" \
1381 -c "a session has been resumed"
1382
1383run_test "Session resume using tickets, DTLS: cache disabled" \
1384 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
1385 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
1386 0 \
1387 -c "client hello, adding session ticket extension" \
1388 -s "found session ticket extension" \
1389 -s "server hello, adding session ticket extension" \
1390 -c "found session_ticket extension" \
1391 -c "parse new session ticket" \
1392 -S "session successfully restored from cache" \
1393 -s "session successfully restored from ticket" \
1394 -s "a session has been resumed" \
1395 -c "a session has been resumed"
1396
1397run_test "Session resume using tickets, DTLS: timeout" \
1398 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
1399 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \
1400 0 \
1401 -c "client hello, adding session ticket extension" \
1402 -s "found session ticket extension" \
1403 -s "server hello, adding session ticket extension" \
1404 -c "found session_ticket extension" \
1405 -c "parse new session ticket" \
1406 -S "session successfully restored from cache" \
1407 -S "session successfully restored from ticket" \
1408 -S "a session has been resumed" \
1409 -C "a session has been resumed"
1410
1411run_test "Session resume using tickets, DTLS: openssl server" \
1412 "$O_SRV -dtls1" \
1413 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1414 0 \
1415 -c "client hello, adding session ticket extension" \
1416 -c "found session_ticket extension" \
1417 -c "parse new session ticket" \
1418 -c "a session has been resumed"
1419
1420run_test "Session resume using tickets, DTLS: openssl client" \
1421 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1422 "( $O_CLI -dtls1 -sess_out $SESSION; \
1423 $O_CLI -dtls1 -sess_in $SESSION; \
1424 rm -f $SESSION )" \
1425 0 \
1426 -s "found session ticket extension" \
1427 -s "server hello, adding session ticket extension" \
1428 -S "session successfully restored from cache" \
1429 -s "session successfully restored from ticket" \
1430 -s "a session has been resumed"
1431
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001432# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001434run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001435 "$P_SRV debug_level=3 tickets=0" \
1436 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001437 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001438 -c "client hello, adding session ticket extension" \
1439 -s "found session ticket extension" \
1440 -S "server hello, adding session ticket extension" \
1441 -C "found session_ticket extension" \
1442 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001443 -s "session successfully restored from cache" \
1444 -S "session successfully restored from ticket" \
1445 -s "a session has been resumed" \
1446 -c "a session has been resumed"
1447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001448run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001449 "$P_SRV debug_level=3 tickets=1" \
1450 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001451 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001452 -C "client hello, adding session ticket extension" \
1453 -S "found session ticket extension" \
1454 -S "server hello, adding session ticket extension" \
1455 -C "found session_ticket extension" \
1456 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001457 -s "session successfully restored from cache" \
1458 -S "session successfully restored from ticket" \
1459 -s "a session has been resumed" \
1460 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001462run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001463 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1464 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001465 0 \
1466 -S "session successfully restored from cache" \
1467 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001468 -S "a session has been resumed" \
1469 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001471run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001472 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1473 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001474 0 \
1475 -s "session successfully restored from cache" \
1476 -S "session successfully restored from ticket" \
1477 -s "a session has been resumed" \
1478 -c "a session has been resumed"
1479
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001480run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001481 "$P_SRV debug_level=3 tickets=0" \
1482 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001483 0 \
1484 -s "session successfully restored from cache" \
1485 -S "session successfully restored from ticket" \
1486 -s "a session has been resumed" \
1487 -c "a session has been resumed"
1488
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001489run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001490 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1491 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001492 0 \
1493 -S "session successfully restored from cache" \
1494 -S "session successfully restored from ticket" \
1495 -S "a session has been resumed" \
1496 -C "a session has been resumed"
1497
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001498run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001499 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1500 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001501 0 \
1502 -s "session successfully restored from cache" \
1503 -S "session successfully restored from ticket" \
1504 -s "a session has been resumed" \
1505 -c "a session has been resumed"
1506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001508 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001509 "( $O_CLI -sess_out $SESSION; \
1510 $O_CLI -sess_in $SESSION; \
1511 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001512 0 \
1513 -s "found session ticket extension" \
1514 -S "server hello, adding session ticket extension" \
1515 -s "session successfully restored from cache" \
1516 -S "session successfully restored from ticket" \
1517 -s "a session has been resumed"
1518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001519run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001520 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001521 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001522 0 \
1523 -C "found session_ticket extension" \
1524 -C "parse new session ticket" \
1525 -c "a session has been resumed"
1526
Hanno Beckerb5546362018-08-21 13:55:22 +01001527# Tests for Session Resume based on session-ID and cache, DTLS
1528
1529run_test "Session resume using cache, DTLS: tickets enabled on client" \
1530 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1531 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1532 0 \
1533 -c "client hello, adding session ticket extension" \
1534 -s "found session ticket extension" \
1535 -S "server hello, adding session ticket extension" \
1536 -C "found session_ticket extension" \
1537 -C "parse new session ticket" \
1538 -s "session successfully restored from cache" \
1539 -S "session successfully restored from ticket" \
1540 -s "a session has been resumed" \
1541 -c "a session has been resumed"
1542
1543run_test "Session resume using cache, DTLS: tickets enabled on server" \
1544 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1545 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1546 0 \
1547 -C "client hello, adding session ticket extension" \
1548 -S "found session ticket extension" \
1549 -S "server hello, adding session ticket extension" \
1550 -C "found session_ticket extension" \
1551 -C "parse new session ticket" \
1552 -s "session successfully restored from cache" \
1553 -S "session successfully restored from ticket" \
1554 -s "a session has been resumed" \
1555 -c "a session has been resumed"
1556
1557run_test "Session resume using cache, DTLS: cache_max=0" \
1558 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
1559 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1560 0 \
1561 -S "session successfully restored from cache" \
1562 -S "session successfully restored from ticket" \
1563 -S "a session has been resumed" \
1564 -C "a session has been resumed"
1565
1566run_test "Session resume using cache, DTLS: cache_max=1" \
1567 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
1568 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1569 0 \
1570 -s "session successfully restored from cache" \
1571 -S "session successfully restored from ticket" \
1572 -s "a session has been resumed" \
1573 -c "a session has been resumed"
1574
1575run_test "Session resume using cache, DTLS: timeout > delay" \
1576 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1577 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
1578 0 \
1579 -s "session successfully restored from cache" \
1580 -S "session successfully restored from ticket" \
1581 -s "a session has been resumed" \
1582 -c "a session has been resumed"
1583
1584run_test "Session resume using cache, DTLS: timeout < delay" \
1585 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
1586 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
1587 0 \
1588 -S "session successfully restored from cache" \
1589 -S "session successfully restored from ticket" \
1590 -S "a session has been resumed" \
1591 -C "a session has been resumed"
1592
1593run_test "Session resume using cache, DTLS: no timeout" \
1594 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
1595 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
1596 0 \
1597 -s "session successfully restored from cache" \
1598 -S "session successfully restored from ticket" \
1599 -s "a session has been resumed" \
1600 -c "a session has been resumed"
1601
1602run_test "Session resume using cache, DTLS: openssl client" \
1603 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1604 "( $O_CLI -dtls1 -sess_out $SESSION; \
1605 $O_CLI -dtls1 -sess_in $SESSION; \
1606 rm -f $SESSION )" \
1607 0 \
1608 -s "found session ticket extension" \
1609 -S "server hello, adding session ticket extension" \
1610 -s "session successfully restored from cache" \
1611 -S "session successfully restored from ticket" \
1612 -s "a session has been resumed"
1613
1614run_test "Session resume using cache, DTLS: openssl server" \
1615 "$O_SRV -dtls1" \
1616 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1617 0 \
1618 -C "found session_ticket extension" \
1619 -C "parse new session ticket" \
1620 -c "a session has been resumed"
1621
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001622# Tests for Max Fragment Length extension
1623
Hanno Becker6428f8d2017-09-22 16:58:50 +01001624MAX_CONTENT_LEN_EXPECT='16384'
1625MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1626
1627if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1628 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1629 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1630 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1631 printf "\n"
1632 printf "The tests assume this value and if it changes, the tests in this\n"
1633 printf "script should also be adjusted.\n"
1634 printf "\n"
1635
1636 exit 1
1637fi
1638
Hanno Becker4aed27e2017-09-18 15:00:34 +01001639requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001640run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001641 "$P_SRV debug_level=3" \
1642 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001643 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001644 -c "Maximum fragment length is 16384" \
1645 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001646 -C "client hello, adding max_fragment_length extension" \
1647 -S "found max fragment length extension" \
1648 -S "server hello, max_fragment_length extension" \
1649 -C "found max_fragment_length extension"
1650
Hanno Becker4aed27e2017-09-18 15:00:34 +01001651requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001652run_test "Max fragment length: enabled, default, larger message" \
1653 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001654 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001655 0 \
1656 -c "Maximum fragment length is 16384" \
1657 -s "Maximum fragment length is 16384" \
1658 -C "client hello, adding max_fragment_length extension" \
1659 -S "found max fragment length extension" \
1660 -S "server hello, max_fragment_length extension" \
1661 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001662 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001663 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001664 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001665
1666requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1667run_test "Max fragment length, DTLS: enabled, default, larger message" \
1668 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001669 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001670 1 \
1671 -c "Maximum fragment length is 16384" \
1672 -s "Maximum fragment length is 16384" \
1673 -C "client hello, adding max_fragment_length extension" \
1674 -S "found max fragment length extension" \
1675 -S "server hello, max_fragment_length extension" \
1676 -C "found max_fragment_length extension" \
1677 -c "fragment larger than.*maximum "
1678
1679requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1680run_test "Max fragment length: disabled, larger message" \
1681 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001682 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001683 0 \
1684 -C "Maximum fragment length is 16384" \
1685 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001686 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001687 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001688 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001689
1690requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1691run_test "Max fragment length DTLS: disabled, larger message" \
1692 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001693 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001694 1 \
1695 -C "Maximum fragment length is 16384" \
1696 -S "Maximum fragment length is 16384" \
1697 -c "fragment larger than.*maximum "
1698
1699requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001700run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001701 "$P_SRV debug_level=3" \
1702 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001703 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001704 -c "Maximum fragment length is 4096" \
1705 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001706 -c "client hello, adding max_fragment_length extension" \
1707 -s "found max fragment length extension" \
1708 -s "server hello, max_fragment_length extension" \
1709 -c "found max_fragment_length extension"
1710
Hanno Becker4aed27e2017-09-18 15:00:34 +01001711requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001712run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001713 "$P_SRV debug_level=3 max_frag_len=4096" \
1714 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001715 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001716 -c "Maximum fragment length is 16384" \
1717 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001718 -C "client hello, adding max_fragment_length extension" \
1719 -S "found max fragment length extension" \
1720 -S "server hello, max_fragment_length extension" \
1721 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001722
Hanno Becker4aed27e2017-09-18 15:00:34 +01001723requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001724requires_gnutls
1725run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001726 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001727 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001728 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001729 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001730 -c "client hello, adding max_fragment_length extension" \
1731 -c "found max_fragment_length extension"
1732
Hanno Becker4aed27e2017-09-18 15:00:34 +01001733requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001734run_test "Max fragment length: client, message just fits" \
1735 "$P_SRV debug_level=3" \
1736 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1737 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001738 -c "Maximum fragment length is 2048" \
1739 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001740 -c "client hello, adding max_fragment_length extension" \
1741 -s "found max fragment length extension" \
1742 -s "server hello, max_fragment_length extension" \
1743 -c "found max_fragment_length extension" \
1744 -c "2048 bytes written in 1 fragments" \
1745 -s "2048 bytes read"
1746
Hanno Becker4aed27e2017-09-18 15:00:34 +01001747requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001748run_test "Max fragment length: client, larger message" \
1749 "$P_SRV debug_level=3" \
1750 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1751 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001752 -c "Maximum fragment length is 2048" \
1753 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001754 -c "client hello, adding max_fragment_length extension" \
1755 -s "found max fragment length extension" \
1756 -s "server hello, max_fragment_length extension" \
1757 -c "found max_fragment_length extension" \
1758 -c "2345 bytes written in 2 fragments" \
1759 -s "2048 bytes read" \
1760 -s "297 bytes read"
1761
Hanno Becker4aed27e2017-09-18 15:00:34 +01001762requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001763run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001764 "$P_SRV debug_level=3 dtls=1" \
1765 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1766 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001767 -c "Maximum fragment length is 2048" \
1768 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001769 -c "client hello, adding max_fragment_length extension" \
1770 -s "found max fragment length extension" \
1771 -s "server hello, max_fragment_length extension" \
1772 -c "found max_fragment_length extension" \
1773 -c "fragment larger than.*maximum"
1774
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001775# Tests for renegotiation
1776
Hanno Becker6a243642017-10-12 15:18:45 +01001777# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001778run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001779 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001780 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001781 0 \
1782 -C "client hello, adding renegotiation extension" \
1783 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1784 -S "found renegotiation extension" \
1785 -s "server hello, secure renegotiation extension" \
1786 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001787 -C "=> renegotiate" \
1788 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001789 -S "write hello request"
1790
Hanno Becker6a243642017-10-12 15:18:45 +01001791requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001792run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001793 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001794 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001795 0 \
1796 -c "client hello, adding renegotiation extension" \
1797 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1798 -s "found renegotiation extension" \
1799 -s "server hello, secure renegotiation extension" \
1800 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001801 -c "=> renegotiate" \
1802 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001803 -S "write hello request"
1804
Hanno Becker6a243642017-10-12 15:18:45 +01001805requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001806run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001807 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001808 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001809 0 \
1810 -c "client hello, adding renegotiation extension" \
1811 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1812 -s "found renegotiation extension" \
1813 -s "server hello, secure renegotiation extension" \
1814 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001815 -c "=> renegotiate" \
1816 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001817 -s "write hello request"
1818
Janos Follathb0f148c2017-10-05 12:29:42 +01001819# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1820# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1821# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001822requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001823run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1824 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1825 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1826 0 \
1827 -c "client hello, adding renegotiation extension" \
1828 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1829 -s "found renegotiation extension" \
1830 -s "server hello, secure renegotiation extension" \
1831 -c "found renegotiation extension" \
1832 -c "=> renegotiate" \
1833 -s "=> renegotiate" \
1834 -S "write hello request" \
1835 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1836
1837# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1838# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1839# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001840requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001841run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1842 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1843 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1844 0 \
1845 -c "client hello, adding renegotiation extension" \
1846 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1847 -s "found renegotiation extension" \
1848 -s "server hello, secure renegotiation extension" \
1849 -c "found renegotiation extension" \
1850 -c "=> renegotiate" \
1851 -s "=> renegotiate" \
1852 -s "write hello request" \
1853 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1854
Hanno Becker6a243642017-10-12 15:18:45 +01001855requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001856run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001857 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001859 0 \
1860 -c "client hello, adding renegotiation extension" \
1861 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1862 -s "found renegotiation extension" \
1863 -s "server hello, secure renegotiation extension" \
1864 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001865 -c "=> renegotiate" \
1866 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001867 -s "write hello request"
1868
Hanno Becker6a243642017-10-12 15:18:45 +01001869requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001870run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001871 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001872 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001873 1 \
1874 -c "client hello, adding renegotiation extension" \
1875 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1876 -S "found renegotiation extension" \
1877 -s "server hello, secure renegotiation extension" \
1878 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001879 -c "=> renegotiate" \
1880 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001881 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001882 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001883 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001884
Hanno Becker6a243642017-10-12 15:18:45 +01001885requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001886run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001887 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001888 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001889 0 \
1890 -C "client hello, adding renegotiation extension" \
1891 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1892 -S "found renegotiation extension" \
1893 -s "server hello, secure renegotiation extension" \
1894 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001895 -C "=> renegotiate" \
1896 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001897 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001898 -S "SSL - An unexpected message was received from our peer" \
1899 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001900
Hanno Becker6a243642017-10-12 15:18:45 +01001901requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001902run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001903 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001904 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001905 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001906 0 \
1907 -C "client hello, adding renegotiation extension" \
1908 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1909 -S "found renegotiation extension" \
1910 -s "server hello, secure renegotiation extension" \
1911 -c "found renegotiation extension" \
1912 -C "=> renegotiate" \
1913 -S "=> renegotiate" \
1914 -s "write hello request" \
1915 -S "SSL - An unexpected message was received from our peer" \
1916 -S "failed"
1917
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001918# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001919requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001920run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001921 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001922 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001923 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001924 0 \
1925 -C "client hello, adding renegotiation extension" \
1926 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1927 -S "found renegotiation extension" \
1928 -s "server hello, secure renegotiation extension" \
1929 -c "found renegotiation extension" \
1930 -C "=> renegotiate" \
1931 -S "=> renegotiate" \
1932 -s "write hello request" \
1933 -S "SSL - An unexpected message was received from our peer" \
1934 -S "failed"
1935
Hanno Becker6a243642017-10-12 15:18:45 +01001936requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001937run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001938 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001939 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001940 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001941 0 \
1942 -C "client hello, adding renegotiation extension" \
1943 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1944 -S "found renegotiation extension" \
1945 -s "server hello, secure renegotiation extension" \
1946 -c "found renegotiation extension" \
1947 -C "=> renegotiate" \
1948 -S "=> renegotiate" \
1949 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001950 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001951
Hanno Becker6a243642017-10-12 15:18:45 +01001952requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001953run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001954 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001955 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001956 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001957 0 \
1958 -c "client hello, adding renegotiation extension" \
1959 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1960 -s "found renegotiation extension" \
1961 -s "server hello, secure renegotiation extension" \
1962 -c "found renegotiation extension" \
1963 -c "=> renegotiate" \
1964 -s "=> renegotiate" \
1965 -s "write hello request" \
1966 -S "SSL - An unexpected message was received from our peer" \
1967 -S "failed"
1968
Hanno Becker6a243642017-10-12 15:18:45 +01001969requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001970run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001971 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001972 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1973 0 \
1974 -C "client hello, adding renegotiation extension" \
1975 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1976 -S "found renegotiation extension" \
1977 -s "server hello, secure renegotiation extension" \
1978 -c "found renegotiation extension" \
1979 -S "record counter limit reached: renegotiate" \
1980 -C "=> renegotiate" \
1981 -S "=> renegotiate" \
1982 -S "write hello request" \
1983 -S "SSL - An unexpected message was received from our peer" \
1984 -S "failed"
1985
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001986# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001987requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001988run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001989 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001990 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001991 0 \
1992 -c "client hello, adding renegotiation extension" \
1993 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1994 -s "found renegotiation extension" \
1995 -s "server hello, secure renegotiation extension" \
1996 -c "found renegotiation extension" \
1997 -s "record counter limit reached: renegotiate" \
1998 -c "=> renegotiate" \
1999 -s "=> renegotiate" \
2000 -s "write hello request" \
2001 -S "SSL - An unexpected message was received from our peer" \
2002 -S "failed"
2003
Hanno Becker6a243642017-10-12 15:18:45 +01002004requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002005run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002006 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002007 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002008 0 \
2009 -c "client hello, adding renegotiation extension" \
2010 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2011 -s "found renegotiation extension" \
2012 -s "server hello, secure renegotiation extension" \
2013 -c "found renegotiation extension" \
2014 -s "record counter limit reached: renegotiate" \
2015 -c "=> renegotiate" \
2016 -s "=> renegotiate" \
2017 -s "write hello request" \
2018 -S "SSL - An unexpected message was received from our peer" \
2019 -S "failed"
2020
Hanno Becker6a243642017-10-12 15:18:45 +01002021requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002022run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002023 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002024 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2025 0 \
2026 -C "client hello, adding renegotiation extension" \
2027 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2028 -S "found renegotiation extension" \
2029 -s "server hello, secure renegotiation extension" \
2030 -c "found renegotiation extension" \
2031 -S "record counter limit reached: renegotiate" \
2032 -C "=> renegotiate" \
2033 -S "=> renegotiate" \
2034 -S "write hello request" \
2035 -S "SSL - An unexpected message was received from our peer" \
2036 -S "failed"
2037
Hanno Becker6a243642017-10-12 15:18:45 +01002038requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002039run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002040 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002041 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002042 0 \
2043 -c "client hello, adding renegotiation extension" \
2044 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2045 -s "found renegotiation extension" \
2046 -s "server hello, secure renegotiation extension" \
2047 -c "found renegotiation extension" \
2048 -c "=> renegotiate" \
2049 -s "=> renegotiate" \
2050 -S "write hello request"
2051
Hanno Becker6a243642017-10-12 15:18:45 +01002052requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002053run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002054 "$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 +02002055 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002056 0 \
2057 -c "client hello, adding renegotiation extension" \
2058 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2059 -s "found renegotiation extension" \
2060 -s "server hello, secure renegotiation extension" \
2061 -c "found renegotiation extension" \
2062 -c "=> renegotiate" \
2063 -s "=> renegotiate" \
2064 -s "write hello request"
2065
Hanno Becker6a243642017-10-12 15:18:45 +01002066requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002067run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002068 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002069 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002070 0 \
2071 -c "client hello, adding renegotiation extension" \
2072 -c "found renegotiation extension" \
2073 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002074 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002075 -C "error" \
2076 -c "HTTP/1.0 200 [Oo][Kk]"
2077
Paul Bakker539d9722015-02-08 16:18:35 +01002078requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002079requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002080run_test "Renegotiation: gnutls server strict, client-initiated" \
2081 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002082 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002083 0 \
2084 -c "client hello, adding renegotiation extension" \
2085 -c "found renegotiation extension" \
2086 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002087 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002088 -C "error" \
2089 -c "HTTP/1.0 200 [Oo][Kk]"
2090
Paul Bakker539d9722015-02-08 16:18:35 +01002091requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002092requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002093run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2094 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2095 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2096 1 \
2097 -c "client hello, adding renegotiation extension" \
2098 -C "found renegotiation extension" \
2099 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002100 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002101 -c "error" \
2102 -C "HTTP/1.0 200 [Oo][Kk]"
2103
Paul Bakker539d9722015-02-08 16:18:35 +01002104requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002105requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002106run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2107 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2108 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2109 allow_legacy=0" \
2110 1 \
2111 -c "client hello, adding renegotiation extension" \
2112 -C "found renegotiation extension" \
2113 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002114 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002115 -c "error" \
2116 -C "HTTP/1.0 200 [Oo][Kk]"
2117
Paul Bakker539d9722015-02-08 16:18:35 +01002118requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002119requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002120run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2121 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2122 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2123 allow_legacy=1" \
2124 0 \
2125 -c "client hello, adding renegotiation extension" \
2126 -C "found renegotiation extension" \
2127 -c "=> renegotiate" \
2128 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002129 -C "error" \
2130 -c "HTTP/1.0 200 [Oo][Kk]"
2131
Hanno Becker6a243642017-10-12 15:18:45 +01002132requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002133run_test "Renegotiation: DTLS, client-initiated" \
2134 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2135 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2136 0 \
2137 -c "client hello, adding renegotiation extension" \
2138 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2139 -s "found renegotiation extension" \
2140 -s "server hello, secure renegotiation extension" \
2141 -c "found renegotiation extension" \
2142 -c "=> renegotiate" \
2143 -s "=> renegotiate" \
2144 -S "write hello request"
2145
Hanno Becker6a243642017-10-12 15:18:45 +01002146requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002147run_test "Renegotiation: DTLS, server-initiated" \
2148 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002149 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2150 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002151 0 \
2152 -c "client hello, adding renegotiation extension" \
2153 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2154 -s "found renegotiation extension" \
2155 -s "server hello, secure renegotiation extension" \
2156 -c "found renegotiation extension" \
2157 -c "=> renegotiate" \
2158 -s "=> renegotiate" \
2159 -s "write hello request"
2160
Hanno Becker6a243642017-10-12 15:18:45 +01002161requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002162run_test "Renegotiation: DTLS, renego_period overflow" \
2163 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2164 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2165 0 \
2166 -c "client hello, adding renegotiation extension" \
2167 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2168 -s "found renegotiation extension" \
2169 -s "server hello, secure renegotiation extension" \
2170 -s "record counter limit reached: renegotiate" \
2171 -c "=> renegotiate" \
2172 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002173 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002174
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002175requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002176requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002177run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2178 "$G_SRV -u --mtu 4096" \
2179 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2180 0 \
2181 -c "client hello, adding renegotiation extension" \
2182 -c "found renegotiation extension" \
2183 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002184 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002185 -C "error" \
2186 -s "Extra-header:"
2187
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002188# Test for the "secure renegotation" extension only (no actual renegotiation)
2189
Paul Bakker539d9722015-02-08 16:18:35 +01002190requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002191run_test "Renego ext: gnutls server strict, client default" \
2192 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2193 "$P_CLI debug_level=3" \
2194 0 \
2195 -c "found renegotiation extension" \
2196 -C "error" \
2197 -c "HTTP/1.0 200 [Oo][Kk]"
2198
Paul Bakker539d9722015-02-08 16:18:35 +01002199requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002200run_test "Renego ext: gnutls server unsafe, client default" \
2201 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2202 "$P_CLI debug_level=3" \
2203 0 \
2204 -C "found renegotiation extension" \
2205 -C "error" \
2206 -c "HTTP/1.0 200 [Oo][Kk]"
2207
Paul Bakker539d9722015-02-08 16:18:35 +01002208requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002209run_test "Renego ext: gnutls server unsafe, client break legacy" \
2210 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2211 "$P_CLI debug_level=3 allow_legacy=-1" \
2212 1 \
2213 -C "found renegotiation extension" \
2214 -c "error" \
2215 -C "HTTP/1.0 200 [Oo][Kk]"
2216
Paul Bakker539d9722015-02-08 16:18:35 +01002217requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002218run_test "Renego ext: gnutls client strict, server default" \
2219 "$P_SRV debug_level=3" \
2220 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2221 0 \
2222 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2223 -s "server hello, secure renegotiation extension"
2224
Paul Bakker539d9722015-02-08 16:18:35 +01002225requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002226run_test "Renego ext: gnutls client unsafe, server default" \
2227 "$P_SRV debug_level=3" \
2228 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2229 0 \
2230 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2231 -S "server hello, secure renegotiation extension"
2232
Paul Bakker539d9722015-02-08 16:18:35 +01002233requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002234run_test "Renego ext: gnutls client unsafe, server break legacy" \
2235 "$P_SRV debug_level=3 allow_legacy=-1" \
2236 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2237 1 \
2238 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2239 -S "server hello, secure renegotiation extension"
2240
Janos Follath0b242342016-02-17 10:11:21 +00002241# Tests for silently dropping trailing extra bytes in .der certificates
2242
2243requires_gnutls
2244run_test "DER format: no trailing bytes" \
2245 "$P_SRV crt_file=data_files/server5-der0.crt \
2246 key_file=data_files/server5.key" \
2247 "$G_CLI " \
2248 0 \
2249 -c "Handshake was completed" \
2250
2251requires_gnutls
2252run_test "DER format: with a trailing zero byte" \
2253 "$P_SRV crt_file=data_files/server5-der1a.crt \
2254 key_file=data_files/server5.key" \
2255 "$G_CLI " \
2256 0 \
2257 -c "Handshake was completed" \
2258
2259requires_gnutls
2260run_test "DER format: with a trailing random byte" \
2261 "$P_SRV crt_file=data_files/server5-der1b.crt \
2262 key_file=data_files/server5.key" \
2263 "$G_CLI " \
2264 0 \
2265 -c "Handshake was completed" \
2266
2267requires_gnutls
2268run_test "DER format: with 2 trailing random bytes" \
2269 "$P_SRV crt_file=data_files/server5-der2.crt \
2270 key_file=data_files/server5.key" \
2271 "$G_CLI " \
2272 0 \
2273 -c "Handshake was completed" \
2274
2275requires_gnutls
2276run_test "DER format: with 4 trailing random bytes" \
2277 "$P_SRV crt_file=data_files/server5-der4.crt \
2278 key_file=data_files/server5.key" \
2279 "$G_CLI " \
2280 0 \
2281 -c "Handshake was completed" \
2282
2283requires_gnutls
2284run_test "DER format: with 8 trailing random bytes" \
2285 "$P_SRV crt_file=data_files/server5-der8.crt \
2286 key_file=data_files/server5.key" \
2287 "$G_CLI " \
2288 0 \
2289 -c "Handshake was completed" \
2290
2291requires_gnutls
2292run_test "DER format: with 9 trailing random bytes" \
2293 "$P_SRV crt_file=data_files/server5-der9.crt \
2294 key_file=data_files/server5.key" \
2295 "$G_CLI " \
2296 0 \
2297 -c "Handshake was completed" \
2298
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002299# Tests for auth_mode
2300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002301run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002302 "$P_SRV crt_file=data_files/server5-badsign.crt \
2303 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002304 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002305 1 \
2306 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002307 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002308 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002309 -c "X509 - Certificate verification failed"
2310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002311run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002312 "$P_SRV crt_file=data_files/server5-badsign.crt \
2313 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002314 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002315 0 \
2316 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002317 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002318 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002319 -C "X509 - Certificate verification failed"
2320
Hanno Beckere6706e62017-05-15 16:05:15 +01002321run_test "Authentication: server goodcert, client optional, no trusted CA" \
2322 "$P_SRV" \
2323 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2324 0 \
2325 -c "x509_verify_cert() returned" \
2326 -c "! The certificate is not correctly signed by the trusted CA" \
2327 -c "! Certificate verification flags"\
2328 -C "! mbedtls_ssl_handshake returned" \
2329 -C "X509 - Certificate verification failed" \
2330 -C "SSL - No CA Chain is set, but required to operate"
2331
2332run_test "Authentication: server goodcert, client required, no trusted CA" \
2333 "$P_SRV" \
2334 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2335 1 \
2336 -c "x509_verify_cert() returned" \
2337 -c "! The certificate is not correctly signed by the trusted CA" \
2338 -c "! Certificate verification flags"\
2339 -c "! mbedtls_ssl_handshake returned" \
2340 -c "SSL - No CA Chain is set, but required to operate"
2341
2342# The purpose of the next two tests is to test the client's behaviour when receiving a server
2343# certificate with an unsupported elliptic curve. This should usually not happen because
2344# the client informs the server about the supported curves - it does, though, in the
2345# corner case of a static ECDH suite, because the server doesn't check the curve on that
2346# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2347# different means to have the server ignoring the client's supported curve list.
2348
2349requires_config_enabled MBEDTLS_ECP_C
2350run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2351 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2352 crt_file=data_files/server5.ku-ka.crt" \
2353 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2354 1 \
2355 -c "bad certificate (EC key curve)"\
2356 -c "! Certificate verification flags"\
2357 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2358
2359requires_config_enabled MBEDTLS_ECP_C
2360run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2361 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2362 crt_file=data_files/server5.ku-ka.crt" \
2363 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2364 1 \
2365 -c "bad certificate (EC key curve)"\
2366 -c "! Certificate verification flags"\
2367 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002369run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002370 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002371 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002372 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002373 0 \
2374 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002375 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002376 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002377 -C "X509 - Certificate verification failed"
2378
Simon Butcher99000142016-10-13 17:21:01 +01002379run_test "Authentication: client SHA256, server required" \
2380 "$P_SRV auth_mode=required" \
2381 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2382 key_file=data_files/server6.key \
2383 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2384 0 \
2385 -c "Supported Signature Algorithm found: 4," \
2386 -c "Supported Signature Algorithm found: 5,"
2387
2388run_test "Authentication: client SHA384, server required" \
2389 "$P_SRV auth_mode=required" \
2390 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2391 key_file=data_files/server6.key \
2392 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2393 0 \
2394 -c "Supported Signature Algorithm found: 4," \
2395 -c "Supported Signature Algorithm found: 5,"
2396
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002397requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2398run_test "Authentication: client has no cert, server required (SSLv3)" \
2399 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2400 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2401 key_file=data_files/server5.key" \
2402 1 \
2403 -S "skip write certificate request" \
2404 -C "skip parse certificate request" \
2405 -c "got a certificate request" \
2406 -c "got no certificate to send" \
2407 -S "x509_verify_cert() returned" \
2408 -s "client has no certificate" \
2409 -s "! mbedtls_ssl_handshake returned" \
2410 -c "! mbedtls_ssl_handshake returned" \
2411 -s "No client certification received from the client, but required by the authentication mode"
2412
2413run_test "Authentication: client has no cert, server required (TLS)" \
2414 "$P_SRV debug_level=3 auth_mode=required" \
2415 "$P_CLI debug_level=3 crt_file=none \
2416 key_file=data_files/server5.key" \
2417 1 \
2418 -S "skip write certificate request" \
2419 -C "skip parse certificate request" \
2420 -c "got a certificate request" \
2421 -c "= write certificate$" \
2422 -C "skip write certificate$" \
2423 -S "x509_verify_cert() returned" \
2424 -s "client has no certificate" \
2425 -s "! mbedtls_ssl_handshake returned" \
2426 -c "! mbedtls_ssl_handshake returned" \
2427 -s "No client certification received from the client, but required by the authentication mode"
2428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002429run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002430 "$P_SRV debug_level=3 auth_mode=required" \
2431 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002432 key_file=data_files/server5.key" \
2433 1 \
2434 -S "skip write certificate request" \
2435 -C "skip parse certificate request" \
2436 -c "got a certificate request" \
2437 -C "skip write certificate" \
2438 -C "skip write certificate verify" \
2439 -S "skip parse certificate verify" \
2440 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002441 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002442 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002443 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002444 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002445 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002446# We don't check that the client receives the alert because it might
2447# detect that its write end of the connection is closed and abort
2448# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002449
Janos Follath89baba22017-04-10 14:34:35 +01002450run_test "Authentication: client cert not trusted, server required" \
2451 "$P_SRV debug_level=3 auth_mode=required" \
2452 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2453 key_file=data_files/server5.key" \
2454 1 \
2455 -S "skip write certificate request" \
2456 -C "skip parse certificate request" \
2457 -c "got a certificate request" \
2458 -C "skip write certificate" \
2459 -C "skip write certificate verify" \
2460 -S "skip parse certificate verify" \
2461 -s "x509_verify_cert() returned" \
2462 -s "! The certificate is not correctly signed by the trusted CA" \
2463 -s "! mbedtls_ssl_handshake returned" \
2464 -c "! mbedtls_ssl_handshake returned" \
2465 -s "X509 - Certificate verification failed"
2466
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002467run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002468 "$P_SRV debug_level=3 auth_mode=optional" \
2469 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002470 key_file=data_files/server5.key" \
2471 0 \
2472 -S "skip write certificate request" \
2473 -C "skip parse certificate request" \
2474 -c "got a certificate request" \
2475 -C "skip write certificate" \
2476 -C "skip write certificate verify" \
2477 -S "skip parse certificate verify" \
2478 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002479 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002480 -S "! mbedtls_ssl_handshake returned" \
2481 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002482 -S "X509 - Certificate verification failed"
2483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002484run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002485 "$P_SRV debug_level=3 auth_mode=none" \
2486 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002487 key_file=data_files/server5.key" \
2488 0 \
2489 -s "skip write certificate request" \
2490 -C "skip parse certificate request" \
2491 -c "got no certificate request" \
2492 -c "skip write certificate" \
2493 -c "skip write certificate verify" \
2494 -s "skip parse certificate verify" \
2495 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002496 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002497 -S "! mbedtls_ssl_handshake returned" \
2498 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002499 -S "X509 - Certificate verification failed"
2500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002501run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002502 "$P_SRV debug_level=3 auth_mode=optional" \
2503 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002504 0 \
2505 -S "skip write certificate request" \
2506 -C "skip parse certificate request" \
2507 -c "got a certificate request" \
2508 -C "skip write certificate$" \
2509 -C "got no certificate to send" \
2510 -S "SSLv3 client has no certificate" \
2511 -c "skip write certificate verify" \
2512 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002513 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002514 -S "! mbedtls_ssl_handshake returned" \
2515 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002516 -S "X509 - Certificate verification failed"
2517
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002518run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002519 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002520 "$O_CLI" \
2521 0 \
2522 -S "skip write certificate request" \
2523 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002524 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002525 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002526 -S "X509 - Certificate verification failed"
2527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002528run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002529 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002530 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002531 0 \
2532 -C "skip parse certificate request" \
2533 -c "got a certificate request" \
2534 -C "skip write certificate$" \
2535 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002536 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002537
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002538run_test "Authentication: client no cert, openssl server required" \
2539 "$O_SRV -Verify 10" \
2540 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2541 1 \
2542 -C "skip parse certificate request" \
2543 -c "got a certificate request" \
2544 -C "skip write certificate$" \
2545 -c "skip write certificate verify" \
2546 -c "! mbedtls_ssl_handshake returned"
2547
Janos Follathe2681a42016-03-07 15:57:05 +00002548requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002549run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002550 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002551 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002552 0 \
2553 -S "skip write certificate request" \
2554 -C "skip parse certificate request" \
2555 -c "got a certificate request" \
2556 -C "skip write certificate$" \
2557 -c "skip write certificate verify" \
2558 -c "got no certificate to send" \
2559 -s "SSLv3 client has no certificate" \
2560 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002561 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002562 -S "! mbedtls_ssl_handshake returned" \
2563 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002564 -S "X509 - Certificate verification failed"
2565
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002566# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2567# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002568
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002569MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002570MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002571
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002572if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002573 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002574 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002575 printf "test value of ${MAX_IM_CA}. \n"
2576 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002577 printf "The tests assume this value and if it changes, the tests in this\n"
2578 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002579 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002580
2581 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002582fi
2583
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002584run_test "Authentication: server max_int chain, client default" \
2585 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2586 key_file=data_files/dir-maxpath/09.key" \
2587 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2588 0 \
2589 -C "X509 - A fatal error occured"
2590
2591run_test "Authentication: server max_int+1 chain, client default" \
2592 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2593 key_file=data_files/dir-maxpath/10.key" \
2594 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2595 1 \
2596 -c "X509 - A fatal error occured"
2597
2598run_test "Authentication: server max_int+1 chain, client optional" \
2599 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2600 key_file=data_files/dir-maxpath/10.key" \
2601 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2602 auth_mode=optional" \
2603 1 \
2604 -c "X509 - A fatal error occured"
2605
2606run_test "Authentication: server max_int+1 chain, client none" \
2607 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2608 key_file=data_files/dir-maxpath/10.key" \
2609 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2610 auth_mode=none" \
2611 0 \
2612 -C "X509 - A fatal error occured"
2613
2614run_test "Authentication: client max_int+1 chain, server default" \
2615 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2616 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2617 key_file=data_files/dir-maxpath/10.key" \
2618 0 \
2619 -S "X509 - A fatal error occured"
2620
2621run_test "Authentication: client max_int+1 chain, server optional" \
2622 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2623 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2624 key_file=data_files/dir-maxpath/10.key" \
2625 1 \
2626 -s "X509 - A fatal error occured"
2627
2628run_test "Authentication: client max_int+1 chain, server required" \
2629 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2630 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2631 key_file=data_files/dir-maxpath/10.key" \
2632 1 \
2633 -s "X509 - A fatal error occured"
2634
2635run_test "Authentication: client max_int chain, server required" \
2636 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2637 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2638 key_file=data_files/dir-maxpath/09.key" \
2639 0 \
2640 -S "X509 - A fatal error occured"
2641
Janos Follath89baba22017-04-10 14:34:35 +01002642# Tests for CA list in CertificateRequest messages
2643
2644run_test "Authentication: send CA list in CertificateRequest (default)" \
2645 "$P_SRV debug_level=3 auth_mode=required" \
2646 "$P_CLI crt_file=data_files/server6.crt \
2647 key_file=data_files/server6.key" \
2648 0 \
2649 -s "requested DN"
2650
2651run_test "Authentication: do not send CA list in CertificateRequest" \
2652 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2653 "$P_CLI crt_file=data_files/server6.crt \
2654 key_file=data_files/server6.key" \
2655 0 \
2656 -S "requested DN"
2657
2658run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2659 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2660 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2661 key_file=data_files/server5.key" \
2662 1 \
2663 -S "requested DN" \
2664 -s "x509_verify_cert() returned" \
2665 -s "! The certificate is not correctly signed by the trusted CA" \
2666 -s "! mbedtls_ssl_handshake returned" \
2667 -c "! mbedtls_ssl_handshake returned" \
2668 -s "X509 - Certificate verification failed"
2669
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002670# Tests for certificate selection based on SHA verson
2671
2672run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2673 "$P_SRV crt_file=data_files/server5.crt \
2674 key_file=data_files/server5.key \
2675 crt_file2=data_files/server5-sha1.crt \
2676 key_file2=data_files/server5.key" \
2677 "$P_CLI force_version=tls1_2" \
2678 0 \
2679 -c "signed using.*ECDSA with SHA256" \
2680 -C "signed using.*ECDSA with SHA1"
2681
2682run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2683 "$P_SRV crt_file=data_files/server5.crt \
2684 key_file=data_files/server5.key \
2685 crt_file2=data_files/server5-sha1.crt \
2686 key_file2=data_files/server5.key" \
2687 "$P_CLI force_version=tls1_1" \
2688 0 \
2689 -C "signed using.*ECDSA with SHA256" \
2690 -c "signed using.*ECDSA with SHA1"
2691
2692run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2693 "$P_SRV crt_file=data_files/server5.crt \
2694 key_file=data_files/server5.key \
2695 crt_file2=data_files/server5-sha1.crt \
2696 key_file2=data_files/server5.key" \
2697 "$P_CLI force_version=tls1" \
2698 0 \
2699 -C "signed using.*ECDSA with SHA256" \
2700 -c "signed using.*ECDSA with SHA1"
2701
2702run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2703 "$P_SRV crt_file=data_files/server5.crt \
2704 key_file=data_files/server5.key \
2705 crt_file2=data_files/server6.crt \
2706 key_file2=data_files/server6.key" \
2707 "$P_CLI force_version=tls1_1" \
2708 0 \
2709 -c "serial number.*09" \
2710 -c "signed using.*ECDSA with SHA256" \
2711 -C "signed using.*ECDSA with SHA1"
2712
2713run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2714 "$P_SRV crt_file=data_files/server6.crt \
2715 key_file=data_files/server6.key \
2716 crt_file2=data_files/server5.crt \
2717 key_file2=data_files/server5.key" \
2718 "$P_CLI force_version=tls1_1" \
2719 0 \
2720 -c "serial number.*0A" \
2721 -c "signed using.*ECDSA with SHA256" \
2722 -C "signed using.*ECDSA with SHA1"
2723
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002724# tests for SNI
2725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002726run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002727 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002728 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002729 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002730 0 \
2731 -S "parse ServerName extension" \
2732 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2733 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002735run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002736 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002737 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002738 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 +02002739 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002740 0 \
2741 -s "parse ServerName extension" \
2742 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2743 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002745run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002746 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002747 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002748 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 +02002749 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002750 0 \
2751 -s "parse ServerName extension" \
2752 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2753 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002755run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002756 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002757 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002758 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 +02002759 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002760 1 \
2761 -s "parse ServerName extension" \
2762 -s "ssl_sni_wrapper() returned" \
2763 -s "mbedtls_ssl_handshake returned" \
2764 -c "mbedtls_ssl_handshake returned" \
2765 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002766
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002767run_test "SNI: client auth no override: optional" \
2768 "$P_SRV debug_level=3 auth_mode=optional \
2769 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2770 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2771 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002772 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002773 -S "skip write certificate request" \
2774 -C "skip parse certificate request" \
2775 -c "got a certificate request" \
2776 -C "skip write certificate" \
2777 -C "skip write certificate verify" \
2778 -S "skip parse certificate verify"
2779
2780run_test "SNI: client auth override: none -> optional" \
2781 "$P_SRV debug_level=3 auth_mode=none \
2782 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2783 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2784 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002785 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002786 -S "skip write certificate request" \
2787 -C "skip parse certificate request" \
2788 -c "got a certificate request" \
2789 -C "skip write certificate" \
2790 -C "skip write certificate verify" \
2791 -S "skip parse certificate verify"
2792
2793run_test "SNI: client auth override: optional -> none" \
2794 "$P_SRV debug_level=3 auth_mode=optional \
2795 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2796 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2797 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002798 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002799 -s "skip write certificate request" \
2800 -C "skip parse certificate request" \
2801 -c "got no certificate request" \
2802 -c "skip write certificate" \
2803 -c "skip write certificate verify" \
2804 -s "skip parse certificate verify"
2805
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002806run_test "SNI: CA no override" \
2807 "$P_SRV debug_level=3 auth_mode=optional \
2808 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2809 ca_file=data_files/test-ca.crt \
2810 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2811 "$P_CLI debug_level=3 server_name=localhost \
2812 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2813 1 \
2814 -S "skip write certificate request" \
2815 -C "skip parse certificate request" \
2816 -c "got a certificate request" \
2817 -C "skip write certificate" \
2818 -C "skip write certificate verify" \
2819 -S "skip parse certificate verify" \
2820 -s "x509_verify_cert() returned" \
2821 -s "! The certificate is not correctly signed by the trusted CA" \
2822 -S "The certificate has been revoked (is on a CRL)"
2823
2824run_test "SNI: CA override" \
2825 "$P_SRV debug_level=3 auth_mode=optional \
2826 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2827 ca_file=data_files/test-ca.crt \
2828 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2829 "$P_CLI debug_level=3 server_name=localhost \
2830 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2831 0 \
2832 -S "skip write certificate request" \
2833 -C "skip parse certificate request" \
2834 -c "got a certificate request" \
2835 -C "skip write certificate" \
2836 -C "skip write certificate verify" \
2837 -S "skip parse certificate verify" \
2838 -S "x509_verify_cert() returned" \
2839 -S "! The certificate is not correctly signed by the trusted CA" \
2840 -S "The certificate has been revoked (is on a CRL)"
2841
2842run_test "SNI: CA override with CRL" \
2843 "$P_SRV debug_level=3 auth_mode=optional \
2844 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2845 ca_file=data_files/test-ca.crt \
2846 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2847 "$P_CLI debug_level=3 server_name=localhost \
2848 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2849 1 \
2850 -S "skip write certificate request" \
2851 -C "skip parse certificate request" \
2852 -c "got a certificate request" \
2853 -C "skip write certificate" \
2854 -C "skip write certificate verify" \
2855 -S "skip parse certificate verify" \
2856 -s "x509_verify_cert() returned" \
2857 -S "! The certificate is not correctly signed by the trusted CA" \
2858 -s "The certificate has been revoked (is on a CRL)"
2859
Andres AGe8b07742016-12-07 10:01:30 +00002860# Tests for SNI and DTLS
2861
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002862run_test "SNI: DTLS, no SNI callback" \
2863 "$P_SRV debug_level=3 dtls=1 \
2864 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2865 "$P_CLI server_name=localhost dtls=1" \
2866 0 \
2867 -S "parse ServerName extension" \
2868 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2869 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2870
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002871run_test "SNI: DTLS, matching cert 1" \
Andres AGe8b07742016-12-07 10:01:30 +00002872 "$P_SRV debug_level=3 dtls=1 \
2873 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2874 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2875 "$P_CLI server_name=localhost dtls=1" \
2876 0 \
2877 -s "parse ServerName extension" \
2878 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2879 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2880
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002881run_test "SNI: DTLS, matching cert 2" \
2882 "$P_SRV debug_level=3 dtls=1 \
2883 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2884 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2885 "$P_CLI server_name=polarssl.example dtls=1" \
2886 0 \
2887 -s "parse ServerName extension" \
2888 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2889 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2890
2891run_test "SNI: DTLS, no matching cert" \
2892 "$P_SRV debug_level=3 dtls=1 \
2893 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2894 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2895 "$P_CLI server_name=nonesuch.example dtls=1" \
2896 1 \
2897 -s "parse ServerName extension" \
2898 -s "ssl_sni_wrapper() returned" \
2899 -s "mbedtls_ssl_handshake returned" \
2900 -c "mbedtls_ssl_handshake returned" \
2901 -c "SSL - A fatal alert message was received from our peer"
2902
2903run_test "SNI: DTLS, client auth no override: optional" \
2904 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2905 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2906 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2907 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2908 0 \
2909 -S "skip write certificate request" \
2910 -C "skip parse certificate request" \
2911 -c "got a certificate request" \
2912 -C "skip write certificate" \
2913 -C "skip write certificate verify" \
2914 -S "skip parse certificate verify"
2915
2916run_test "SNI: DTLS, client auth override: none -> optional" \
2917 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2918 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2919 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2920 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2921 0 \
2922 -S "skip write certificate request" \
2923 -C "skip parse certificate request" \
2924 -c "got a certificate request" \
2925 -C "skip write certificate" \
2926 -C "skip write certificate verify" \
2927 -S "skip parse certificate verify"
2928
2929run_test "SNI: DTLS, client auth override: optional -> none" \
2930 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2931 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2932 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2933 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2934 0 \
2935 -s "skip write certificate request" \
2936 -C "skip parse certificate request" \
2937 -c "got no certificate request" \
2938 -c "skip write certificate" \
2939 -c "skip write certificate verify" \
2940 -s "skip parse certificate verify"
2941
2942run_test "SNI: DTLS, CA no override" \
2943 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2944 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2945 ca_file=data_files/test-ca.crt \
2946 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2947 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2948 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2949 1 \
2950 -S "skip write certificate request" \
2951 -C "skip parse certificate request" \
2952 -c "got a certificate request" \
2953 -C "skip write certificate" \
2954 -C "skip write certificate verify" \
2955 -S "skip parse certificate verify" \
2956 -s "x509_verify_cert() returned" \
2957 -s "! The certificate is not correctly signed by the trusted CA" \
2958 -S "The certificate has been revoked (is on a CRL)"
2959
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002960run_test "SNI: DTLS, CA override" \
Andres AGe8b07742016-12-07 10:01:30 +00002961 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2962 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2963 ca_file=data_files/test-ca.crt \
2964 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2965 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2966 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2967 0 \
2968 -S "skip write certificate request" \
2969 -C "skip parse certificate request" \
2970 -c "got a certificate request" \
2971 -C "skip write certificate" \
2972 -C "skip write certificate verify" \
2973 -S "skip parse certificate verify" \
2974 -S "x509_verify_cert() returned" \
2975 -S "! The certificate is not correctly signed by the trusted CA" \
2976 -S "The certificate has been revoked (is on a CRL)"
2977
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002978run_test "SNI: DTLS, CA override with CRL" \
Andres AGe8b07742016-12-07 10:01:30 +00002979 "$P_SRV debug_level=3 auth_mode=optional \
2980 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2981 ca_file=data_files/test-ca.crt \
2982 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2983 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2984 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2985 1 \
2986 -S "skip write certificate request" \
2987 -C "skip parse certificate request" \
2988 -c "got a certificate request" \
2989 -C "skip write certificate" \
2990 -C "skip write certificate verify" \
2991 -S "skip parse certificate verify" \
2992 -s "x509_verify_cert() returned" \
2993 -S "! The certificate is not correctly signed by the trusted CA" \
2994 -s "The certificate has been revoked (is on a CRL)"
2995
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002996# Tests for non-blocking I/O: exercise a variety of handshake flows
2997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002998run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002999 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3000 "$P_CLI nbio=2 tickets=0" \
3001 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003002 -S "mbedtls_ssl_handshake returned" \
3003 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003004 -c "Read from server: .* bytes read"
3005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003006run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003007 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3008 "$P_CLI nbio=2 tickets=0" \
3009 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003010 -S "mbedtls_ssl_handshake returned" \
3011 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003012 -c "Read from server: .* bytes read"
3013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003014run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003015 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3016 "$P_CLI nbio=2 tickets=1" \
3017 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003018 -S "mbedtls_ssl_handshake returned" \
3019 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003020 -c "Read from server: .* bytes read"
3021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003022run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003023 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3024 "$P_CLI nbio=2 tickets=1" \
3025 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003026 -S "mbedtls_ssl_handshake returned" \
3027 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003028 -c "Read from server: .* bytes read"
3029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003030run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003031 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3032 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3033 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003034 -S "mbedtls_ssl_handshake returned" \
3035 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003036 -c "Read from server: .* bytes read"
3037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003038run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003039 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3040 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3041 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003042 -S "mbedtls_ssl_handshake returned" \
3043 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003044 -c "Read from server: .* bytes read"
3045
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003046run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003047 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3048 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3049 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003050 -S "mbedtls_ssl_handshake returned" \
3051 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003052 -c "Read from server: .* bytes read"
3053
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003054# Tests for version negotiation
3055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003056run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003057 "$P_SRV" \
3058 "$P_CLI" \
3059 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003060 -S "mbedtls_ssl_handshake returned" \
3061 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003062 -s "Protocol is TLSv1.2" \
3063 -c "Protocol is TLSv1.2"
3064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003065run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003066 "$P_SRV" \
3067 "$P_CLI max_version=tls1_1" \
3068 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003069 -S "mbedtls_ssl_handshake returned" \
3070 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003071 -s "Protocol is TLSv1.1" \
3072 -c "Protocol is TLSv1.1"
3073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003074run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003075 "$P_SRV max_version=tls1_1" \
3076 "$P_CLI" \
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é-Gonnarda3d808e2014-02-26 16:33:03 +01003080 -s "Protocol is TLSv1.1" \
3081 -c "Protocol is TLSv1.1"
3082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003083run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003084 "$P_SRV max_version=tls1_1" \
3085 "$P_CLI max_version=tls1_1" \
3086 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003087 -S "mbedtls_ssl_handshake returned" \
3088 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003089 -s "Protocol is TLSv1.1" \
3090 -c "Protocol is TLSv1.1"
3091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003092run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003093 "$P_SRV min_version=tls1_1" \
3094 "$P_CLI max_version=tls1_1" \
3095 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003096 -S "mbedtls_ssl_handshake returned" \
3097 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003098 -s "Protocol is TLSv1.1" \
3099 -c "Protocol is TLSv1.1"
3100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003101run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003102 "$P_SRV max_version=tls1_1" \
3103 "$P_CLI min_version=tls1_1" \
3104 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003105 -S "mbedtls_ssl_handshake returned" \
3106 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003107 -s "Protocol is TLSv1.1" \
3108 -c "Protocol is TLSv1.1"
3109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003110run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003111 "$P_SRV max_version=tls1_1" \
3112 "$P_CLI min_version=tls1_2" \
3113 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003114 -s "mbedtls_ssl_handshake returned" \
3115 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003116 -c "SSL - Handshake protocol not within min/max boundaries"
3117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003118run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003119 "$P_SRV min_version=tls1_2" \
3120 "$P_CLI max_version=tls1_1" \
3121 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003122 -s "mbedtls_ssl_handshake returned" \
3123 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003124 -s "SSL - Handshake protocol not within min/max boundaries"
3125
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003126# Tests for ALPN extension
3127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003128run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003129 "$P_SRV debug_level=3" \
3130 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003131 0 \
3132 -C "client hello, adding alpn extension" \
3133 -S "found alpn extension" \
3134 -C "got an alert message, type: \\[2:120]" \
3135 -S "server hello, adding alpn extension" \
3136 -C "found alpn extension " \
3137 -C "Application Layer Protocol is" \
3138 -S "Application Layer Protocol is"
3139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003140run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003141 "$P_SRV debug_level=3" \
3142 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003143 0 \
3144 -c "client hello, adding alpn extension" \
3145 -s "found alpn extension" \
3146 -C "got an alert message, type: \\[2:120]" \
3147 -S "server hello, adding alpn extension" \
3148 -C "found alpn extension " \
3149 -c "Application Layer Protocol is (none)" \
3150 -S "Application Layer Protocol is"
3151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003152run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003153 "$P_SRV debug_level=3 alpn=abc,1234" \
3154 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003155 0 \
3156 -C "client hello, adding alpn extension" \
3157 -S "found alpn extension" \
3158 -C "got an alert message, type: \\[2:120]" \
3159 -S "server hello, adding alpn extension" \
3160 -C "found alpn extension " \
3161 -C "Application Layer Protocol is" \
3162 -s "Application Layer Protocol is (none)"
3163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003164run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003165 "$P_SRV debug_level=3 alpn=abc,1234" \
3166 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003167 0 \
3168 -c "client hello, adding alpn extension" \
3169 -s "found alpn extension" \
3170 -C "got an alert message, type: \\[2:120]" \
3171 -s "server hello, adding alpn extension" \
3172 -c "found alpn extension" \
3173 -c "Application Layer Protocol is abc" \
3174 -s "Application Layer Protocol is abc"
3175
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003176run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003177 "$P_SRV debug_level=3 alpn=abc,1234" \
3178 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003179 0 \
3180 -c "client hello, adding alpn extension" \
3181 -s "found alpn extension" \
3182 -C "got an alert message, type: \\[2:120]" \
3183 -s "server hello, adding alpn extension" \
3184 -c "found alpn extension" \
3185 -c "Application Layer Protocol is abc" \
3186 -s "Application Layer Protocol is abc"
3187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003188run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003189 "$P_SRV debug_level=3 alpn=abc,1234" \
3190 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003191 0 \
3192 -c "client hello, adding alpn extension" \
3193 -s "found alpn extension" \
3194 -C "got an alert message, type: \\[2:120]" \
3195 -s "server hello, adding alpn extension" \
3196 -c "found alpn extension" \
3197 -c "Application Layer Protocol is 1234" \
3198 -s "Application Layer Protocol is 1234"
3199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003200run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003201 "$P_SRV debug_level=3 alpn=abc,123" \
3202 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003203 1 \
3204 -c "client hello, adding alpn extension" \
3205 -s "found alpn extension" \
3206 -c "got an alert message, type: \\[2:120]" \
3207 -S "server hello, adding alpn extension" \
3208 -C "found alpn extension" \
3209 -C "Application Layer Protocol is 1234" \
3210 -S "Application Layer Protocol is 1234"
3211
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003212
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003213# Tests for keyUsage in leaf certificates, part 1:
3214# server-side certificate/suite selection
3215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003216run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003217 "$P_SRV key_file=data_files/server2.key \
3218 crt_file=data_files/server2.ku-ds.crt" \
3219 "$P_CLI" \
3220 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003221 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003222
3223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003224run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003225 "$P_SRV key_file=data_files/server2.key \
3226 crt_file=data_files/server2.ku-ke.crt" \
3227 "$P_CLI" \
3228 0 \
3229 -c "Ciphersuite is TLS-RSA-WITH-"
3230
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003231run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003232 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003233 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003234 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003235 1 \
3236 -C "Ciphersuite is "
3237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003238run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003239 "$P_SRV key_file=data_files/server5.key \
3240 crt_file=data_files/server5.ku-ds.crt" \
3241 "$P_CLI" \
3242 0 \
3243 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3244
3245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003246run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003247 "$P_SRV key_file=data_files/server5.key \
3248 crt_file=data_files/server5.ku-ka.crt" \
3249 "$P_CLI" \
3250 0 \
3251 -c "Ciphersuite is TLS-ECDH-"
3252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003253run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003254 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003255 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003256 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003257 1 \
3258 -C "Ciphersuite is "
3259
3260# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003261# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003262
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003263run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003264 "$O_SRV -key data_files/server2.key \
3265 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003266 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003267 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3268 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003269 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003270 -C "Processing of the Certificate handshake message failed" \
3271 -c "Ciphersuite is TLS-"
3272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003273run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003274 "$O_SRV -key data_files/server2.key \
3275 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003276 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003277 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3278 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003279 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003280 -C "Processing of the Certificate handshake message failed" \
3281 -c "Ciphersuite is TLS-"
3282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003283run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003284 "$O_SRV -key data_files/server2.key \
3285 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003286 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003287 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3288 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003289 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003290 -C "Processing of the Certificate handshake message failed" \
3291 -c "Ciphersuite is TLS-"
3292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003293run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003294 "$O_SRV -key data_files/server2.key \
3295 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003296 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003297 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3298 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003299 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003300 -c "Processing of the Certificate handshake message failed" \
3301 -C "Ciphersuite is TLS-"
3302
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003303run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3304 "$O_SRV -key data_files/server2.key \
3305 -cert data_files/server2.ku-ke.crt" \
3306 "$P_CLI debug_level=1 auth_mode=optional \
3307 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3308 0 \
3309 -c "bad certificate (usage extensions)" \
3310 -C "Processing of the Certificate handshake message failed" \
3311 -c "Ciphersuite is TLS-" \
3312 -c "! Usage does not match the keyUsage extension"
3313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003314run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003315 "$O_SRV -key data_files/server2.key \
3316 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003317 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003318 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3319 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003320 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003321 -C "Processing of the Certificate handshake message failed" \
3322 -c "Ciphersuite is TLS-"
3323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003324run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003325 "$O_SRV -key data_files/server2.key \
3326 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003327 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003328 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3329 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003330 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003331 -c "Processing of the Certificate handshake message failed" \
3332 -C "Ciphersuite is TLS-"
3333
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003334run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3335 "$O_SRV -key data_files/server2.key \
3336 -cert data_files/server2.ku-ds.crt" \
3337 "$P_CLI debug_level=1 auth_mode=optional \
3338 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3339 0 \
3340 -c "bad certificate (usage extensions)" \
3341 -C "Processing of the Certificate handshake message failed" \
3342 -c "Ciphersuite is TLS-" \
3343 -c "! Usage does not match the keyUsage extension"
3344
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003345# Tests for keyUsage in leaf certificates, part 3:
3346# server-side checking of client cert
3347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003348run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003349 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003350 "$O_CLI -key data_files/server2.key \
3351 -cert data_files/server2.ku-ds.crt" \
3352 0 \
3353 -S "bad certificate (usage extensions)" \
3354 -S "Processing of the Certificate handshake message failed"
3355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003356run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003357 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003358 "$O_CLI -key data_files/server2.key \
3359 -cert data_files/server2.ku-ke.crt" \
3360 0 \
3361 -s "bad certificate (usage extensions)" \
3362 -S "Processing of the Certificate handshake message failed"
3363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003364run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003365 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003366 "$O_CLI -key data_files/server2.key \
3367 -cert data_files/server2.ku-ke.crt" \
3368 1 \
3369 -s "bad certificate (usage extensions)" \
3370 -s "Processing of the Certificate handshake message failed"
3371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003372run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003373 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003374 "$O_CLI -key data_files/server5.key \
3375 -cert data_files/server5.ku-ds.crt" \
3376 0 \
3377 -S "bad certificate (usage extensions)" \
3378 -S "Processing of the Certificate handshake message failed"
3379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003380run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003381 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003382 "$O_CLI -key data_files/server5.key \
3383 -cert data_files/server5.ku-ka.crt" \
3384 0 \
3385 -s "bad certificate (usage extensions)" \
3386 -S "Processing of the Certificate handshake message failed"
3387
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003388# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003390run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003391 "$P_SRV key_file=data_files/server5.key \
3392 crt_file=data_files/server5.eku-srv.crt" \
3393 "$P_CLI" \
3394 0
3395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003396run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003397 "$P_SRV key_file=data_files/server5.key \
3398 crt_file=data_files/server5.eku-srv.crt" \
3399 "$P_CLI" \
3400 0
3401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003402run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003403 "$P_SRV key_file=data_files/server5.key \
3404 crt_file=data_files/server5.eku-cs_any.crt" \
3405 "$P_CLI" \
3406 0
3407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003408run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003409 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003410 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003411 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003412 1
3413
3414# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003416run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003417 "$O_SRV -key data_files/server5.key \
3418 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003419 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003420 0 \
3421 -C "bad certificate (usage extensions)" \
3422 -C "Processing of the Certificate handshake message failed" \
3423 -c "Ciphersuite is TLS-"
3424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003425run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003426 "$O_SRV -key data_files/server5.key \
3427 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003428 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003429 0 \
3430 -C "bad certificate (usage extensions)" \
3431 -C "Processing of the Certificate handshake message failed" \
3432 -c "Ciphersuite is TLS-"
3433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003434run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003435 "$O_SRV -key data_files/server5.key \
3436 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003437 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003438 0 \
3439 -C "bad certificate (usage extensions)" \
3440 -C "Processing of the Certificate handshake message failed" \
3441 -c "Ciphersuite is TLS-"
3442
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003443run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003444 "$O_SRV -key data_files/server5.key \
3445 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003446 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003447 1 \
3448 -c "bad certificate (usage extensions)" \
3449 -c "Processing of the Certificate handshake message failed" \
3450 -C "Ciphersuite is TLS-"
3451
3452# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003454run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003455 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003456 "$O_CLI -key data_files/server5.key \
3457 -cert data_files/server5.eku-cli.crt" \
3458 0 \
3459 -S "bad certificate (usage extensions)" \
3460 -S "Processing of the Certificate handshake message failed"
3461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003462run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003463 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003464 "$O_CLI -key data_files/server5.key \
3465 -cert data_files/server5.eku-srv_cli.crt" \
3466 0 \
3467 -S "bad certificate (usage extensions)" \
3468 -S "Processing of the Certificate handshake message failed"
3469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003470run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003471 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003472 "$O_CLI -key data_files/server5.key \
3473 -cert data_files/server5.eku-cs_any.crt" \
3474 0 \
3475 -S "bad certificate (usage extensions)" \
3476 -S "Processing of the Certificate handshake message failed"
3477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003478run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003479 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003480 "$O_CLI -key data_files/server5.key \
3481 -cert data_files/server5.eku-cs.crt" \
3482 0 \
3483 -s "bad certificate (usage extensions)" \
3484 -S "Processing of the Certificate handshake message failed"
3485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003486run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003487 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003488 "$O_CLI -key data_files/server5.key \
3489 -cert data_files/server5.eku-cs.crt" \
3490 1 \
3491 -s "bad certificate (usage extensions)" \
3492 -s "Processing of the Certificate handshake message failed"
3493
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003494# Tests for DHM parameters loading
3495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003496run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003497 "$P_SRV" \
3498 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3499 debug_level=3" \
3500 0 \
3501 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003502 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003504run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003505 "$P_SRV dhm_file=data_files/dhparams.pem" \
3506 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3507 debug_level=3" \
3508 0 \
3509 -c "value of 'DHM: P ' (1024 bits)" \
3510 -c "value of 'DHM: G ' (2 bits)"
3511
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003512# Tests for DHM client-side size checking
3513
3514run_test "DHM size: server default, client default, OK" \
3515 "$P_SRV" \
3516 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3517 debug_level=1" \
3518 0 \
3519 -C "DHM prime too short:"
3520
3521run_test "DHM size: server default, client 2048, OK" \
3522 "$P_SRV" \
3523 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3524 debug_level=1 dhmlen=2048" \
3525 0 \
3526 -C "DHM prime too short:"
3527
3528run_test "DHM size: server 1024, client default, OK" \
3529 "$P_SRV dhm_file=data_files/dhparams.pem" \
3530 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3531 debug_level=1" \
3532 0 \
3533 -C "DHM prime too short:"
3534
3535run_test "DHM size: server 1000, client default, rejected" \
3536 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3537 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3538 debug_level=1" \
3539 1 \
3540 -c "DHM prime too short:"
3541
3542run_test "DHM size: server default, client 2049, rejected" \
3543 "$P_SRV" \
3544 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3545 debug_level=1 dhmlen=2049" \
3546 1 \
3547 -c "DHM prime too short:"
3548
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003549# Tests for PSK callback
3550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003551run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003552 "$P_SRV psk=abc123 psk_identity=foo" \
3553 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3554 psk_identity=foo psk=abc123" \
3555 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003556 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003557 -S "SSL - Unknown identity received" \
3558 -S "SSL - Verification of the message MAC failed"
3559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003560run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003561 "$P_SRV" \
3562 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3563 psk_identity=foo psk=abc123" \
3564 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003565 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003566 -S "SSL - Unknown identity received" \
3567 -S "SSL - Verification of the message MAC failed"
3568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003569run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003570 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3571 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3572 psk_identity=foo psk=abc123" \
3573 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003574 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003575 -s "SSL - Unknown identity received" \
3576 -S "SSL - Verification of the message MAC failed"
3577
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003578run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003579 "$P_SRV psk_list=abc,dead,def,beef" \
3580 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3581 psk_identity=abc psk=dead" \
3582 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003583 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003584 -S "SSL - Unknown identity received" \
3585 -S "SSL - Verification of the message MAC failed"
3586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003587run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003588 "$P_SRV psk_list=abc,dead,def,beef" \
3589 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3590 psk_identity=def psk=beef" \
3591 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003592 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003593 -S "SSL - Unknown identity received" \
3594 -S "SSL - Verification of the message MAC failed"
3595
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003596run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003597 "$P_SRV psk_list=abc,dead,def,beef" \
3598 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3599 psk_identity=ghi psk=beef" \
3600 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003601 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003602 -s "SSL - Unknown identity received" \
3603 -S "SSL - Verification of the message MAC failed"
3604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003605run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003606 "$P_SRV psk_list=abc,dead,def,beef" \
3607 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3608 psk_identity=abc psk=beef" \
3609 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003610 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003611 -S "SSL - Unknown identity received" \
3612 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003613
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003614# Tests for EC J-PAKE
3615
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003616requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003617run_test "ECJPAKE: client not configured" \
3618 "$P_SRV debug_level=3" \
3619 "$P_CLI debug_level=3" \
3620 0 \
3621 -C "add ciphersuite: c0ff" \
3622 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003623 -S "found ecjpake kkpp extension" \
3624 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003625 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003626 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003627 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003628 -S "None of the common ciphersuites is usable"
3629
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003630requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003631run_test "ECJPAKE: server not configured" \
3632 "$P_SRV debug_level=3" \
3633 "$P_CLI debug_level=3 ecjpake_pw=bla \
3634 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3635 1 \
3636 -c "add ciphersuite: c0ff" \
3637 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003638 -s "found ecjpake kkpp extension" \
3639 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003640 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003641 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003642 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003643 -s "None of the common ciphersuites is usable"
3644
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003645requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003646run_test "ECJPAKE: working, TLS" \
3647 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3648 "$P_CLI debug_level=3 ecjpake_pw=bla \
3649 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003650 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003651 -c "add ciphersuite: c0ff" \
3652 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003653 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003654 -s "found ecjpake kkpp extension" \
3655 -S "skip ecjpake kkpp extension" \
3656 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003657 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003658 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003659 -S "None of the common ciphersuites is usable" \
3660 -S "SSL - Verification of the message MAC failed"
3661
Janos Follath74537a62016-09-02 13:45:28 +01003662server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003663requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003664run_test "ECJPAKE: password mismatch, TLS" \
3665 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3666 "$P_CLI debug_level=3 ecjpake_pw=bad \
3667 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3668 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003669 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003670 -s "SSL - Verification of the message MAC failed"
3671
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003672requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003673run_test "ECJPAKE: working, DTLS" \
3674 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3675 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3676 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3677 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003678 -c "re-using cached ecjpake parameters" \
3679 -S "SSL - Verification of the message MAC failed"
3680
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003681requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003682run_test "ECJPAKE: working, DTLS, no cookie" \
3683 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3684 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3685 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3686 0 \
3687 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003688 -S "SSL - Verification of the message MAC failed"
3689
Janos Follath74537a62016-09-02 13:45:28 +01003690server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003691requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003692run_test "ECJPAKE: password mismatch, DTLS" \
3693 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3694 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3695 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3696 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003697 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003698 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003699
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003700# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003701requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003702run_test "ECJPAKE: working, DTLS, nolog" \
3703 "$P_SRV dtls=1 ecjpake_pw=bla" \
3704 "$P_CLI dtls=1 ecjpake_pw=bla \
3705 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3706 0
3707
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003708# Tests for ciphersuites per version
3709
Janos Follathe2681a42016-03-07 15:57:05 +00003710requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003711requires_config_enabled MBEDTLS_CAMELLIA_C
3712requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003713run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003714 "$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 +02003715 "$P_CLI force_version=ssl3" \
3716 0 \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003717 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003718
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003719requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
3720requires_config_enabled MBEDTLS_CAMELLIA_C
3721requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003722run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003723 "$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 +01003724 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003725 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003726 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003727
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003728requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
3729requires_config_enabled MBEDTLS_CAMELLIA_C
3730requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003731run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003732 "$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 +02003733 "$P_CLI force_version=tls1_1" \
3734 0 \
3735 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3736
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003737requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
3738requires_config_enabled MBEDTLS_CAMELLIA_C
3739requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003740run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003741 "$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 +02003742 "$P_CLI force_version=tls1_2" \
3743 0 \
3744 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3745
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003746# Test for ClientHello without extensions
3747
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003748requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003749run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003750 "$P_SRV debug_level=3" \
3751 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3752 0 \
3753 -s "dumping 'client hello extensions' (0 bytes)"
3754
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003755requires_gnutls
3756run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3757 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3758 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3759 0 \
3760 -s "dumping 'client hello extensions' (0 bytes)"
3761
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003762# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003763
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003764run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003765 "$P_SRV" \
3766 "$P_CLI request_size=100" \
3767 0 \
3768 -s "Read from client: 100 bytes read$"
3769
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003770run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003771 "$P_SRV" \
3772 "$P_CLI request_size=500" \
3773 0 \
3774 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003775
Andrzej Kurekd731a632018-06-19 09:37:30 -04003776# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003777
Janos Follathe2681a42016-03-07 15:57:05 +00003778requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekd731a632018-06-19 09:37:30 -04003779run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003780 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003781 "$P_CLI request_size=1 force_version=ssl3 \
3782 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3783 0 \
3784 -s "Read from client: 1 bytes read"
3785
Janos Follathe2681a42016-03-07 15:57:05 +00003786requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekd731a632018-06-19 09:37:30 -04003787run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003788 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003789 "$P_CLI request_size=1 force_version=ssl3 \
3790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3791 0 \
3792 -s "Read from client: 1 bytes read"
3793
Andrzej Kurekd731a632018-06-19 09:37:30 -04003794run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003795 "$P_SRV" \
3796 "$P_CLI request_size=1 force_version=tls1 \
3797 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3798 0 \
3799 -s "Read from client: 1 bytes read"
3800
Andrzej Kurekd731a632018-06-19 09:37:30 -04003801run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003802 "$P_SRV" \
3803 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3804 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3805 0 \
3806 -s "Read from client: 1 bytes read"
3807
Hanno Becker32c55012017-11-10 08:42:54 +00003808requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003809run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003810 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003811 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003812 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003813 0 \
3814 -s "Read from client: 1 bytes read"
3815
Hanno Becker32c55012017-11-10 08:42:54 +00003816requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003817run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003818 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003819 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003820 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003821 0 \
3822 -s "Read from client: 1 bytes read"
3823
Andrzej Kurekd731a632018-06-19 09:37:30 -04003824run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003825 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003826 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003827 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3828 0 \
3829 -s "Read from client: 1 bytes read"
3830
Andrzej Kurekd731a632018-06-19 09:37:30 -04003831run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003832 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3833 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003834 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003835 0 \
3836 -s "Read from client: 1 bytes read"
3837
3838requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003839run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003840 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003841 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003842 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003843 0 \
3844 -s "Read from client: 1 bytes read"
3845
Hanno Becker8501f982017-11-10 08:59:04 +00003846requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003847run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003848 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3849 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3850 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003851 0 \
3852 -s "Read from client: 1 bytes read"
3853
Andrzej Kurekd731a632018-06-19 09:37:30 -04003854run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003855 "$P_SRV" \
3856 "$P_CLI request_size=1 force_version=tls1_1 \
3857 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3858 0 \
3859 -s "Read from client: 1 bytes read"
3860
Andrzej Kurekd731a632018-06-19 09:37:30 -04003861run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003862 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003863 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003864 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003865 0 \
3866 -s "Read from client: 1 bytes read"
3867
3868requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003869run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003870 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003871 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003872 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003873 0 \
3874 -s "Read from client: 1 bytes read"
3875
3876requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003877run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003878 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003879 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003880 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003881 0 \
3882 -s "Read from client: 1 bytes read"
3883
Andrzej Kurekd731a632018-06-19 09:37:30 -04003884run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003885 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003886 "$P_CLI request_size=1 force_version=tls1_1 \
3887 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3888 0 \
3889 -s "Read from client: 1 bytes read"
3890
Andrzej Kurekd731a632018-06-19 09:37:30 -04003891run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003892 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003893 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003894 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003895 0 \
3896 -s "Read from client: 1 bytes read"
3897
Hanno Becker8501f982017-11-10 08:59:04 +00003898requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003899run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003900 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003901 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003902 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003903 0 \
3904 -s "Read from client: 1 bytes read"
3905
Hanno Becker32c55012017-11-10 08:42:54 +00003906requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003907run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003908 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003909 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003910 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003911 0 \
3912 -s "Read from client: 1 bytes read"
3913
Andrzej Kurekd731a632018-06-19 09:37:30 -04003914run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003915 "$P_SRV" \
3916 "$P_CLI request_size=1 force_version=tls1_2 \
3917 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3918 0 \
3919 -s "Read from client: 1 bytes read"
3920
Andrzej Kurekd731a632018-06-19 09:37:30 -04003921run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003922 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003923 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003924 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003925 0 \
3926 -s "Read from client: 1 bytes read"
3927
Andrzej Kurekd731a632018-06-19 09:37:30 -04003928run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003929 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003930 "$P_CLI request_size=1 force_version=tls1_2 \
3931 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003932 0 \
3933 -s "Read from client: 1 bytes read"
3934
Hanno Becker32c55012017-11-10 08:42:54 +00003935requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003936run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003937 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003938 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003939 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003940 0 \
3941 -s "Read from client: 1 bytes read"
3942
Hanno Becker8501f982017-11-10 08:59:04 +00003943requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003944run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003945 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003946 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003947 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003948 0 \
3949 -s "Read from client: 1 bytes read"
3950
Andrzej Kurekd731a632018-06-19 09:37:30 -04003951run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003952 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003953 "$P_CLI request_size=1 force_version=tls1_2 \
3954 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3955 0 \
3956 -s "Read from client: 1 bytes read"
3957
Andrzej Kurekd731a632018-06-19 09:37:30 -04003958run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003959 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003960 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003961 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003962 0 \
3963 -s "Read from client: 1 bytes read"
3964
Hanno Becker32c55012017-11-10 08:42:54 +00003965requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003966run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003967 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003968 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003969 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003970 0 \
3971 -s "Read from client: 1 bytes read"
3972
Hanno Becker8501f982017-11-10 08:59:04 +00003973requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003974run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003975 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003976 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003977 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003978 0 \
3979 -s "Read from client: 1 bytes read"
3980
Andrzej Kurekd731a632018-06-19 09:37:30 -04003981run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003982 "$P_SRV" \
3983 "$P_CLI request_size=1 force_version=tls1_2 \
3984 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3985 0 \
3986 -s "Read from client: 1 bytes read"
3987
Andrzej Kurekd731a632018-06-19 09:37:30 -04003988run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003989 "$P_SRV" \
3990 "$P_CLI request_size=1 force_version=tls1_2 \
3991 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3992 0 \
3993 -s "Read from client: 1 bytes read"
3994
Andrzej Kurekd731a632018-06-19 09:37:30 -04003995# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00003996
3997requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04003998run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003999 "$P_SRV dtls=1 force_version=dtls1" \
4000 "$P_CLI dtls=1 request_size=1 \
4001 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4002 0 \
4003 -s "Read from client: 1 bytes read"
4004
4005requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004006run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004007 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4008 "$P_CLI dtls=1 request_size=1 \
4009 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4010 0 \
4011 -s "Read from client: 1 bytes read"
4012
4013requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4014requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004015run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004016 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4017 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004018 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4019 0 \
4020 -s "Read from client: 1 bytes read"
4021
4022requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4023requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004024run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004025 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004026 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004027 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004028 0 \
4029 -s "Read from client: 1 bytes read"
4030
4031requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004032run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004033 "$P_SRV dtls=1 force_version=dtls1_2" \
4034 "$P_CLI dtls=1 request_size=1 \
4035 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4036 0 \
4037 -s "Read from client: 1 bytes read"
4038
4039requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004040run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004041 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004042 "$P_CLI dtls=1 request_size=1 \
4043 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4044 0 \
4045 -s "Read from client: 1 bytes read"
4046
4047requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4048requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004049run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004050 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004051 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004052 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004053 0 \
4054 -s "Read from client: 1 bytes read"
4055
4056requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4057requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004058run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004059 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004060 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004061 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004062 0 \
4063 -s "Read from client: 1 bytes read"
4064
Andrzej Kurekd731a632018-06-19 09:37:30 -04004065# Tests for small server packets
4066
4067requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4068run_test "Small server packet SSLv3 BlockCipher" \
4069 "$P_SRV response_size=1 min_version=ssl3" \
4070 "$P_CLI force_version=ssl3 \
4071 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4072 0 \
4073 -c "Read from server: 1 bytes read"
4074
4075requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4076run_test "Small server packet SSLv3 StreamCipher" \
4077 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4078 "$P_CLI force_version=ssl3 \
4079 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4080 0 \
4081 -c "Read from server: 1 bytes read"
4082
4083run_test "Small server packet TLS 1.0 BlockCipher" \
4084 "$P_SRV response_size=1" \
4085 "$P_CLI force_version=tls1 \
4086 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4087 0 \
4088 -c "Read from server: 1 bytes read"
4089
4090run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4091 "$P_SRV response_size=1" \
4092 "$P_CLI force_version=tls1 etm=0 \
4093 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4094 0 \
4095 -c "Read from server: 1 bytes read"
4096
4097requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4098run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4099 "$P_SRV response_size=1 trunc_hmac=1" \
4100 "$P_CLI force_version=tls1 \
4101 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4102 0 \
4103 -c "Read from server: 1 bytes read"
4104
4105requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4106run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4107 "$P_SRV response_size=1 trunc_hmac=1" \
4108 "$P_CLI force_version=tls1 \
4109 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4110 0 \
4111 -c "Read from server: 1 bytes read"
4112
4113run_test "Small server packet TLS 1.0 StreamCipher" \
4114 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4115 "$P_CLI force_version=tls1 \
4116 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4117 0 \
4118 -c "Read from server: 1 bytes read"
4119
4120run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4121 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4122 "$P_CLI force_version=tls1 \
4123 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4124 0 \
4125 -c "Read from server: 1 bytes read"
4126
4127requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4128run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4129 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4130 "$P_CLI force_version=tls1 \
4131 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4132 0 \
4133 -c "Read from server: 1 bytes read"
4134
4135requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4136run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4137 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4138 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4139 trunc_hmac=1 etm=0" \
4140 0 \
4141 -c "Read from server: 1 bytes read"
4142
4143run_test "Small server packet TLS 1.1 BlockCipher" \
4144 "$P_SRV response_size=1" \
4145 "$P_CLI force_version=tls1_1 \
4146 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4147 0 \
4148 -c "Read from server: 1 bytes read"
4149
4150run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4151 "$P_SRV response_size=1" \
4152 "$P_CLI force_version=tls1_1 \
4153 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4154 0 \
4155 -c "Read from server: 1 bytes read"
4156
4157requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4158run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4159 "$P_SRV response_size=1 trunc_hmac=1" \
4160 "$P_CLI force_version=tls1_1 \
4161 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4162 0 \
4163 -c "Read from server: 1 bytes read"
4164
4165requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4166run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4167 "$P_SRV response_size=1 trunc_hmac=1" \
4168 "$P_CLI force_version=tls1_1 \
4169 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4170 0 \
4171 -c "Read from server: 1 bytes read"
4172
4173run_test "Small server packet TLS 1.1 StreamCipher" \
4174 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4175 "$P_CLI force_version=tls1_1 \
4176 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4177 0 \
4178 -c "Read from server: 1 bytes read"
4179
4180run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4181 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4182 "$P_CLI force_version=tls1_1 \
4183 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4184 0 \
4185 -c "Read from server: 1 bytes read"
4186
4187requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4188run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4189 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4190 "$P_CLI force_version=tls1_1 \
4191 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4192 0 \
4193 -c "Read from server: 1 bytes read"
4194
4195requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4196run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4197 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4198 "$P_CLI force_version=tls1_1 \
4199 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4200 0 \
4201 -c "Read from server: 1 bytes read"
4202
4203run_test "Small server packet TLS 1.2 BlockCipher" \
4204 "$P_SRV response_size=1" \
4205 "$P_CLI force_version=tls1_2 \
4206 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4207 0 \
4208 -c "Read from server: 1 bytes read"
4209
4210run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4211 "$P_SRV response_size=1" \
4212 "$P_CLI force_version=tls1_2 \
4213 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4214 0 \
4215 -c "Read from server: 1 bytes read"
4216
4217run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4218 "$P_SRV response_size=1" \
4219 "$P_CLI force_version=tls1_2 \
4220 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4221 0 \
4222 -c "Read from server: 1 bytes read"
4223
4224requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4225run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4226 "$P_SRV response_size=1 trunc_hmac=1" \
4227 "$P_CLI force_version=tls1_2 \
4228 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4229 0 \
4230 -c "Read from server: 1 bytes read"
4231
4232requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4233run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4234 "$P_SRV response_size=1 trunc_hmac=1" \
4235 "$P_CLI force_version=tls1_2 \
4236 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4237 0 \
4238 -c "Read from server: 1 bytes read"
4239
4240run_test "Small server packet TLS 1.2 StreamCipher" \
4241 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4242 "$P_CLI force_version=tls1_2 \
4243 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4244 0 \
4245 -c "Read from server: 1 bytes read"
4246
4247run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4248 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4249 "$P_CLI force_version=tls1_2 \
4250 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4251 0 \
4252 -c "Read from server: 1 bytes read"
4253
4254requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4255run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4256 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4257 "$P_CLI force_version=tls1_2 \
4258 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4259 0 \
4260 -c "Read from server: 1 bytes read"
4261
4262requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4263run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4264 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4265 "$P_CLI force_version=tls1_2 \
4266 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4267 0 \
4268 -c "Read from server: 1 bytes read"
4269
4270run_test "Small server packet TLS 1.2 AEAD" \
4271 "$P_SRV response_size=1" \
4272 "$P_CLI force_version=tls1_2 \
4273 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4274 0 \
4275 -c "Read from server: 1 bytes read"
4276
4277run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4278 "$P_SRV response_size=1" \
4279 "$P_CLI force_version=tls1_2 \
4280 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4281 0 \
4282 -c "Read from server: 1 bytes read"
4283
4284# Tests for small server packets in DTLS
4285
4286requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4287run_test "Small server packet DTLS 1.0" \
4288 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4289 "$P_CLI dtls=1 \
4290 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4291 0 \
4292 -c "Read from server: 1 bytes read"
4293
4294requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4295run_test "Small server packet DTLS 1.0, without EtM" \
4296 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4297 "$P_CLI dtls=1 \
4298 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4299 0 \
4300 -c "Read from server: 1 bytes read"
4301
4302requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4303requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4304run_test "Small server packet DTLS 1.0, truncated hmac" \
4305 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4306 "$P_CLI dtls=1 trunc_hmac=1 \
4307 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4308 0 \
4309 -c "Read from server: 1 bytes read"
4310
4311requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4312requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4313run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4314 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4315 "$P_CLI dtls=1 \
4316 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4317 0 \
4318 -c "Read from server: 1 bytes read"
4319
4320requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4321run_test "Small server packet DTLS 1.2" \
4322 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4323 "$P_CLI dtls=1 \
4324 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4325 0 \
4326 -c "Read from server: 1 bytes read"
4327
4328requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4329run_test "Small server packet DTLS 1.2, without EtM" \
4330 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4331 "$P_CLI dtls=1 \
4332 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4333 0 \
4334 -c "Read from server: 1 bytes read"
4335
4336requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4337requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4338run_test "Small server packet DTLS 1.2, truncated hmac" \
4339 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4340 "$P_CLI dtls=1 \
4341 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4342 0 \
4343 -c "Read from server: 1 bytes read"
4344
4345requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4346requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4347run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4348 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4349 "$P_CLI dtls=1 \
4350 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4351 0 \
4352 -c "Read from server: 1 bytes read"
4353
Janos Follath00efff72016-05-06 13:48:23 +01004354# A test for extensions in SSLv3
4355
4356requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4357run_test "SSLv3 with extensions, server side" \
4358 "$P_SRV min_version=ssl3 debug_level=3" \
4359 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4360 0 \
4361 -S "dumping 'client hello extensions'" \
4362 -S "server hello, total extension length:"
4363
Andrzej Kurek557335e2018-06-28 04:03:10 -04004364# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004365
Janos Follathe2681a42016-03-07 15:57:05 +00004366requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek557335e2018-06-28 04:03:10 -04004367run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004368 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004369 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004370 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4371 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004372 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004373 -s "Read from client: 16384 bytes read"
4374
Janos Follathe2681a42016-03-07 15:57:05 +00004375requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek557335e2018-06-28 04:03:10 -04004376run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004377 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004378 "$P_CLI request_size=16384 force_version=ssl3 \
4379 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4380 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004381 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004382 -s "Read from client: 16384 bytes read"
4383
Andrzej Kurek557335e2018-06-28 04:03:10 -04004384run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004385 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004386 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004387 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4388 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004389 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004390 -s "Read from client: 16384 bytes read"
4391
Andrzej Kurek557335e2018-06-28 04:03:10 -04004392run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004393 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004394 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4395 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4396 0 \
4397 -s "Read from client: 16384 bytes read"
4398
Hanno Becker32c55012017-11-10 08:42:54 +00004399requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004400run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004401 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004402 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004403 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004404 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004405 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004406 -s "Read from client: 16384 bytes read"
4407
Hanno Becker32c55012017-11-10 08:42:54 +00004408requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004409run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004410 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004411 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004412 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004413 0 \
4414 -s "Read from client: 16384 bytes read"
4415
Andrzej Kurek557335e2018-06-28 04:03:10 -04004416run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004417 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004418 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004419 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4420 0 \
4421 -s "Read from client: 16384 bytes read"
4422
Andrzej Kurek557335e2018-06-28 04:03:10 -04004423run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004424 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4425 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004426 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004427 0 \
4428 -s "Read from client: 16384 bytes read"
4429
4430requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004431run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004432 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004433 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004434 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004435 0 \
4436 -s "Read from client: 16384 bytes read"
4437
Hanno Becker278fc7a2017-11-10 09:16:28 +00004438requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004439run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004440 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004441 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004442 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004443 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004444 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004445 -s "Read from client: 16384 bytes read"
4446
Andrzej Kurek557335e2018-06-28 04:03:10 -04004447run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004448 "$P_SRV" \
4449 "$P_CLI request_size=16384 force_version=tls1_1 \
4450 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4451 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004452 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004453 -s "Read from client: 16384 bytes read"
4454
Andrzej Kurek557335e2018-06-28 04:03:10 -04004455run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004456 "$P_SRV" \
4457 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4458 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004459 0 \
4460 -s "Read from client: 16384 bytes read"
4461
Hanno Becker32c55012017-11-10 08:42:54 +00004462requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004463run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004464 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004465 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004466 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004467 0 \
4468 -s "Read from client: 16384 bytes read"
4469
Hanno Becker32c55012017-11-10 08:42:54 +00004470requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004471run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004472 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004473 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004474 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004475 0 \
4476 -s "Read from client: 16384 bytes read"
4477
Andrzej Kurek557335e2018-06-28 04:03:10 -04004478run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004479 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4480 "$P_CLI request_size=16384 force_version=tls1_1 \
4481 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4482 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004483 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004484 -s "Read from client: 16384 bytes read"
4485
Andrzej Kurek557335e2018-06-28 04:03:10 -04004486run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004487 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004488 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004489 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004490 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004491 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004492 -s "Read from client: 16384 bytes read"
4493
Hanno Becker278fc7a2017-11-10 09:16:28 +00004494requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004495run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004496 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004497 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004498 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004499 0 \
4500 -s "Read from client: 16384 bytes read"
4501
Hanno Becker278fc7a2017-11-10 09:16:28 +00004502requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004503run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004504 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004505 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004506 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004507 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004508 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004509 -s "Read from client: 16384 bytes read"
4510
Andrzej Kurek557335e2018-06-28 04:03:10 -04004511run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004512 "$P_SRV" \
4513 "$P_CLI request_size=16384 force_version=tls1_2 \
4514 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4515 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004516 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004517 -s "Read from client: 16384 bytes read"
4518
Andrzej Kurek557335e2018-06-28 04:03:10 -04004519run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004520 "$P_SRV" \
4521 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4522 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4523 0 \
4524 -s "Read from client: 16384 bytes read"
4525
Andrzej Kurek557335e2018-06-28 04:03:10 -04004526run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004527 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004528 "$P_CLI request_size=16384 force_version=tls1_2 \
4529 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004530 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004531 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004532 -s "Read from client: 16384 bytes read"
4533
Hanno Becker32c55012017-11-10 08:42:54 +00004534requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004535run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004536 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004537 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004538 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004539 0 \
4540 -s "Read from client: 16384 bytes read"
4541
Hanno Becker278fc7a2017-11-10 09:16:28 +00004542requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004543run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004544 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004545 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004546 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004547 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004548 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004549 -s "Read from client: 16384 bytes read"
4550
Andrzej Kurek557335e2018-06-28 04:03:10 -04004551run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004552 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004553 "$P_CLI request_size=16384 force_version=tls1_2 \
4554 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4555 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004556 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004557 -s "Read from client: 16384 bytes read"
4558
Andrzej Kurek557335e2018-06-28 04:03:10 -04004559run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004560 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004561 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004562 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4563 0 \
4564 -s "Read from client: 16384 bytes read"
4565
Hanno Becker32c55012017-11-10 08:42:54 +00004566requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004567run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004568 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004569 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004570 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004571 0 \
4572 -s "Read from client: 16384 bytes read"
4573
Hanno Becker278fc7a2017-11-10 09:16:28 +00004574requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004575run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004576 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004577 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004578 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004579 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004580 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004581 -s "Read from client: 16384 bytes read"
4582
Andrzej Kurek557335e2018-06-28 04:03:10 -04004583run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004584 "$P_SRV" \
4585 "$P_CLI request_size=16384 force_version=tls1_2 \
4586 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4587 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004588 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004589 -s "Read from client: 16384 bytes read"
4590
Andrzej Kurek557335e2018-06-28 04:03:10 -04004591run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004592 "$P_SRV" \
4593 "$P_CLI request_size=16384 force_version=tls1_2 \
4594 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4595 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004596 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004597 -s "Read from client: 16384 bytes read"
4598
Ron Eldorc7f15232018-06-28 13:22:05 +03004599# Tests for ECC extensions (rfc 4492)
4600
Ron Eldor94226d82018-06-28 16:17:00 +03004601requires_config_enabled MBEDTLS_AES_C
4602requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4603requires_config_enabled MBEDTLS_SHA256_C
4604requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004605run_test "Force a non ECC ciphersuite in the client side" \
4606 "$P_SRV debug_level=3" \
Ron Eldor94226d82018-06-28 16:17:00 +03004607 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004608 0 \
4609 -C "client hello, adding supported_elliptic_curves extension" \
4610 -C "client hello, adding supported_point_formats extension" \
4611 -S "found supported elliptic curves extension" \
4612 -S "found supported point formats extension"
4613
Ron Eldor94226d82018-06-28 16:17:00 +03004614requires_config_enabled MBEDTLS_AES_C
4615requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4616requires_config_enabled MBEDTLS_SHA256_C
4617requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004618run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor94226d82018-06-28 16:17:00 +03004619 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004620 "$P_CLI debug_level=3" \
4621 0 \
4622 -C "found supported_point_formats extension" \
4623 -S "server hello, supported_point_formats extension"
4624
Ron Eldor94226d82018-06-28 16:17:00 +03004625requires_config_enabled MBEDTLS_AES_C
4626requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4627requires_config_enabled MBEDTLS_SHA256_C
4628requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004629run_test "Force an ECC ciphersuite in the client side" \
4630 "$P_SRV debug_level=3" \
4631 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4632 0 \
4633 -c "client hello, adding supported_elliptic_curves extension" \
4634 -c "client hello, adding supported_point_formats extension" \
4635 -s "found supported elliptic curves extension" \
4636 -s "found supported point formats extension"
4637
Ron Eldor94226d82018-06-28 16:17:00 +03004638requires_config_enabled MBEDTLS_AES_C
4639requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4640requires_config_enabled MBEDTLS_SHA256_C
4641requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004642run_test "Force an ECC ciphersuite in the server side" \
4643 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4644 "$P_CLI debug_level=3" \
4645 0 \
4646 -c "found supported_point_formats extension" \
4647 -s "server hello, supported_point_formats extension"
4648
Andrzej Kurek557335e2018-06-28 04:03:10 -04004649# Test for large server packets
Andrzej Kurek557335e2018-06-28 04:03:10 -04004650requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4651run_test "Large server packet SSLv3 StreamCipher" \
4652 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4653 "$P_CLI force_version=ssl3 \
4654 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4655 0 \
4656 -c "Read from server: 16384 bytes read"
4657
Andrzej Kurekc8958212018-08-27 08:00:13 -04004658# Checking next 4 tests logs for 1n-1 split against BEAST too
4659requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4660run_test "Large server packet SSLv3 BlockCipher" \
4661 "$P_SRV response_size=16384 min_version=ssl3" \
4662 "$P_CLI force_version=ssl3 recsplit=0 \
4663 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4664 0 \
4665 -c "Read from server: 1 bytes read"\
4666 -c "16383 bytes read"\
4667 -C "Read from server: 16384 bytes read"
4668
Andrzej Kurek557335e2018-06-28 04:03:10 -04004669run_test "Large server packet TLS 1.0 BlockCipher" \
4670 "$P_SRV response_size=16384" \
4671 "$P_CLI force_version=tls1 recsplit=0 \
4672 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4673 0 \
4674 -c "Read from server: 1 bytes read"\
4675 -c "16383 bytes read"\
4676 -C "Read from server: 16384 bytes read"
4677
Andrzej Kurekd731a632018-06-19 09:37:30 -04004678run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
4679 "$P_SRV response_size=16384" \
4680 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
4681 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4682 0 \
4683 -c "Read from server: 1 bytes read"\
4684 -c "16383 bytes read"\
4685 -C "Read from server: 16384 bytes read"
4686
Andrzej Kurek557335e2018-06-28 04:03:10 -04004687requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4688run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
4689 "$P_SRV response_size=16384" \
4690 "$P_CLI force_version=tls1 recsplit=0 \
4691 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4692 trunc_hmac=1" \
4693 0 \
4694 -c "Read from server: 1 bytes read"\
4695 -c "16383 bytes read"\
4696 -C "Read from server: 16384 bytes read"
4697
4698requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4699run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
4700 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4701 "$P_CLI force_version=tls1 \
4702 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4703 trunc_hmac=1" \
4704 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004705 -s "16384 bytes written in 1 fragments" \
4706 -c "Read from server: 16384 bytes read"
4707
4708run_test "Large server packet TLS 1.0 StreamCipher" \
4709 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4710 "$P_CLI force_version=tls1 \
4711 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4712 0 \
4713 -s "16384 bytes written in 1 fragments" \
4714 -c "Read from server: 16384 bytes read"
4715
4716run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
4717 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4718 "$P_CLI force_version=tls1 \
4719 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4720 0 \
4721 -s "16384 bytes written in 1 fragments" \
4722 -c "Read from server: 16384 bytes read"
4723
4724requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4725run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
4726 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4727 "$P_CLI force_version=tls1 \
4728 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4729 0 \
4730 -s "16384 bytes written in 1 fragments" \
4731 -c "Read from server: 16384 bytes read"
4732
4733requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4734run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4735 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4736 "$P_CLI force_version=tls1 \
4737 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4738 0 \
4739 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004740 -c "Read from server: 16384 bytes read"
4741
4742run_test "Large server packet TLS 1.1 BlockCipher" \
4743 "$P_SRV response_size=16384" \
4744 "$P_CLI force_version=tls1_1 \
4745 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4746 0 \
4747 -c "Read from server: 16384 bytes read"
4748
Andrzej Kurekd731a632018-06-19 09:37:30 -04004749run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
4750 "$P_SRV response_size=16384" \
4751 "$P_CLI force_version=tls1_1 etm=0 \
4752 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004753 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004754 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004755 -c "Read from server: 16384 bytes read"
4756
4757requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4758run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
4759 "$P_SRV response_size=16384" \
4760 "$P_CLI force_version=tls1_1 \
4761 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4762 trunc_hmac=1" \
4763 0 \
4764 -c "Read from server: 16384 bytes read"
4765
4766requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004767run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4768 "$P_SRV response_size=16384 trunc_hmac=1" \
4769 "$P_CLI force_version=tls1_1 \
4770 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4771 0 \
4772 -s "16384 bytes written in 1 fragments" \
4773 -c "Read from server: 16384 bytes read"
4774
4775run_test "Large server packet TLS 1.1 StreamCipher" \
4776 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4777 "$P_CLI force_version=tls1_1 \
4778 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4779 0 \
4780 -c "Read from server: 16384 bytes read"
4781
4782run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
4783 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4784 "$P_CLI force_version=tls1_1 \
4785 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4786 0 \
4787 -s "16384 bytes written in 1 fragments" \
4788 -c "Read from server: 16384 bytes read"
4789
4790requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004791run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
4792 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4793 "$P_CLI force_version=tls1_1 \
4794 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4795 trunc_hmac=1" \
4796 0 \
4797 -c "Read from server: 16384 bytes read"
4798
Andrzej Kurekd731a632018-06-19 09:37:30 -04004799run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4800 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4801 "$P_CLI force_version=tls1_1 \
4802 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4803 0 \
4804 -s "16384 bytes written in 1 fragments" \
4805 -c "Read from server: 16384 bytes read"
4806
Andrzej Kurek557335e2018-06-28 04:03:10 -04004807run_test "Large server packet TLS 1.2 BlockCipher" \
4808 "$P_SRV response_size=16384" \
4809 "$P_CLI force_version=tls1_2 \
4810 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4811 0 \
4812 -c "Read from server: 16384 bytes read"
4813
Andrzej Kurekd731a632018-06-19 09:37:30 -04004814run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
4815 "$P_SRV response_size=16384" \
4816 "$P_CLI force_version=tls1_2 etm=0 \
4817 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4818 0 \
4819 -s "16384 bytes written in 1 fragments" \
4820 -c "Read from server: 16384 bytes read"
4821
Andrzej Kurek557335e2018-06-28 04:03:10 -04004822run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
4823 "$P_SRV response_size=16384" \
4824 "$P_CLI force_version=tls1_2 \
4825 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4826 0 \
4827 -c "Read from server: 16384 bytes read"
4828
4829requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4830run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
4831 "$P_SRV response_size=16384" \
4832 "$P_CLI force_version=tls1_2 \
4833 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4834 trunc_hmac=1" \
4835 0 \
4836 -c "Read from server: 16384 bytes read"
4837
Andrzej Kurekd731a632018-06-19 09:37:30 -04004838run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4839 "$P_SRV response_size=16384 trunc_hmac=1" \
4840 "$P_CLI force_version=tls1_2 \
4841 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4842 0 \
4843 -s "16384 bytes written in 1 fragments" \
4844 -c "Read from server: 16384 bytes read"
4845
Andrzej Kurek557335e2018-06-28 04:03:10 -04004846run_test "Large server packet TLS 1.2 StreamCipher" \
4847 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4848 "$P_CLI force_version=tls1_2 \
4849 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4850 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004851 -s "16384 bytes written in 1 fragments" \
4852 -c "Read from server: 16384 bytes read"
4853
4854run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
4855 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4856 "$P_CLI force_version=tls1_2 \
4857 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4858 0 \
4859 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004860 -c "Read from server: 16384 bytes read"
4861
4862requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4863run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
4864 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4865 "$P_CLI force_version=tls1_2 \
4866 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4867 trunc_hmac=1" \
4868 0 \
4869 -c "Read from server: 16384 bytes read"
4870
Andrzej Kurekd731a632018-06-19 09:37:30 -04004871requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4872run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4873 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4874 "$P_CLI force_version=tls1_2 \
4875 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4876 0 \
4877 -s "16384 bytes written in 1 fragments" \
4878 -c "Read from server: 16384 bytes read"
4879
Andrzej Kurek557335e2018-06-28 04:03:10 -04004880run_test "Large server packet TLS 1.2 AEAD" \
4881 "$P_SRV response_size=16384" \
4882 "$P_CLI force_version=tls1_2 \
4883 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4884 0 \
4885 -c "Read from server: 16384 bytes read"
4886
4887run_test "Large server packet TLS 1.2 AEAD shorter tag" \
4888 "$P_SRV response_size=16384" \
4889 "$P_CLI force_version=tls1_2 \
4890 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4891 0 \
4892 -c "Read from server: 16384 bytes read"
4893
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004894# Tests for DTLS HelloVerifyRequest
4895
4896run_test "DTLS cookie: enabled" \
4897 "$P_SRV dtls=1 debug_level=2" \
4898 "$P_CLI dtls=1 debug_level=2" \
4899 0 \
4900 -s "cookie verification failed" \
4901 -s "cookie verification passed" \
4902 -S "cookie verification skipped" \
4903 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004904 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004905 -S "SSL - The requested feature is not available"
4906
4907run_test "DTLS cookie: disabled" \
4908 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4909 "$P_CLI dtls=1 debug_level=2" \
4910 0 \
4911 -S "cookie verification failed" \
4912 -S "cookie verification passed" \
4913 -s "cookie verification skipped" \
4914 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004915 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004916 -S "SSL - The requested feature is not available"
4917
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004918run_test "DTLS cookie: default (failing)" \
4919 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4920 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4921 1 \
4922 -s "cookie verification failed" \
4923 -S "cookie verification passed" \
4924 -S "cookie verification skipped" \
4925 -C "received hello verify request" \
4926 -S "hello verification requested" \
4927 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004928
4929requires_ipv6
4930run_test "DTLS cookie: enabled, IPv6" \
4931 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4932 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4933 0 \
4934 -s "cookie verification failed" \
4935 -s "cookie verification passed" \
4936 -S "cookie verification skipped" \
4937 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004938 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004939 -S "SSL - The requested feature is not available"
4940
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004941run_test "DTLS cookie: enabled, nbio" \
4942 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4943 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4944 0 \
4945 -s "cookie verification failed" \
4946 -s "cookie verification passed" \
4947 -S "cookie verification skipped" \
4948 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004949 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004950 -S "SSL - The requested feature is not available"
4951
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004952# Tests for client reconnecting from the same port with DTLS
4953
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004954not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004955run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004956 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4957 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004958 0 \
4959 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004960 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004961 -S "Client initiated reconnection from same port"
4962
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004963not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004964run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004965 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4966 "$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 +02004967 0 \
4968 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004969 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004970 -s "Client initiated reconnection from same port"
4971
Paul Bakker362689d2016-05-13 10:33:25 +01004972not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4973run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004974 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4975 "$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 +02004976 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004977 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004978 -s "Client initiated reconnection from same port"
4979
Paul Bakker362689d2016-05-13 10:33:25 +01004980only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4981run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4982 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4983 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4984 0 \
4985 -S "The operation timed out" \
4986 -s "Client initiated reconnection from same port"
4987
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004988run_test "DTLS client reconnect from same port: no cookies" \
4989 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004990 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4991 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004992 -s "The operation timed out" \
4993 -S "Client initiated reconnection from same port"
4994
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004995# Tests for various cases of client authentication with DTLS
4996# (focused on handshake flows and message parsing)
4997
4998run_test "DTLS client auth: required" \
4999 "$P_SRV dtls=1 auth_mode=required" \
5000 "$P_CLI dtls=1" \
5001 0 \
5002 -s "Verifying peer X.509 certificate... ok"
5003
5004run_test "DTLS client auth: optional, client has no cert" \
5005 "$P_SRV dtls=1 auth_mode=optional" \
5006 "$P_CLI dtls=1 crt_file=none key_file=none" \
5007 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005008 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005009
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005010run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005011 "$P_SRV dtls=1 auth_mode=none" \
5012 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5013 0 \
5014 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005015 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005016
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005017run_test "DTLS wrong PSK: badmac alert" \
5018 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5019 "$P_CLI dtls=1 psk=abc124" \
5020 1 \
5021 -s "SSL - Verification of the message MAC failed" \
5022 -c "SSL - A fatal alert message was received from our peer"
5023
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005024# Tests for receiving fragmented handshake messages with DTLS
5025
5026requires_gnutls
5027run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5028 "$G_SRV -u --mtu 2048 -a" \
5029 "$P_CLI dtls=1 debug_level=2" \
5030 0 \
5031 -C "found fragmented DTLS handshake message" \
5032 -C "error"
5033
5034requires_gnutls
5035run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5036 "$G_SRV -u --mtu 512" \
5037 "$P_CLI dtls=1 debug_level=2" \
5038 0 \
5039 -c "found fragmented DTLS handshake message" \
5040 -C "error"
5041
5042requires_gnutls
5043run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5044 "$G_SRV -u --mtu 128" \
5045 "$P_CLI dtls=1 debug_level=2" \
5046 0 \
5047 -c "found fragmented DTLS handshake message" \
5048 -C "error"
5049
5050requires_gnutls
5051run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5052 "$G_SRV -u --mtu 128" \
5053 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5054 0 \
5055 -c "found fragmented DTLS handshake message" \
5056 -C "error"
5057
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005058requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005059requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005060run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5061 "$G_SRV -u --mtu 256" \
5062 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5063 0 \
5064 -c "found fragmented DTLS handshake message" \
5065 -c "client hello, adding renegotiation extension" \
5066 -c "found renegotiation extension" \
5067 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005068 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005069 -C "error" \
5070 -s "Extra-header:"
5071
5072requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005073requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005074run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5075 "$G_SRV -u --mtu 256" \
5076 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5077 0 \
5078 -c "found fragmented DTLS handshake message" \
5079 -c "client hello, adding renegotiation extension" \
5080 -c "found renegotiation extension" \
5081 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005082 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005083 -C "error" \
5084 -s "Extra-header:"
5085
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005086run_test "DTLS reassembly: no fragmentation (openssl server)" \
5087 "$O_SRV -dtls1 -mtu 2048" \
5088 "$P_CLI dtls=1 debug_level=2" \
5089 0 \
5090 -C "found fragmented DTLS handshake message" \
5091 -C "error"
5092
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005093run_test "DTLS reassembly: some fragmentation (openssl server)" \
5094 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005095 "$P_CLI dtls=1 debug_level=2" \
5096 0 \
5097 -c "found fragmented DTLS handshake message" \
5098 -C "error"
5099
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005100run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005101 "$O_SRV -dtls1 -mtu 256" \
5102 "$P_CLI dtls=1 debug_level=2" \
5103 0 \
5104 -c "found fragmented DTLS handshake message" \
5105 -C "error"
5106
5107run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5108 "$O_SRV -dtls1 -mtu 256" \
5109 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5110 0 \
5111 -c "found fragmented DTLS handshake message" \
5112 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005113
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005114# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005115
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005116not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005117run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005118 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005119 "$P_SRV dtls=1 debug_level=2" \
5120 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005121 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005122 -C "replayed record" \
5123 -S "replayed record" \
5124 -C "record from another epoch" \
5125 -S "record from another epoch" \
5126 -C "discarding invalid record" \
5127 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005128 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005129 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005130 -c "HTTP/1.0 200 OK"
5131
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005132not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005133run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005134 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005135 "$P_SRV dtls=1 debug_level=2" \
5136 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005137 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005138 -c "replayed record" \
5139 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005140 -c "discarding invalid record" \
5141 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005142 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005143 -s "Extra-header:" \
5144 -c "HTTP/1.0 200 OK"
5145
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005146run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
5147 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005148 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
5149 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005150 0 \
5151 -c "replayed record" \
5152 -S "replayed record" \
5153 -c "discarding invalid record" \
5154 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005155 -c "resend" \
5156 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005157 -s "Extra-header:" \
5158 -c "HTTP/1.0 200 OK"
5159
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005160run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005161 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005162 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005163 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005164 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005165 -c "discarding invalid record (mac)" \
5166 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005167 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005168 -c "HTTP/1.0 200 OK" \
5169 -S "too many records with bad MAC" \
5170 -S "Verification of the message MAC failed"
5171
5172run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
5173 -p "$P_PXY bad_ad=1" \
5174 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
5175 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5176 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005177 -C "discarding invalid record (mac)" \
5178 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005179 -S "Extra-header:" \
5180 -C "HTTP/1.0 200 OK" \
5181 -s "too many records with bad MAC" \
5182 -s "Verification of the message MAC failed"
5183
5184run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
5185 -p "$P_PXY bad_ad=1" \
5186 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
5187 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5188 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005189 -c "discarding invalid record (mac)" \
5190 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005191 -s "Extra-header:" \
5192 -c "HTTP/1.0 200 OK" \
5193 -S "too many records with bad MAC" \
5194 -S "Verification of the message MAC failed"
5195
5196run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
5197 -p "$P_PXY bad_ad=1" \
5198 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
5199 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
5200 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005201 -c "discarding invalid record (mac)" \
5202 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005203 -s "Extra-header:" \
5204 -c "HTTP/1.0 200 OK" \
5205 -s "too many records with bad MAC" \
5206 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005207
5208run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005209 -p "$P_PXY delay_ccs=1" \
5210 "$P_SRV dtls=1 debug_level=1" \
5211 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005212 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005213 -c "record from another epoch" \
5214 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005215 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005216 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005217 -s "Extra-header:" \
5218 -c "HTTP/1.0 200 OK"
5219
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005220# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005221
Janos Follath74537a62016-09-02 13:45:28 +01005222client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005223run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005224 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005225 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5226 psk=abc123" \
5227 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005228 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5229 0 \
5230 -s "Extra-header:" \
5231 -c "HTTP/1.0 200 OK"
5232
Janos Follath74537a62016-09-02 13:45:28 +01005233client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005234run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
5235 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005236 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
5237 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005238 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5239 0 \
5240 -s "Extra-header:" \
5241 -c "HTTP/1.0 200 OK"
5242
Janos Follath74537a62016-09-02 13:45:28 +01005243client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005244run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
5245 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005246 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
5247 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005248 0 \
5249 -s "Extra-header:" \
5250 -c "HTTP/1.0 200 OK"
5251
Janos Follath74537a62016-09-02 13:45:28 +01005252client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005253run_test "DTLS proxy: 3d, FS, client auth" \
5254 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005255 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
5256 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005257 0 \
5258 -s "Extra-header:" \
5259 -c "HTTP/1.0 200 OK"
5260
Janos Follath74537a62016-09-02 13:45:28 +01005261client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005262run_test "DTLS proxy: 3d, FS, ticket" \
5263 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005264 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
5265 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005266 0 \
5267 -s "Extra-header:" \
5268 -c "HTTP/1.0 200 OK"
5269
Janos Follath74537a62016-09-02 13:45:28 +01005270client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005271run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
5272 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005273 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
5274 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005275 0 \
5276 -s "Extra-header:" \
5277 -c "HTTP/1.0 200 OK"
5278
Janos Follath74537a62016-09-02 13:45:28 +01005279client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005280run_test "DTLS proxy: 3d, max handshake, nbio" \
5281 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005282 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
5283 auth_mode=required" \
5284 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005285 0 \
5286 -s "Extra-header:" \
5287 -c "HTTP/1.0 200 OK"
5288
Janos Follath74537a62016-09-02 13:45:28 +01005289client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005290run_test "DTLS proxy: 3d, min handshake, resumption" \
5291 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5292 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5293 psk=abc123 debug_level=3" \
5294 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5295 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5296 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5297 0 \
5298 -s "a session has been resumed" \
5299 -c "a session has been resumed" \
5300 -s "Extra-header:" \
5301 -c "HTTP/1.0 200 OK"
5302
Janos Follath74537a62016-09-02 13:45:28 +01005303client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005304run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
5305 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5306 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5307 psk=abc123 debug_level=3 nbio=2" \
5308 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5309 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5310 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
5311 0 \
5312 -s "a session has been resumed" \
5313 -c "a session has been resumed" \
5314 -s "Extra-header:" \
5315 -c "HTTP/1.0 200 OK"
5316
Janos Follath74537a62016-09-02 13:45:28 +01005317client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005318requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005319run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005320 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005321 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5322 psk=abc123 renegotiation=1 debug_level=2" \
5323 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5324 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005325 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5326 0 \
5327 -c "=> renegotiate" \
5328 -s "=> renegotiate" \
5329 -s "Extra-header:" \
5330 -c "HTTP/1.0 200 OK"
5331
Janos Follath74537a62016-09-02 13:45:28 +01005332client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005333requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005334run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
5335 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005336 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5337 psk=abc123 renegotiation=1 debug_level=2" \
5338 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5339 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005340 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5341 0 \
5342 -c "=> renegotiate" \
5343 -s "=> renegotiate" \
5344 -s "Extra-header:" \
5345 -c "HTTP/1.0 200 OK"
5346
Janos Follath74537a62016-09-02 13:45:28 +01005347client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005348requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005349run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005350 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005351 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005352 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005353 debug_level=2" \
5354 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005355 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005356 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5357 0 \
5358 -c "=> renegotiate" \
5359 -s "=> renegotiate" \
5360 -s "Extra-header:" \
5361 -c "HTTP/1.0 200 OK"
5362
Janos Follath74537a62016-09-02 13:45:28 +01005363client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005364requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005365run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005366 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005367 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005368 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005369 debug_level=2 nbio=2" \
5370 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005371 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005372 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5373 0 \
5374 -c "=> renegotiate" \
5375 -s "=> renegotiate" \
5376 -s "Extra-header:" \
5377 -c "HTTP/1.0 200 OK"
5378
Janos Follath74537a62016-09-02 13:45:28 +01005379client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005380not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005381run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005382 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5383 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005384 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005385 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005386 -c "HTTP/1.0 200 OK"
5387
Janos Follath74537a62016-09-02 13:45:28 +01005388client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005389not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005390run_test "DTLS proxy: 3d, openssl server, fragmentation" \
5391 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5392 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005393 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005394 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005395 -c "HTTP/1.0 200 OK"
5396
Janos Follath74537a62016-09-02 13:45:28 +01005397client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005398not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005399run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
5400 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5401 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005402 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005403 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005404 -c "HTTP/1.0 200 OK"
5405
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005406requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005407client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005408not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005409run_test "DTLS proxy: 3d, gnutls server" \
5410 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5411 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005412 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005413 0 \
5414 -s "Extra-header:" \
5415 -c "Extra-header:"
5416
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005417requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005418client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005419not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005420run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
5421 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5422 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005423 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005424 0 \
5425 -s "Extra-header:" \
5426 -c "Extra-header:"
5427
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005428requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005429client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005430not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005431run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
5432 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5433 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005434 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005435 0 \
5436 -s "Extra-header:" \
5437 -c "Extra-header:"
5438
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01005439# Final report
5440
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005441echo "------------------------------------------------------------------------"
5442
5443if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005444 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005445else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005446 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005447fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02005448PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02005449echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005450
5451exit $FAILS