blob: e0f7f81893dcd8a12fd23ebad93850f4335745ae [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
Jaeden Amero34730912019-07-03 13:51:04 +010024# Limit the size of each log to 10 GiB, in case of failures with this script
25# where it may output seemingly unlimited length error logs.
26ulimit -f 20971520
27
Antonin Décimo8fd91562019-01-23 15:24:37 +010028# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010029: ${P_SRV:=../programs/ssl/ssl_server2}
30: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020031: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010032: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020033: ${GNUTLS_CLI:=gnutls-cli}
34: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020035: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010036
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020037O_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 +010038O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020039G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010040G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020041TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010042
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010043TESTS=0
44FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020045SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010046
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000047CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020048
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010049MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010050FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020051EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052
Paul Bakkere20310a2016-05-10 11:18:17 +010053SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010054RUN_TEST_NUMBER=''
55
Paul Bakkeracaac852016-05-10 11:47:13 +010056PRESERVE_LOGS=0
57
Gilles Peskinef93c7d32017-04-14 17:55:28 +020058# Pick a "unique" server port in the range 10000-19999, and a proxy
59# port which is this plus 10000. Each port number may be independently
60# overridden by a command line option.
61SRV_PORT=$(($$ % 10000 + 10000))
62PXY_PORT=$((SRV_PORT + 10000))
63
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010064print_usage() {
65 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010066 printf " -h|--help\tPrint this help.\n"
67 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020068 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
69 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010070 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010071 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010072 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020073 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
74 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010075 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010076}
77
78get_options() {
79 while [ $# -gt 0 ]; do
80 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010081 -f|--filter)
82 shift; FILTER=$1
83 ;;
84 -e|--exclude)
85 shift; EXCLUDE=$1
86 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010087 -m|--memcheck)
88 MEMCHECK=1
89 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010090 -n|--number)
91 shift; RUN_TEST_NUMBER=$1
92 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010093 -s|--show-numbers)
94 SHOW_TEST_NUMBER=1
95 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010096 -p|--preserve-logs)
97 PRESERVE_LOGS=1
98 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020099 --port)
100 shift; SRV_PORT=$1
101 ;;
102 --proxy-port)
103 shift; PXY_PORT=$1
104 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100105 --seed)
106 shift; SEED="$1"
107 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100108 -h|--help)
109 print_usage
110 exit 0
111 ;;
112 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200113 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100114 print_usage
115 exit 1
116 ;;
117 esac
118 shift
119 done
120}
121
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100122# skip next test if the flag is not enabled in config.h
123requires_config_enabled() {
124 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
125 SKIP_NEXT="YES"
126 fi
127}
128
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200129# skip next test if the flag is enabled in config.h
130requires_config_disabled() {
131 if grep "^#define $1" $CONFIG_H > /dev/null; then
132 SKIP_NEXT="YES"
133 fi
134}
135
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200136# skip next test if OpenSSL doesn't support FALLBACK_SCSV
137requires_openssl_with_fallback_scsv() {
138 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
139 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
140 then
141 OPENSSL_HAS_FBSCSV="YES"
142 else
143 OPENSSL_HAS_FBSCSV="NO"
144 fi
145 fi
146 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
147 SKIP_NEXT="YES"
148 fi
149}
150
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151# skip next test if GnuTLS isn't available
152requires_gnutls() {
153 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200154 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200155 GNUTLS_AVAILABLE="YES"
156 else
157 GNUTLS_AVAILABLE="NO"
158 fi
159 fi
160 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
161 SKIP_NEXT="YES"
162 fi
163}
164
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200165# skip next test if IPv6 isn't available on this host
166requires_ipv6() {
167 if [ -z "${HAS_IPV6:-}" ]; then
168 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
169 SRV_PID=$!
170 sleep 1
171 kill $SRV_PID >/dev/null 2>&1
172 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
173 HAS_IPV6="NO"
174 else
175 HAS_IPV6="YES"
176 fi
177 rm -r $SRV_OUT
178 fi
179
180 if [ "$HAS_IPV6" = "NO" ]; then
181 SKIP_NEXT="YES"
182 fi
183}
184
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200185# skip the next test if valgrind is in use
186not_with_valgrind() {
187 if [ "$MEMCHECK" -gt 0 ]; then
188 SKIP_NEXT="YES"
189 fi
190}
191
Paul Bakker362689d2016-05-13 10:33:25 +0100192# skip the next test if valgrind is NOT in use
193only_with_valgrind() {
194 if [ "$MEMCHECK" -eq 0 ]; then
195 SKIP_NEXT="YES"
196 fi
197}
198
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200199# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100200client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200201 CLI_DELAY_FACTOR=$1
202}
203
Janos Follath74537a62016-09-02 13:45:28 +0100204# wait for the given seconds after the client finished in the next test
205server_needs_more_time() {
206 SRV_DELAY_SECONDS=$1
207}
208
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100209# print_name <name>
210print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100211 TESTS=$(( $TESTS + 1 ))
212 LINE=""
213
214 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
215 LINE="$TESTS "
216 fi
217
218 LINE="$LINE$1"
219 printf "$LINE "
220 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100221 for i in `seq 1 $LEN`; do printf '.'; done
222 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100223
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100224}
225
226# fail <message>
227fail() {
228 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100229 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100230
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200231 mv $SRV_OUT o-srv-${TESTS}.log
232 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200233 if [ -n "$PXY_CMD" ]; then
234 mv $PXY_OUT o-pxy-${TESTS}.log
235 fi
236 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100237
Azim Khan03da1212018-03-29 11:04:20 +0100238 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 +0200239 echo " ! server output:"
240 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200241 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200242 echo " ! client output:"
243 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200244 if [ -n "$PXY_CMD" ]; then
245 echo " ! ========================================================"
246 echo " ! proxy output:"
247 cat o-pxy-${TESTS}.log
248 fi
249 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200250 fi
251
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200252 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100253}
254
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100255# is_polar <cmd_line>
256is_polar() {
257 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
258}
259
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200260# openssl s_server doesn't have -www with DTLS
261check_osrv_dtls() {
262 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
263 NEEDS_INPUT=1
264 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
265 else
266 NEEDS_INPUT=0
267 fi
268}
269
270# provide input to commands that need it
271provide_input() {
272 if [ $NEEDS_INPUT -eq 0 ]; then
273 return
274 fi
275
276 while true; do
277 echo "HTTP/1.0 200 OK"
278 sleep 1
279 done
280}
281
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100282# has_mem_err <log_file_name>
283has_mem_err() {
284 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
285 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
286 then
287 return 1 # false: does not have errors
288 else
289 return 0 # true: has errors
290 fi
291}
292
Gilles Peskine418b5362017-12-14 18:58:42 +0100293# Wait for process $2 to be listening on port $1
294if type lsof >/dev/null 2>/dev/null; then
295 wait_server_start() {
296 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200297 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100298 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200299 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100300 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200301 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100302 # Make a tight loop, server normally takes less than 1s to start.
303 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
304 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
305 echo "SERVERSTART TIMEOUT"
306 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
307 break
308 fi
309 # Linux and *BSD support decimal arguments to sleep. On other
310 # OSes this may be a tight loop.
311 sleep 0.1 2>/dev/null || true
312 done
313 }
314else
Gilles Peskine7163a6a2018-06-29 15:48:13 +0200315 echo "Warning: lsof not available, wait_server_start = sleep"
Gilles Peskine418b5362017-12-14 18:58:42 +0100316 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200317 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100318 }
319fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200320
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100321# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100322# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100323# acceptable bounds
324check_server_hello_time() {
325 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100326 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100327 # Get the Unix timestamp for now
328 CUR_TIME=$(date +'%s')
329 THRESHOLD_IN_SECS=300
330
331 # Check if the ServerHello time was printed
332 if [ -z "$SERVER_HELLO_TIME" ]; then
333 return 1
334 fi
335
336 # Check the time in ServerHello is within acceptable bounds
337 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
338 # The time in ServerHello is at least 5 minutes before now
339 return 1
340 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100341 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100342 return 1
343 else
344 return 0
345 fi
346}
347
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200348# wait for client to terminate and set CLI_EXIT
349# must be called right after starting the client
350wait_client_done() {
351 CLI_PID=$!
352
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200353 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
354 CLI_DELAY_FACTOR=1
355
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200356 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200357 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200358
359 wait $CLI_PID
360 CLI_EXIT=$?
361
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200362 kill $DOG_PID >/dev/null 2>&1
363 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200364
365 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100366
367 sleep $SRV_DELAY_SECONDS
368 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200369}
370
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200371# check if the given command uses dtls and sets global variable DTLS
372detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200373 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200374 DTLS=1
375 else
376 DTLS=0
377 fi
378}
379
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200380# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100381# Options: -s pattern pattern that must be present in server output
382# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100383# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100384# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100385# -S pattern pattern that must be absent in server output
386# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100387# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100388# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100389run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100390 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200391 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100392
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100393 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
394 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200395 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100396 return
397 fi
398
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100399 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100400
Paul Bakkerb7584a52016-05-10 10:50:43 +0100401 # Do we only run numbered tests?
402 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
403 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
404 else
405 SKIP_NEXT="YES"
406 fi
407
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200408 # should we skip?
409 if [ "X$SKIP_NEXT" = "XYES" ]; then
410 SKIP_NEXT="NO"
411 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200412 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200413 return
414 fi
415
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200416 # does this test use a proxy?
417 if [ "X$1" = "X-p" ]; then
418 PXY_CMD="$2"
419 shift 2
420 else
421 PXY_CMD=""
422 fi
423
424 # get commands and client output
425 SRV_CMD="$1"
426 CLI_CMD="$2"
427 CLI_EXPECT="$3"
428 shift 3
429
430 # fix client port
431 if [ -n "$PXY_CMD" ]; then
432 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
433 else
434 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
435 fi
436
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200437 # update DTLS variable
438 detect_dtls "$SRV_CMD"
439
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100440 # prepend valgrind to our commands if active
441 if [ "$MEMCHECK" -gt 0 ]; then
442 if is_polar "$SRV_CMD"; then
443 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
444 fi
445 if is_polar "$CLI_CMD"; then
446 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
447 fi
448 fi
449
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200450 TIMES_LEFT=2
451 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200452 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200453
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200454 # run the commands
455 if [ -n "$PXY_CMD" ]; then
456 echo "$PXY_CMD" > $PXY_OUT
457 $PXY_CMD >> $PXY_OUT 2>&1 &
458 PXY_PID=$!
459 # assume proxy starts faster than server
460 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200461
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200462 check_osrv_dtls
463 echo "$SRV_CMD" > $SRV_OUT
464 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
465 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100466 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200467
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200468 echo "$CLI_CMD" > $CLI_OUT
469 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
470 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100471
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200472 # terminate the server (and the proxy)
473 kill $SRV_PID
474 wait $SRV_PID
475 if [ -n "$PXY_CMD" ]; then
476 kill $PXY_PID >/dev/null 2>&1
477 wait $PXY_PID
478 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100479
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200480 # retry only on timeouts
481 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
482 printf "RETRY "
483 else
484 TIMES_LEFT=0
485 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200486 done
487
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100488 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200489 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100490 # expected client exit to incorrectly succeed in case of catastrophic
491 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100492 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200493 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100494 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100495 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100496 return
497 fi
498 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100499 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200500 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100501 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100502 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100503 return
504 fi
505 fi
506
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100507 # check server exit code
508 if [ $? != 0 ]; then
509 fail "server fail"
510 return
511 fi
512
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100513 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100514 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
515 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100516 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200517 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100518 return
519 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100520
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100521 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200522 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100523 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100524 while [ $# -gt 0 ]
525 do
526 case $1 in
527 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100528 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 +0100529 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100530 return
531 fi
532 ;;
533
534 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100535 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 +0100536 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100537 return
538 fi
539 ;;
540
541 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100542 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 +0100543 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100544 return
545 fi
546 ;;
547
548 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100549 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 +0100550 fail "pattern '$2' MUST NOT be present in the Client output"
551 return
552 fi
553 ;;
554
555 # The filtering in the following two options (-u and -U) do the following
556 # - ignore valgrind output
Antonin Décimo8fd91562019-01-23 15:24:37 +0100557 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100558 # - keep one of each non-unique line
559 # - count how many lines remain
560 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
561 # if there were no duplicates.
562 "-U")
563 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
564 fail "lines following pattern '$2' must be unique in Server output"
565 return
566 fi
567 ;;
568
569 "-u")
570 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
571 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100572 return
573 fi
574 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100575 "-F")
576 if ! $2 "$SRV_OUT"; then
577 fail "function call to '$2' failed on Server output"
578 return
579 fi
580 ;;
581 "-f")
582 if ! $2 "$CLI_OUT"; then
583 fail "function call to '$2' failed on Client output"
584 return
585 fi
586 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100587
588 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200589 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100590 exit 1
591 esac
592 shift 2
593 done
594
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100595 # check valgrind's results
596 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200597 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100598 fail "Server has memory errors"
599 return
600 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200601 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100602 fail "Client has memory errors"
603 return
604 fi
605 fi
606
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100607 # if we're here, everything is ok
608 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100609 if [ "$PRESERVE_LOGS" -gt 0 ]; then
610 mv $SRV_OUT o-srv-${TESTS}.log
611 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Beckerdc6c0e42018-08-20 12:21:35 +0100612 if [ -n "$PXY_CMD" ]; then
613 mv $PXY_OUT o-pxy-${TESTS}.log
614 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100615 fi
616
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100618}
619
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100620cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200621 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200622 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
623 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
624 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
625 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100626 exit 1
627}
628
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100629#
630# MAIN
631#
632
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000633if cd $( dirname $0 ); then :; else
634 echo "cd $( dirname $0 ) failed" >&2
635 exit 1
636fi
637
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100638get_options "$@"
639
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100640# sanity checks, avoid an avalanche of errors
641if [ ! -x "$P_SRV" ]; then
642 echo "Command '$P_SRV' is not an executable file"
643 exit 1
644fi
645if [ ! -x "$P_CLI" ]; then
646 echo "Command '$P_CLI' is not an executable file"
647 exit 1
648fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200649if [ ! -x "$P_PXY" ]; then
650 echo "Command '$P_PXY' is not an executable file"
651 exit 1
652fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100653if [ "$MEMCHECK" -gt 0 ]; then
654 if which valgrind >/dev/null 2>&1; then :; else
655 echo "Memcheck not possible. Valgrind not found"
656 exit 1
657 fi
658fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100659if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
660 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100661 exit 1
662fi
663
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200664# used by watchdog
665MAIN_PID="$$"
666
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100667# We use somewhat arbitrary delays for tests:
668# - how long do we wait for the server to start (when lsof not available)?
669# - how long do we allow for the client to finish?
670# (not to check performance, just to avoid waiting indefinitely)
671# Things are slower with valgrind, so give extra time here.
672#
673# Note: without lsof, there is a trade-off between the running time of this
674# script and the risk of spurious errors because we didn't wait long enough.
675# The watchdog delay on the other hand doesn't affect normal running time of
676# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200677if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100678 START_DELAY=6
679 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200680else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100681 START_DELAY=2
682 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200683fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100684
685# some particular tests need more time:
686# - for the client, we multiply the usual watchdog limit by a factor
687# - for the server, we sleep for a number of seconds after the client exits
688# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200689CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100690SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200691
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200692# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000693# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200694P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
695P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100696P_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 +0200697O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200698O_CLI="$O_CLI -connect localhost:+SRV_PORT"
699G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000700G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200701
Gilles Peskine62469d92017-05-10 10:13:59 +0200702# Allow SHA-1, because many of our test certificates use it
703P_SRV="$P_SRV allow_sha1=1"
704P_CLI="$P_CLI allow_sha1=1"
705
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200706# Also pick a unique name for intermediate files
707SRV_OUT="srv_out.$$"
708CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200709PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200710SESSION="session.$$"
711
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200712SKIP_NEXT="NO"
713
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100714trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100715
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200716# Basic test
717
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200718# Checks that:
719# - things work with all ciphersuites active (used with config-full in all.sh)
720# - the expected (highest security) parameters are selected
721# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200722run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200723 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200724 "$P_CLI" \
725 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200726 -s "Protocol is TLSv1.2" \
727 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
728 -s "client hello v3, signature_algorithm ext: 6" \
729 -s "ECDHE curve: secp521r1" \
730 -S "error" \
731 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200732
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000733run_test "Default, DTLS" \
734 "$P_SRV dtls=1" \
735 "$P_CLI dtls=1" \
736 0 \
737 -s "Protocol is DTLSv1.2" \
738 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
739
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100740# Test current time in ServerHello
741requires_config_enabled MBEDTLS_HAVE_TIME
742run_test "Default, ServerHello contains gmt_unix_time" \
743 "$P_SRV debug_level=3" \
744 "$P_CLI debug_level=3" \
745 0 \
746 -s "Protocol is TLSv1.2" \
747 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
748 -s "client hello v3, signature_algorithm ext: 6" \
749 -s "ECDHE curve: secp521r1" \
750 -S "error" \
751 -C "error" \
752 -f "check_server_hello_time" \
753 -F "check_server_hello_time"
754
Simon Butcher8e004102016-10-14 00:48:33 +0100755# Test for uniqueness of IVs in AEAD ciphersuites
756run_test "Unique IV in GCM" \
757 "$P_SRV exchanges=20 debug_level=4" \
758 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
759 0 \
760 -u "IV used" \
761 -U "IV used"
762
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100763# Tests for rc4 option
764
Simon Butchera410af52016-05-19 22:12:18 +0100765requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100766run_test "RC4: server disabled, client enabled" \
767 "$P_SRV" \
768 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
769 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100770 -s "SSL - The server has no ciphersuites in common"
771
Simon Butchera410af52016-05-19 22:12:18 +0100772requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100773run_test "RC4: server half, client enabled" \
774 "$P_SRV arc4=1" \
775 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
776 1 \
777 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100778
779run_test "RC4: server enabled, client disabled" \
780 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
781 "$P_CLI" \
782 1 \
783 -s "SSL - The server has no ciphersuites in common"
784
785run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100786 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100787 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
788 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100789 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100790 -S "SSL - The server has no ciphersuites in common"
791
Hanno Becker3a333a52018-08-17 09:54:10 +0100792# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
793
794requires_gnutls
795requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
796run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
797 "$G_SRV"\
798 "$P_CLI force_version=tls1_1" \
799 0
800
801requires_gnutls
802requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
803run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
804 "$G_SRV"\
805 "$P_CLI force_version=tls1" \
806 0
807
Gilles Peskinebc70a182017-05-09 15:59:24 +0200808# Tests for SHA-1 support
809
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200810requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200811run_test "SHA-1 forbidden by default in server certificate" \
812 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
813 "$P_CLI debug_level=2 allow_sha1=0" \
814 1 \
815 -c "The certificate is signed with an unacceptable hash"
816
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200817requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
818run_test "SHA-1 forbidden by default in server certificate" \
819 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
820 "$P_CLI debug_level=2 allow_sha1=0" \
821 0
822
Gilles Peskinebc70a182017-05-09 15:59:24 +0200823run_test "SHA-1 explicitly allowed in server certificate" \
824 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
825 "$P_CLI allow_sha1=1" \
826 0
827
828run_test "SHA-256 allowed by default in server certificate" \
829 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
830 "$P_CLI allow_sha1=0" \
831 0
832
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200833requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200834run_test "SHA-1 forbidden by default in client certificate" \
835 "$P_SRV auth_mode=required allow_sha1=0" \
836 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
837 1 \
838 -s "The certificate is signed with an unacceptable hash"
839
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200840requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
841run_test "SHA-1 forbidden by default in client certificate" \
842 "$P_SRV auth_mode=required allow_sha1=0" \
843 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
844 0
845
Gilles Peskinebc70a182017-05-09 15:59:24 +0200846run_test "SHA-1 explicitly allowed in client certificate" \
847 "$P_SRV auth_mode=required allow_sha1=1" \
848 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
849 0
850
851run_test "SHA-256 allowed by default in client certificate" \
852 "$P_SRV auth_mode=required allow_sha1=0" \
853 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
854 0
855
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100856# Tests for Truncated HMAC extension
857
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100858run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200859 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100860 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100861 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000862 -s "dumping 'expected mac' (20 bytes)" \
863 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100864
Hanno Becker32c55012017-11-10 08:42:54 +0000865requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100866run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200867 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000868 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100869 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000870 -s "dumping 'expected mac' (20 bytes)" \
871 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100872
Hanno Becker32c55012017-11-10 08:42:54 +0000873requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100874run_test "Truncated HMAC: client enabled, server default" \
875 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000876 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100877 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000878 -s "dumping 'expected mac' (20 bytes)" \
879 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100880
Hanno Becker32c55012017-11-10 08:42:54 +0000881requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100882run_test "Truncated HMAC: client enabled, server disabled" \
883 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000884 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100885 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000886 -s "dumping 'expected mac' (20 bytes)" \
887 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100888
Hanno Becker32c55012017-11-10 08:42:54 +0000889requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000890run_test "Truncated HMAC: client disabled, server enabled" \
891 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000892 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000893 0 \
894 -s "dumping 'expected mac' (20 bytes)" \
895 -S "dumping 'expected mac' (10 bytes)"
896
897requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100898run_test "Truncated HMAC: client enabled, server enabled" \
899 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000900 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100901 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000902 -S "dumping 'expected mac' (20 bytes)" \
903 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100904
Hanno Becker4c4f4102017-11-10 09:16:05 +0000905run_test "Truncated HMAC, DTLS: client default, server default" \
906 "$P_SRV dtls=1 debug_level=4" \
907 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
908 0 \
909 -s "dumping 'expected mac' (20 bytes)" \
910 -S "dumping 'expected mac' (10 bytes)"
911
912requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
913run_test "Truncated HMAC, DTLS: client disabled, server default" \
914 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000915 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000916 0 \
917 -s "dumping 'expected mac' (20 bytes)" \
918 -S "dumping 'expected mac' (10 bytes)"
919
920requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
921run_test "Truncated HMAC, DTLS: client enabled, server default" \
922 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000923 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000924 0 \
925 -s "dumping 'expected mac' (20 bytes)" \
926 -S "dumping 'expected mac' (10 bytes)"
927
928requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
929run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
930 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000931 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000932 0 \
933 -s "dumping 'expected mac' (20 bytes)" \
934 -S "dumping 'expected mac' (10 bytes)"
935
936requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
937run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
938 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000939 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000940 0 \
941 -s "dumping 'expected mac' (20 bytes)" \
942 -S "dumping 'expected mac' (10 bytes)"
943
944requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
945run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
946 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000947 "$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 +0100948 0 \
949 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100950 -s "dumping 'expected mac' (10 bytes)"
951
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100952# Tests for Encrypt-then-MAC extension
953
954run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100955 "$P_SRV debug_level=3 \
956 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100957 "$P_CLI debug_level=3" \
958 0 \
959 -c "client hello, adding encrypt_then_mac extension" \
960 -s "found encrypt then mac extension" \
961 -s "server hello, adding encrypt then mac extension" \
962 -c "found encrypt_then_mac extension" \
963 -c "using encrypt then mac" \
964 -s "using encrypt then mac"
965
966run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100967 "$P_SRV debug_level=3 etm=0 \
968 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100969 "$P_CLI debug_level=3 etm=1" \
970 0 \
971 -c "client hello, adding encrypt_then_mac extension" \
972 -s "found encrypt then mac extension" \
973 -S "server hello, adding encrypt then mac extension" \
974 -C "found encrypt_then_mac extension" \
975 -C "using encrypt then mac" \
976 -S "using encrypt then mac"
977
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100978run_test "Encrypt then MAC: client enabled, aead cipher" \
979 "$P_SRV debug_level=3 etm=1 \
980 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
981 "$P_CLI debug_level=3 etm=1" \
982 0 \
983 -c "client hello, adding encrypt_then_mac extension" \
984 -s "found encrypt then mac extension" \
985 -S "server hello, adding encrypt then mac extension" \
986 -C "found encrypt_then_mac extension" \
987 -C "using encrypt then mac" \
988 -S "using encrypt then mac"
989
990run_test "Encrypt then MAC: client enabled, stream cipher" \
991 "$P_SRV debug_level=3 etm=1 \
992 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100993 "$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 +0100994 0 \
995 -c "client hello, adding encrypt_then_mac extension" \
996 -s "found encrypt then mac extension" \
997 -S "server hello, adding encrypt then mac extension" \
998 -C "found encrypt_then_mac extension" \
999 -C "using encrypt then mac" \
1000 -S "using encrypt then mac"
1001
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001002run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001003 "$P_SRV debug_level=3 etm=1 \
1004 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001005 "$P_CLI debug_level=3 etm=0" \
1006 0 \
1007 -C "client hello, adding encrypt_then_mac extension" \
1008 -S "found encrypt then mac extension" \
1009 -S "server hello, adding encrypt then mac extension" \
1010 -C "found encrypt_then_mac extension" \
1011 -C "using encrypt then mac" \
1012 -S "using encrypt then mac"
1013
Janos Follathe2681a42016-03-07 15:57:05 +00001014requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001015run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001016 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001017 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001018 "$P_CLI debug_level=3 force_version=ssl3" \
1019 0 \
1020 -C "client hello, adding encrypt_then_mac extension" \
1021 -S "found encrypt then mac extension" \
1022 -S "server hello, adding encrypt then mac extension" \
1023 -C "found encrypt_then_mac extension" \
1024 -C "using encrypt then mac" \
1025 -S "using encrypt then mac"
1026
Janos Follathe2681a42016-03-07 15:57:05 +00001027requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001028run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001029 "$P_SRV debug_level=3 force_version=ssl3 \
1030 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001031 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001032 0 \
1033 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001034 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001035 -S "server hello, adding encrypt then mac extension" \
1036 -C "found encrypt_then_mac extension" \
1037 -C "using encrypt then mac" \
1038 -S "using encrypt then mac"
1039
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001040# Tests for Extended Master Secret extension
1041
1042run_test "Extended Master Secret: default" \
1043 "$P_SRV debug_level=3" \
1044 "$P_CLI debug_level=3" \
1045 0 \
1046 -c "client hello, adding extended_master_secret extension" \
1047 -s "found extended master secret extension" \
1048 -s "server hello, adding extended master secret extension" \
1049 -c "found extended_master_secret extension" \
1050 -c "using extended master secret" \
1051 -s "using extended master secret"
1052
1053run_test "Extended Master Secret: client enabled, server disabled" \
1054 "$P_SRV debug_level=3 extended_ms=0" \
1055 "$P_CLI debug_level=3 extended_ms=1" \
1056 0 \
1057 -c "client hello, adding extended_master_secret extension" \
1058 -s "found extended master secret extension" \
1059 -S "server hello, adding extended master secret extension" \
1060 -C "found extended_master_secret extension" \
1061 -C "using extended master secret" \
1062 -S "using extended master secret"
1063
1064run_test "Extended Master Secret: client disabled, server enabled" \
1065 "$P_SRV debug_level=3 extended_ms=1" \
1066 "$P_CLI debug_level=3 extended_ms=0" \
1067 0 \
1068 -C "client hello, adding extended_master_secret extension" \
1069 -S "found extended master secret extension" \
1070 -S "server hello, adding extended master secret extension" \
1071 -C "found extended_master_secret extension" \
1072 -C "using extended master secret" \
1073 -S "using extended master secret"
1074
Janos Follathe2681a42016-03-07 15:57:05 +00001075requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001076run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001077 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001078 "$P_CLI debug_level=3 force_version=ssl3" \
1079 0 \
1080 -C "client hello, adding extended_master_secret extension" \
1081 -S "found extended master secret extension" \
1082 -S "server hello, adding extended master secret extension" \
1083 -C "found extended_master_secret extension" \
1084 -C "using extended master secret" \
1085 -S "using extended master secret"
1086
Janos Follathe2681a42016-03-07 15:57:05 +00001087requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001088run_test "Extended Master Secret: client enabled, server SSLv3" \
1089 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001090 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001091 0 \
1092 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001093 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001094 -S "server hello, adding extended master secret extension" \
1095 -C "found extended_master_secret extension" \
1096 -C "using extended master secret" \
1097 -S "using extended master secret"
1098
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001099# Tests for FALLBACK_SCSV
1100
1101run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001102 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001103 "$P_CLI debug_level=3 force_version=tls1_1" \
1104 0 \
1105 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001106 -S "received FALLBACK_SCSV" \
1107 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001108 -C "is a fatal alert message (msg 86)"
1109
1110run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001111 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001112 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1113 0 \
1114 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001115 -S "received FALLBACK_SCSV" \
1116 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001117 -C "is a fatal alert message (msg 86)"
1118
1119run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001120 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001121 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001122 1 \
1123 -c "adding FALLBACK_SCSV" \
1124 -s "received FALLBACK_SCSV" \
1125 -s "inapropriate fallback" \
1126 -c "is a fatal alert message (msg 86)"
1127
1128run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001129 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001130 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001131 0 \
1132 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001133 -s "received FALLBACK_SCSV" \
1134 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001135 -C "is a fatal alert message (msg 86)"
1136
1137requires_openssl_with_fallback_scsv
1138run_test "Fallback SCSV: default, openssl server" \
1139 "$O_SRV" \
1140 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1141 0 \
1142 -C "adding FALLBACK_SCSV" \
1143 -C "is a fatal alert message (msg 86)"
1144
1145requires_openssl_with_fallback_scsv
1146run_test "Fallback SCSV: enabled, openssl server" \
1147 "$O_SRV" \
1148 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1149 1 \
1150 -c "adding FALLBACK_SCSV" \
1151 -c "is a fatal alert message (msg 86)"
1152
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001153requires_openssl_with_fallback_scsv
1154run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001155 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001156 "$O_CLI -tls1_1" \
1157 0 \
1158 -S "received FALLBACK_SCSV" \
1159 -S "inapropriate fallback"
1160
1161requires_openssl_with_fallback_scsv
1162run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001163 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001164 "$O_CLI -tls1_1 -fallback_scsv" \
1165 1 \
1166 -s "received FALLBACK_SCSV" \
1167 -s "inapropriate fallback"
1168
1169requires_openssl_with_fallback_scsv
1170run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001171 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001172 "$O_CLI -fallback_scsv" \
1173 0 \
1174 -s "received FALLBACK_SCSV" \
1175 -S "inapropriate fallback"
1176
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001177# Test sending and receiving empty application data records
1178
1179run_test "Encrypt then MAC: empty application data record" \
1180 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1181 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1182 0 \
1183 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1184 -s "dumping 'input payload after decrypt' (0 bytes)" \
1185 -c "0 bytes written in 1 fragments"
1186
1187run_test "Default, no Encrypt then MAC: empty application data record" \
1188 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1189 "$P_CLI auth_mode=none etm=0 request_size=0" \
1190 0 \
1191 -s "dumping 'input payload after decrypt' (0 bytes)" \
1192 -c "0 bytes written in 1 fragments"
1193
1194run_test "Encrypt then MAC, DTLS: empty application data record" \
1195 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1196 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1197 0 \
1198 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1199 -s "dumping 'input payload after decrypt' (0 bytes)" \
1200 -c "0 bytes written in 1 fragments"
1201
1202run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
1203 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1204 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1205 0 \
1206 -s "dumping 'input payload after decrypt' (0 bytes)" \
1207 -c "0 bytes written in 1 fragments"
1208
Gilles Peskined50177f2017-05-16 17:53:03 +02001209## ClientHello generated with
1210## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1211## then manually twiddling the ciphersuite list.
1212## The ClientHello content is spelled out below as a hex string as
1213## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1214## The expected response is an inappropriate_fallback alert.
1215requires_openssl_with_fallback_scsv
1216run_test "Fallback SCSV: beginning of list" \
1217 "$P_SRV debug_level=2" \
1218 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1219 0 \
1220 -s "received FALLBACK_SCSV" \
1221 -s "inapropriate fallback"
1222
1223requires_openssl_with_fallback_scsv
1224run_test "Fallback SCSV: end of list" \
1225 "$P_SRV debug_level=2" \
1226 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1227 0 \
1228 -s "received FALLBACK_SCSV" \
1229 -s "inapropriate fallback"
1230
1231## Here the expected response is a valid ServerHello prefix, up to the random.
1232requires_openssl_with_fallback_scsv
1233run_test "Fallback SCSV: not in list" \
1234 "$P_SRV debug_level=2" \
1235 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1236 0 \
1237 -S "received FALLBACK_SCSV" \
1238 -S "inapropriate fallback"
1239
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001240# Tests for CBC 1/n-1 record splitting
1241
1242run_test "CBC Record splitting: TLS 1.2, no splitting" \
1243 "$P_SRV" \
1244 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1245 request_size=123 force_version=tls1_2" \
1246 0 \
1247 -s "Read from client: 123 bytes read" \
1248 -S "Read from client: 1 bytes read" \
1249 -S "122 bytes read"
1250
1251run_test "CBC Record splitting: TLS 1.1, no splitting" \
1252 "$P_SRV" \
1253 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1254 request_size=123 force_version=tls1_1" \
1255 0 \
1256 -s "Read from client: 123 bytes read" \
1257 -S "Read from client: 1 bytes read" \
1258 -S "122 bytes read"
1259
1260run_test "CBC Record splitting: TLS 1.0, splitting" \
1261 "$P_SRV" \
1262 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1263 request_size=123 force_version=tls1" \
1264 0 \
1265 -S "Read from client: 123 bytes read" \
1266 -s "Read from client: 1 bytes read" \
1267 -s "122 bytes read"
1268
Janos Follathe2681a42016-03-07 15:57:05 +00001269requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001270run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001271 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001272 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1273 request_size=123 force_version=ssl3" \
1274 0 \
1275 -S "Read from client: 123 bytes read" \
1276 -s "Read from client: 1 bytes read" \
1277 -s "122 bytes read"
1278
1279run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001280 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001281 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1282 request_size=123 force_version=tls1" \
1283 0 \
1284 -s "Read from client: 123 bytes read" \
1285 -S "Read from client: 1 bytes read" \
1286 -S "122 bytes read"
1287
1288run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1289 "$P_SRV" \
1290 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1291 request_size=123 force_version=tls1 recsplit=0" \
1292 0 \
1293 -s "Read from client: 123 bytes read" \
1294 -S "Read from client: 1 bytes read" \
1295 -S "122 bytes read"
1296
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001297run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1298 "$P_SRV nbio=2" \
1299 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1300 request_size=123 force_version=tls1" \
1301 0 \
1302 -S "Read from client: 123 bytes read" \
1303 -s "Read from client: 1 bytes read" \
1304 -s "122 bytes read"
1305
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001306# Tests for Session Tickets
1307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001308run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001309 "$P_SRV debug_level=3 tickets=1" \
1310 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001311 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001312 -c "client hello, adding session ticket extension" \
1313 -s "found session ticket extension" \
1314 -s "server hello, adding session ticket extension" \
1315 -c "found session_ticket extension" \
1316 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001317 -S "session successfully restored from cache" \
1318 -s "session successfully restored from ticket" \
1319 -s "a session has been resumed" \
1320 -c "a session has been resumed"
1321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001322run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001323 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1324 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001325 0 \
1326 -c "client hello, adding session ticket extension" \
1327 -s "found session ticket extension" \
1328 -s "server hello, adding session ticket extension" \
1329 -c "found session_ticket extension" \
1330 -c "parse new session ticket" \
1331 -S "session successfully restored from cache" \
1332 -s "session successfully restored from ticket" \
1333 -s "a session has been resumed" \
1334 -c "a session has been resumed"
1335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001336run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001337 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1338 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001339 0 \
1340 -c "client hello, adding session ticket extension" \
1341 -s "found session ticket extension" \
1342 -s "server hello, adding session ticket extension" \
1343 -c "found session_ticket extension" \
1344 -c "parse new session ticket" \
1345 -S "session successfully restored from cache" \
1346 -S "session successfully restored from ticket" \
1347 -S "a session has been resumed" \
1348 -C "a session has been resumed"
1349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001350run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001351 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001352 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001353 0 \
1354 -c "client hello, adding session ticket extension" \
1355 -c "found session_ticket extension" \
1356 -c "parse new session ticket" \
1357 -c "a session has been resumed"
1358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001359run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001360 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001361 "( $O_CLI -sess_out $SESSION; \
1362 $O_CLI -sess_in $SESSION; \
1363 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001364 0 \
1365 -s "found session ticket extension" \
1366 -s "server hello, adding session ticket extension" \
1367 -S "session successfully restored from cache" \
1368 -s "session successfully restored from ticket" \
1369 -s "a session has been resumed"
1370
Hanno Beckerb5546362018-08-21 13:55:22 +01001371# Tests for Session Tickets with DTLS
1372
1373run_test "Session resume using tickets, DTLS: basic" \
1374 "$P_SRV debug_level=3 dtls=1 tickets=1" \
1375 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
1376 0 \
1377 -c "client hello, adding session ticket extension" \
1378 -s "found session ticket extension" \
1379 -s "server hello, adding session ticket extension" \
1380 -c "found session_ticket extension" \
1381 -c "parse new session ticket" \
1382 -S "session successfully restored from cache" \
1383 -s "session successfully restored from ticket" \
1384 -s "a session has been resumed" \
1385 -c "a session has been resumed"
1386
1387run_test "Session resume using tickets, DTLS: cache disabled" \
1388 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
1389 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
1390 0 \
1391 -c "client hello, adding session ticket extension" \
1392 -s "found session ticket extension" \
1393 -s "server hello, adding session ticket extension" \
1394 -c "found session_ticket extension" \
1395 -c "parse new session ticket" \
1396 -S "session successfully restored from cache" \
1397 -s "session successfully restored from ticket" \
1398 -s "a session has been resumed" \
1399 -c "a session has been resumed"
1400
1401run_test "Session resume using tickets, DTLS: timeout" \
1402 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
1403 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \
1404 0 \
1405 -c "client hello, adding session ticket extension" \
1406 -s "found session ticket extension" \
1407 -s "server hello, adding session ticket extension" \
1408 -c "found session_ticket extension" \
1409 -c "parse new session ticket" \
1410 -S "session successfully restored from cache" \
1411 -S "session successfully restored from ticket" \
1412 -S "a session has been resumed" \
1413 -C "a session has been resumed"
1414
1415run_test "Session resume using tickets, DTLS: openssl server" \
1416 "$O_SRV -dtls1" \
1417 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1418 0 \
1419 -c "client hello, adding session ticket extension" \
1420 -c "found session_ticket extension" \
1421 -c "parse new session ticket" \
1422 -c "a session has been resumed"
1423
1424run_test "Session resume using tickets, DTLS: openssl client" \
1425 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1426 "( $O_CLI -dtls1 -sess_out $SESSION; \
1427 $O_CLI -dtls1 -sess_in $SESSION; \
1428 rm -f $SESSION )" \
1429 0 \
1430 -s "found session ticket extension" \
1431 -s "server hello, adding session ticket extension" \
1432 -S "session successfully restored from cache" \
1433 -s "session successfully restored from ticket" \
1434 -s "a session has been resumed"
1435
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001436# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001438run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001439 "$P_SRV debug_level=3 tickets=0" \
1440 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001441 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001442 -c "client hello, adding session ticket extension" \
1443 -s "found session ticket extension" \
1444 -S "server hello, adding session ticket extension" \
1445 -C "found session_ticket extension" \
1446 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001447 -s "session successfully restored from cache" \
1448 -S "session successfully restored from ticket" \
1449 -s "a session has been resumed" \
1450 -c "a session has been resumed"
1451
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001452run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001453 "$P_SRV debug_level=3 tickets=1" \
1454 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001455 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001456 -C "client hello, adding session ticket extension" \
1457 -S "found session ticket extension" \
1458 -S "server hello, adding session ticket extension" \
1459 -C "found session_ticket extension" \
1460 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001461 -s "session successfully restored from cache" \
1462 -S "session successfully restored from ticket" \
1463 -s "a session has been resumed" \
1464 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001466run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001467 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1468 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001469 0 \
1470 -S "session successfully restored from cache" \
1471 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001472 -S "a session has been resumed" \
1473 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001475run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001476 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1477 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001478 0 \
1479 -s "session successfully restored from cache" \
1480 -S "session successfully restored from ticket" \
1481 -s "a session has been resumed" \
1482 -c "a session has been resumed"
1483
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001484run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001485 "$P_SRV debug_level=3 tickets=0" \
1486 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001487 0 \
1488 -s "session successfully restored from cache" \
1489 -S "session successfully restored from ticket" \
1490 -s "a session has been resumed" \
1491 -c "a session has been resumed"
1492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001493run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001494 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1495 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001496 0 \
1497 -S "session successfully restored from cache" \
1498 -S "session successfully restored from ticket" \
1499 -S "a session has been resumed" \
1500 -C "a session has been resumed"
1501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001502run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001503 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1504 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001505 0 \
1506 -s "session successfully restored from cache" \
1507 -S "session successfully restored from ticket" \
1508 -s "a session has been resumed" \
1509 -c "a session has been resumed"
1510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001511run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001512 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001513 "( $O_CLI -sess_out $SESSION; \
1514 $O_CLI -sess_in $SESSION; \
1515 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001516 0 \
1517 -s "found session ticket extension" \
1518 -S "server hello, adding session ticket extension" \
1519 -s "session successfully restored from cache" \
1520 -S "session successfully restored from ticket" \
1521 -s "a session has been resumed"
1522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001523run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001524 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001526 0 \
1527 -C "found session_ticket extension" \
1528 -C "parse new session ticket" \
1529 -c "a session has been resumed"
1530
Hanno Beckerb5546362018-08-21 13:55:22 +01001531# Tests for Session Resume based on session-ID and cache, DTLS
1532
1533run_test "Session resume using cache, DTLS: tickets enabled on client" \
1534 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1535 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1536 0 \
1537 -c "client hello, adding session ticket extension" \
1538 -s "found session ticket extension" \
1539 -S "server hello, adding session ticket extension" \
1540 -C "found session_ticket extension" \
1541 -C "parse new session ticket" \
1542 -s "session successfully restored from cache" \
1543 -S "session successfully restored from ticket" \
1544 -s "a session has been resumed" \
1545 -c "a session has been resumed"
1546
1547run_test "Session resume using cache, DTLS: tickets enabled on server" \
1548 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1549 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1550 0 \
1551 -C "client hello, adding session ticket extension" \
1552 -S "found session ticket extension" \
1553 -S "server hello, adding session ticket extension" \
1554 -C "found session_ticket extension" \
1555 -C "parse new session ticket" \
1556 -s "session successfully restored from cache" \
1557 -S "session successfully restored from ticket" \
1558 -s "a session has been resumed" \
1559 -c "a session has been resumed"
1560
1561run_test "Session resume using cache, DTLS: cache_max=0" \
1562 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
1563 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1564 0 \
1565 -S "session successfully restored from cache" \
1566 -S "session successfully restored from ticket" \
1567 -S "a session has been resumed" \
1568 -C "a session has been resumed"
1569
1570run_test "Session resume using cache, DTLS: cache_max=1" \
1571 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
1572 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1573 0 \
1574 -s "session successfully restored from cache" \
1575 -S "session successfully restored from ticket" \
1576 -s "a session has been resumed" \
1577 -c "a session has been resumed"
1578
1579run_test "Session resume using cache, DTLS: timeout > delay" \
1580 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1581 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
1582 0 \
1583 -s "session successfully restored from cache" \
1584 -S "session successfully restored from ticket" \
1585 -s "a session has been resumed" \
1586 -c "a session has been resumed"
1587
1588run_test "Session resume using cache, DTLS: timeout < delay" \
1589 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
1590 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
1591 0 \
1592 -S "session successfully restored from cache" \
1593 -S "session successfully restored from ticket" \
1594 -S "a session has been resumed" \
1595 -C "a session has been resumed"
1596
1597run_test "Session resume using cache, DTLS: no timeout" \
1598 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
1599 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
1600 0 \
1601 -s "session successfully restored from cache" \
1602 -S "session successfully restored from ticket" \
1603 -s "a session has been resumed" \
1604 -c "a session has been resumed"
1605
1606run_test "Session resume using cache, DTLS: openssl client" \
1607 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1608 "( $O_CLI -dtls1 -sess_out $SESSION; \
1609 $O_CLI -dtls1 -sess_in $SESSION; \
1610 rm -f $SESSION )" \
1611 0 \
1612 -s "found session ticket extension" \
1613 -S "server hello, adding session ticket extension" \
1614 -s "session successfully restored from cache" \
1615 -S "session successfully restored from ticket" \
1616 -s "a session has been resumed"
1617
1618run_test "Session resume using cache, DTLS: openssl server" \
1619 "$O_SRV -dtls1" \
1620 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1621 0 \
1622 -C "found session_ticket extension" \
1623 -C "parse new session ticket" \
1624 -c "a session has been resumed"
1625
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001626# Tests for Max Fragment Length extension
1627
Hanno Becker6428f8d2017-09-22 16:58:50 +01001628MAX_CONTENT_LEN_EXPECT='16384'
1629MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1630
1631if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1632 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1633 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1634 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1635 printf "\n"
1636 printf "The tests assume this value and if it changes, the tests in this\n"
1637 printf "script should also be adjusted.\n"
1638 printf "\n"
1639
1640 exit 1
1641fi
1642
Hanno Becker4aed27e2017-09-18 15:00:34 +01001643requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001644run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001645 "$P_SRV debug_level=3" \
1646 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001647 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001648 -c "Maximum fragment length is 16384" \
1649 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001650 -C "client hello, adding max_fragment_length extension" \
1651 -S "found max fragment length extension" \
1652 -S "server hello, max_fragment_length extension" \
1653 -C "found max_fragment_length extension"
1654
Hanno Becker4aed27e2017-09-18 15:00:34 +01001655requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001656run_test "Max fragment length: enabled, default, larger message" \
1657 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001658 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001659 0 \
1660 -c "Maximum fragment length is 16384" \
1661 -s "Maximum fragment length is 16384" \
1662 -C "client hello, adding max_fragment_length extension" \
1663 -S "found max fragment length extension" \
1664 -S "server hello, max_fragment_length extension" \
1665 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001666 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001667 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001668 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001669
1670requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1671run_test "Max fragment length, DTLS: enabled, default, larger message" \
1672 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001673 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001674 1 \
1675 -c "Maximum fragment length is 16384" \
1676 -s "Maximum fragment length is 16384" \
1677 -C "client hello, adding max_fragment_length extension" \
1678 -S "found max fragment length extension" \
1679 -S "server hello, max_fragment_length extension" \
1680 -C "found max_fragment_length extension" \
1681 -c "fragment larger than.*maximum "
1682
1683requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1684run_test "Max fragment length: disabled, larger message" \
1685 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001686 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001687 0 \
1688 -C "Maximum fragment length is 16384" \
1689 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001690 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001691 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001692 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001693
1694requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1695run_test "Max fragment length DTLS: disabled, larger message" \
1696 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001697 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001698 1 \
1699 -C "Maximum fragment length is 16384" \
1700 -S "Maximum fragment length is 16384" \
1701 -c "fragment larger than.*maximum "
1702
1703requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001704run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001705 "$P_SRV debug_level=3" \
1706 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001707 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001708 -c "Maximum fragment length is 4096" \
1709 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001710 -c "client hello, adding max_fragment_length extension" \
1711 -s "found max fragment length extension" \
1712 -s "server hello, max_fragment_length extension" \
1713 -c "found max_fragment_length extension"
1714
Hanno Becker4aed27e2017-09-18 15:00:34 +01001715requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001716run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001717 "$P_SRV debug_level=3 max_frag_len=4096" \
1718 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001719 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001720 -c "Maximum fragment length is 16384" \
1721 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001722 -C "client hello, adding max_fragment_length extension" \
1723 -S "found max fragment length extension" \
1724 -S "server hello, max_fragment_length extension" \
1725 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001726
Hanno Becker4aed27e2017-09-18 15:00:34 +01001727requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001728requires_gnutls
1729run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001730 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001731 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001732 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001733 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001734 -c "client hello, adding max_fragment_length extension" \
1735 -c "found max_fragment_length extension"
1736
Hanno Becker4aed27e2017-09-18 15:00:34 +01001737requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001738run_test "Max fragment length: client, message just fits" \
1739 "$P_SRV debug_level=3" \
1740 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1741 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001742 -c "Maximum fragment length is 2048" \
1743 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001744 -c "client hello, adding max_fragment_length extension" \
1745 -s "found max fragment length extension" \
1746 -s "server hello, max_fragment_length extension" \
1747 -c "found max_fragment_length extension" \
1748 -c "2048 bytes written in 1 fragments" \
1749 -s "2048 bytes read"
1750
Hanno Becker4aed27e2017-09-18 15:00:34 +01001751requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001752run_test "Max fragment length: client, larger message" \
1753 "$P_SRV debug_level=3" \
1754 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1755 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001756 -c "Maximum fragment length is 2048" \
1757 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001758 -c "client hello, adding max_fragment_length extension" \
1759 -s "found max fragment length extension" \
1760 -s "server hello, max_fragment_length extension" \
1761 -c "found max_fragment_length extension" \
1762 -c "2345 bytes written in 2 fragments" \
1763 -s "2048 bytes read" \
1764 -s "297 bytes read"
1765
Hanno Becker4aed27e2017-09-18 15:00:34 +01001766requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001767run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001768 "$P_SRV debug_level=3 dtls=1" \
1769 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1770 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001771 -c "Maximum fragment length is 2048" \
1772 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001773 -c "client hello, adding max_fragment_length extension" \
1774 -s "found max fragment length extension" \
1775 -s "server hello, max_fragment_length extension" \
1776 -c "found max_fragment_length extension" \
1777 -c "fragment larger than.*maximum"
1778
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001779# Tests for renegotiation
1780
Hanno Becker6a243642017-10-12 15:18:45 +01001781# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001782run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001783 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001784 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001785 0 \
1786 -C "client hello, adding renegotiation extension" \
1787 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1788 -S "found renegotiation extension" \
1789 -s "server hello, secure renegotiation extension" \
1790 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001791 -C "=> renegotiate" \
1792 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001793 -S "write hello request"
1794
Hanno Becker6a243642017-10-12 15:18:45 +01001795requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001796run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001797 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001798 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001799 0 \
1800 -c "client hello, adding renegotiation extension" \
1801 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1802 -s "found renegotiation extension" \
1803 -s "server hello, secure renegotiation extension" \
1804 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001805 -c "=> renegotiate" \
1806 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001807 -S "write hello request"
1808
Hanno Becker6a243642017-10-12 15:18:45 +01001809requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001810run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001811 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001812 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001813 0 \
1814 -c "client hello, adding renegotiation extension" \
1815 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1816 -s "found renegotiation extension" \
1817 -s "server hello, secure renegotiation extension" \
1818 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001819 -c "=> renegotiate" \
1820 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001821 -s "write hello request"
1822
Janos Follathb0f148c2017-10-05 12:29:42 +01001823# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1824# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1825# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001826requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001827run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1828 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1829 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1830 0 \
1831 -c "client hello, adding renegotiation extension" \
1832 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1833 -s "found renegotiation extension" \
1834 -s "server hello, secure renegotiation extension" \
1835 -c "found renegotiation extension" \
1836 -c "=> renegotiate" \
1837 -s "=> renegotiate" \
1838 -S "write hello request" \
1839 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1840
1841# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1842# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1843# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001844requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001845run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1846 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1847 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1848 0 \
1849 -c "client hello, adding renegotiation extension" \
1850 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1851 -s "found renegotiation extension" \
1852 -s "server hello, secure renegotiation extension" \
1853 -c "found renegotiation extension" \
1854 -c "=> renegotiate" \
1855 -s "=> renegotiate" \
1856 -s "write hello request" \
1857 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1858
Hanno Becker6a243642017-10-12 15:18:45 +01001859requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001860run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001861 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001862 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001863 0 \
1864 -c "client hello, adding renegotiation extension" \
1865 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1866 -s "found renegotiation extension" \
1867 -s "server hello, secure renegotiation extension" \
1868 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001869 -c "=> renegotiate" \
1870 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001871 -s "write hello request"
1872
Hanno Becker6a243642017-10-12 15:18:45 +01001873requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001874run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001875 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001876 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001877 1 \
1878 -c "client hello, adding renegotiation extension" \
1879 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1880 -S "found renegotiation extension" \
1881 -s "server hello, secure renegotiation extension" \
1882 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001883 -c "=> renegotiate" \
1884 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001885 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001886 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001887 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001888
Hanno Becker6a243642017-10-12 15:18:45 +01001889requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001890run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001891 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001892 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001893 0 \
1894 -C "client hello, adding renegotiation extension" \
1895 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1896 -S "found renegotiation extension" \
1897 -s "server hello, secure renegotiation extension" \
1898 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001899 -C "=> renegotiate" \
1900 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001901 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001902 -S "SSL - An unexpected message was received from our peer" \
1903 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001904
Hanno Becker6a243642017-10-12 15:18:45 +01001905requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001906run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001907 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001908 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001909 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001910 0 \
1911 -C "client hello, adding renegotiation extension" \
1912 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1913 -S "found renegotiation extension" \
1914 -s "server hello, secure renegotiation extension" \
1915 -c "found renegotiation extension" \
1916 -C "=> renegotiate" \
1917 -S "=> renegotiate" \
1918 -s "write hello request" \
1919 -S "SSL - An unexpected message was received from our peer" \
1920 -S "failed"
1921
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001922# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001923requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001924run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001925 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001926 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001927 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001928 0 \
1929 -C "client hello, adding renegotiation extension" \
1930 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1931 -S "found renegotiation extension" \
1932 -s "server hello, secure renegotiation extension" \
1933 -c "found renegotiation extension" \
1934 -C "=> renegotiate" \
1935 -S "=> renegotiate" \
1936 -s "write hello request" \
1937 -S "SSL - An unexpected message was received from our peer" \
1938 -S "failed"
1939
Hanno Becker6a243642017-10-12 15:18:45 +01001940requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001941run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001942 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001943 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001944 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001945 0 \
1946 -C "client hello, adding renegotiation extension" \
1947 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1948 -S "found renegotiation extension" \
1949 -s "server hello, secure renegotiation extension" \
1950 -c "found renegotiation extension" \
1951 -C "=> renegotiate" \
1952 -S "=> renegotiate" \
1953 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001954 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001955
Hanno Becker6a243642017-10-12 15:18:45 +01001956requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001957run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001958 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001959 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001960 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001961 0 \
1962 -c "client hello, adding renegotiation extension" \
1963 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1964 -s "found renegotiation extension" \
1965 -s "server hello, secure renegotiation extension" \
1966 -c "found renegotiation extension" \
1967 -c "=> renegotiate" \
1968 -s "=> renegotiate" \
1969 -s "write hello request" \
1970 -S "SSL - An unexpected message was received from our peer" \
1971 -S "failed"
1972
Hanno Becker6a243642017-10-12 15:18:45 +01001973requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001974run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001975 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001976 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1977 0 \
1978 -C "client hello, adding renegotiation extension" \
1979 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1980 -S "found renegotiation extension" \
1981 -s "server hello, secure renegotiation extension" \
1982 -c "found renegotiation extension" \
1983 -S "record counter limit reached: renegotiate" \
1984 -C "=> renegotiate" \
1985 -S "=> renegotiate" \
1986 -S "write hello request" \
1987 -S "SSL - An unexpected message was received from our peer" \
1988 -S "failed"
1989
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001990# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001991requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001992run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001993 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001994 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001995 0 \
1996 -c "client hello, adding renegotiation extension" \
1997 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1998 -s "found renegotiation extension" \
1999 -s "server hello, secure renegotiation extension" \
2000 -c "found renegotiation extension" \
2001 -s "record counter limit reached: renegotiate" \
2002 -c "=> renegotiate" \
2003 -s "=> renegotiate" \
2004 -s "write hello request" \
2005 -S "SSL - An unexpected message was received from our peer" \
2006 -S "failed"
2007
Hanno Becker6a243642017-10-12 15:18:45 +01002008requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002009run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002010 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002011 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002012 0 \
2013 -c "client hello, adding renegotiation extension" \
2014 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2015 -s "found renegotiation extension" \
2016 -s "server hello, secure renegotiation extension" \
2017 -c "found renegotiation extension" \
2018 -s "record counter limit reached: renegotiate" \
2019 -c "=> renegotiate" \
2020 -s "=> renegotiate" \
2021 -s "write hello request" \
2022 -S "SSL - An unexpected message was received from our peer" \
2023 -S "failed"
2024
Hanno Becker6a243642017-10-12 15:18:45 +01002025requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002026run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002027 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002028 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2029 0 \
2030 -C "client hello, adding renegotiation extension" \
2031 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2032 -S "found renegotiation extension" \
2033 -s "server hello, secure renegotiation extension" \
2034 -c "found renegotiation extension" \
2035 -S "record counter limit reached: renegotiate" \
2036 -C "=> renegotiate" \
2037 -S "=> renegotiate" \
2038 -S "write hello request" \
2039 -S "SSL - An unexpected message was received from our peer" \
2040 -S "failed"
2041
Hanno Becker6a243642017-10-12 15:18:45 +01002042requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002043run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002044 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002045 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002046 0 \
2047 -c "client hello, adding renegotiation extension" \
2048 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2049 -s "found renegotiation extension" \
2050 -s "server hello, secure renegotiation extension" \
2051 -c "found renegotiation extension" \
2052 -c "=> renegotiate" \
2053 -s "=> renegotiate" \
2054 -S "write hello request"
2055
Hanno Becker6a243642017-10-12 15:18:45 +01002056requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002057run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002058 "$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 +02002059 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002060 0 \
2061 -c "client hello, adding renegotiation extension" \
2062 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2063 -s "found renegotiation extension" \
2064 -s "server hello, secure renegotiation extension" \
2065 -c "found renegotiation extension" \
2066 -c "=> renegotiate" \
2067 -s "=> renegotiate" \
2068 -s "write hello request"
2069
Hanno Becker6a243642017-10-12 15:18:45 +01002070requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002071run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002072 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002073 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002074 0 \
2075 -c "client hello, adding renegotiation extension" \
2076 -c "found renegotiation extension" \
2077 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002078 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002079 -C "error" \
2080 -c "HTTP/1.0 200 [Oo][Kk]"
2081
Paul Bakker539d9722015-02-08 16:18:35 +01002082requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002083requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002084run_test "Renegotiation: gnutls server strict, client-initiated" \
2085 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002086 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002087 0 \
2088 -c "client hello, adding renegotiation extension" \
2089 -c "found renegotiation extension" \
2090 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002091 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002092 -C "error" \
2093 -c "HTTP/1.0 200 [Oo][Kk]"
2094
Paul Bakker539d9722015-02-08 16:18:35 +01002095requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002096requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002097run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2098 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2099 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2100 1 \
2101 -c "client hello, adding renegotiation extension" \
2102 -C "found renegotiation extension" \
2103 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002104 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002105 -c "error" \
2106 -C "HTTP/1.0 200 [Oo][Kk]"
2107
Paul Bakker539d9722015-02-08 16:18:35 +01002108requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002109requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002110run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2111 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2112 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2113 allow_legacy=0" \
2114 1 \
2115 -c "client hello, adding renegotiation extension" \
2116 -C "found renegotiation extension" \
2117 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002118 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002119 -c "error" \
2120 -C "HTTP/1.0 200 [Oo][Kk]"
2121
Paul Bakker539d9722015-02-08 16:18:35 +01002122requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002123requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002124run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2125 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2126 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2127 allow_legacy=1" \
2128 0 \
2129 -c "client hello, adding renegotiation extension" \
2130 -C "found renegotiation extension" \
2131 -c "=> renegotiate" \
2132 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002133 -C "error" \
2134 -c "HTTP/1.0 200 [Oo][Kk]"
2135
Hanno Becker6a243642017-10-12 15:18:45 +01002136requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002137run_test "Renegotiation: DTLS, client-initiated" \
2138 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2139 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2140 0 \
2141 -c "client hello, adding renegotiation extension" \
2142 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2143 -s "found renegotiation extension" \
2144 -s "server hello, secure renegotiation extension" \
2145 -c "found renegotiation extension" \
2146 -c "=> renegotiate" \
2147 -s "=> renegotiate" \
2148 -S "write hello request"
2149
Hanno Becker6a243642017-10-12 15:18:45 +01002150requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002151run_test "Renegotiation: DTLS, server-initiated" \
2152 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002153 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2154 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002155 0 \
2156 -c "client hello, adding renegotiation extension" \
2157 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2158 -s "found renegotiation extension" \
2159 -s "server hello, secure renegotiation extension" \
2160 -c "found renegotiation extension" \
2161 -c "=> renegotiate" \
2162 -s "=> renegotiate" \
2163 -s "write hello request"
2164
Hanno Becker6a243642017-10-12 15:18:45 +01002165requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002166run_test "Renegotiation: DTLS, renego_period overflow" \
2167 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2168 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2169 0 \
2170 -c "client hello, adding renegotiation extension" \
2171 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2172 -s "found renegotiation extension" \
2173 -s "server hello, secure renegotiation extension" \
2174 -s "record counter limit reached: renegotiate" \
2175 -c "=> renegotiate" \
2176 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002177 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002178
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002179requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002180requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002181run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2182 "$G_SRV -u --mtu 4096" \
2183 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2184 0 \
2185 -c "client hello, adding renegotiation extension" \
2186 -c "found renegotiation extension" \
2187 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002188 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002189 -C "error" \
2190 -s "Extra-header:"
2191
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002192# Test for the "secure renegotation" extension only (no actual renegotiation)
2193
Paul Bakker539d9722015-02-08 16:18:35 +01002194requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002195run_test "Renego ext: gnutls server strict, client default" \
2196 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2197 "$P_CLI debug_level=3" \
2198 0 \
2199 -c "found renegotiation extension" \
2200 -C "error" \
2201 -c "HTTP/1.0 200 [Oo][Kk]"
2202
Paul Bakker539d9722015-02-08 16:18:35 +01002203requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002204run_test "Renego ext: gnutls server unsafe, client default" \
2205 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2206 "$P_CLI debug_level=3" \
2207 0 \
2208 -C "found renegotiation extension" \
2209 -C "error" \
2210 -c "HTTP/1.0 200 [Oo][Kk]"
2211
Paul Bakker539d9722015-02-08 16:18:35 +01002212requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002213run_test "Renego ext: gnutls server unsafe, client break legacy" \
2214 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2215 "$P_CLI debug_level=3 allow_legacy=-1" \
2216 1 \
2217 -C "found renegotiation extension" \
2218 -c "error" \
2219 -C "HTTP/1.0 200 [Oo][Kk]"
2220
Paul Bakker539d9722015-02-08 16:18:35 +01002221requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002222run_test "Renego ext: gnutls client strict, server default" \
2223 "$P_SRV debug_level=3" \
2224 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2225 0 \
2226 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2227 -s "server hello, secure renegotiation extension"
2228
Paul Bakker539d9722015-02-08 16:18:35 +01002229requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002230run_test "Renego ext: gnutls client unsafe, server default" \
2231 "$P_SRV debug_level=3" \
2232 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2233 0 \
2234 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2235 -S "server hello, secure renegotiation extension"
2236
Paul Bakker539d9722015-02-08 16:18:35 +01002237requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002238run_test "Renego ext: gnutls client unsafe, server break legacy" \
2239 "$P_SRV debug_level=3 allow_legacy=-1" \
2240 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2241 1 \
2242 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2243 -S "server hello, secure renegotiation extension"
2244
Janos Follath0b242342016-02-17 10:11:21 +00002245# Tests for silently dropping trailing extra bytes in .der certificates
2246
2247requires_gnutls
2248run_test "DER format: no trailing bytes" \
2249 "$P_SRV crt_file=data_files/server5-der0.crt \
2250 key_file=data_files/server5.key" \
2251 "$G_CLI " \
2252 0 \
2253 -c "Handshake was completed" \
2254
2255requires_gnutls
2256run_test "DER format: with a trailing zero byte" \
2257 "$P_SRV crt_file=data_files/server5-der1a.crt \
2258 key_file=data_files/server5.key" \
2259 "$G_CLI " \
2260 0 \
2261 -c "Handshake was completed" \
2262
2263requires_gnutls
2264run_test "DER format: with a trailing random byte" \
2265 "$P_SRV crt_file=data_files/server5-der1b.crt \
2266 key_file=data_files/server5.key" \
2267 "$G_CLI " \
2268 0 \
2269 -c "Handshake was completed" \
2270
2271requires_gnutls
2272run_test "DER format: with 2 trailing random bytes" \
2273 "$P_SRV crt_file=data_files/server5-der2.crt \
2274 key_file=data_files/server5.key" \
2275 "$G_CLI " \
2276 0 \
2277 -c "Handshake was completed" \
2278
2279requires_gnutls
2280run_test "DER format: with 4 trailing random bytes" \
2281 "$P_SRV crt_file=data_files/server5-der4.crt \
2282 key_file=data_files/server5.key" \
2283 "$G_CLI " \
2284 0 \
2285 -c "Handshake was completed" \
2286
2287requires_gnutls
2288run_test "DER format: with 8 trailing random bytes" \
2289 "$P_SRV crt_file=data_files/server5-der8.crt \
2290 key_file=data_files/server5.key" \
2291 "$G_CLI " \
2292 0 \
2293 -c "Handshake was completed" \
2294
2295requires_gnutls
2296run_test "DER format: with 9 trailing random bytes" \
2297 "$P_SRV crt_file=data_files/server5-der9.crt \
2298 key_file=data_files/server5.key" \
2299 "$G_CLI " \
2300 0 \
2301 -c "Handshake was completed" \
2302
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002303# Tests for auth_mode
2304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002305run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002306 "$P_SRV crt_file=data_files/server5-badsign.crt \
2307 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002308 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002309 1 \
2310 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002311 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002312 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002313 -c "X509 - Certificate verification failed"
2314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002315run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002316 "$P_SRV crt_file=data_files/server5-badsign.crt \
2317 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002318 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002319 0 \
2320 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002321 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002322 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002323 -C "X509 - Certificate verification failed"
2324
Hanno Beckere6706e62017-05-15 16:05:15 +01002325run_test "Authentication: server goodcert, client optional, no trusted CA" \
2326 "$P_SRV" \
2327 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2328 0 \
2329 -c "x509_verify_cert() returned" \
2330 -c "! The certificate is not correctly signed by the trusted CA" \
2331 -c "! Certificate verification flags"\
2332 -C "! mbedtls_ssl_handshake returned" \
2333 -C "X509 - Certificate verification failed" \
2334 -C "SSL - No CA Chain is set, but required to operate"
2335
2336run_test "Authentication: server goodcert, client required, no trusted CA" \
2337 "$P_SRV" \
2338 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2339 1 \
2340 -c "x509_verify_cert() returned" \
2341 -c "! The certificate is not correctly signed by the trusted CA" \
2342 -c "! Certificate verification flags"\
2343 -c "! mbedtls_ssl_handshake returned" \
2344 -c "SSL - No CA Chain is set, but required to operate"
2345
2346# The purpose of the next two tests is to test the client's behaviour when receiving a server
2347# certificate with an unsupported elliptic curve. This should usually not happen because
2348# the client informs the server about the supported curves - it does, though, in the
2349# corner case of a static ECDH suite, because the server doesn't check the curve on that
2350# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2351# different means to have the server ignoring the client's supported curve list.
2352
2353requires_config_enabled MBEDTLS_ECP_C
2354run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2355 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2356 crt_file=data_files/server5.ku-ka.crt" \
2357 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2358 1 \
2359 -c "bad certificate (EC key curve)"\
2360 -c "! Certificate verification flags"\
2361 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2362
2363requires_config_enabled MBEDTLS_ECP_C
2364run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2365 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2366 crt_file=data_files/server5.ku-ka.crt" \
2367 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2368 1 \
2369 -c "bad certificate (EC key curve)"\
2370 -c "! Certificate verification flags"\
2371 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002373run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002374 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002375 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002376 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002377 0 \
2378 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002379 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002380 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002381 -C "X509 - Certificate verification failed"
2382
Simon Butcher99000142016-10-13 17:21:01 +01002383run_test "Authentication: client SHA256, server required" \
2384 "$P_SRV auth_mode=required" \
2385 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2386 key_file=data_files/server6.key \
2387 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2388 0 \
2389 -c "Supported Signature Algorithm found: 4," \
2390 -c "Supported Signature Algorithm found: 5,"
2391
2392run_test "Authentication: client SHA384, server required" \
2393 "$P_SRV auth_mode=required" \
2394 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2395 key_file=data_files/server6.key \
2396 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2397 0 \
2398 -c "Supported Signature Algorithm found: 4," \
2399 -c "Supported Signature Algorithm found: 5,"
2400
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002401requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2402run_test "Authentication: client has no cert, server required (SSLv3)" \
2403 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2404 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2405 key_file=data_files/server5.key" \
2406 1 \
2407 -S "skip write certificate request" \
2408 -C "skip parse certificate request" \
2409 -c "got a certificate request" \
2410 -c "got no certificate to send" \
2411 -S "x509_verify_cert() returned" \
2412 -s "client has no certificate" \
2413 -s "! mbedtls_ssl_handshake returned" \
2414 -c "! mbedtls_ssl_handshake returned" \
2415 -s "No client certification received from the client, but required by the authentication mode"
2416
2417run_test "Authentication: client has no cert, server required (TLS)" \
2418 "$P_SRV debug_level=3 auth_mode=required" \
2419 "$P_CLI debug_level=3 crt_file=none \
2420 key_file=data_files/server5.key" \
2421 1 \
2422 -S "skip write certificate request" \
2423 -C "skip parse certificate request" \
2424 -c "got a certificate request" \
2425 -c "= write certificate$" \
2426 -C "skip write certificate$" \
2427 -S "x509_verify_cert() returned" \
2428 -s "client has no certificate" \
2429 -s "! mbedtls_ssl_handshake returned" \
2430 -c "! mbedtls_ssl_handshake returned" \
2431 -s "No client certification received from the client, but required by the authentication mode"
2432
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002433run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002434 "$P_SRV debug_level=3 auth_mode=required" \
2435 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002436 key_file=data_files/server5.key" \
2437 1 \
2438 -S "skip write certificate request" \
2439 -C "skip parse certificate request" \
2440 -c "got a certificate request" \
2441 -C "skip write certificate" \
2442 -C "skip write certificate verify" \
2443 -S "skip parse certificate verify" \
2444 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002445 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002446 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002447 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002448 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002449 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002450# We don't check that the client receives the alert because it might
2451# detect that its write end of the connection is closed and abort
2452# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002453
Janos Follath89baba22017-04-10 14:34:35 +01002454run_test "Authentication: client cert not trusted, server required" \
2455 "$P_SRV debug_level=3 auth_mode=required" \
2456 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2457 key_file=data_files/server5.key" \
2458 1 \
2459 -S "skip write certificate request" \
2460 -C "skip parse certificate request" \
2461 -c "got a certificate request" \
2462 -C "skip write certificate" \
2463 -C "skip write certificate verify" \
2464 -S "skip parse certificate verify" \
2465 -s "x509_verify_cert() returned" \
2466 -s "! The certificate is not correctly signed by the trusted CA" \
2467 -s "! mbedtls_ssl_handshake returned" \
2468 -c "! mbedtls_ssl_handshake returned" \
2469 -s "X509 - Certificate verification failed"
2470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002471run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002472 "$P_SRV debug_level=3 auth_mode=optional" \
2473 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002474 key_file=data_files/server5.key" \
2475 0 \
2476 -S "skip write certificate request" \
2477 -C "skip parse certificate request" \
2478 -c "got a certificate request" \
2479 -C "skip write certificate" \
2480 -C "skip write certificate verify" \
2481 -S "skip parse certificate verify" \
2482 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002483 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002484 -S "! mbedtls_ssl_handshake returned" \
2485 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002486 -S "X509 - Certificate verification failed"
2487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002488run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002489 "$P_SRV debug_level=3 auth_mode=none" \
2490 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002491 key_file=data_files/server5.key" \
2492 0 \
2493 -s "skip write certificate request" \
2494 -C "skip parse certificate request" \
2495 -c "got no certificate request" \
2496 -c "skip write certificate" \
2497 -c "skip write certificate verify" \
2498 -s "skip parse certificate verify" \
2499 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002500 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002501 -S "! mbedtls_ssl_handshake returned" \
2502 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002503 -S "X509 - Certificate verification failed"
2504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002505run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002506 "$P_SRV debug_level=3 auth_mode=optional" \
2507 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002508 0 \
2509 -S "skip write certificate request" \
2510 -C "skip parse certificate request" \
2511 -c "got a certificate request" \
2512 -C "skip write certificate$" \
2513 -C "got no certificate to send" \
2514 -S "SSLv3 client has no certificate" \
2515 -c "skip write certificate verify" \
2516 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002517 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002518 -S "! mbedtls_ssl_handshake returned" \
2519 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002520 -S "X509 - Certificate verification failed"
2521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002522run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002523 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002524 "$O_CLI" \
2525 0 \
2526 -S "skip write certificate request" \
2527 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002528 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002529 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002530 -S "X509 - Certificate verification failed"
2531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002532run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002533 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002534 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002535 0 \
2536 -C "skip parse certificate request" \
2537 -c "got a certificate request" \
2538 -C "skip write certificate$" \
2539 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002540 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002541
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002542run_test "Authentication: client no cert, openssl server required" \
2543 "$O_SRV -Verify 10" \
2544 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2545 1 \
2546 -C "skip parse certificate request" \
2547 -c "got a certificate request" \
2548 -C "skip write certificate$" \
2549 -c "skip write certificate verify" \
2550 -c "! mbedtls_ssl_handshake returned"
2551
Janos Follathe2681a42016-03-07 15:57:05 +00002552requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002553run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002554 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002555 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002556 0 \
2557 -S "skip write certificate request" \
2558 -C "skip parse certificate request" \
2559 -c "got a certificate request" \
2560 -C "skip write certificate$" \
2561 -c "skip write certificate verify" \
2562 -c "got no certificate to send" \
2563 -s "SSLv3 client has no certificate" \
2564 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002565 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002566 -S "! mbedtls_ssl_handshake returned" \
2567 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002568 -S "X509 - Certificate verification failed"
2569
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002570# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2571# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002572
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002573MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002574MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002575
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002576if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002577 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002578 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002579 printf "test value of ${MAX_IM_CA}. \n"
2580 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002581 printf "The tests assume this value and if it changes, the tests in this\n"
2582 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002583 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002584
2585 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002586fi
2587
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002588run_test "Authentication: server max_int chain, client default" \
2589 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2590 key_file=data_files/dir-maxpath/09.key" \
2591 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2592 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002593 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002594
2595run_test "Authentication: server max_int+1 chain, client default" \
2596 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2597 key_file=data_files/dir-maxpath/10.key" \
2598 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2599 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002600 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002601
2602run_test "Authentication: server max_int+1 chain, client optional" \
2603 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2604 key_file=data_files/dir-maxpath/10.key" \
2605 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2606 auth_mode=optional" \
2607 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002608 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002609
2610run_test "Authentication: server max_int+1 chain, client none" \
2611 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2612 key_file=data_files/dir-maxpath/10.key" \
2613 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2614 auth_mode=none" \
2615 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002616 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002617
2618run_test "Authentication: client max_int+1 chain, server default" \
2619 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2620 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2621 key_file=data_files/dir-maxpath/10.key" \
2622 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002623 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002624
2625run_test "Authentication: client max_int+1 chain, server optional" \
2626 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2627 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2628 key_file=data_files/dir-maxpath/10.key" \
2629 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002630 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002631
2632run_test "Authentication: client max_int+1 chain, server required" \
2633 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2634 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2635 key_file=data_files/dir-maxpath/10.key" \
2636 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002637 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002638
2639run_test "Authentication: client max_int chain, server required" \
2640 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2641 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2642 key_file=data_files/dir-maxpath/09.key" \
2643 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002644 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002645
Janos Follath89baba22017-04-10 14:34:35 +01002646# Tests for CA list in CertificateRequest messages
2647
2648run_test "Authentication: send CA list in CertificateRequest (default)" \
2649 "$P_SRV debug_level=3 auth_mode=required" \
2650 "$P_CLI crt_file=data_files/server6.crt \
2651 key_file=data_files/server6.key" \
2652 0 \
2653 -s "requested DN"
2654
2655run_test "Authentication: do not send CA list in CertificateRequest" \
2656 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2657 "$P_CLI crt_file=data_files/server6.crt \
2658 key_file=data_files/server6.key" \
2659 0 \
2660 -S "requested DN"
2661
2662run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2663 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2664 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2665 key_file=data_files/server5.key" \
2666 1 \
2667 -S "requested DN" \
2668 -s "x509_verify_cert() returned" \
2669 -s "! The certificate is not correctly signed by the trusted CA" \
2670 -s "! mbedtls_ssl_handshake returned" \
2671 -c "! mbedtls_ssl_handshake returned" \
2672 -s "X509 - Certificate verification failed"
2673
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002674# Tests for certificate selection based on SHA verson
2675
2676run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2677 "$P_SRV crt_file=data_files/server5.crt \
2678 key_file=data_files/server5.key \
2679 crt_file2=data_files/server5-sha1.crt \
2680 key_file2=data_files/server5.key" \
2681 "$P_CLI force_version=tls1_2" \
2682 0 \
2683 -c "signed using.*ECDSA with SHA256" \
2684 -C "signed using.*ECDSA with SHA1"
2685
2686run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2687 "$P_SRV crt_file=data_files/server5.crt \
2688 key_file=data_files/server5.key \
2689 crt_file2=data_files/server5-sha1.crt \
2690 key_file2=data_files/server5.key" \
2691 "$P_CLI force_version=tls1_1" \
2692 0 \
2693 -C "signed using.*ECDSA with SHA256" \
2694 -c "signed using.*ECDSA with SHA1"
2695
2696run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2697 "$P_SRV crt_file=data_files/server5.crt \
2698 key_file=data_files/server5.key \
2699 crt_file2=data_files/server5-sha1.crt \
2700 key_file2=data_files/server5.key" \
2701 "$P_CLI force_version=tls1" \
2702 0 \
2703 -C "signed using.*ECDSA with SHA256" \
2704 -c "signed using.*ECDSA with SHA1"
2705
2706run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2707 "$P_SRV crt_file=data_files/server5.crt \
2708 key_file=data_files/server5.key \
2709 crt_file2=data_files/server6.crt \
2710 key_file2=data_files/server6.key" \
2711 "$P_CLI force_version=tls1_1" \
2712 0 \
2713 -c "serial number.*09" \
2714 -c "signed using.*ECDSA with SHA256" \
2715 -C "signed using.*ECDSA with SHA1"
2716
2717run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2718 "$P_SRV crt_file=data_files/server6.crt \
2719 key_file=data_files/server6.key \
2720 crt_file2=data_files/server5.crt \
2721 key_file2=data_files/server5.key" \
2722 "$P_CLI force_version=tls1_1" \
2723 0 \
2724 -c "serial number.*0A" \
2725 -c "signed using.*ECDSA with SHA256" \
2726 -C "signed using.*ECDSA with SHA1"
2727
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002728# tests for SNI
2729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002730run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002731 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002732 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002733 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002734 0 \
2735 -S "parse ServerName extension" \
2736 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2737 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002739run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002740 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002741 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002742 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 +02002743 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002744 0 \
2745 -s "parse ServerName extension" \
2746 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2747 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002749run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002750 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002751 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002752 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 +02002753 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002754 0 \
2755 -s "parse ServerName extension" \
2756 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2757 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002759run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002760 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002761 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002762 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 +02002763 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002764 1 \
2765 -s "parse ServerName extension" \
2766 -s "ssl_sni_wrapper() returned" \
2767 -s "mbedtls_ssl_handshake returned" \
2768 -c "mbedtls_ssl_handshake returned" \
2769 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002770
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002771run_test "SNI: client auth no override: optional" \
2772 "$P_SRV debug_level=3 auth_mode=optional \
2773 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2774 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2775 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002776 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002777 -S "skip write certificate request" \
2778 -C "skip parse certificate request" \
2779 -c "got a certificate request" \
2780 -C "skip write certificate" \
2781 -C "skip write certificate verify" \
2782 -S "skip parse certificate verify"
2783
2784run_test "SNI: client auth override: none -> optional" \
2785 "$P_SRV debug_level=3 auth_mode=none \
2786 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2787 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2788 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002789 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002790 -S "skip write certificate request" \
2791 -C "skip parse certificate request" \
2792 -c "got a certificate request" \
2793 -C "skip write certificate" \
2794 -C "skip write certificate verify" \
2795 -S "skip parse certificate verify"
2796
2797run_test "SNI: client auth override: optional -> none" \
2798 "$P_SRV debug_level=3 auth_mode=optional \
2799 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2800 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2801 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002802 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002803 -s "skip write certificate request" \
2804 -C "skip parse certificate request" \
2805 -c "got no certificate request" \
2806 -c "skip write certificate" \
2807 -c "skip write certificate verify" \
2808 -s "skip parse certificate verify"
2809
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002810run_test "SNI: CA no override" \
2811 "$P_SRV debug_level=3 auth_mode=optional \
2812 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2813 ca_file=data_files/test-ca.crt \
2814 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2815 "$P_CLI debug_level=3 server_name=localhost \
2816 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2817 1 \
2818 -S "skip write certificate request" \
2819 -C "skip parse certificate request" \
2820 -c "got a certificate request" \
2821 -C "skip write certificate" \
2822 -C "skip write certificate verify" \
2823 -S "skip parse certificate verify" \
2824 -s "x509_verify_cert() returned" \
2825 -s "! The certificate is not correctly signed by the trusted CA" \
2826 -S "The certificate has been revoked (is on a CRL)"
2827
2828run_test "SNI: CA override" \
2829 "$P_SRV debug_level=3 auth_mode=optional \
2830 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2831 ca_file=data_files/test-ca.crt \
2832 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2833 "$P_CLI debug_level=3 server_name=localhost \
2834 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2835 0 \
2836 -S "skip write certificate request" \
2837 -C "skip parse certificate request" \
2838 -c "got a certificate request" \
2839 -C "skip write certificate" \
2840 -C "skip write certificate verify" \
2841 -S "skip parse certificate verify" \
2842 -S "x509_verify_cert() returned" \
2843 -S "! The certificate is not correctly signed by the trusted CA" \
2844 -S "The certificate has been revoked (is on a CRL)"
2845
2846run_test "SNI: CA override with CRL" \
2847 "$P_SRV debug_level=3 auth_mode=optional \
2848 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2849 ca_file=data_files/test-ca.crt \
2850 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2851 "$P_CLI debug_level=3 server_name=localhost \
2852 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2853 1 \
2854 -S "skip write certificate request" \
2855 -C "skip parse certificate request" \
2856 -c "got a certificate request" \
2857 -C "skip write certificate" \
2858 -C "skip write certificate verify" \
2859 -S "skip parse certificate verify" \
2860 -s "x509_verify_cert() returned" \
2861 -S "! The certificate is not correctly signed by the trusted CA" \
2862 -s "The certificate has been revoked (is on a CRL)"
2863
Andres AGe8b07742016-12-07 10:01:30 +00002864# Tests for SNI and DTLS
2865
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002866run_test "SNI: DTLS, no SNI callback" \
2867 "$P_SRV debug_level=3 dtls=1 \
2868 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2869 "$P_CLI server_name=localhost dtls=1" \
2870 0 \
2871 -S "parse ServerName extension" \
2872 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2873 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2874
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002875run_test "SNI: DTLS, matching cert 1" \
Andres AGe8b07742016-12-07 10:01:30 +00002876 "$P_SRV debug_level=3 dtls=1 \
2877 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2878 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2879 "$P_CLI server_name=localhost dtls=1" \
2880 0 \
2881 -s "parse ServerName extension" \
2882 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2883 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2884
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002885run_test "SNI: DTLS, matching cert 2" \
2886 "$P_SRV debug_level=3 dtls=1 \
2887 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2888 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2889 "$P_CLI server_name=polarssl.example dtls=1" \
2890 0 \
2891 -s "parse ServerName extension" \
2892 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2893 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2894
2895run_test "SNI: DTLS, no matching cert" \
2896 "$P_SRV debug_level=3 dtls=1 \
2897 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2898 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2899 "$P_CLI server_name=nonesuch.example dtls=1" \
2900 1 \
2901 -s "parse ServerName extension" \
2902 -s "ssl_sni_wrapper() returned" \
2903 -s "mbedtls_ssl_handshake returned" \
2904 -c "mbedtls_ssl_handshake returned" \
2905 -c "SSL - A fatal alert message was received from our peer"
2906
2907run_test "SNI: DTLS, client auth no override: optional" \
2908 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2909 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2910 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2911 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2912 0 \
2913 -S "skip write certificate request" \
2914 -C "skip parse certificate request" \
2915 -c "got a certificate request" \
2916 -C "skip write certificate" \
2917 -C "skip write certificate verify" \
2918 -S "skip parse certificate verify"
2919
2920run_test "SNI: DTLS, client auth override: none -> optional" \
2921 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2922 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2923 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2924 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2925 0 \
2926 -S "skip write certificate request" \
2927 -C "skip parse certificate request" \
2928 -c "got a certificate request" \
2929 -C "skip write certificate" \
2930 -C "skip write certificate verify" \
2931 -S "skip parse certificate verify"
2932
2933run_test "SNI: DTLS, client auth override: optional -> none" \
2934 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2935 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2936 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2937 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2938 0 \
2939 -s "skip write certificate request" \
2940 -C "skip parse certificate request" \
2941 -c "got no certificate request" \
2942 -c "skip write certificate" \
2943 -c "skip write certificate verify" \
2944 -s "skip parse certificate verify"
2945
2946run_test "SNI: DTLS, CA no override" \
2947 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2948 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2949 ca_file=data_files/test-ca.crt \
2950 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2951 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2952 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2953 1 \
2954 -S "skip write certificate request" \
2955 -C "skip parse certificate request" \
2956 -c "got a certificate request" \
2957 -C "skip write certificate" \
2958 -C "skip write certificate verify" \
2959 -S "skip parse certificate verify" \
2960 -s "x509_verify_cert() returned" \
2961 -s "! The certificate is not correctly signed by the trusted CA" \
2962 -S "The certificate has been revoked (is on a CRL)"
2963
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002964run_test "SNI: DTLS, CA override" \
Andres AGe8b07742016-12-07 10:01:30 +00002965 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2966 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2967 ca_file=data_files/test-ca.crt \
2968 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2969 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2970 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2971 0 \
2972 -S "skip write certificate request" \
2973 -C "skip parse certificate request" \
2974 -c "got a certificate request" \
2975 -C "skip write certificate" \
2976 -C "skip write certificate verify" \
2977 -S "skip parse certificate verify" \
2978 -S "x509_verify_cert() returned" \
2979 -S "! The certificate is not correctly signed by the trusted CA" \
2980 -S "The certificate has been revoked (is on a CRL)"
2981
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002982run_test "SNI: DTLS, CA override with CRL" \
Andres AGe8b07742016-12-07 10:01:30 +00002983 "$P_SRV debug_level=3 auth_mode=optional \
2984 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2985 ca_file=data_files/test-ca.crt \
2986 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2987 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2988 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2989 1 \
2990 -S "skip write certificate request" \
2991 -C "skip parse certificate request" \
2992 -c "got a certificate request" \
2993 -C "skip write certificate" \
2994 -C "skip write certificate verify" \
2995 -S "skip parse certificate verify" \
2996 -s "x509_verify_cert() returned" \
2997 -S "! The certificate is not correctly signed by the trusted CA" \
2998 -s "The certificate has been revoked (is on a CRL)"
2999
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003000# Tests for non-blocking I/O: exercise a variety of handshake flows
3001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003002run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003003 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3004 "$P_CLI nbio=2 tickets=0" \
3005 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003006 -S "mbedtls_ssl_handshake returned" \
3007 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003008 -c "Read from server: .* bytes read"
3009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003010run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003011 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3012 "$P_CLI nbio=2 tickets=0" \
3013 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003014 -S "mbedtls_ssl_handshake returned" \
3015 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003016 -c "Read from server: .* bytes read"
3017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003018run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003019 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3020 "$P_CLI nbio=2 tickets=1" \
3021 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003022 -S "mbedtls_ssl_handshake returned" \
3023 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003024 -c "Read from server: .* bytes read"
3025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003026run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003027 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3028 "$P_CLI nbio=2 tickets=1" \
3029 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003030 -S "mbedtls_ssl_handshake returned" \
3031 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003032 -c "Read from server: .* bytes read"
3033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003034run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003035 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3036 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3037 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003038 -S "mbedtls_ssl_handshake returned" \
3039 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003040 -c "Read from server: .* bytes read"
3041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003042run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003043 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3044 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3045 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003046 -S "mbedtls_ssl_handshake returned" \
3047 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003048 -c "Read from server: .* bytes read"
3049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003050run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003051 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3052 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3053 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003054 -S "mbedtls_ssl_handshake returned" \
3055 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003056 -c "Read from server: .* bytes read"
3057
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003058# Tests for version negotiation
3059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003060run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003061 "$P_SRV" \
3062 "$P_CLI" \
3063 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003064 -S "mbedtls_ssl_handshake returned" \
3065 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003066 -s "Protocol is TLSv1.2" \
3067 -c "Protocol is TLSv1.2"
3068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003069run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003070 "$P_SRV" \
3071 "$P_CLI max_version=tls1_1" \
3072 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003073 -S "mbedtls_ssl_handshake returned" \
3074 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003075 -s "Protocol is TLSv1.1" \
3076 -c "Protocol is TLSv1.1"
3077
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003078run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003079 "$P_SRV max_version=tls1_1" \
3080 "$P_CLI" \
3081 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003082 -S "mbedtls_ssl_handshake returned" \
3083 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003084 -s "Protocol is TLSv1.1" \
3085 -c "Protocol is TLSv1.1"
3086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003087run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003088 "$P_SRV max_version=tls1_1" \
3089 "$P_CLI max_version=tls1_1" \
3090 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003091 -S "mbedtls_ssl_handshake returned" \
3092 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003093 -s "Protocol is TLSv1.1" \
3094 -c "Protocol is TLSv1.1"
3095
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003096run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003097 "$P_SRV min_version=tls1_1" \
3098 "$P_CLI max_version=tls1_1" \
3099 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003100 -S "mbedtls_ssl_handshake returned" \
3101 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003102 -s "Protocol is TLSv1.1" \
3103 -c "Protocol is TLSv1.1"
3104
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003105run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003106 "$P_SRV max_version=tls1_1" \
3107 "$P_CLI min_version=tls1_1" \
3108 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003109 -S "mbedtls_ssl_handshake returned" \
3110 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003111 -s "Protocol is TLSv1.1" \
3112 -c "Protocol is TLSv1.1"
3113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003114run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003115 "$P_SRV max_version=tls1_1" \
3116 "$P_CLI min_version=tls1_2" \
3117 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003118 -s "mbedtls_ssl_handshake returned" \
3119 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003120 -c "SSL - Handshake protocol not within min/max boundaries"
3121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003122run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003123 "$P_SRV min_version=tls1_2" \
3124 "$P_CLI max_version=tls1_1" \
3125 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003126 -s "mbedtls_ssl_handshake returned" \
3127 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003128 -s "SSL - Handshake protocol not within min/max boundaries"
3129
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003130# Tests for ALPN extension
3131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003132run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003133 "$P_SRV debug_level=3" \
3134 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003135 0 \
3136 -C "client hello, adding alpn extension" \
3137 -S "found alpn extension" \
3138 -C "got an alert message, type: \\[2:120]" \
3139 -S "server hello, adding alpn extension" \
3140 -C "found alpn extension " \
3141 -C "Application Layer Protocol is" \
3142 -S "Application Layer Protocol is"
3143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003144run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003145 "$P_SRV debug_level=3" \
3146 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003147 0 \
3148 -c "client hello, adding alpn extension" \
3149 -s "found alpn extension" \
3150 -C "got an alert message, type: \\[2:120]" \
3151 -S "server hello, adding alpn extension" \
3152 -C "found alpn extension " \
3153 -c "Application Layer Protocol is (none)" \
3154 -S "Application Layer Protocol is"
3155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003156run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003157 "$P_SRV debug_level=3 alpn=abc,1234" \
3158 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003159 0 \
3160 -C "client hello, adding alpn extension" \
3161 -S "found alpn extension" \
3162 -C "got an alert message, type: \\[2:120]" \
3163 -S "server hello, adding alpn extension" \
3164 -C "found alpn extension " \
3165 -C "Application Layer Protocol is" \
3166 -s "Application Layer Protocol is (none)"
3167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003168run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003169 "$P_SRV debug_level=3 alpn=abc,1234" \
3170 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003171 0 \
3172 -c "client hello, adding alpn extension" \
3173 -s "found alpn extension" \
3174 -C "got an alert message, type: \\[2:120]" \
3175 -s "server hello, adding alpn extension" \
3176 -c "found alpn extension" \
3177 -c "Application Layer Protocol is abc" \
3178 -s "Application Layer Protocol is abc"
3179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003180run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003181 "$P_SRV debug_level=3 alpn=abc,1234" \
3182 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003183 0 \
3184 -c "client hello, adding alpn extension" \
3185 -s "found alpn extension" \
3186 -C "got an alert message, type: \\[2:120]" \
3187 -s "server hello, adding alpn extension" \
3188 -c "found alpn extension" \
3189 -c "Application Layer Protocol is abc" \
3190 -s "Application Layer Protocol is abc"
3191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003192run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003193 "$P_SRV debug_level=3 alpn=abc,1234" \
3194 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003195 0 \
3196 -c "client hello, adding alpn extension" \
3197 -s "found alpn extension" \
3198 -C "got an alert message, type: \\[2:120]" \
3199 -s "server hello, adding alpn extension" \
3200 -c "found alpn extension" \
3201 -c "Application Layer Protocol is 1234" \
3202 -s "Application Layer Protocol is 1234"
3203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003204run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003205 "$P_SRV debug_level=3 alpn=abc,123" \
3206 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003207 1 \
3208 -c "client hello, adding alpn extension" \
3209 -s "found alpn extension" \
3210 -c "got an alert message, type: \\[2:120]" \
3211 -S "server hello, adding alpn extension" \
3212 -C "found alpn extension" \
3213 -C "Application Layer Protocol is 1234" \
3214 -S "Application Layer Protocol is 1234"
3215
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003216
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003217# Tests for keyUsage in leaf certificates, part 1:
3218# server-side certificate/suite selection
3219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003220run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003221 "$P_SRV key_file=data_files/server2.key \
3222 crt_file=data_files/server2.ku-ds.crt" \
3223 "$P_CLI" \
3224 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003225 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003226
3227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003228run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003229 "$P_SRV key_file=data_files/server2.key \
3230 crt_file=data_files/server2.ku-ke.crt" \
3231 "$P_CLI" \
3232 0 \
3233 -c "Ciphersuite is TLS-RSA-WITH-"
3234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003235run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003236 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003237 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003238 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003239 1 \
3240 -C "Ciphersuite is "
3241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003242run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003243 "$P_SRV key_file=data_files/server5.key \
3244 crt_file=data_files/server5.ku-ds.crt" \
3245 "$P_CLI" \
3246 0 \
3247 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3248
3249
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003250run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003251 "$P_SRV key_file=data_files/server5.key \
3252 crt_file=data_files/server5.ku-ka.crt" \
3253 "$P_CLI" \
3254 0 \
3255 -c "Ciphersuite is TLS-ECDH-"
3256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003257run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003258 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003259 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003260 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003261 1 \
3262 -C "Ciphersuite is "
3263
3264# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003265# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003267run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003268 "$O_SRV -key data_files/server2.key \
3269 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003270 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003271 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3272 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003273 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003274 -C "Processing of the Certificate handshake message failed" \
3275 -c "Ciphersuite is TLS-"
3276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003277run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003278 "$O_SRV -key data_files/server2.key \
3279 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003280 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003281 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3282 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003283 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003284 -C "Processing of the Certificate handshake message failed" \
3285 -c "Ciphersuite is TLS-"
3286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003287run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003288 "$O_SRV -key data_files/server2.key \
3289 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003290 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003291 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3292 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003293 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003294 -C "Processing of the Certificate handshake message failed" \
3295 -c "Ciphersuite is TLS-"
3296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003297run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003298 "$O_SRV -key data_files/server2.key \
3299 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003300 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003301 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3302 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003303 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003304 -c "Processing of the Certificate handshake message failed" \
3305 -C "Ciphersuite is TLS-"
3306
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003307run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3308 "$O_SRV -key data_files/server2.key \
3309 -cert data_files/server2.ku-ke.crt" \
3310 "$P_CLI debug_level=1 auth_mode=optional \
3311 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3312 0 \
3313 -c "bad certificate (usage extensions)" \
3314 -C "Processing of the Certificate handshake message failed" \
3315 -c "Ciphersuite is TLS-" \
3316 -c "! Usage does not match the keyUsage extension"
3317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003318run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003319 "$O_SRV -key data_files/server2.key \
3320 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003321 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003322 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3323 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003324 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003325 -C "Processing of the Certificate handshake message failed" \
3326 -c "Ciphersuite is TLS-"
3327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003328run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003329 "$O_SRV -key data_files/server2.key \
3330 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003331 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003332 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3333 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003334 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003335 -c "Processing of the Certificate handshake message failed" \
3336 -C "Ciphersuite is TLS-"
3337
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003338run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3339 "$O_SRV -key data_files/server2.key \
3340 -cert data_files/server2.ku-ds.crt" \
3341 "$P_CLI debug_level=1 auth_mode=optional \
3342 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3343 0 \
3344 -c "bad certificate (usage extensions)" \
3345 -C "Processing of the Certificate handshake message failed" \
3346 -c "Ciphersuite is TLS-" \
3347 -c "! Usage does not match the keyUsage extension"
3348
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003349# Tests for keyUsage in leaf certificates, part 3:
3350# server-side checking of client cert
3351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003352run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003353 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003354 "$O_CLI -key data_files/server2.key \
3355 -cert data_files/server2.ku-ds.crt" \
3356 0 \
3357 -S "bad certificate (usage extensions)" \
3358 -S "Processing of the Certificate handshake message failed"
3359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003360run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003361 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003362 "$O_CLI -key data_files/server2.key \
3363 -cert data_files/server2.ku-ke.crt" \
3364 0 \
3365 -s "bad certificate (usage extensions)" \
3366 -S "Processing of the Certificate handshake message failed"
3367
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003368run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003369 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003370 "$O_CLI -key data_files/server2.key \
3371 -cert data_files/server2.ku-ke.crt" \
3372 1 \
3373 -s "bad certificate (usage extensions)" \
3374 -s "Processing of the Certificate handshake message failed"
3375
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003376run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003377 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003378 "$O_CLI -key data_files/server5.key \
3379 -cert data_files/server5.ku-ds.crt" \
3380 0 \
3381 -S "bad certificate (usage extensions)" \
3382 -S "Processing of the Certificate handshake message failed"
3383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003384run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003385 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003386 "$O_CLI -key data_files/server5.key \
3387 -cert data_files/server5.ku-ka.crt" \
3388 0 \
3389 -s "bad certificate (usage extensions)" \
3390 -S "Processing of the Certificate handshake message failed"
3391
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003392# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003394run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003395 "$P_SRV key_file=data_files/server5.key \
3396 crt_file=data_files/server5.eku-srv.crt" \
3397 "$P_CLI" \
3398 0
3399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003400run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003401 "$P_SRV key_file=data_files/server5.key \
3402 crt_file=data_files/server5.eku-srv.crt" \
3403 "$P_CLI" \
3404 0
3405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003406run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003407 "$P_SRV key_file=data_files/server5.key \
3408 crt_file=data_files/server5.eku-cs_any.crt" \
3409 "$P_CLI" \
3410 0
3411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003412run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003413 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003414 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003415 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003416 1
3417
3418# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003420run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003421 "$O_SRV -key data_files/server5.key \
3422 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003423 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003424 0 \
3425 -C "bad certificate (usage extensions)" \
3426 -C "Processing of the Certificate handshake message failed" \
3427 -c "Ciphersuite is TLS-"
3428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003429run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003430 "$O_SRV -key data_files/server5.key \
3431 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003432 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003433 0 \
3434 -C "bad certificate (usage extensions)" \
3435 -C "Processing of the Certificate handshake message failed" \
3436 -c "Ciphersuite is TLS-"
3437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003438run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003439 "$O_SRV -key data_files/server5.key \
3440 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003441 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003442 0 \
3443 -C "bad certificate (usage extensions)" \
3444 -C "Processing of the Certificate handshake message failed" \
3445 -c "Ciphersuite is TLS-"
3446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003447run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003448 "$O_SRV -key data_files/server5.key \
3449 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003450 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003451 1 \
3452 -c "bad certificate (usage extensions)" \
3453 -c "Processing of the Certificate handshake message failed" \
3454 -C "Ciphersuite is TLS-"
3455
3456# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003458run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003459 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003460 "$O_CLI -key data_files/server5.key \
3461 -cert data_files/server5.eku-cli.crt" \
3462 0 \
3463 -S "bad certificate (usage extensions)" \
3464 -S "Processing of the Certificate handshake message failed"
3465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003466run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003467 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003468 "$O_CLI -key data_files/server5.key \
3469 -cert data_files/server5.eku-srv_cli.crt" \
3470 0 \
3471 -S "bad certificate (usage extensions)" \
3472 -S "Processing of the Certificate handshake message failed"
3473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003474run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003475 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003476 "$O_CLI -key data_files/server5.key \
3477 -cert data_files/server5.eku-cs_any.crt" \
3478 0 \
3479 -S "bad certificate (usage extensions)" \
3480 -S "Processing of the Certificate handshake message failed"
3481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003482run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003483 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003484 "$O_CLI -key data_files/server5.key \
3485 -cert data_files/server5.eku-cs.crt" \
3486 0 \
3487 -s "bad certificate (usage extensions)" \
3488 -S "Processing of the Certificate handshake message failed"
3489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003490run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003491 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003492 "$O_CLI -key data_files/server5.key \
3493 -cert data_files/server5.eku-cs.crt" \
3494 1 \
3495 -s "bad certificate (usage extensions)" \
3496 -s "Processing of the Certificate handshake message failed"
3497
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003498# Tests for DHM parameters loading
3499
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003500run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003501 "$P_SRV" \
3502 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3503 debug_level=3" \
3504 0 \
3505 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003506 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003508run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003509 "$P_SRV dhm_file=data_files/dhparams.pem" \
3510 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3511 debug_level=3" \
3512 0 \
3513 -c "value of 'DHM: P ' (1024 bits)" \
3514 -c "value of 'DHM: G ' (2 bits)"
3515
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003516# Tests for DHM client-side size checking
3517
3518run_test "DHM size: server default, client default, OK" \
3519 "$P_SRV" \
3520 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3521 debug_level=1" \
3522 0 \
3523 -C "DHM prime too short:"
3524
3525run_test "DHM size: server default, client 2048, OK" \
3526 "$P_SRV" \
3527 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3528 debug_level=1 dhmlen=2048" \
3529 0 \
3530 -C "DHM prime too short:"
3531
3532run_test "DHM size: server 1024, client default, OK" \
3533 "$P_SRV dhm_file=data_files/dhparams.pem" \
3534 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3535 debug_level=1" \
3536 0 \
3537 -C "DHM prime too short:"
3538
3539run_test "DHM size: server 1000, client default, rejected" \
3540 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3541 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3542 debug_level=1" \
3543 1 \
3544 -c "DHM prime too short:"
3545
3546run_test "DHM size: server default, client 2049, rejected" \
3547 "$P_SRV" \
3548 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3549 debug_level=1 dhmlen=2049" \
3550 1 \
3551 -c "DHM prime too short:"
3552
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003553# Tests for PSK callback
3554
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003555run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003556 "$P_SRV psk=abc123 psk_identity=foo" \
3557 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3558 psk_identity=foo psk=abc123" \
3559 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003560 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003561 -S "SSL - Unknown identity received" \
3562 -S "SSL - Verification of the message MAC failed"
3563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003564run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003565 "$P_SRV" \
3566 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3567 psk_identity=foo psk=abc123" \
3568 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003569 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003570 -S "SSL - Unknown identity received" \
3571 -S "SSL - Verification of the message MAC failed"
3572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003573run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003574 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3575 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3576 psk_identity=foo psk=abc123" \
3577 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003578 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003579 -s "SSL - Unknown identity received" \
3580 -S "SSL - Verification of the message MAC failed"
3581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003582run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003583 "$P_SRV psk_list=abc,dead,def,beef" \
3584 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3585 psk_identity=abc psk=dead" \
3586 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003587 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003588 -S "SSL - Unknown identity received" \
3589 -S "SSL - Verification of the message MAC failed"
3590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003591run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003592 "$P_SRV psk_list=abc,dead,def,beef" \
3593 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3594 psk_identity=def psk=beef" \
3595 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003596 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003597 -S "SSL - Unknown identity received" \
3598 -S "SSL - Verification of the message MAC failed"
3599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003600run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003601 "$P_SRV psk_list=abc,dead,def,beef" \
3602 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3603 psk_identity=ghi psk=beef" \
3604 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003605 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003606 -s "SSL - Unknown identity received" \
3607 -S "SSL - Verification of the message MAC failed"
3608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003609run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003610 "$P_SRV psk_list=abc,dead,def,beef" \
3611 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3612 psk_identity=abc psk=beef" \
3613 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003614 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003615 -S "SSL - Unknown identity received" \
3616 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003617
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003618# Tests for EC J-PAKE
3619
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003620requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003621run_test "ECJPAKE: client not configured" \
3622 "$P_SRV debug_level=3" \
3623 "$P_CLI debug_level=3" \
3624 0 \
3625 -C "add ciphersuite: c0ff" \
3626 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003627 -S "found ecjpake kkpp extension" \
3628 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003629 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003630 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003631 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003632 -S "None of the common ciphersuites is usable"
3633
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003634requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003635run_test "ECJPAKE: server not configured" \
3636 "$P_SRV debug_level=3" \
3637 "$P_CLI debug_level=3 ecjpake_pw=bla \
3638 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3639 1 \
3640 -c "add ciphersuite: c0ff" \
3641 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003642 -s "found ecjpake kkpp extension" \
3643 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003644 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003645 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003646 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003647 -s "None of the common ciphersuites is usable"
3648
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003649requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003650run_test "ECJPAKE: working, TLS" \
3651 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3652 "$P_CLI debug_level=3 ecjpake_pw=bla \
3653 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003654 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003655 -c "add ciphersuite: c0ff" \
3656 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003657 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003658 -s "found ecjpake kkpp extension" \
3659 -S "skip ecjpake kkpp extension" \
3660 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003661 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003662 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003663 -S "None of the common ciphersuites is usable" \
3664 -S "SSL - Verification of the message MAC failed"
3665
Janos Follath74537a62016-09-02 13:45:28 +01003666server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003667requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003668run_test "ECJPAKE: password mismatch, TLS" \
3669 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3670 "$P_CLI debug_level=3 ecjpake_pw=bad \
3671 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3672 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003673 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003674 -s "SSL - Verification of the message MAC failed"
3675
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003676requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003677run_test "ECJPAKE: working, DTLS" \
3678 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3679 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3680 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3681 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003682 -c "re-using cached ecjpake parameters" \
3683 -S "SSL - Verification of the message MAC failed"
3684
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003685requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003686run_test "ECJPAKE: working, DTLS, no cookie" \
3687 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3688 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3689 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3690 0 \
3691 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003692 -S "SSL - Verification of the message MAC failed"
3693
Janos Follath74537a62016-09-02 13:45:28 +01003694server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003695requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003696run_test "ECJPAKE: password mismatch, DTLS" \
3697 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3698 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3699 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3700 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003701 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003702 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003703
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003704# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003705requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003706run_test "ECJPAKE: working, DTLS, nolog" \
3707 "$P_SRV dtls=1 ecjpake_pw=bla" \
3708 "$P_CLI dtls=1 ecjpake_pw=bla \
3709 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3710 0
3711
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003712# Tests for ciphersuites per version
3713
Janos Follathe2681a42016-03-07 15:57:05 +00003714requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003715requires_config_enabled MBEDTLS_CAMELLIA_C
3716requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003717run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003718 "$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 +02003719 "$P_CLI force_version=ssl3" \
3720 0 \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003721 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003722
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003723requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
3724requires_config_enabled MBEDTLS_CAMELLIA_C
3725requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003726run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003727 "$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 +01003728 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003729 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003730 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003731
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003732requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
3733requires_config_enabled MBEDTLS_CAMELLIA_C
3734requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003735run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003736 "$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 +02003737 "$P_CLI force_version=tls1_1" \
3738 0 \
3739 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3740
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003741requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
3742requires_config_enabled MBEDTLS_CAMELLIA_C
3743requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003744run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003745 "$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 +02003746 "$P_CLI force_version=tls1_2" \
3747 0 \
3748 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3749
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003750# Test for ClientHello without extensions
3751
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003752requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003753run_test "ClientHello without extensions, SHA-1 allowed" \
Ron Eldor664623e2019-01-16 23:14:41 +02003754 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003755 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3756 0 \
3757 -s "dumping 'client hello extensions' (0 bytes)"
3758
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003759requires_gnutls
3760run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3761 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3762 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3763 0 \
3764 -s "dumping 'client hello extensions' (0 bytes)"
3765
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003766# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003767
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003768run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003769 "$P_SRV" \
3770 "$P_CLI request_size=100" \
3771 0 \
3772 -s "Read from client: 100 bytes read$"
3773
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003774run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003775 "$P_SRV" \
3776 "$P_CLI request_size=500" \
3777 0 \
3778 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003779
Andrzej Kurekd731a632018-06-19 09:37:30 -04003780# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003781
Janos Follathe2681a42016-03-07 15:57:05 +00003782requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekd731a632018-06-19 09:37:30 -04003783run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003784 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003785 "$P_CLI request_size=1 force_version=ssl3 \
3786 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3787 0 \
3788 -s "Read from client: 1 bytes read"
3789
Janos Follathe2681a42016-03-07 15:57:05 +00003790requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekd731a632018-06-19 09:37:30 -04003791run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003792 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003793 "$P_CLI request_size=1 force_version=ssl3 \
3794 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3795 0 \
3796 -s "Read from client: 1 bytes read"
3797
Andrzej Kurekd731a632018-06-19 09:37:30 -04003798run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003799 "$P_SRV" \
3800 "$P_CLI request_size=1 force_version=tls1 \
3801 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3802 0 \
3803 -s "Read from client: 1 bytes read"
3804
Andrzej Kurekd731a632018-06-19 09:37:30 -04003805run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003806 "$P_SRV" \
3807 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3808 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3809 0 \
3810 -s "Read from client: 1 bytes read"
3811
Hanno Becker32c55012017-11-10 08:42:54 +00003812requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003813run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003814 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003815 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003816 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003817 0 \
3818 -s "Read from client: 1 bytes read"
3819
Hanno Becker32c55012017-11-10 08:42:54 +00003820requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003821run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003822 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003823 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003824 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003825 0 \
3826 -s "Read from client: 1 bytes read"
3827
Andrzej Kurekd731a632018-06-19 09:37:30 -04003828run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003829 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003830 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003831 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3832 0 \
3833 -s "Read from client: 1 bytes read"
3834
Andrzej Kurekd731a632018-06-19 09:37:30 -04003835run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003836 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3837 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003838 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003839 0 \
3840 -s "Read from client: 1 bytes read"
3841
3842requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003843run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003844 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003845 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003846 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003847 0 \
3848 -s "Read from client: 1 bytes read"
3849
Hanno Becker8501f982017-11-10 08:59:04 +00003850requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003851run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003852 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3853 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3854 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003855 0 \
3856 -s "Read from client: 1 bytes read"
3857
Andrzej Kurekd731a632018-06-19 09:37:30 -04003858run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003859 "$P_SRV" \
3860 "$P_CLI request_size=1 force_version=tls1_1 \
3861 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3862 0 \
3863 -s "Read from client: 1 bytes read"
3864
Andrzej Kurekd731a632018-06-19 09:37:30 -04003865run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003866 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003867 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003868 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003869 0 \
3870 -s "Read from client: 1 bytes read"
3871
3872requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003873run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003874 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003875 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003876 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003877 0 \
3878 -s "Read from client: 1 bytes read"
3879
3880requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003881run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003882 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003883 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003884 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003885 0 \
3886 -s "Read from client: 1 bytes read"
3887
Andrzej Kurekd731a632018-06-19 09:37:30 -04003888run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003889 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003890 "$P_CLI request_size=1 force_version=tls1_1 \
3891 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3892 0 \
3893 -s "Read from client: 1 bytes read"
3894
Andrzej Kurekd731a632018-06-19 09:37:30 -04003895run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003896 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003897 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003898 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003899 0 \
3900 -s "Read from client: 1 bytes read"
3901
Hanno Becker8501f982017-11-10 08:59:04 +00003902requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003903run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003904 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003905 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003906 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003907 0 \
3908 -s "Read from client: 1 bytes read"
3909
Hanno Becker32c55012017-11-10 08:42:54 +00003910requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003911run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003912 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003913 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003914 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003915 0 \
3916 -s "Read from client: 1 bytes read"
3917
Andrzej Kurekd731a632018-06-19 09:37:30 -04003918run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003919 "$P_SRV" \
3920 "$P_CLI request_size=1 force_version=tls1_2 \
3921 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3922 0 \
3923 -s "Read from client: 1 bytes read"
3924
Andrzej Kurekd731a632018-06-19 09:37:30 -04003925run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003926 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003927 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003928 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003929 0 \
3930 -s "Read from client: 1 bytes read"
3931
Andrzej Kurekd731a632018-06-19 09:37:30 -04003932run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003933 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003934 "$P_CLI request_size=1 force_version=tls1_2 \
3935 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003936 0 \
3937 -s "Read from client: 1 bytes read"
3938
Hanno Becker32c55012017-11-10 08:42:54 +00003939requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003940run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003941 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003942 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003943 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003944 0 \
3945 -s "Read from client: 1 bytes read"
3946
Hanno Becker8501f982017-11-10 08:59:04 +00003947requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003948run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003949 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003950 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003951 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003952 0 \
3953 -s "Read from client: 1 bytes read"
3954
Andrzej Kurekd731a632018-06-19 09:37:30 -04003955run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003956 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003957 "$P_CLI request_size=1 force_version=tls1_2 \
3958 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3959 0 \
3960 -s "Read from client: 1 bytes read"
3961
Andrzej Kurekd731a632018-06-19 09:37:30 -04003962run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003963 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003964 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003965 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003966 0 \
3967 -s "Read from client: 1 bytes read"
3968
Hanno Becker32c55012017-11-10 08:42:54 +00003969requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003970run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003971 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003972 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003973 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003974 0 \
3975 -s "Read from client: 1 bytes read"
3976
Hanno Becker8501f982017-11-10 08:59:04 +00003977requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003978run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003979 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003980 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003981 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003982 0 \
3983 -s "Read from client: 1 bytes read"
3984
Andrzej Kurekd731a632018-06-19 09:37:30 -04003985run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003986 "$P_SRV" \
3987 "$P_CLI request_size=1 force_version=tls1_2 \
3988 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3989 0 \
3990 -s "Read from client: 1 bytes read"
3991
Andrzej Kurekd731a632018-06-19 09:37:30 -04003992run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003993 "$P_SRV" \
3994 "$P_CLI request_size=1 force_version=tls1_2 \
3995 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3996 0 \
3997 -s "Read from client: 1 bytes read"
3998
Andrzej Kurekd731a632018-06-19 09:37:30 -04003999# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004000
4001requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004002run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004003 "$P_SRV dtls=1 force_version=dtls1" \
4004 "$P_CLI dtls=1 request_size=1 \
4005 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4006 0 \
4007 -s "Read from client: 1 bytes read"
4008
4009requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004010run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004011 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4012 "$P_CLI dtls=1 request_size=1 \
4013 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4014 0 \
4015 -s "Read from client: 1 bytes read"
4016
4017requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4018requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004019run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004020 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4021 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004022 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4023 0 \
4024 -s "Read from client: 1 bytes read"
4025
4026requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4027requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004028run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004029 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004030 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004031 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004032 0 \
4033 -s "Read from client: 1 bytes read"
4034
4035requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004036run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004037 "$P_SRV dtls=1 force_version=dtls1_2" \
4038 "$P_CLI dtls=1 request_size=1 \
4039 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4040 0 \
4041 -s "Read from client: 1 bytes read"
4042
4043requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004044run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004045 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004046 "$P_CLI dtls=1 request_size=1 \
4047 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4048 0 \
4049 -s "Read from client: 1 bytes read"
4050
4051requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4052requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004053run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004054 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004055 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004056 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004057 0 \
4058 -s "Read from client: 1 bytes read"
4059
4060requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4061requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004062run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004063 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004064 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004065 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004066 0 \
4067 -s "Read from client: 1 bytes read"
4068
Andrzej Kurekd731a632018-06-19 09:37:30 -04004069# Tests for small server packets
4070
4071requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4072run_test "Small server packet SSLv3 BlockCipher" \
4073 "$P_SRV response_size=1 min_version=ssl3" \
4074 "$P_CLI force_version=ssl3 \
4075 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4076 0 \
4077 -c "Read from server: 1 bytes read"
4078
4079requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4080run_test "Small server packet SSLv3 StreamCipher" \
4081 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4082 "$P_CLI force_version=ssl3 \
4083 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4084 0 \
4085 -c "Read from server: 1 bytes read"
4086
4087run_test "Small server packet TLS 1.0 BlockCipher" \
4088 "$P_SRV response_size=1" \
4089 "$P_CLI force_version=tls1 \
4090 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4091 0 \
4092 -c "Read from server: 1 bytes read"
4093
4094run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4095 "$P_SRV response_size=1" \
4096 "$P_CLI force_version=tls1 etm=0 \
4097 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4098 0 \
4099 -c "Read from server: 1 bytes read"
4100
4101requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4102run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4103 "$P_SRV response_size=1 trunc_hmac=1" \
4104 "$P_CLI force_version=tls1 \
4105 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4106 0 \
4107 -c "Read from server: 1 bytes read"
4108
4109requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4110run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4111 "$P_SRV response_size=1 trunc_hmac=1" \
4112 "$P_CLI force_version=tls1 \
4113 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4114 0 \
4115 -c "Read from server: 1 bytes read"
4116
4117run_test "Small server packet TLS 1.0 StreamCipher" \
4118 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4119 "$P_CLI force_version=tls1 \
4120 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4121 0 \
4122 -c "Read from server: 1 bytes read"
4123
4124run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4125 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4126 "$P_CLI force_version=tls1 \
4127 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4128 0 \
4129 -c "Read from server: 1 bytes read"
4130
4131requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4132run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4133 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4134 "$P_CLI force_version=tls1 \
4135 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4136 0 \
4137 -c "Read from server: 1 bytes read"
4138
4139requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4140run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4141 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4142 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4143 trunc_hmac=1 etm=0" \
4144 0 \
4145 -c "Read from server: 1 bytes read"
4146
4147run_test "Small server packet TLS 1.1 BlockCipher" \
4148 "$P_SRV response_size=1" \
4149 "$P_CLI force_version=tls1_1 \
4150 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4151 0 \
4152 -c "Read from server: 1 bytes read"
4153
4154run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4155 "$P_SRV response_size=1" \
4156 "$P_CLI force_version=tls1_1 \
4157 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4158 0 \
4159 -c "Read from server: 1 bytes read"
4160
4161requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4162run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4163 "$P_SRV response_size=1 trunc_hmac=1" \
4164 "$P_CLI force_version=tls1_1 \
4165 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4166 0 \
4167 -c "Read from server: 1 bytes read"
4168
4169requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4170run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4171 "$P_SRV response_size=1 trunc_hmac=1" \
4172 "$P_CLI force_version=tls1_1 \
4173 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4174 0 \
4175 -c "Read from server: 1 bytes read"
4176
4177run_test "Small server packet TLS 1.1 StreamCipher" \
4178 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4179 "$P_CLI force_version=tls1_1 \
4180 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4181 0 \
4182 -c "Read from server: 1 bytes read"
4183
4184run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4185 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4186 "$P_CLI force_version=tls1_1 \
4187 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4188 0 \
4189 -c "Read from server: 1 bytes read"
4190
4191requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4192run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4193 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4194 "$P_CLI force_version=tls1_1 \
4195 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4196 0 \
4197 -c "Read from server: 1 bytes read"
4198
4199requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4200run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4201 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4202 "$P_CLI force_version=tls1_1 \
4203 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4204 0 \
4205 -c "Read from server: 1 bytes read"
4206
4207run_test "Small server packet TLS 1.2 BlockCipher" \
4208 "$P_SRV response_size=1" \
4209 "$P_CLI force_version=tls1_2 \
4210 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4211 0 \
4212 -c "Read from server: 1 bytes read"
4213
4214run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4215 "$P_SRV response_size=1" \
4216 "$P_CLI force_version=tls1_2 \
4217 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4218 0 \
4219 -c "Read from server: 1 bytes read"
4220
4221run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4222 "$P_SRV response_size=1" \
4223 "$P_CLI force_version=tls1_2 \
4224 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4225 0 \
4226 -c "Read from server: 1 bytes read"
4227
4228requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4229run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4230 "$P_SRV response_size=1 trunc_hmac=1" \
4231 "$P_CLI force_version=tls1_2 \
4232 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4233 0 \
4234 -c "Read from server: 1 bytes read"
4235
4236requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4237run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4238 "$P_SRV response_size=1 trunc_hmac=1" \
4239 "$P_CLI force_version=tls1_2 \
4240 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4241 0 \
4242 -c "Read from server: 1 bytes read"
4243
4244run_test "Small server packet TLS 1.2 StreamCipher" \
4245 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4246 "$P_CLI force_version=tls1_2 \
4247 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4248 0 \
4249 -c "Read from server: 1 bytes read"
4250
4251run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4252 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4253 "$P_CLI force_version=tls1_2 \
4254 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4255 0 \
4256 -c "Read from server: 1 bytes read"
4257
4258requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4259run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4260 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4261 "$P_CLI force_version=tls1_2 \
4262 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4263 0 \
4264 -c "Read from server: 1 bytes read"
4265
4266requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4267run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4268 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4269 "$P_CLI force_version=tls1_2 \
4270 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4271 0 \
4272 -c "Read from server: 1 bytes read"
4273
4274run_test "Small server packet TLS 1.2 AEAD" \
4275 "$P_SRV response_size=1" \
4276 "$P_CLI force_version=tls1_2 \
4277 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4278 0 \
4279 -c "Read from server: 1 bytes read"
4280
4281run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4282 "$P_SRV response_size=1" \
4283 "$P_CLI force_version=tls1_2 \
4284 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4285 0 \
4286 -c "Read from server: 1 bytes read"
4287
4288# Tests for small server packets in DTLS
4289
4290requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4291run_test "Small server packet DTLS 1.0" \
4292 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4293 "$P_CLI dtls=1 \
4294 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4295 0 \
4296 -c "Read from server: 1 bytes read"
4297
4298requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4299run_test "Small server packet DTLS 1.0, without EtM" \
4300 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4301 "$P_CLI dtls=1 \
4302 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4303 0 \
4304 -c "Read from server: 1 bytes read"
4305
4306requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4307requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4308run_test "Small server packet DTLS 1.0, truncated hmac" \
4309 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4310 "$P_CLI dtls=1 trunc_hmac=1 \
4311 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4312 0 \
4313 -c "Read from server: 1 bytes read"
4314
4315requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4316requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4317run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4318 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4319 "$P_CLI dtls=1 \
4320 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4321 0 \
4322 -c "Read from server: 1 bytes read"
4323
4324requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4325run_test "Small server packet DTLS 1.2" \
4326 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4327 "$P_CLI dtls=1 \
4328 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4329 0 \
4330 -c "Read from server: 1 bytes read"
4331
4332requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4333run_test "Small server packet DTLS 1.2, without EtM" \
4334 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4335 "$P_CLI dtls=1 \
4336 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4337 0 \
4338 -c "Read from server: 1 bytes read"
4339
4340requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4341requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4342run_test "Small server packet DTLS 1.2, truncated hmac" \
4343 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4344 "$P_CLI dtls=1 \
4345 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4346 0 \
4347 -c "Read from server: 1 bytes read"
4348
4349requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4350requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4351run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4352 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4353 "$P_CLI dtls=1 \
4354 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4355 0 \
4356 -c "Read from server: 1 bytes read"
4357
Janos Follath00efff72016-05-06 13:48:23 +01004358# A test for extensions in SSLv3
4359
4360requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4361run_test "SSLv3 with extensions, server side" \
4362 "$P_SRV min_version=ssl3 debug_level=3" \
4363 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4364 0 \
4365 -S "dumping 'client hello extensions'" \
4366 -S "server hello, total extension length:"
4367
Andrzej Kurek557335e2018-06-28 04:03:10 -04004368# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004369
Janos Follathe2681a42016-03-07 15:57:05 +00004370requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek557335e2018-06-28 04:03:10 -04004371run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004372 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004373 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004374 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4375 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004376 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004377 -s "Read from client: 16384 bytes read"
4378
Janos Follathe2681a42016-03-07 15:57:05 +00004379requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek557335e2018-06-28 04:03:10 -04004380run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004381 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004382 "$P_CLI request_size=16384 force_version=ssl3 \
4383 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4384 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004385 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004386 -s "Read from client: 16384 bytes read"
4387
Andrzej Kurek557335e2018-06-28 04:03:10 -04004388run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004389 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004390 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004391 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4392 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004393 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004394 -s "Read from client: 16384 bytes read"
4395
Andrzej Kurek557335e2018-06-28 04:03:10 -04004396run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004397 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004398 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4399 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4400 0 \
4401 -s "Read from client: 16384 bytes read"
4402
Hanno Becker32c55012017-11-10 08:42:54 +00004403requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004404run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004405 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004406 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004407 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004408 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004409 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004410 -s "Read from client: 16384 bytes read"
4411
Hanno Becker32c55012017-11-10 08:42:54 +00004412requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004413run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004414 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004415 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004416 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004417 0 \
4418 -s "Read from client: 16384 bytes read"
4419
Andrzej Kurek557335e2018-06-28 04:03:10 -04004420run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004421 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004422 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004423 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4424 0 \
4425 -s "Read from client: 16384 bytes read"
4426
Andrzej Kurek557335e2018-06-28 04:03:10 -04004427run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004428 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4429 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004430 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004431 0 \
4432 -s "Read from client: 16384 bytes read"
4433
4434requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004435run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004436 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004437 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004438 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004439 0 \
4440 -s "Read from client: 16384 bytes read"
4441
Hanno Becker278fc7a2017-11-10 09:16:28 +00004442requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004443run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004444 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004445 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004446 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004447 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004448 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004449 -s "Read from client: 16384 bytes read"
4450
Andrzej Kurek557335e2018-06-28 04:03:10 -04004451run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004452 "$P_SRV" \
4453 "$P_CLI request_size=16384 force_version=tls1_1 \
4454 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4455 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004456 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004457 -s "Read from client: 16384 bytes read"
4458
Andrzej Kurek557335e2018-06-28 04:03:10 -04004459run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004460 "$P_SRV" \
4461 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4462 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004463 0 \
4464 -s "Read from client: 16384 bytes read"
4465
Hanno Becker32c55012017-11-10 08:42:54 +00004466requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004467run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004468 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004469 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004470 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004471 0 \
4472 -s "Read from client: 16384 bytes read"
4473
Hanno Becker32c55012017-11-10 08:42:54 +00004474requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004475run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004476 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004477 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004478 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004479 0 \
4480 -s "Read from client: 16384 bytes read"
4481
Andrzej Kurek557335e2018-06-28 04:03:10 -04004482run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004483 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4484 "$P_CLI request_size=16384 force_version=tls1_1 \
4485 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4486 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004487 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004488 -s "Read from client: 16384 bytes read"
4489
Andrzej Kurek557335e2018-06-28 04:03:10 -04004490run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004491 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004492 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004493 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004494 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004495 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004496 -s "Read from client: 16384 bytes read"
4497
Hanno Becker278fc7a2017-11-10 09:16:28 +00004498requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004499run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004500 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004501 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004502 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004503 0 \
4504 -s "Read from client: 16384 bytes read"
4505
Hanno Becker278fc7a2017-11-10 09:16:28 +00004506requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004507run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004508 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004509 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004510 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004511 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004512 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004513 -s "Read from client: 16384 bytes read"
4514
Andrzej Kurek557335e2018-06-28 04:03:10 -04004515run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004516 "$P_SRV" \
4517 "$P_CLI request_size=16384 force_version=tls1_2 \
4518 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4519 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004520 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004521 -s "Read from client: 16384 bytes read"
4522
Andrzej Kurek557335e2018-06-28 04:03:10 -04004523run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004524 "$P_SRV" \
4525 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4526 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4527 0 \
4528 -s "Read from client: 16384 bytes read"
4529
Andrzej Kurek557335e2018-06-28 04:03:10 -04004530run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004531 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004532 "$P_CLI request_size=16384 force_version=tls1_2 \
4533 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004534 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004535 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004536 -s "Read from client: 16384 bytes read"
4537
Hanno Becker32c55012017-11-10 08:42:54 +00004538requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004539run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004540 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004541 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004542 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004543 0 \
4544 -s "Read from client: 16384 bytes read"
4545
Hanno Becker278fc7a2017-11-10 09:16:28 +00004546requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004547run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004548 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004549 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004550 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004551 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004552 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004553 -s "Read from client: 16384 bytes read"
4554
Andrzej Kurek557335e2018-06-28 04:03:10 -04004555run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004556 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004557 "$P_CLI request_size=16384 force_version=tls1_2 \
4558 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4559 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004560 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004561 -s "Read from client: 16384 bytes read"
4562
Andrzej Kurek557335e2018-06-28 04:03:10 -04004563run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004564 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004565 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004566 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4567 0 \
4568 -s "Read from client: 16384 bytes read"
4569
Hanno Becker32c55012017-11-10 08:42:54 +00004570requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004571run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004572 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004573 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004574 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004575 0 \
4576 -s "Read from client: 16384 bytes read"
4577
Hanno Becker278fc7a2017-11-10 09:16:28 +00004578requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004579run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004580 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004581 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004582 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004583 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004584 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004585 -s "Read from client: 16384 bytes read"
4586
Andrzej Kurek557335e2018-06-28 04:03:10 -04004587run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004588 "$P_SRV" \
4589 "$P_CLI request_size=16384 force_version=tls1_2 \
4590 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4591 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004592 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004593 -s "Read from client: 16384 bytes read"
4594
Andrzej Kurek557335e2018-06-28 04:03:10 -04004595run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004596 "$P_SRV" \
4597 "$P_CLI request_size=16384 force_version=tls1_2 \
4598 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4599 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004600 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004601 -s "Read from client: 16384 bytes read"
4602
Ron Eldorc7f15232018-06-28 13:22:05 +03004603# Tests for ECC extensions (rfc 4492)
4604
Ron Eldor94226d82018-06-28 16:17:00 +03004605requires_config_enabled MBEDTLS_AES_C
4606requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4607requires_config_enabled MBEDTLS_SHA256_C
4608requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004609run_test "Force a non ECC ciphersuite in the client side" \
4610 "$P_SRV debug_level=3" \
Ron Eldor94226d82018-06-28 16:17:00 +03004611 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004612 0 \
4613 -C "client hello, adding supported_elliptic_curves extension" \
4614 -C "client hello, adding supported_point_formats extension" \
4615 -S "found supported elliptic curves extension" \
4616 -S "found supported point formats extension"
4617
Ron Eldor94226d82018-06-28 16:17:00 +03004618requires_config_enabled MBEDTLS_AES_C
4619requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4620requires_config_enabled MBEDTLS_SHA256_C
4621requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004622run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor94226d82018-06-28 16:17:00 +03004623 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004624 "$P_CLI debug_level=3" \
4625 0 \
4626 -C "found supported_point_formats extension" \
4627 -S "server hello, supported_point_formats extension"
4628
Ron Eldor94226d82018-06-28 16:17:00 +03004629requires_config_enabled MBEDTLS_AES_C
4630requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4631requires_config_enabled MBEDTLS_SHA256_C
4632requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004633run_test "Force an ECC ciphersuite in the client side" \
4634 "$P_SRV debug_level=3" \
4635 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4636 0 \
4637 -c "client hello, adding supported_elliptic_curves extension" \
4638 -c "client hello, adding supported_point_formats extension" \
4639 -s "found supported elliptic curves extension" \
4640 -s "found supported point formats extension"
4641
Ron Eldor94226d82018-06-28 16:17:00 +03004642requires_config_enabled MBEDTLS_AES_C
4643requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4644requires_config_enabled MBEDTLS_SHA256_C
4645requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004646run_test "Force an ECC ciphersuite in the server side" \
4647 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4648 "$P_CLI debug_level=3" \
4649 0 \
4650 -c "found supported_point_formats extension" \
4651 -s "server hello, supported_point_formats extension"
4652
Andrzej Kurek557335e2018-06-28 04:03:10 -04004653# Test for large server packets
Andrzej Kurek557335e2018-06-28 04:03:10 -04004654requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4655run_test "Large server packet SSLv3 StreamCipher" \
4656 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4657 "$P_CLI force_version=ssl3 \
4658 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4659 0 \
4660 -c "Read from server: 16384 bytes read"
4661
Andrzej Kurekc8958212018-08-27 08:00:13 -04004662# Checking next 4 tests logs for 1n-1 split against BEAST too
4663requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4664run_test "Large server packet SSLv3 BlockCipher" \
4665 "$P_SRV response_size=16384 min_version=ssl3" \
4666 "$P_CLI force_version=ssl3 recsplit=0 \
4667 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4668 0 \
4669 -c "Read from server: 1 bytes read"\
4670 -c "16383 bytes read"\
4671 -C "Read from server: 16384 bytes read"
4672
Andrzej Kurek557335e2018-06-28 04:03:10 -04004673run_test "Large server packet TLS 1.0 BlockCipher" \
4674 "$P_SRV response_size=16384" \
4675 "$P_CLI force_version=tls1 recsplit=0 \
4676 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4677 0 \
4678 -c "Read from server: 1 bytes read"\
4679 -c "16383 bytes read"\
4680 -C "Read from server: 16384 bytes read"
4681
Andrzej Kurekd731a632018-06-19 09:37:30 -04004682run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
4683 "$P_SRV response_size=16384" \
4684 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
4685 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4686 0 \
4687 -c "Read from server: 1 bytes read"\
4688 -c "16383 bytes read"\
4689 -C "Read from server: 16384 bytes read"
4690
Andrzej Kurek557335e2018-06-28 04:03:10 -04004691requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4692run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
4693 "$P_SRV response_size=16384" \
4694 "$P_CLI force_version=tls1 recsplit=0 \
4695 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4696 trunc_hmac=1" \
4697 0 \
4698 -c "Read from server: 1 bytes read"\
4699 -c "16383 bytes read"\
4700 -C "Read from server: 16384 bytes read"
4701
4702requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4703run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
4704 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4705 "$P_CLI force_version=tls1 \
4706 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4707 trunc_hmac=1" \
4708 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004709 -s "16384 bytes written in 1 fragments" \
4710 -c "Read from server: 16384 bytes read"
4711
4712run_test "Large server packet TLS 1.0 StreamCipher" \
4713 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4714 "$P_CLI force_version=tls1 \
4715 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4716 0 \
4717 -s "16384 bytes written in 1 fragments" \
4718 -c "Read from server: 16384 bytes read"
4719
4720run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
4721 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4722 "$P_CLI force_version=tls1 \
4723 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4724 0 \
4725 -s "16384 bytes written in 1 fragments" \
4726 -c "Read from server: 16384 bytes read"
4727
4728requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4729run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
4730 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4731 "$P_CLI force_version=tls1 \
4732 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4733 0 \
4734 -s "16384 bytes written in 1 fragments" \
4735 -c "Read from server: 16384 bytes read"
4736
4737requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4738run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4739 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4740 "$P_CLI force_version=tls1 \
4741 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4742 0 \
4743 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004744 -c "Read from server: 16384 bytes read"
4745
4746run_test "Large server packet TLS 1.1 BlockCipher" \
4747 "$P_SRV response_size=16384" \
4748 "$P_CLI force_version=tls1_1 \
4749 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4750 0 \
4751 -c "Read from server: 16384 bytes read"
4752
Andrzej Kurekd731a632018-06-19 09:37:30 -04004753run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
4754 "$P_SRV response_size=16384" \
4755 "$P_CLI force_version=tls1_1 etm=0 \
4756 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004757 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004758 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004759 -c "Read from server: 16384 bytes read"
4760
4761requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4762run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
4763 "$P_SRV response_size=16384" \
4764 "$P_CLI force_version=tls1_1 \
4765 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4766 trunc_hmac=1" \
4767 0 \
4768 -c "Read from server: 16384 bytes read"
4769
4770requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004771run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4772 "$P_SRV response_size=16384 trunc_hmac=1" \
4773 "$P_CLI force_version=tls1_1 \
4774 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4775 0 \
4776 -s "16384 bytes written in 1 fragments" \
4777 -c "Read from server: 16384 bytes read"
4778
4779run_test "Large server packet TLS 1.1 StreamCipher" \
4780 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4781 "$P_CLI force_version=tls1_1 \
4782 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4783 0 \
4784 -c "Read from server: 16384 bytes read"
4785
4786run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
4787 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4788 "$P_CLI force_version=tls1_1 \
4789 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4790 0 \
4791 -s "16384 bytes written in 1 fragments" \
4792 -c "Read from server: 16384 bytes read"
4793
4794requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004795run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
4796 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4797 "$P_CLI force_version=tls1_1 \
4798 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4799 trunc_hmac=1" \
4800 0 \
4801 -c "Read from server: 16384 bytes read"
4802
Andrzej Kurekd731a632018-06-19 09:37:30 -04004803run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4804 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4805 "$P_CLI force_version=tls1_1 \
4806 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4807 0 \
4808 -s "16384 bytes written in 1 fragments" \
4809 -c "Read from server: 16384 bytes read"
4810
Andrzej Kurek557335e2018-06-28 04:03:10 -04004811run_test "Large server packet TLS 1.2 BlockCipher" \
4812 "$P_SRV response_size=16384" \
4813 "$P_CLI force_version=tls1_2 \
4814 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4815 0 \
4816 -c "Read from server: 16384 bytes read"
4817
Andrzej Kurekd731a632018-06-19 09:37:30 -04004818run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
4819 "$P_SRV response_size=16384" \
4820 "$P_CLI force_version=tls1_2 etm=0 \
4821 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4822 0 \
4823 -s "16384 bytes written in 1 fragments" \
4824 -c "Read from server: 16384 bytes read"
4825
Andrzej Kurek557335e2018-06-28 04:03:10 -04004826run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
4827 "$P_SRV response_size=16384" \
4828 "$P_CLI force_version=tls1_2 \
4829 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4830 0 \
4831 -c "Read from server: 16384 bytes read"
4832
4833requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4834run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
4835 "$P_SRV response_size=16384" \
4836 "$P_CLI force_version=tls1_2 \
4837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4838 trunc_hmac=1" \
4839 0 \
4840 -c "Read from server: 16384 bytes read"
4841
Andrzej Kurekd731a632018-06-19 09:37:30 -04004842run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4843 "$P_SRV response_size=16384 trunc_hmac=1" \
4844 "$P_CLI force_version=tls1_2 \
4845 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4846 0 \
4847 -s "16384 bytes written in 1 fragments" \
4848 -c "Read from server: 16384 bytes read"
4849
Andrzej Kurek557335e2018-06-28 04:03:10 -04004850run_test "Large server packet TLS 1.2 StreamCipher" \
4851 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4852 "$P_CLI force_version=tls1_2 \
4853 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4854 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004855 -s "16384 bytes written in 1 fragments" \
4856 -c "Read from server: 16384 bytes read"
4857
4858run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
4859 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4860 "$P_CLI force_version=tls1_2 \
4861 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4862 0 \
4863 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004864 -c "Read from server: 16384 bytes read"
4865
4866requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4867run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
4868 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4869 "$P_CLI force_version=tls1_2 \
4870 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4871 trunc_hmac=1" \
4872 0 \
4873 -c "Read from server: 16384 bytes read"
4874
Andrzej Kurekd731a632018-06-19 09:37:30 -04004875requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4876run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4877 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4878 "$P_CLI force_version=tls1_2 \
4879 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4880 0 \
4881 -s "16384 bytes written in 1 fragments" \
4882 -c "Read from server: 16384 bytes read"
4883
Andrzej Kurek557335e2018-06-28 04:03:10 -04004884run_test "Large server packet TLS 1.2 AEAD" \
4885 "$P_SRV response_size=16384" \
4886 "$P_CLI force_version=tls1_2 \
4887 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4888 0 \
4889 -c "Read from server: 16384 bytes read"
4890
4891run_test "Large server packet TLS 1.2 AEAD shorter tag" \
4892 "$P_SRV response_size=16384" \
4893 "$P_CLI force_version=tls1_2 \
4894 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4895 0 \
4896 -c "Read from server: 16384 bytes read"
4897
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004898# Tests for DTLS HelloVerifyRequest
4899
4900run_test "DTLS cookie: enabled" \
4901 "$P_SRV dtls=1 debug_level=2" \
4902 "$P_CLI dtls=1 debug_level=2" \
4903 0 \
4904 -s "cookie verification failed" \
4905 -s "cookie verification passed" \
4906 -S "cookie verification skipped" \
4907 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004908 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004909 -S "SSL - The requested feature is not available"
4910
4911run_test "DTLS cookie: disabled" \
4912 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4913 "$P_CLI dtls=1 debug_level=2" \
4914 0 \
4915 -S "cookie verification failed" \
4916 -S "cookie verification passed" \
4917 -s "cookie verification skipped" \
4918 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004919 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004920 -S "SSL - The requested feature is not available"
4921
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004922run_test "DTLS cookie: default (failing)" \
4923 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4924 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4925 1 \
4926 -s "cookie verification failed" \
4927 -S "cookie verification passed" \
4928 -S "cookie verification skipped" \
4929 -C "received hello verify request" \
4930 -S "hello verification requested" \
4931 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004932
4933requires_ipv6
4934run_test "DTLS cookie: enabled, IPv6" \
4935 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4936 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4937 0 \
4938 -s "cookie verification failed" \
4939 -s "cookie verification passed" \
4940 -S "cookie verification skipped" \
4941 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004942 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004943 -S "SSL - The requested feature is not available"
4944
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004945run_test "DTLS cookie: enabled, nbio" \
4946 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4947 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4948 0 \
4949 -s "cookie verification failed" \
4950 -s "cookie verification passed" \
4951 -S "cookie verification skipped" \
4952 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004953 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004954 -S "SSL - The requested feature is not available"
4955
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004956# Tests for client reconnecting from the same port with DTLS
4957
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004958not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004959run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004960 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4961 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004962 0 \
4963 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004964 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004965 -S "Client initiated reconnection from same port"
4966
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004967not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004968run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004969 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4970 "$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 +02004971 0 \
4972 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004973 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004974 -s "Client initiated reconnection from same port"
4975
Paul Bakker362689d2016-05-13 10:33:25 +01004976not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4977run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004978 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4979 "$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 +02004980 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004981 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004982 -s "Client initiated reconnection from same port"
4983
Paul Bakker362689d2016-05-13 10:33:25 +01004984only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4985run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4986 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4987 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4988 0 \
4989 -S "The operation timed out" \
4990 -s "Client initiated reconnection from same port"
4991
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004992run_test "DTLS client reconnect from same port: no cookies" \
4993 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004994 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4995 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004996 -s "The operation timed out" \
4997 -S "Client initiated reconnection from same port"
4998
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004999# Tests for various cases of client authentication with DTLS
5000# (focused on handshake flows and message parsing)
5001
5002run_test "DTLS client auth: required" \
5003 "$P_SRV dtls=1 auth_mode=required" \
5004 "$P_CLI dtls=1" \
5005 0 \
5006 -s "Verifying peer X.509 certificate... ok"
5007
5008run_test "DTLS client auth: optional, client has no cert" \
5009 "$P_SRV dtls=1 auth_mode=optional" \
5010 "$P_CLI dtls=1 crt_file=none key_file=none" \
5011 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005012 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005013
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005014run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005015 "$P_SRV dtls=1 auth_mode=none" \
5016 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5017 0 \
5018 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005019 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005020
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005021run_test "DTLS wrong PSK: badmac alert" \
5022 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5023 "$P_CLI dtls=1 psk=abc124" \
5024 1 \
5025 -s "SSL - Verification of the message MAC failed" \
5026 -c "SSL - A fatal alert message was received from our peer"
5027
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005028# Tests for receiving fragmented handshake messages with DTLS
5029
5030requires_gnutls
5031run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5032 "$G_SRV -u --mtu 2048 -a" \
5033 "$P_CLI dtls=1 debug_level=2" \
5034 0 \
5035 -C "found fragmented DTLS handshake message" \
5036 -C "error"
5037
5038requires_gnutls
5039run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5040 "$G_SRV -u --mtu 512" \
5041 "$P_CLI dtls=1 debug_level=2" \
5042 0 \
5043 -c "found fragmented DTLS handshake message" \
5044 -C "error"
5045
5046requires_gnutls
5047run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5048 "$G_SRV -u --mtu 128" \
5049 "$P_CLI dtls=1 debug_level=2" \
5050 0 \
5051 -c "found fragmented DTLS handshake message" \
5052 -C "error"
5053
5054requires_gnutls
5055run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5056 "$G_SRV -u --mtu 128" \
5057 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5058 0 \
5059 -c "found fragmented DTLS handshake message" \
5060 -C "error"
5061
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005062requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005063requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005064run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5065 "$G_SRV -u --mtu 256" \
5066 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5067 0 \
5068 -c "found fragmented DTLS handshake message" \
5069 -c "client hello, adding renegotiation extension" \
5070 -c "found renegotiation extension" \
5071 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005072 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005073 -C "error" \
5074 -s "Extra-header:"
5075
5076requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005077requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005078run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5079 "$G_SRV -u --mtu 256" \
5080 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5081 0 \
5082 -c "found fragmented DTLS handshake message" \
5083 -c "client hello, adding renegotiation extension" \
5084 -c "found renegotiation extension" \
5085 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005086 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005087 -C "error" \
5088 -s "Extra-header:"
5089
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005090run_test "DTLS reassembly: no fragmentation (openssl server)" \
5091 "$O_SRV -dtls1 -mtu 2048" \
5092 "$P_CLI dtls=1 debug_level=2" \
5093 0 \
5094 -C "found fragmented DTLS handshake message" \
5095 -C "error"
5096
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005097run_test "DTLS reassembly: some fragmentation (openssl server)" \
5098 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005099 "$P_CLI dtls=1 debug_level=2" \
5100 0 \
5101 -c "found fragmented DTLS handshake message" \
5102 -C "error"
5103
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005104run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005105 "$O_SRV -dtls1 -mtu 256" \
5106 "$P_CLI dtls=1 debug_level=2" \
5107 0 \
5108 -c "found fragmented DTLS handshake message" \
5109 -C "error"
5110
5111run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5112 "$O_SRV -dtls1 -mtu 256" \
5113 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5114 0 \
5115 -c "found fragmented DTLS handshake message" \
5116 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005117
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005118# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005119
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005120not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005121run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005122 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005123 "$P_SRV dtls=1 debug_level=2" \
5124 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005125 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005126 -C "replayed record" \
5127 -S "replayed record" \
5128 -C "record from another epoch" \
5129 -S "record from another epoch" \
5130 -C "discarding invalid record" \
5131 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005132 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005133 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005134 -c "HTTP/1.0 200 OK"
5135
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005136not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005137run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005138 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005139 "$P_SRV dtls=1 debug_level=2" \
5140 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005141 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005142 -c "replayed record" \
5143 -s "replayed record" \
Hanno Beckera34cc6b2017-05-26 16:07:36 +01005144 -c "record from another epoch" \
5145 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005146 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005147 -s "Extra-header:" \
5148 -c "HTTP/1.0 200 OK"
5149
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005150run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
5151 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005152 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
5153 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005154 0 \
5155 -c "replayed record" \
5156 -S "replayed record" \
Hanno Beckera34cc6b2017-05-26 16:07:36 +01005157 -c "record from another epoch" \
5158 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005159 -c "resend" \
5160 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005161 -s "Extra-header:" \
5162 -c "HTTP/1.0 200 OK"
5163
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005164run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005165 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005166 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005167 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005168 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005169 -c "discarding invalid record (mac)" \
5170 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005171 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005172 -c "HTTP/1.0 200 OK" \
5173 -S "too many records with bad MAC" \
5174 -S "Verification of the message MAC failed"
5175
5176run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
5177 -p "$P_PXY bad_ad=1" \
5178 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
5179 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5180 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005181 -C "discarding invalid record (mac)" \
5182 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005183 -S "Extra-header:" \
5184 -C "HTTP/1.0 200 OK" \
5185 -s "too many records with bad MAC" \
5186 -s "Verification of the message MAC failed"
5187
5188run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
5189 -p "$P_PXY bad_ad=1" \
5190 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
5191 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5192 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005193 -c "discarding invalid record (mac)" \
5194 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005195 -s "Extra-header:" \
5196 -c "HTTP/1.0 200 OK" \
5197 -S "too many records with bad MAC" \
5198 -S "Verification of the message MAC failed"
5199
5200run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
5201 -p "$P_PXY bad_ad=1" \
5202 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
5203 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
5204 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005205 -c "discarding invalid record (mac)" \
5206 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005207 -s "Extra-header:" \
5208 -c "HTTP/1.0 200 OK" \
5209 -s "too many records with bad MAC" \
5210 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005211
5212run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005213 -p "$P_PXY delay_ccs=1" \
5214 "$P_SRV dtls=1 debug_level=1" \
5215 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005216 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005217 -c "record from another epoch" \
5218 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005219 -s "Extra-header:" \
5220 -c "HTTP/1.0 200 OK"
5221
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005222# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005223
Janos Follath74537a62016-09-02 13:45:28 +01005224client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005225run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005226 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005227 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5228 psk=abc123" \
5229 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005230 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5231 0 \
5232 -s "Extra-header:" \
5233 -c "HTTP/1.0 200 OK"
5234
Janos Follath74537a62016-09-02 13:45:28 +01005235client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005236run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
5237 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005238 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
5239 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005240 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5241 0 \
5242 -s "Extra-header:" \
5243 -c "HTTP/1.0 200 OK"
5244
Janos Follath74537a62016-09-02 13:45:28 +01005245client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005246run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
5247 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005248 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
5249 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005250 0 \
5251 -s "Extra-header:" \
5252 -c "HTTP/1.0 200 OK"
5253
Janos Follath74537a62016-09-02 13:45:28 +01005254client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005255run_test "DTLS proxy: 3d, FS, client auth" \
5256 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005257 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
5258 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005259 0 \
5260 -s "Extra-header:" \
5261 -c "HTTP/1.0 200 OK"
5262
Janos Follath74537a62016-09-02 13:45:28 +01005263client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005264run_test "DTLS proxy: 3d, FS, ticket" \
5265 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005266 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
5267 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005268 0 \
5269 -s "Extra-header:" \
5270 -c "HTTP/1.0 200 OK"
5271
Janos Follath74537a62016-09-02 13:45:28 +01005272client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005273run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
5274 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005275 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
5276 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005277 0 \
5278 -s "Extra-header:" \
5279 -c "HTTP/1.0 200 OK"
5280
Janos Follath74537a62016-09-02 13:45:28 +01005281client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005282run_test "DTLS proxy: 3d, max handshake, nbio" \
5283 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005284 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
5285 auth_mode=required" \
5286 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005287 0 \
5288 -s "Extra-header:" \
5289 -c "HTTP/1.0 200 OK"
5290
Janos Follath74537a62016-09-02 13:45:28 +01005291client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005292run_test "DTLS proxy: 3d, min handshake, resumption" \
5293 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5294 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5295 psk=abc123 debug_level=3" \
5296 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5297 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5298 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5299 0 \
5300 -s "a session has been resumed" \
5301 -c "a session has been resumed" \
5302 -s "Extra-header:" \
5303 -c "HTTP/1.0 200 OK"
5304
Janos Follath74537a62016-09-02 13:45:28 +01005305client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005306run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
5307 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5308 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5309 psk=abc123 debug_level=3 nbio=2" \
5310 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5311 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5312 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
5313 0 \
5314 -s "a session has been resumed" \
5315 -c "a session has been resumed" \
5316 -s "Extra-header:" \
5317 -c "HTTP/1.0 200 OK"
5318
Janos Follath74537a62016-09-02 13:45:28 +01005319client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005320requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005321run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005322 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005323 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5324 psk=abc123 renegotiation=1 debug_level=2" \
5325 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5326 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005327 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5328 0 \
5329 -c "=> renegotiate" \
5330 -s "=> renegotiate" \
5331 -s "Extra-header:" \
5332 -c "HTTP/1.0 200 OK"
5333
Janos Follath74537a62016-09-02 13:45:28 +01005334client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005335requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005336run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
5337 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005338 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5339 psk=abc123 renegotiation=1 debug_level=2" \
5340 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5341 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005342 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5343 0 \
5344 -c "=> renegotiate" \
5345 -s "=> renegotiate" \
5346 -s "Extra-header:" \
5347 -c "HTTP/1.0 200 OK"
5348
Janos Follath74537a62016-09-02 13:45:28 +01005349client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005350requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005351run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005352 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005353 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005354 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005355 debug_level=2" \
5356 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005357 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005358 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5359 0 \
5360 -c "=> renegotiate" \
5361 -s "=> renegotiate" \
5362 -s "Extra-header:" \
5363 -c "HTTP/1.0 200 OK"
5364
Janos Follath74537a62016-09-02 13:45:28 +01005365client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005366requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005367run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005368 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005369 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005370 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005371 debug_level=2 nbio=2" \
5372 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005373 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005374 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5375 0 \
5376 -c "=> renegotiate" \
5377 -s "=> renegotiate" \
5378 -s "Extra-header:" \
5379 -c "HTTP/1.0 200 OK"
5380
Janos Follath74537a62016-09-02 13:45:28 +01005381client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005382not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005383run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005384 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5385 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005386 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005387 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005388 -c "HTTP/1.0 200 OK"
5389
Janos Follath74537a62016-09-02 13:45:28 +01005390client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005391not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005392run_test "DTLS proxy: 3d, openssl server, fragmentation" \
5393 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5394 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005395 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005396 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005397 -c "HTTP/1.0 200 OK"
5398
Janos Follath74537a62016-09-02 13:45:28 +01005399client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005400not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005401run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
5402 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5403 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005404 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005405 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005406 -c "HTTP/1.0 200 OK"
5407
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005408requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005409client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005410not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005411run_test "DTLS proxy: 3d, gnutls server" \
5412 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5413 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005414 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005415 0 \
5416 -s "Extra-header:" \
5417 -c "Extra-header:"
5418
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005419requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005420client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005421not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005422run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
5423 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5424 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005425 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005426 0 \
5427 -s "Extra-header:" \
5428 -c "Extra-header:"
5429
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005430requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005431client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005432not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005433run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
5434 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5435 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005436 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005437 0 \
5438 -s "Extra-header:" \
5439 -c "Extra-header:"
5440
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01005441# Final report
5442
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005443echo "------------------------------------------------------------------------"
5444
5445if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005446 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005447else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005448 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005449fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02005450PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02005451echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005452
5453exit $FAILS