blob: 92151fd87f22c1aac1be1585e41b47317c277632 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200125# skip next test if the flag is enabled in config.h
126requires_config_disabled() {
127 if grep "^#define $1" $CONFIG_H > /dev/null; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200132# skip next test if OpenSSL doesn't support FALLBACK_SCSV
133requires_openssl_with_fallback_scsv() {
134 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
135 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
136 then
137 OPENSSL_HAS_FBSCSV="YES"
138 else
139 OPENSSL_HAS_FBSCSV="NO"
140 fi
141 fi
142 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
143 SKIP_NEXT="YES"
144 fi
145}
146
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200147# skip next test if GnuTLS isn't available
148requires_gnutls() {
149 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200150 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151 GNUTLS_AVAILABLE="YES"
152 else
153 GNUTLS_AVAILABLE="NO"
154 fi
155 fi
156 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200161# skip next test if IPv6 isn't available on this host
162requires_ipv6() {
163 if [ -z "${HAS_IPV6:-}" ]; then
164 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
165 SRV_PID=$!
166 sleep 1
167 kill $SRV_PID >/dev/null 2>&1
168 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
169 HAS_IPV6="NO"
170 else
171 HAS_IPV6="YES"
172 fi
173 rm -r $SRV_OUT
174 fi
175
176 if [ "$HAS_IPV6" = "NO" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200181# skip the next test if valgrind is in use
182not_with_valgrind() {
183 if [ "$MEMCHECK" -gt 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Paul Bakker362689d2016-05-13 10:33:25 +0100188# skip the next test if valgrind is NOT in use
189only_with_valgrind() {
190 if [ "$MEMCHECK" -eq 0 ]; then
191 SKIP_NEXT="YES"
192 fi
193}
194
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200195# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100196client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200197 CLI_DELAY_FACTOR=$1
198}
199
Janos Follath74537a62016-09-02 13:45:28 +0100200# wait for the given seconds after the client finished in the next test
201server_needs_more_time() {
202 SRV_DELAY_SECONDS=$1
203}
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205# print_name <name>
206print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100207 TESTS=$(( $TESTS + 1 ))
208 LINE=""
209
210 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
211 LINE="$TESTS "
212 fi
213
214 LINE="$LINE$1"
215 printf "$LINE "
216 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100217 for i in `seq 1 $LEN`; do printf '.'; done
218 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100220}
221
222# fail <message>
223fail() {
224 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100225 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200227 mv $SRV_OUT o-srv-${TESTS}.log
228 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if [ -n "$PXY_CMD" ]; then
230 mv $PXY_OUT o-pxy-${TESTS}.log
231 fi
232 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100233
Azim Khan19d13732018-03-29 11:04:20 +0100234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot -o "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200235 echo " ! server output:"
236 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200237 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200238 echo " ! client output:"
239 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200240 if [ -n "$PXY_CMD" ]; then
241 echo " ! ========================================================"
242 echo " ! proxy output:"
243 cat o-pxy-${TESTS}.log
244 fi
245 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200246 fi
247
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200248 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249}
250
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251# is_polar <cmd_line>
252is_polar() {
253 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
254}
255
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200256# openssl s_server doesn't have -www with DTLS
257check_osrv_dtls() {
258 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
259 NEEDS_INPUT=1
260 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
261 else
262 NEEDS_INPUT=0
263 fi
264}
265
266# provide input to commands that need it
267provide_input() {
268 if [ $NEEDS_INPUT -eq 0 ]; then
269 return
270 fi
271
272 while true; do
273 echo "HTTP/1.0 200 OK"
274 sleep 1
275 done
276}
277
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100278# has_mem_err <log_file_name>
279has_mem_err() {
280 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
281 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
282 then
283 return 1 # false: does not have errors
284 else
285 return 0 # true: has errors
286 fi
287}
288
Gilles Peskine418b5362017-12-14 18:58:42 +0100289# Wait for process $2 to be listening on port $1
290if type lsof >/dev/null 2>/dev/null; then
291 wait_server_start() {
292 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200293 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100294 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200295 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100296 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200297 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100298 # Make a tight loop, server normally takes less than 1s to start.
299 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
300 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
301 echo "SERVERSTART TIMEOUT"
302 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
303 break
304 fi
305 # Linux and *BSD support decimal arguments to sleep. On other
306 # OSes this may be a tight loop.
307 sleep 0.1 2>/dev/null || true
308 done
309 }
310else
Gilles Peskine3c9e2b52018-01-08 12:38:15 +0100311 echo "Warning: lsof not available, wait_server_start = sleep $START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100312 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200313 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100314 }
315fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200316
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100317# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100318# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100319# acceptable bounds
320check_server_hello_time() {
321 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100322 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100323 # Get the Unix timestamp for now
324 CUR_TIME=$(date +'%s')
325 THRESHOLD_IN_SECS=300
326
327 # Check if the ServerHello time was printed
328 if [ -z "$SERVER_HELLO_TIME" ]; then
329 return 1
330 fi
331
332 # Check the time in ServerHello is within acceptable bounds
333 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
334 # The time in ServerHello is at least 5 minutes before now
335 return 1
336 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100337 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100338 return 1
339 else
340 return 0
341 fi
342}
343
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200344# wait for client to terminate and set CLI_EXIT
345# must be called right after starting the client
346wait_client_done() {
347 CLI_PID=$!
348
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200349 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
350 CLI_DELAY_FACTOR=1
351
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200352 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200353 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200354
355 wait $CLI_PID
356 CLI_EXIT=$?
357
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200358 kill $DOG_PID >/dev/null 2>&1
359 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200360
361 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100362
363 sleep $SRV_DELAY_SECONDS
364 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200365}
366
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200367# check if the given command uses dtls and sets global variable DTLS
368detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200369 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200370 DTLS=1
371 else
372 DTLS=0
373 fi
374}
375
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200376# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100377# Options: -s pattern pattern that must be present in server output
378# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100379# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100380# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100381# -S pattern pattern that must be absent in server output
382# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100383# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100384# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100385run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100386 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200387 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100388
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100389 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
390 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200391 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100392 return
393 fi
394
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100396
Paul Bakkerb7584a52016-05-10 10:50:43 +0100397 # Do we only run numbered tests?
398 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
399 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
400 else
401 SKIP_NEXT="YES"
402 fi
403
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200404 # should we skip?
405 if [ "X$SKIP_NEXT" = "XYES" ]; then
406 SKIP_NEXT="NO"
407 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200408 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200409 return
410 fi
411
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200412 # does this test use a proxy?
413 if [ "X$1" = "X-p" ]; then
414 PXY_CMD="$2"
415 shift 2
416 else
417 PXY_CMD=""
418 fi
419
420 # get commands and client output
421 SRV_CMD="$1"
422 CLI_CMD="$2"
423 CLI_EXPECT="$3"
424 shift 3
425
426 # fix client port
427 if [ -n "$PXY_CMD" ]; then
428 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
429 else
430 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
431 fi
432
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200433 # update DTLS variable
434 detect_dtls "$SRV_CMD"
435
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100436 # prepend valgrind to our commands if active
437 if [ "$MEMCHECK" -gt 0 ]; then
438 if is_polar "$SRV_CMD"; then
439 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
440 fi
441 if is_polar "$CLI_CMD"; then
442 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
443 fi
444 fi
445
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200446 TIMES_LEFT=2
447 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200448 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200449
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200450 # run the commands
451 if [ -n "$PXY_CMD" ]; then
452 echo "$PXY_CMD" > $PXY_OUT
453 $PXY_CMD >> $PXY_OUT 2>&1 &
454 PXY_PID=$!
455 # assume proxy starts faster than server
456 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200457
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200458 check_osrv_dtls
459 echo "$SRV_CMD" > $SRV_OUT
460 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
461 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100462 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200463
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200464 echo "$CLI_CMD" > $CLI_OUT
465 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
466 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100467
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100468 sleep 0.05
469
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200470 # terminate the server (and the proxy)
471 kill $SRV_PID
472 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100473
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200474 if [ -n "$PXY_CMD" ]; then
475 kill $PXY_PID >/dev/null 2>&1
476 wait $PXY_PID
477 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100478
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200479 # retry only on timeouts
480 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
481 printf "RETRY "
482 else
483 TIMES_LEFT=0
484 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200485 done
486
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100487 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200488 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100489 # expected client exit to incorrectly succeed in case of catastrophic
490 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100491 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200492 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100493 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100494 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100495 return
496 fi
497 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100498 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200499 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100500 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100501 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100502 return
503 fi
504 fi
505
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100506 # check server exit code
507 if [ $? != 0 ]; then
508 fail "server fail"
509 return
510 fi
511
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100512 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100513 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
514 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100515 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200516 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100517 return
518 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100519
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100520 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200521 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100522 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100523 while [ $# -gt 0 ]
524 do
525 case $1 in
526 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100527 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 +0100528 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100529 return
530 fi
531 ;;
532
533 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100534 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 +0100535 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100536 return
537 fi
538 ;;
539
540 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100541 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 +0100542 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100543 return
544 fi
545 ;;
546
547 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100548 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 +0100549 fail "pattern '$2' MUST NOT be present in the Client output"
550 return
551 fi
552 ;;
553
554 # The filtering in the following two options (-u and -U) do the following
555 # - ignore valgrind output
556 # - filter out everything but lines right after the pattern occurances
557 # - keep one of each non-unique line
558 # - count how many lines remain
559 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
560 # if there were no duplicates.
561 "-U")
562 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
563 fail "lines following pattern '$2' must be unique in Server output"
564 return
565 fi
566 ;;
567
568 "-u")
569 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
570 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100571 return
572 fi
573 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100574 "-F")
575 if ! $2 "$SRV_OUT"; then
576 fail "function call to '$2' failed on Server output"
577 return
578 fi
579 ;;
580 "-f")
581 if ! $2 "$CLI_OUT"; then
582 fail "function call to '$2' failed on Client output"
583 return
584 fi
585 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100586
587 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200588 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100589 exit 1
590 esac
591 shift 2
592 done
593
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100594 # check valgrind's results
595 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200596 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100597 fail "Server has memory errors"
598 return
599 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200600 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100601 fail "Client has memory errors"
602 return
603 fi
604 fi
605
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100606 # if we're here, everything is ok
607 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100608 if [ "$PRESERVE_LOGS" -gt 0 ]; then
609 mv $SRV_OUT o-srv-${TESTS}.log
610 mv $CLI_OUT o-cli-${TESTS}.log
611 fi
612
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200613 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100614}
615
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100616cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200618 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
619 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
620 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
621 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100622 exit 1
623}
624
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100625#
626# MAIN
627#
628
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000629if cd $( dirname $0 ); then :; else
630 echo "cd $( dirname $0 ) failed" >&2
631 exit 1
632fi
633
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100634get_options "$@"
635
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100636# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100637P_SRV_BIN="${P_SRV%%[ ]*}"
638P_CLI_BIN="${P_CLI%%[ ]*}"
639P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100640if [ ! -x "$P_SRV_BIN" ]; then
641 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100642 exit 1
643fi
Hanno Becker17c04932017-10-10 14:44:53 +0100644if [ ! -x "$P_CLI_BIN" ]; then
645 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100646 exit 1
647fi
Hanno Becker17c04932017-10-10 14:44:53 +0100648if [ ! -x "$P_PXY_BIN" ]; then
649 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200650 exit 1
651fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100652if [ "$MEMCHECK" -gt 0 ]; then
653 if which valgrind >/dev/null 2>&1; then :; else
654 echo "Memcheck not possible. Valgrind not found"
655 exit 1
656 fi
657fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100658if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
659 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100660 exit 1
661fi
662
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200663# used by watchdog
664MAIN_PID="$$"
665
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100666# We use somewhat arbitrary delays for tests:
667# - how long do we wait for the server to start (when lsof not available)?
668# - how long do we allow for the client to finish?
669# (not to check performance, just to avoid waiting indefinitely)
670# Things are slower with valgrind, so give extra time here.
671#
672# Note: without lsof, there is a trade-off between the running time of this
673# script and the risk of spurious errors because we didn't wait long enough.
674# The watchdog delay on the other hand doesn't affect normal running time of
675# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200676if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100677 START_DELAY=6
678 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200679else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100680 START_DELAY=2
681 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200682fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100683
684# some particular tests need more time:
685# - for the client, we multiply the usual watchdog limit by a factor
686# - for the server, we sleep for a number of seconds after the client exits
687# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200688CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100689SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200690
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200691# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000692# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200693P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
694P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100695P_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 +0200696O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200697O_CLI="$O_CLI -connect localhost:+SRV_PORT"
698G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000699G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200700
Gilles Peskine62469d92017-05-10 10:13:59 +0200701# Allow SHA-1, because many of our test certificates use it
702P_SRV="$P_SRV allow_sha1=1"
703P_CLI="$P_CLI allow_sha1=1"
704
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200705# Also pick a unique name for intermediate files
706SRV_OUT="srv_out.$$"
707CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200708PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200709SESSION="session.$$"
710
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200711SKIP_NEXT="NO"
712
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100713trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100714
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200715# Basic test
716
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200717# Checks that:
718# - things work with all ciphersuites active (used with config-full in all.sh)
719# - the expected (highest security) parameters are selected
720# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200721run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200722 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200723 "$P_CLI" \
724 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200725 -s "Protocol is TLSv1.2" \
726 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
727 -s "client hello v3, signature_algorithm ext: 6" \
728 -s "ECDHE curve: secp521r1" \
729 -S "error" \
730 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200731
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000732run_test "Default, DTLS" \
733 "$P_SRV dtls=1" \
734 "$P_CLI dtls=1" \
735 0 \
736 -s "Protocol is DTLSv1.2" \
737 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
738
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100739# Test current time in ServerHello
740requires_config_enabled MBEDTLS_HAVE_TIME
741run_test "Default, ServerHello contains gmt_unix_time" \
742 "$P_SRV debug_level=3" \
743 "$P_CLI debug_level=3" \
744 0 \
745 -s "Protocol is TLSv1.2" \
746 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
747 -s "client hello v3, signature_algorithm ext: 6" \
748 -s "ECDHE curve: secp521r1" \
749 -S "error" \
750 -C "error" \
751 -f "check_server_hello_time" \
752 -F "check_server_hello_time"
753
Simon Butcher8e004102016-10-14 00:48:33 +0100754# Test for uniqueness of IVs in AEAD ciphersuites
755run_test "Unique IV in GCM" \
756 "$P_SRV exchanges=20 debug_level=4" \
757 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
758 0 \
759 -u "IV used" \
760 -U "IV used"
761
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100762# Tests for rc4 option
763
Simon Butchera410af52016-05-19 22:12:18 +0100764requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100765run_test "RC4: server disabled, client enabled" \
766 "$P_SRV" \
767 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
768 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100769 -s "SSL - The server has no ciphersuites in common"
770
Simon Butchera410af52016-05-19 22:12:18 +0100771requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100772run_test "RC4: server half, client enabled" \
773 "$P_SRV arc4=1" \
774 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
775 1 \
776 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100777
778run_test "RC4: server enabled, client disabled" \
779 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
780 "$P_CLI" \
781 1 \
782 -s "SSL - The server has no ciphersuites in common"
783
784run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100785 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100786 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
787 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100788 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100789 -S "SSL - The server has no ciphersuites in common"
790
Gilles Peskinebc70a182017-05-09 15:59:24 +0200791# Tests for SHA-1 support
792
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200793requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200794run_test "SHA-1 forbidden by default in server certificate" \
795 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
796 "$P_CLI debug_level=2 allow_sha1=0" \
797 1 \
798 -c "The certificate is signed with an unacceptable hash"
799
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200800requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
801run_test "SHA-1 forbidden by default in server certificate" \
802 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
803 "$P_CLI debug_level=2 allow_sha1=0" \
804 0
805
Gilles Peskinebc70a182017-05-09 15:59:24 +0200806run_test "SHA-1 explicitly allowed in server certificate" \
807 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
808 "$P_CLI allow_sha1=1" \
809 0
810
811run_test "SHA-256 allowed by default in server certificate" \
812 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
813 "$P_CLI allow_sha1=0" \
814 0
815
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200816requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200817run_test "SHA-1 forbidden by default in client certificate" \
818 "$P_SRV auth_mode=required allow_sha1=0" \
819 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
820 1 \
821 -s "The certificate is signed with an unacceptable hash"
822
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200823requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
824run_test "SHA-1 forbidden by default in client certificate" \
825 "$P_SRV auth_mode=required allow_sha1=0" \
826 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
827 0
828
Gilles Peskinebc70a182017-05-09 15:59:24 +0200829run_test "SHA-1 explicitly allowed in client certificate" \
830 "$P_SRV auth_mode=required allow_sha1=1" \
831 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
832 0
833
834run_test "SHA-256 allowed 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-sha256.crt" \
837 0
838
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100839# Tests for Truncated HMAC extension
840
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100841run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200842 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100843 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100844 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000845 -s "dumping 'expected mac' (20 bytes)" \
846 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100847
Hanno Becker32c55012017-11-10 08:42:54 +0000848requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100849run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200850 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000851 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100852 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000853 -s "dumping 'expected mac' (20 bytes)" \
854 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100855
Hanno Becker32c55012017-11-10 08:42:54 +0000856requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100857run_test "Truncated HMAC: client enabled, server default" \
858 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000859 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100860 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000861 -s "dumping 'expected mac' (20 bytes)" \
862 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100863
Hanno Becker32c55012017-11-10 08:42:54 +0000864requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100865run_test "Truncated HMAC: client enabled, server disabled" \
866 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000867 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100868 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000869 -s "dumping 'expected mac' (20 bytes)" \
870 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100871
Hanno Becker32c55012017-11-10 08:42:54 +0000872requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000873run_test "Truncated HMAC: client disabled, server enabled" \
874 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000875 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000876 0 \
877 -s "dumping 'expected mac' (20 bytes)" \
878 -S "dumping 'expected mac' (10 bytes)"
879
880requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100881run_test "Truncated HMAC: client enabled, server enabled" \
882 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000883 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100884 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000885 -S "dumping 'expected mac' (20 bytes)" \
886 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100887
Hanno Becker4c4f4102017-11-10 09:16:05 +0000888run_test "Truncated HMAC, DTLS: client default, server default" \
889 "$P_SRV dtls=1 debug_level=4" \
890 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
891 0 \
892 -s "dumping 'expected mac' (20 bytes)" \
893 -S "dumping 'expected mac' (10 bytes)"
894
895requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
896run_test "Truncated HMAC, DTLS: client disabled, server default" \
897 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000898 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000899 0 \
900 -s "dumping 'expected mac' (20 bytes)" \
901 -S "dumping 'expected mac' (10 bytes)"
902
903requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
904run_test "Truncated HMAC, DTLS: client enabled, server default" \
905 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000906 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000907 0 \
908 -s "dumping 'expected mac' (20 bytes)" \
909 -S "dumping 'expected mac' (10 bytes)"
910
911requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
912run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
913 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000914 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000915 0 \
916 -s "dumping 'expected mac' (20 bytes)" \
917 -S "dumping 'expected mac' (10 bytes)"
918
919requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
920run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
921 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000922 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000923 0 \
924 -s "dumping 'expected mac' (20 bytes)" \
925 -S "dumping 'expected mac' (10 bytes)"
926
927requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
928run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
929 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000930 "$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 +0100931 0 \
932 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100933 -s "dumping 'expected mac' (10 bytes)"
934
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100935# Tests for Encrypt-then-MAC extension
936
937run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100938 "$P_SRV debug_level=3 \
939 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100940 "$P_CLI debug_level=3" \
941 0 \
942 -c "client hello, adding encrypt_then_mac extension" \
943 -s "found encrypt then mac extension" \
944 -s "server hello, adding encrypt then mac extension" \
945 -c "found encrypt_then_mac extension" \
946 -c "using encrypt then mac" \
947 -s "using encrypt then mac"
948
949run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100950 "$P_SRV debug_level=3 etm=0 \
951 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100952 "$P_CLI debug_level=3 etm=1" \
953 0 \
954 -c "client hello, adding encrypt_then_mac extension" \
955 -s "found encrypt then mac extension" \
956 -S "server hello, adding encrypt then mac extension" \
957 -C "found encrypt_then_mac extension" \
958 -C "using encrypt then mac" \
959 -S "using encrypt then mac"
960
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100961run_test "Encrypt then MAC: client enabled, aead cipher" \
962 "$P_SRV debug_level=3 etm=1 \
963 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
964 "$P_CLI debug_level=3 etm=1" \
965 0 \
966 -c "client hello, adding encrypt_then_mac extension" \
967 -s "found encrypt then mac extension" \
968 -S "server hello, adding encrypt then mac extension" \
969 -C "found encrypt_then_mac extension" \
970 -C "using encrypt then mac" \
971 -S "using encrypt then mac"
972
973run_test "Encrypt then MAC: client enabled, stream cipher" \
974 "$P_SRV debug_level=3 etm=1 \
975 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100976 "$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 +0100977 0 \
978 -c "client hello, adding encrypt_then_mac extension" \
979 -s "found encrypt then mac extension" \
980 -S "server hello, adding encrypt then mac extension" \
981 -C "found encrypt_then_mac extension" \
982 -C "using encrypt then mac" \
983 -S "using encrypt then mac"
984
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100985run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100986 "$P_SRV debug_level=3 etm=1 \
987 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100988 "$P_CLI debug_level=3 etm=0" \
989 0 \
990 -C "client hello, adding encrypt_then_mac extension" \
991 -S "found encrypt then mac extension" \
992 -S "server hello, adding encrypt then mac extension" \
993 -C "found encrypt_then_mac extension" \
994 -C "using encrypt then mac" \
995 -S "using encrypt then mac"
996
Janos Follathe2681a42016-03-07 15:57:05 +0000997requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100998run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100999 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001000 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001001 "$P_CLI debug_level=3 force_version=ssl3" \
1002 0 \
1003 -C "client hello, adding encrypt_then_mac extension" \
1004 -S "found encrypt then mac extension" \
1005 -S "server hello, adding encrypt then mac extension" \
1006 -C "found encrypt_then_mac extension" \
1007 -C "using encrypt then mac" \
1008 -S "using encrypt then mac"
1009
Janos Follathe2681a42016-03-07 15:57:05 +00001010requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001011run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001012 "$P_SRV debug_level=3 force_version=ssl3 \
1013 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001014 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001015 0 \
1016 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001017 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001018 -S "server hello, adding encrypt then mac extension" \
1019 -C "found encrypt_then_mac extension" \
1020 -C "using encrypt then mac" \
1021 -S "using encrypt then mac"
1022
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001023# Tests for Extended Master Secret extension
1024
1025run_test "Extended Master Secret: default" \
1026 "$P_SRV debug_level=3" \
1027 "$P_CLI debug_level=3" \
1028 0 \
1029 -c "client hello, adding extended_master_secret extension" \
1030 -s "found extended master secret extension" \
1031 -s "server hello, adding extended master secret extension" \
1032 -c "found extended_master_secret extension" \
1033 -c "using extended master secret" \
1034 -s "using extended master secret"
1035
1036run_test "Extended Master Secret: client enabled, server disabled" \
1037 "$P_SRV debug_level=3 extended_ms=0" \
1038 "$P_CLI debug_level=3 extended_ms=1" \
1039 0 \
1040 -c "client hello, adding extended_master_secret extension" \
1041 -s "found extended master secret extension" \
1042 -S "server hello, adding extended master secret extension" \
1043 -C "found extended_master_secret extension" \
1044 -C "using extended master secret" \
1045 -S "using extended master secret"
1046
1047run_test "Extended Master Secret: client disabled, server enabled" \
1048 "$P_SRV debug_level=3 extended_ms=1" \
1049 "$P_CLI debug_level=3 extended_ms=0" \
1050 0 \
1051 -C "client hello, adding extended_master_secret extension" \
1052 -S "found extended master secret extension" \
1053 -S "server hello, adding extended master secret extension" \
1054 -C "found extended_master_secret extension" \
1055 -C "using extended master secret" \
1056 -S "using extended master secret"
1057
Janos Follathe2681a42016-03-07 15:57:05 +00001058requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001059run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001060 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001061 "$P_CLI debug_level=3 force_version=ssl3" \
1062 0 \
1063 -C "client hello, adding extended_master_secret extension" \
1064 -S "found extended master secret extension" \
1065 -S "server hello, adding extended master secret extension" \
1066 -C "found extended_master_secret extension" \
1067 -C "using extended master secret" \
1068 -S "using extended master secret"
1069
Janos Follathe2681a42016-03-07 15:57:05 +00001070requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001071run_test "Extended Master Secret: client enabled, server SSLv3" \
1072 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001073 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001074 0 \
1075 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001076 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001077 -S "server hello, adding extended master secret extension" \
1078 -C "found extended_master_secret extension" \
1079 -C "using extended master secret" \
1080 -S "using extended master secret"
1081
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001082# Tests for FALLBACK_SCSV
1083
1084run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001085 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001086 "$P_CLI debug_level=3 force_version=tls1_1" \
1087 0 \
1088 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001089 -S "received FALLBACK_SCSV" \
1090 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001091 -C "is a fatal alert message (msg 86)"
1092
1093run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001094 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001095 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1096 0 \
1097 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001098 -S "received FALLBACK_SCSV" \
1099 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001100 -C "is a fatal alert message (msg 86)"
1101
1102run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001103 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001104 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001105 1 \
1106 -c "adding FALLBACK_SCSV" \
1107 -s "received FALLBACK_SCSV" \
1108 -s "inapropriate fallback" \
1109 -c "is a fatal alert message (msg 86)"
1110
1111run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001112 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001113 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001114 0 \
1115 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001116 -s "received FALLBACK_SCSV" \
1117 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001118 -C "is a fatal alert message (msg 86)"
1119
1120requires_openssl_with_fallback_scsv
1121run_test "Fallback SCSV: default, openssl server" \
1122 "$O_SRV" \
1123 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1124 0 \
1125 -C "adding FALLBACK_SCSV" \
1126 -C "is a fatal alert message (msg 86)"
1127
1128requires_openssl_with_fallback_scsv
1129run_test "Fallback SCSV: enabled, openssl server" \
1130 "$O_SRV" \
1131 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1132 1 \
1133 -c "adding FALLBACK_SCSV" \
1134 -c "is a fatal alert message (msg 86)"
1135
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001136requires_openssl_with_fallback_scsv
1137run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001138 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001139 "$O_CLI -tls1_1" \
1140 0 \
1141 -S "received FALLBACK_SCSV" \
1142 -S "inapropriate fallback"
1143
1144requires_openssl_with_fallback_scsv
1145run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001146 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001147 "$O_CLI -tls1_1 -fallback_scsv" \
1148 1 \
1149 -s "received FALLBACK_SCSV" \
1150 -s "inapropriate fallback"
1151
1152requires_openssl_with_fallback_scsv
1153run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001154 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001155 "$O_CLI -fallback_scsv" \
1156 0 \
1157 -s "received FALLBACK_SCSV" \
1158 -S "inapropriate fallback"
1159
Gilles Peskined50177f2017-05-16 17:53:03 +02001160## ClientHello generated with
1161## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1162## then manually twiddling the ciphersuite list.
1163## The ClientHello content is spelled out below as a hex string as
1164## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1165## The expected response is an inappropriate_fallback alert.
1166requires_openssl_with_fallback_scsv
1167run_test "Fallback SCSV: beginning of list" \
1168 "$P_SRV debug_level=2" \
1169 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1170 0 \
1171 -s "received FALLBACK_SCSV" \
1172 -s "inapropriate fallback"
1173
1174requires_openssl_with_fallback_scsv
1175run_test "Fallback SCSV: end of list" \
1176 "$P_SRV debug_level=2" \
1177 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1178 0 \
1179 -s "received FALLBACK_SCSV" \
1180 -s "inapropriate fallback"
1181
1182## Here the expected response is a valid ServerHello prefix, up to the random.
1183requires_openssl_with_fallback_scsv
1184run_test "Fallback SCSV: not in list" \
1185 "$P_SRV debug_level=2" \
1186 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1187 0 \
1188 -S "received FALLBACK_SCSV" \
1189 -S "inapropriate fallback"
1190
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001191# Tests for CBC 1/n-1 record splitting
1192
1193run_test "CBC Record splitting: TLS 1.2, no splitting" \
1194 "$P_SRV" \
1195 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1196 request_size=123 force_version=tls1_2" \
1197 0 \
1198 -s "Read from client: 123 bytes read" \
1199 -S "Read from client: 1 bytes read" \
1200 -S "122 bytes read"
1201
1202run_test "CBC Record splitting: TLS 1.1, no splitting" \
1203 "$P_SRV" \
1204 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1205 request_size=123 force_version=tls1_1" \
1206 0 \
1207 -s "Read from client: 123 bytes read" \
1208 -S "Read from client: 1 bytes read" \
1209 -S "122 bytes read"
1210
1211run_test "CBC Record splitting: TLS 1.0, splitting" \
1212 "$P_SRV" \
1213 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1214 request_size=123 force_version=tls1" \
1215 0 \
1216 -S "Read from client: 123 bytes read" \
1217 -s "Read from client: 1 bytes read" \
1218 -s "122 bytes read"
1219
Janos Follathe2681a42016-03-07 15:57:05 +00001220requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001221run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001222 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001223 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1224 request_size=123 force_version=ssl3" \
1225 0 \
1226 -S "Read from client: 123 bytes read" \
1227 -s "Read from client: 1 bytes read" \
1228 -s "122 bytes read"
1229
1230run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001231 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001232 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1233 request_size=123 force_version=tls1" \
1234 0 \
1235 -s "Read from client: 123 bytes read" \
1236 -S "Read from client: 1 bytes read" \
1237 -S "122 bytes read"
1238
1239run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1240 "$P_SRV" \
1241 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1242 request_size=123 force_version=tls1 recsplit=0" \
1243 0 \
1244 -s "Read from client: 123 bytes read" \
1245 -S "Read from client: 1 bytes read" \
1246 -S "122 bytes read"
1247
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001248run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1249 "$P_SRV nbio=2" \
1250 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1251 request_size=123 force_version=tls1" \
1252 0 \
1253 -S "Read from client: 123 bytes read" \
1254 -s "Read from client: 1 bytes read" \
1255 -s "122 bytes read"
1256
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001257# Tests for Session Tickets
1258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001259run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001260 "$P_SRV debug_level=3 tickets=1" \
1261 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001262 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001263 -c "client hello, adding session ticket extension" \
1264 -s "found session ticket extension" \
1265 -s "server hello, adding session ticket extension" \
1266 -c "found session_ticket extension" \
1267 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001268 -S "session successfully restored from cache" \
1269 -s "session successfully restored from ticket" \
1270 -s "a session has been resumed" \
1271 -c "a session has been resumed"
1272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001273run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001274 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1275 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001276 0 \
1277 -c "client hello, adding session ticket extension" \
1278 -s "found session ticket extension" \
1279 -s "server hello, adding session ticket extension" \
1280 -c "found session_ticket extension" \
1281 -c "parse new session ticket" \
1282 -S "session successfully restored from cache" \
1283 -s "session successfully restored from ticket" \
1284 -s "a session has been resumed" \
1285 -c "a session has been resumed"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1289 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001290 0 \
1291 -c "client hello, adding session ticket extension" \
1292 -s "found session ticket extension" \
1293 -s "server hello, adding session ticket extension" \
1294 -c "found session_ticket extension" \
1295 -c "parse new session ticket" \
1296 -S "session successfully restored from cache" \
1297 -S "session successfully restored from ticket" \
1298 -S "a session has been resumed" \
1299 -C "a session has been resumed"
1300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001301run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001302 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001303 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001304 0 \
1305 -c "client hello, adding session ticket extension" \
1306 -c "found session_ticket extension" \
1307 -c "parse new session ticket" \
1308 -c "a session has been resumed"
1309
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001310run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001311 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001312 "( $O_CLI -sess_out $SESSION; \
1313 $O_CLI -sess_in $SESSION; \
1314 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001315 0 \
1316 -s "found session ticket extension" \
1317 -s "server hello, adding session ticket extension" \
1318 -S "session successfully restored from cache" \
1319 -s "session successfully restored from ticket" \
1320 -s "a session has been resumed"
1321
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001322# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001324run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001325 "$P_SRV debug_level=3 tickets=0" \
1326 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001327 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001328 -c "client hello, adding session ticket extension" \
1329 -s "found session ticket extension" \
1330 -S "server hello, adding session ticket extension" \
1331 -C "found session_ticket extension" \
1332 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001333 -s "session successfully restored from cache" \
1334 -S "session successfully restored from ticket" \
1335 -s "a session has been resumed" \
1336 -c "a session has been resumed"
1337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001338run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001339 "$P_SRV debug_level=3 tickets=1" \
1340 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001341 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001342 -C "client hello, adding session ticket extension" \
1343 -S "found session ticket extension" \
1344 -S "server hello, adding session ticket extension" \
1345 -C "found session_ticket extension" \
1346 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001347 -s "session successfully restored from cache" \
1348 -S "session successfully restored from ticket" \
1349 -s "a session has been resumed" \
1350 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001352run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001353 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1354 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001355 0 \
1356 -S "session successfully restored from cache" \
1357 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001358 -S "a session has been resumed" \
1359 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001361run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001362 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1363 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001364 0 \
1365 -s "session successfully restored from cache" \
1366 -S "session successfully restored from ticket" \
1367 -s "a session has been resumed" \
1368 -c "a session has been resumed"
1369
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001370run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001371 "$P_SRV debug_level=3 tickets=0" \
1372 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001373 0 \
1374 -s "session successfully restored from cache" \
1375 -S "session successfully restored from ticket" \
1376 -s "a session has been resumed" \
1377 -c "a session has been resumed"
1378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001379run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001380 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1381 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001382 0 \
1383 -S "session successfully restored from cache" \
1384 -S "session successfully restored from ticket" \
1385 -S "a session has been resumed" \
1386 -C "a session has been resumed"
1387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001388run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001389 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1390 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001391 0 \
1392 -s "session successfully restored from cache" \
1393 -S "session successfully restored from ticket" \
1394 -s "a session has been resumed" \
1395 -c "a session has been resumed"
1396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001397run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001398 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001399 "( $O_CLI -sess_out $SESSION; \
1400 $O_CLI -sess_in $SESSION; \
1401 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001402 0 \
1403 -s "found session ticket extension" \
1404 -S "server hello, adding session ticket extension" \
1405 -s "session successfully restored from cache" \
1406 -S "session successfully restored from ticket" \
1407 -s "a session has been resumed"
1408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001410 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001411 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001412 0 \
1413 -C "found session_ticket extension" \
1414 -C "parse new session ticket" \
1415 -c "a session has been resumed"
1416
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001417# Tests for Max Fragment Length extension
1418
Hanno Becker6428f8d2017-09-22 16:58:50 +01001419MAX_CONTENT_LEN_EXPECT='16384'
1420MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1421
1422if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1423 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1424 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1425 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1426 printf "\n"
1427 printf "The tests assume this value and if it changes, the tests in this\n"
1428 printf "script should also be adjusted.\n"
1429 printf "\n"
1430
1431 exit 1
1432fi
1433
Hanno Becker4aed27e2017-09-18 15:00:34 +01001434requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001435run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001436 "$P_SRV debug_level=3" \
1437 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001438 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001439 -c "Maximum fragment length is 16384" \
1440 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001441 -C "client hello, adding max_fragment_length extension" \
1442 -S "found max fragment length extension" \
1443 -S "server hello, max_fragment_length extension" \
1444 -C "found max_fragment_length extension"
1445
Hanno Becker4aed27e2017-09-18 15:00:34 +01001446requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001447run_test "Max fragment length: enabled, default, larger message" \
1448 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001449 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001450 0 \
1451 -c "Maximum fragment length is 16384" \
1452 -s "Maximum fragment length is 16384" \
1453 -C "client hello, adding max_fragment_length extension" \
1454 -S "found max fragment length extension" \
1455 -S "server hello, max_fragment_length extension" \
1456 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001457 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001458 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001459 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001460
1461requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1462run_test "Max fragment length, DTLS: enabled, default, larger message" \
1463 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001464 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001465 1 \
1466 -c "Maximum fragment length is 16384" \
1467 -s "Maximum fragment length is 16384" \
1468 -C "client hello, adding max_fragment_length extension" \
1469 -S "found max fragment length extension" \
1470 -S "server hello, max_fragment_length extension" \
1471 -C "found max_fragment_length extension" \
1472 -c "fragment larger than.*maximum "
1473
1474requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1475run_test "Max fragment length: disabled, larger message" \
1476 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001477 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001478 0 \
1479 -C "Maximum fragment length is 16384" \
1480 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001481 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001482 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001483 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001484
1485requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1486run_test "Max fragment length DTLS: disabled, larger message" \
1487 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001488 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001489 1 \
1490 -C "Maximum fragment length is 16384" \
1491 -S "Maximum fragment length is 16384" \
1492 -c "fragment larger than.*maximum "
1493
1494requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001495run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001496 "$P_SRV debug_level=3" \
1497 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001498 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001499 -c "Maximum fragment length is 4096" \
1500 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001501 -c "client hello, adding max_fragment_length extension" \
1502 -s "found max fragment length extension" \
1503 -s "server hello, max_fragment_length extension" \
1504 -c "found max_fragment_length extension"
1505
Hanno Becker4aed27e2017-09-18 15:00:34 +01001506requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001508 "$P_SRV debug_level=3 max_frag_len=4096" \
1509 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001510 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001511 -c "Maximum fragment length is 16384" \
1512 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001513 -C "client hello, adding max_fragment_length extension" \
1514 -S "found max fragment length extension" \
1515 -S "server hello, max_fragment_length extension" \
1516 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001517
Hanno Becker4aed27e2017-09-18 15:00:34 +01001518requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001519requires_gnutls
1520run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001521 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001522 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001523 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001524 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001525 -c "client hello, adding max_fragment_length extension" \
1526 -c "found max_fragment_length extension"
1527
Hanno Becker4aed27e2017-09-18 15:00:34 +01001528requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001529run_test "Max fragment length: client, message just fits" \
1530 "$P_SRV debug_level=3" \
1531 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1532 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001533 -c "Maximum fragment length is 2048" \
1534 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001535 -c "client hello, adding max_fragment_length extension" \
1536 -s "found max fragment length extension" \
1537 -s "server hello, max_fragment_length extension" \
1538 -c "found max_fragment_length extension" \
1539 -c "2048 bytes written in 1 fragments" \
1540 -s "2048 bytes read"
1541
Hanno Becker4aed27e2017-09-18 15:00:34 +01001542requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001543run_test "Max fragment length: client, larger message" \
1544 "$P_SRV debug_level=3" \
1545 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1546 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001547 -c "Maximum fragment length is 2048" \
1548 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001549 -c "client hello, adding max_fragment_length extension" \
1550 -s "found max fragment length extension" \
1551 -s "server hello, max_fragment_length extension" \
1552 -c "found max_fragment_length extension" \
1553 -c "2345 bytes written in 2 fragments" \
1554 -s "2048 bytes read" \
1555 -s "297 bytes read"
1556
Hanno Becker4aed27e2017-09-18 15:00:34 +01001557requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001558run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001559 "$P_SRV debug_level=3 dtls=1" \
1560 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1561 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001562 -c "Maximum fragment length is 2048" \
1563 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001564 -c "client hello, adding max_fragment_length extension" \
1565 -s "found max fragment length extension" \
1566 -s "server hello, max_fragment_length extension" \
1567 -c "found max_fragment_length extension" \
1568 -c "fragment larger than.*maximum"
1569
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001570# Tests for renegotiation
1571
Hanno Becker6a243642017-10-12 15:18:45 +01001572# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001573run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001574 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001575 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001576 0 \
1577 -C "client hello, adding renegotiation extension" \
1578 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1579 -S "found renegotiation extension" \
1580 -s "server hello, secure renegotiation extension" \
1581 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001582 -C "=> renegotiate" \
1583 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001584 -S "write hello request"
1585
Hanno Becker6a243642017-10-12 15:18:45 +01001586requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001587run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001588 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001589 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001590 0 \
1591 -c "client hello, adding renegotiation extension" \
1592 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1593 -s "found renegotiation extension" \
1594 -s "server hello, secure renegotiation extension" \
1595 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001596 -c "=> renegotiate" \
1597 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001598 -S "write hello request"
1599
Hanno Becker6a243642017-10-12 15:18:45 +01001600requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001601run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001602 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001603 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001604 0 \
1605 -c "client hello, adding renegotiation extension" \
1606 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1607 -s "found renegotiation extension" \
1608 -s "server hello, secure renegotiation extension" \
1609 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001610 -c "=> renegotiate" \
1611 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001612 -s "write hello request"
1613
Janos Follathb0f148c2017-10-05 12:29:42 +01001614# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1615# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1616# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001617requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001618run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1619 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1620 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1621 0 \
1622 -c "client hello, adding renegotiation extension" \
1623 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1624 -s "found renegotiation extension" \
1625 -s "server hello, secure renegotiation extension" \
1626 -c "found renegotiation extension" \
1627 -c "=> renegotiate" \
1628 -s "=> renegotiate" \
1629 -S "write hello request" \
1630 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1631
1632# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1633# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1634# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001635requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001636run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1637 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1638 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1639 0 \
1640 -c "client hello, adding renegotiation extension" \
1641 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1642 -s "found renegotiation extension" \
1643 -s "server hello, secure renegotiation extension" \
1644 -c "found renegotiation extension" \
1645 -c "=> renegotiate" \
1646 -s "=> renegotiate" \
1647 -s "write hello request" \
1648 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1649
Hanno Becker6a243642017-10-12 15:18:45 +01001650requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001651run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001652 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001653 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001654 0 \
1655 -c "client hello, adding renegotiation extension" \
1656 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1657 -s "found renegotiation extension" \
1658 -s "server hello, secure renegotiation extension" \
1659 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001660 -c "=> renegotiate" \
1661 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001662 -s "write hello request"
1663
Hanno Becker6a243642017-10-12 15:18:45 +01001664requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001665run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001666 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001667 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001668 1 \
1669 -c "client hello, adding renegotiation extension" \
1670 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1671 -S "found renegotiation extension" \
1672 -s "server hello, secure renegotiation extension" \
1673 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001674 -c "=> renegotiate" \
1675 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001676 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001677 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001678 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001679
Hanno Becker6a243642017-10-12 15:18:45 +01001680requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001681run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001682 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001683 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001684 0 \
1685 -C "client hello, adding renegotiation extension" \
1686 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1687 -S "found renegotiation extension" \
1688 -s "server hello, secure renegotiation extension" \
1689 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001690 -C "=> renegotiate" \
1691 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001692 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001693 -S "SSL - An unexpected message was received from our peer" \
1694 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001695
Hanno Becker6a243642017-10-12 15:18:45 +01001696requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001697run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001698 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001699 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001700 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001701 0 \
1702 -C "client hello, adding renegotiation extension" \
1703 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1704 -S "found renegotiation extension" \
1705 -s "server hello, secure renegotiation extension" \
1706 -c "found renegotiation extension" \
1707 -C "=> renegotiate" \
1708 -S "=> renegotiate" \
1709 -s "write hello request" \
1710 -S "SSL - An unexpected message was received from our peer" \
1711 -S "failed"
1712
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001713# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001714requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001715run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001716 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001717 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001718 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001719 0 \
1720 -C "client hello, adding renegotiation extension" \
1721 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1722 -S "found renegotiation extension" \
1723 -s "server hello, secure renegotiation extension" \
1724 -c "found renegotiation extension" \
1725 -C "=> renegotiate" \
1726 -S "=> renegotiate" \
1727 -s "write hello request" \
1728 -S "SSL - An unexpected message was received from our peer" \
1729 -S "failed"
1730
Hanno Becker6a243642017-10-12 15:18:45 +01001731requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001732run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001733 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001734 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001735 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001736 0 \
1737 -C "client hello, adding renegotiation extension" \
1738 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1739 -S "found renegotiation extension" \
1740 -s "server hello, secure renegotiation extension" \
1741 -c "found renegotiation extension" \
1742 -C "=> renegotiate" \
1743 -S "=> renegotiate" \
1744 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001745 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001746
Hanno Becker6a243642017-10-12 15:18:45 +01001747requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001748run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001749 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001750 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001751 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001752 0 \
1753 -c "client hello, adding renegotiation extension" \
1754 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1755 -s "found renegotiation extension" \
1756 -s "server hello, secure renegotiation extension" \
1757 -c "found renegotiation extension" \
1758 -c "=> renegotiate" \
1759 -s "=> renegotiate" \
1760 -s "write hello request" \
1761 -S "SSL - An unexpected message was received from our peer" \
1762 -S "failed"
1763
Hanno Becker6a243642017-10-12 15:18:45 +01001764requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001765run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001766 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001767 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1768 0 \
1769 -C "client hello, adding renegotiation extension" \
1770 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1771 -S "found renegotiation extension" \
1772 -s "server hello, secure renegotiation extension" \
1773 -c "found renegotiation extension" \
1774 -S "record counter limit reached: renegotiate" \
1775 -C "=> renegotiate" \
1776 -S "=> renegotiate" \
1777 -S "write hello request" \
1778 -S "SSL - An unexpected message was received from our peer" \
1779 -S "failed"
1780
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001781# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001782requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001783run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001784 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001785 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001786 0 \
1787 -c "client hello, adding renegotiation extension" \
1788 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1789 -s "found renegotiation extension" \
1790 -s "server hello, secure renegotiation extension" \
1791 -c "found renegotiation extension" \
1792 -s "record counter limit reached: renegotiate" \
1793 -c "=> renegotiate" \
1794 -s "=> renegotiate" \
1795 -s "write hello request" \
1796 -S "SSL - An unexpected message was received from our peer" \
1797 -S "failed"
1798
Hanno Becker6a243642017-10-12 15:18:45 +01001799requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001800run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001801 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001802 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001803 0 \
1804 -c "client hello, adding renegotiation extension" \
1805 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1806 -s "found renegotiation extension" \
1807 -s "server hello, secure renegotiation extension" \
1808 -c "found renegotiation extension" \
1809 -s "record counter limit reached: renegotiate" \
1810 -c "=> renegotiate" \
1811 -s "=> renegotiate" \
1812 -s "write hello request" \
1813 -S "SSL - An unexpected message was received from our peer" \
1814 -S "failed"
1815
Hanno Becker6a243642017-10-12 15:18:45 +01001816requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001817run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001818 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001819 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1820 0 \
1821 -C "client hello, adding renegotiation extension" \
1822 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1823 -S "found renegotiation extension" \
1824 -s "server hello, secure renegotiation extension" \
1825 -c "found renegotiation extension" \
1826 -S "record counter limit reached: renegotiate" \
1827 -C "=> renegotiate" \
1828 -S "=> renegotiate" \
1829 -S "write hello request" \
1830 -S "SSL - An unexpected message was received from our peer" \
1831 -S "failed"
1832
Hanno Becker6a243642017-10-12 15:18:45 +01001833requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001834run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001835 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001836 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001837 0 \
1838 -c "client hello, adding renegotiation extension" \
1839 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1840 -s "found renegotiation extension" \
1841 -s "server hello, secure renegotiation extension" \
1842 -c "found renegotiation extension" \
1843 -c "=> renegotiate" \
1844 -s "=> renegotiate" \
1845 -S "write hello request"
1846
Hanno Becker6a243642017-10-12 15:18:45 +01001847requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001848run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001849 "$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 +02001850 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001851 0 \
1852 -c "client hello, adding renegotiation extension" \
1853 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1854 -s "found renegotiation extension" \
1855 -s "server hello, secure renegotiation extension" \
1856 -c "found renegotiation extension" \
1857 -c "=> renegotiate" \
1858 -s "=> renegotiate" \
1859 -s "write hello request"
1860
Hanno Becker6a243642017-10-12 15:18:45 +01001861requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001862run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001863 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001864 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001865 0 \
1866 -c "client hello, adding renegotiation extension" \
1867 -c "found renegotiation extension" \
1868 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001869 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001870 -C "error" \
1871 -c "HTTP/1.0 200 [Oo][Kk]"
1872
Paul Bakker539d9722015-02-08 16:18:35 +01001873requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001874requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001875run_test "Renegotiation: gnutls server strict, client-initiated" \
1876 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001877 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001878 0 \
1879 -c "client hello, adding renegotiation extension" \
1880 -c "found renegotiation extension" \
1881 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001882 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001883 -C "error" \
1884 -c "HTTP/1.0 200 [Oo][Kk]"
1885
Paul Bakker539d9722015-02-08 16:18:35 +01001886requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001887requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001888run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1889 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1890 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1891 1 \
1892 -c "client hello, adding renegotiation extension" \
1893 -C "found renegotiation extension" \
1894 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001895 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001896 -c "error" \
1897 -C "HTTP/1.0 200 [Oo][Kk]"
1898
Paul Bakker539d9722015-02-08 16:18:35 +01001899requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001900requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001901run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1902 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1903 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1904 allow_legacy=0" \
1905 1 \
1906 -c "client hello, adding renegotiation extension" \
1907 -C "found renegotiation extension" \
1908 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001909 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001910 -c "error" \
1911 -C "HTTP/1.0 200 [Oo][Kk]"
1912
Paul Bakker539d9722015-02-08 16:18:35 +01001913requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001914requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001915run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1916 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1917 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1918 allow_legacy=1" \
1919 0 \
1920 -c "client hello, adding renegotiation extension" \
1921 -C "found renegotiation extension" \
1922 -c "=> renegotiate" \
1923 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001924 -C "error" \
1925 -c "HTTP/1.0 200 [Oo][Kk]"
1926
Hanno Becker6a243642017-10-12 15:18:45 +01001927requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001928run_test "Renegotiation: DTLS, client-initiated" \
1929 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1930 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1931 0 \
1932 -c "client hello, adding renegotiation extension" \
1933 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1934 -s "found renegotiation extension" \
1935 -s "server hello, secure renegotiation extension" \
1936 -c "found renegotiation extension" \
1937 -c "=> renegotiate" \
1938 -s "=> renegotiate" \
1939 -S "write hello request"
1940
Hanno Becker6a243642017-10-12 15:18:45 +01001941requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001942run_test "Renegotiation: DTLS, server-initiated" \
1943 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001944 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1945 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001946 0 \
1947 -c "client hello, adding renegotiation extension" \
1948 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1949 -s "found renegotiation extension" \
1950 -s "server hello, secure renegotiation extension" \
1951 -c "found renegotiation extension" \
1952 -c "=> renegotiate" \
1953 -s "=> renegotiate" \
1954 -s "write hello request"
1955
Hanno Becker6a243642017-10-12 15:18:45 +01001956requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00001957run_test "Renegotiation: DTLS, renego_period overflow" \
1958 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1959 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1960 0 \
1961 -c "client hello, adding renegotiation extension" \
1962 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1963 -s "found renegotiation extension" \
1964 -s "server hello, secure renegotiation extension" \
1965 -s "record counter limit reached: renegotiate" \
1966 -c "=> renegotiate" \
1967 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01001968 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00001969
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001970requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001971requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001972run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1973 "$G_SRV -u --mtu 4096" \
1974 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1975 0 \
1976 -c "client hello, adding renegotiation extension" \
1977 -c "found renegotiation extension" \
1978 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001979 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001980 -C "error" \
1981 -s "Extra-header:"
1982
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001983# Test for the "secure renegotation" extension only (no actual renegotiation)
1984
Paul Bakker539d9722015-02-08 16:18:35 +01001985requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001986run_test "Renego ext: gnutls server strict, client default" \
1987 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1988 "$P_CLI debug_level=3" \
1989 0 \
1990 -c "found renegotiation extension" \
1991 -C "error" \
1992 -c "HTTP/1.0 200 [Oo][Kk]"
1993
Paul Bakker539d9722015-02-08 16:18:35 +01001994requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001995run_test "Renego ext: gnutls server unsafe, client default" \
1996 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1997 "$P_CLI debug_level=3" \
1998 0 \
1999 -C "found renegotiation extension" \
2000 -C "error" \
2001 -c "HTTP/1.0 200 [Oo][Kk]"
2002
Paul Bakker539d9722015-02-08 16:18:35 +01002003requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002004run_test "Renego ext: gnutls server unsafe, client break legacy" \
2005 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2006 "$P_CLI debug_level=3 allow_legacy=-1" \
2007 1 \
2008 -C "found renegotiation extension" \
2009 -c "error" \
2010 -C "HTTP/1.0 200 [Oo][Kk]"
2011
Paul Bakker539d9722015-02-08 16:18:35 +01002012requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002013run_test "Renego ext: gnutls client strict, server default" \
2014 "$P_SRV debug_level=3" \
2015 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2016 0 \
2017 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2018 -s "server hello, secure renegotiation extension"
2019
Paul Bakker539d9722015-02-08 16:18:35 +01002020requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002021run_test "Renego ext: gnutls client unsafe, server default" \
2022 "$P_SRV debug_level=3" \
2023 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2024 0 \
2025 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2026 -S "server hello, secure renegotiation extension"
2027
Paul Bakker539d9722015-02-08 16:18:35 +01002028requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002029run_test "Renego ext: gnutls client unsafe, server break legacy" \
2030 "$P_SRV debug_level=3 allow_legacy=-1" \
2031 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2032 1 \
2033 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2034 -S "server hello, secure renegotiation extension"
2035
Janos Follath0b242342016-02-17 10:11:21 +00002036# Tests for silently dropping trailing extra bytes in .der certificates
2037
2038requires_gnutls
2039run_test "DER format: no trailing bytes" \
2040 "$P_SRV crt_file=data_files/server5-der0.crt \
2041 key_file=data_files/server5.key" \
2042 "$G_CLI " \
2043 0 \
2044 -c "Handshake was completed" \
2045
2046requires_gnutls
2047run_test "DER format: with a trailing zero byte" \
2048 "$P_SRV crt_file=data_files/server5-der1a.crt \
2049 key_file=data_files/server5.key" \
2050 "$G_CLI " \
2051 0 \
2052 -c "Handshake was completed" \
2053
2054requires_gnutls
2055run_test "DER format: with a trailing random byte" \
2056 "$P_SRV crt_file=data_files/server5-der1b.crt \
2057 key_file=data_files/server5.key" \
2058 "$G_CLI " \
2059 0 \
2060 -c "Handshake was completed" \
2061
2062requires_gnutls
2063run_test "DER format: with 2 trailing random bytes" \
2064 "$P_SRV crt_file=data_files/server5-der2.crt \
2065 key_file=data_files/server5.key" \
2066 "$G_CLI " \
2067 0 \
2068 -c "Handshake was completed" \
2069
2070requires_gnutls
2071run_test "DER format: with 4 trailing random bytes" \
2072 "$P_SRV crt_file=data_files/server5-der4.crt \
2073 key_file=data_files/server5.key" \
2074 "$G_CLI " \
2075 0 \
2076 -c "Handshake was completed" \
2077
2078requires_gnutls
2079run_test "DER format: with 8 trailing random bytes" \
2080 "$P_SRV crt_file=data_files/server5-der8.crt \
2081 key_file=data_files/server5.key" \
2082 "$G_CLI " \
2083 0 \
2084 -c "Handshake was completed" \
2085
2086requires_gnutls
2087run_test "DER format: with 9 trailing random bytes" \
2088 "$P_SRV crt_file=data_files/server5-der9.crt \
2089 key_file=data_files/server5.key" \
2090 "$G_CLI " \
2091 0 \
2092 -c "Handshake was completed" \
2093
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002094# Tests for auth_mode
2095
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002096run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002097 "$P_SRV crt_file=data_files/server5-badsign.crt \
2098 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002099 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002100 1 \
2101 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002102 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002103 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002104 -c "X509 - Certificate verification failed"
2105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002106run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002107 "$P_SRV crt_file=data_files/server5-badsign.crt \
2108 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002109 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002110 0 \
2111 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002112 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002113 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002114 -C "X509 - Certificate verification failed"
2115
Hanno Beckere6706e62017-05-15 16:05:15 +01002116run_test "Authentication: server goodcert, client optional, no trusted CA" \
2117 "$P_SRV" \
2118 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2119 0 \
2120 -c "x509_verify_cert() returned" \
2121 -c "! The certificate is not correctly signed by the trusted CA" \
2122 -c "! Certificate verification flags"\
2123 -C "! mbedtls_ssl_handshake returned" \
2124 -C "X509 - Certificate verification failed" \
2125 -C "SSL - No CA Chain is set, but required to operate"
2126
2127run_test "Authentication: server goodcert, client required, no trusted CA" \
2128 "$P_SRV" \
2129 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2130 1 \
2131 -c "x509_verify_cert() returned" \
2132 -c "! The certificate is not correctly signed by the trusted CA" \
2133 -c "! Certificate verification flags"\
2134 -c "! mbedtls_ssl_handshake returned" \
2135 -c "SSL - No CA Chain is set, but required to operate"
2136
2137# The purpose of the next two tests is to test the client's behaviour when receiving a server
2138# certificate with an unsupported elliptic curve. This should usually not happen because
2139# the client informs the server about the supported curves - it does, though, in the
2140# corner case of a static ECDH suite, because the server doesn't check the curve on that
2141# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2142# different means to have the server ignoring the client's supported curve list.
2143
2144requires_config_enabled MBEDTLS_ECP_C
2145run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2146 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2147 crt_file=data_files/server5.ku-ka.crt" \
2148 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2149 1 \
2150 -c "bad certificate (EC key curve)"\
2151 -c "! Certificate verification flags"\
2152 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2153
2154requires_config_enabled MBEDTLS_ECP_C
2155run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2156 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2157 crt_file=data_files/server5.ku-ka.crt" \
2158 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2159 1 \
2160 -c "bad certificate (EC key curve)"\
2161 -c "! Certificate verification flags"\
2162 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002164run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002165 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002166 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002167 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002168 0 \
2169 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002170 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002171 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002172 -C "X509 - Certificate verification failed"
2173
Simon Butcher99000142016-10-13 17:21:01 +01002174run_test "Authentication: client SHA256, server required" \
2175 "$P_SRV auth_mode=required" \
2176 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2177 key_file=data_files/server6.key \
2178 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2179 0 \
2180 -c "Supported Signature Algorithm found: 4," \
2181 -c "Supported Signature Algorithm found: 5,"
2182
2183run_test "Authentication: client SHA384, server required" \
2184 "$P_SRV auth_mode=required" \
2185 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2186 key_file=data_files/server6.key \
2187 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2188 0 \
2189 -c "Supported Signature Algorithm found: 4," \
2190 -c "Supported Signature Algorithm found: 5,"
2191
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002192requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2193run_test "Authentication: client has no cert, server required (SSLv3)" \
2194 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2195 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2196 key_file=data_files/server5.key" \
2197 1 \
2198 -S "skip write certificate request" \
2199 -C "skip parse certificate request" \
2200 -c "got a certificate request" \
2201 -c "got no certificate to send" \
2202 -S "x509_verify_cert() returned" \
2203 -s "client has no certificate" \
2204 -s "! mbedtls_ssl_handshake returned" \
2205 -c "! mbedtls_ssl_handshake returned" \
2206 -s "No client certification received from the client, but required by the authentication mode"
2207
2208run_test "Authentication: client has no cert, server required (TLS)" \
2209 "$P_SRV debug_level=3 auth_mode=required" \
2210 "$P_CLI debug_level=3 crt_file=none \
2211 key_file=data_files/server5.key" \
2212 1 \
2213 -S "skip write certificate request" \
2214 -C "skip parse certificate request" \
2215 -c "got a certificate request" \
2216 -c "= write certificate$" \
2217 -C "skip write certificate$" \
2218 -S "x509_verify_cert() returned" \
2219 -s "client has no certificate" \
2220 -s "! mbedtls_ssl_handshake returned" \
2221 -c "! mbedtls_ssl_handshake returned" \
2222 -s "No client certification received from the client, but required by the authentication mode"
2223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002224run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002225 "$P_SRV debug_level=3 auth_mode=required" \
2226 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002227 key_file=data_files/server5.key" \
2228 1 \
2229 -S "skip write certificate request" \
2230 -C "skip parse certificate request" \
2231 -c "got a certificate request" \
2232 -C "skip write certificate" \
2233 -C "skip write certificate verify" \
2234 -S "skip parse certificate verify" \
2235 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002236 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002237 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002238 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002239 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002240 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002241# We don't check that the client receives the alert because it might
2242# detect that its write end of the connection is closed and abort
2243# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002244
Janos Follath89baba22017-04-10 14:34:35 +01002245run_test "Authentication: client cert not trusted, server required" \
2246 "$P_SRV debug_level=3 auth_mode=required" \
2247 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2248 key_file=data_files/server5.key" \
2249 1 \
2250 -S "skip write certificate request" \
2251 -C "skip parse certificate request" \
2252 -c "got a certificate request" \
2253 -C "skip write certificate" \
2254 -C "skip write certificate verify" \
2255 -S "skip parse certificate verify" \
2256 -s "x509_verify_cert() returned" \
2257 -s "! The certificate is not correctly signed by the trusted CA" \
2258 -s "! mbedtls_ssl_handshake returned" \
2259 -c "! mbedtls_ssl_handshake returned" \
2260 -s "X509 - Certificate verification failed"
2261
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002262run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002263 "$P_SRV debug_level=3 auth_mode=optional" \
2264 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002265 key_file=data_files/server5.key" \
2266 0 \
2267 -S "skip write certificate request" \
2268 -C "skip parse certificate request" \
2269 -c "got a certificate request" \
2270 -C "skip write certificate" \
2271 -C "skip write certificate verify" \
2272 -S "skip parse certificate verify" \
2273 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002274 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002275 -S "! mbedtls_ssl_handshake returned" \
2276 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002277 -S "X509 - Certificate verification failed"
2278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002279run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002280 "$P_SRV debug_level=3 auth_mode=none" \
2281 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002282 key_file=data_files/server5.key" \
2283 0 \
2284 -s "skip write certificate request" \
2285 -C "skip parse certificate request" \
2286 -c "got no certificate request" \
2287 -c "skip write certificate" \
2288 -c "skip write certificate verify" \
2289 -s "skip parse certificate verify" \
2290 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002291 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002292 -S "! mbedtls_ssl_handshake returned" \
2293 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002294 -S "X509 - Certificate verification failed"
2295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002296run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002297 "$P_SRV debug_level=3 auth_mode=optional" \
2298 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002299 0 \
2300 -S "skip write certificate request" \
2301 -C "skip parse certificate request" \
2302 -c "got a certificate request" \
2303 -C "skip write certificate$" \
2304 -C "got no certificate to send" \
2305 -S "SSLv3 client has no certificate" \
2306 -c "skip write certificate verify" \
2307 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002308 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002309 -S "! mbedtls_ssl_handshake returned" \
2310 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002311 -S "X509 - Certificate verification failed"
2312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002313run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002314 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002315 "$O_CLI" \
2316 0 \
2317 -S "skip write certificate request" \
2318 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002319 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002320 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002321 -S "X509 - Certificate verification failed"
2322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002323run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002324 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002325 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002326 0 \
2327 -C "skip parse certificate request" \
2328 -c "got a certificate request" \
2329 -C "skip write certificate$" \
2330 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002331 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002332
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002333run_test "Authentication: client no cert, openssl server required" \
2334 "$O_SRV -Verify 10" \
2335 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2336 1 \
2337 -C "skip parse certificate request" \
2338 -c "got a certificate request" \
2339 -C "skip write certificate$" \
2340 -c "skip write certificate verify" \
2341 -c "! mbedtls_ssl_handshake returned"
2342
Janos Follathe2681a42016-03-07 15:57:05 +00002343requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002344run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002345 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002346 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002347 0 \
2348 -S "skip write certificate request" \
2349 -C "skip parse certificate request" \
2350 -c "got a certificate request" \
2351 -C "skip write certificate$" \
2352 -c "skip write certificate verify" \
2353 -c "got no certificate to send" \
2354 -s "SSLv3 client has no certificate" \
2355 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002356 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002357 -S "! mbedtls_ssl_handshake returned" \
2358 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002359 -S "X509 - Certificate verification failed"
2360
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002361# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2362# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002363
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002364MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002365MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002366
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002367if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002368 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002369 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002370 printf "test value of ${MAX_IM_CA}. \n"
2371 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002372 printf "The tests assume this value and if it changes, the tests in this\n"
2373 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002374 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002375
2376 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002377fi
2378
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002379run_test "Authentication: server max_int chain, client default" \
2380 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2381 key_file=data_files/dir-maxpath/09.key" \
2382 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2383 0 \
2384 -C "X509 - A fatal error occured"
2385
2386run_test "Authentication: server max_int+1 chain, client default" \
2387 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2388 key_file=data_files/dir-maxpath/10.key" \
2389 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2390 1 \
2391 -c "X509 - A fatal error occured"
2392
2393run_test "Authentication: server max_int+1 chain, client optional" \
2394 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2395 key_file=data_files/dir-maxpath/10.key" \
2396 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2397 auth_mode=optional" \
2398 1 \
2399 -c "X509 - A fatal error occured"
2400
2401run_test "Authentication: server max_int+1 chain, client none" \
2402 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2403 key_file=data_files/dir-maxpath/10.key" \
2404 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2405 auth_mode=none" \
2406 0 \
2407 -C "X509 - A fatal error occured"
2408
2409run_test "Authentication: client max_int+1 chain, server default" \
2410 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2411 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2412 key_file=data_files/dir-maxpath/10.key" \
2413 0 \
2414 -S "X509 - A fatal error occured"
2415
2416run_test "Authentication: client max_int+1 chain, server optional" \
2417 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2418 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2419 key_file=data_files/dir-maxpath/10.key" \
2420 1 \
2421 -s "X509 - A fatal error occured"
2422
2423run_test "Authentication: client max_int+1 chain, server required" \
2424 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2425 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2426 key_file=data_files/dir-maxpath/10.key" \
2427 1 \
2428 -s "X509 - A fatal error occured"
2429
2430run_test "Authentication: client max_int chain, server required" \
2431 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2432 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2433 key_file=data_files/dir-maxpath/09.key" \
2434 0 \
2435 -S "X509 - A fatal error occured"
2436
Janos Follath89baba22017-04-10 14:34:35 +01002437# Tests for CA list in CertificateRequest messages
2438
2439run_test "Authentication: send CA list in CertificateRequest (default)" \
2440 "$P_SRV debug_level=3 auth_mode=required" \
2441 "$P_CLI crt_file=data_files/server6.crt \
2442 key_file=data_files/server6.key" \
2443 0 \
2444 -s "requested DN"
2445
2446run_test "Authentication: do not send CA list in CertificateRequest" \
2447 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2448 "$P_CLI crt_file=data_files/server6.crt \
2449 key_file=data_files/server6.key" \
2450 0 \
2451 -S "requested DN"
2452
2453run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2454 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2455 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2456 key_file=data_files/server5.key" \
2457 1 \
2458 -S "requested DN" \
2459 -s "x509_verify_cert() returned" \
2460 -s "! The certificate is not correctly signed by the trusted CA" \
2461 -s "! mbedtls_ssl_handshake returned" \
2462 -c "! mbedtls_ssl_handshake returned" \
2463 -s "X509 - Certificate verification failed"
2464
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002465# Tests for certificate selection based on SHA verson
2466
2467run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2468 "$P_SRV crt_file=data_files/server5.crt \
2469 key_file=data_files/server5.key \
2470 crt_file2=data_files/server5-sha1.crt \
2471 key_file2=data_files/server5.key" \
2472 "$P_CLI force_version=tls1_2" \
2473 0 \
2474 -c "signed using.*ECDSA with SHA256" \
2475 -C "signed using.*ECDSA with SHA1"
2476
2477run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2478 "$P_SRV crt_file=data_files/server5.crt \
2479 key_file=data_files/server5.key \
2480 crt_file2=data_files/server5-sha1.crt \
2481 key_file2=data_files/server5.key" \
2482 "$P_CLI force_version=tls1_1" \
2483 0 \
2484 -C "signed using.*ECDSA with SHA256" \
2485 -c "signed using.*ECDSA with SHA1"
2486
2487run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2488 "$P_SRV crt_file=data_files/server5.crt \
2489 key_file=data_files/server5.key \
2490 crt_file2=data_files/server5-sha1.crt \
2491 key_file2=data_files/server5.key" \
2492 "$P_CLI force_version=tls1" \
2493 0 \
2494 -C "signed using.*ECDSA with SHA256" \
2495 -c "signed using.*ECDSA with SHA1"
2496
2497run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2498 "$P_SRV crt_file=data_files/server5.crt \
2499 key_file=data_files/server5.key \
2500 crt_file2=data_files/server6.crt \
2501 key_file2=data_files/server6.key" \
2502 "$P_CLI force_version=tls1_1" \
2503 0 \
2504 -c "serial number.*09" \
2505 -c "signed using.*ECDSA with SHA256" \
2506 -C "signed using.*ECDSA with SHA1"
2507
2508run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2509 "$P_SRV crt_file=data_files/server6.crt \
2510 key_file=data_files/server6.key \
2511 crt_file2=data_files/server5.crt \
2512 key_file2=data_files/server5.key" \
2513 "$P_CLI force_version=tls1_1" \
2514 0 \
2515 -c "serial number.*0A" \
2516 -c "signed using.*ECDSA with SHA256" \
2517 -C "signed using.*ECDSA with SHA1"
2518
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002519# tests for SNI
2520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002521run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002522 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002523 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002524 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002525 0 \
2526 -S "parse ServerName extension" \
2527 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2528 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002530run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002531 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002532 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002533 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 +02002534 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002535 0 \
2536 -s "parse ServerName extension" \
2537 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2538 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002540run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002541 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002542 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002543 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 +02002544 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002545 0 \
2546 -s "parse ServerName extension" \
2547 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2548 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002550run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002551 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002552 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002553 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 +02002554 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002555 1 \
2556 -s "parse ServerName extension" \
2557 -s "ssl_sni_wrapper() returned" \
2558 -s "mbedtls_ssl_handshake returned" \
2559 -c "mbedtls_ssl_handshake returned" \
2560 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002561
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002562run_test "SNI: client auth no override: optional" \
2563 "$P_SRV debug_level=3 auth_mode=optional \
2564 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2565 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2566 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002567 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002568 -S "skip write certificate request" \
2569 -C "skip parse certificate request" \
2570 -c "got a certificate request" \
2571 -C "skip write certificate" \
2572 -C "skip write certificate verify" \
2573 -S "skip parse certificate verify"
2574
2575run_test "SNI: client auth override: none -> optional" \
2576 "$P_SRV debug_level=3 auth_mode=none \
2577 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2578 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2579 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002580 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002581 -S "skip write certificate request" \
2582 -C "skip parse certificate request" \
2583 -c "got a certificate request" \
2584 -C "skip write certificate" \
2585 -C "skip write certificate verify" \
2586 -S "skip parse certificate verify"
2587
2588run_test "SNI: client auth override: optional -> none" \
2589 "$P_SRV debug_level=3 auth_mode=optional \
2590 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2591 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2592 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002593 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002594 -s "skip write certificate request" \
2595 -C "skip parse certificate request" \
2596 -c "got no certificate request" \
2597 -c "skip write certificate" \
2598 -c "skip write certificate verify" \
2599 -s "skip parse certificate verify"
2600
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002601run_test "SNI: CA no override" \
2602 "$P_SRV debug_level=3 auth_mode=optional \
2603 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2604 ca_file=data_files/test-ca.crt \
2605 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2606 "$P_CLI debug_level=3 server_name=localhost \
2607 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2608 1 \
2609 -S "skip write certificate request" \
2610 -C "skip parse certificate request" \
2611 -c "got a certificate request" \
2612 -C "skip write certificate" \
2613 -C "skip write certificate verify" \
2614 -S "skip parse certificate verify" \
2615 -s "x509_verify_cert() returned" \
2616 -s "! The certificate is not correctly signed by the trusted CA" \
2617 -S "The certificate has been revoked (is on a CRL)"
2618
2619run_test "SNI: CA override" \
2620 "$P_SRV debug_level=3 auth_mode=optional \
2621 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2622 ca_file=data_files/test-ca.crt \
2623 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2624 "$P_CLI debug_level=3 server_name=localhost \
2625 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2626 0 \
2627 -S "skip write certificate request" \
2628 -C "skip parse certificate request" \
2629 -c "got a certificate request" \
2630 -C "skip write certificate" \
2631 -C "skip write certificate verify" \
2632 -S "skip parse certificate verify" \
2633 -S "x509_verify_cert() returned" \
2634 -S "! The certificate is not correctly signed by the trusted CA" \
2635 -S "The certificate has been revoked (is on a CRL)"
2636
2637run_test "SNI: CA override with CRL" \
2638 "$P_SRV debug_level=3 auth_mode=optional \
2639 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2640 ca_file=data_files/test-ca.crt \
2641 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2642 "$P_CLI debug_level=3 server_name=localhost \
2643 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2644 1 \
2645 -S "skip write certificate request" \
2646 -C "skip parse certificate request" \
2647 -c "got a certificate request" \
2648 -C "skip write certificate" \
2649 -C "skip write certificate verify" \
2650 -S "skip parse certificate verify" \
2651 -s "x509_verify_cert() returned" \
2652 -S "! The certificate is not correctly signed by the trusted CA" \
2653 -s "The certificate has been revoked (is on a CRL)"
2654
Andres AG1a834452016-12-07 10:01:30 +00002655# Tests for SNI and DTLS
2656
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002657run_test "SNI: DTLS, no SNI callback" \
2658 "$P_SRV debug_level=3 dtls=1 \
2659 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2660 "$P_CLI server_name=localhost dtls=1" \
2661 0 \
2662 -S "parse ServerName extension" \
2663 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2664 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2665
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002666run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00002667 "$P_SRV debug_level=3 dtls=1 \
2668 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2669 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2670 "$P_CLI server_name=localhost dtls=1" \
2671 0 \
2672 -s "parse ServerName extension" \
2673 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2674 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2675
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002676run_test "SNI: DTLS, matching cert 2" \
2677 "$P_SRV debug_level=3 dtls=1 \
2678 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2679 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2680 "$P_CLI server_name=polarssl.example dtls=1" \
2681 0 \
2682 -s "parse ServerName extension" \
2683 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2684 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2685
2686run_test "SNI: DTLS, no matching cert" \
2687 "$P_SRV debug_level=3 dtls=1 \
2688 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2689 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2690 "$P_CLI server_name=nonesuch.example dtls=1" \
2691 1 \
2692 -s "parse ServerName extension" \
2693 -s "ssl_sni_wrapper() returned" \
2694 -s "mbedtls_ssl_handshake returned" \
2695 -c "mbedtls_ssl_handshake returned" \
2696 -c "SSL - A fatal alert message was received from our peer"
2697
2698run_test "SNI: DTLS, client auth no override: optional" \
2699 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2700 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2701 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2702 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2703 0 \
2704 -S "skip write certificate request" \
2705 -C "skip parse certificate request" \
2706 -c "got a certificate request" \
2707 -C "skip write certificate" \
2708 -C "skip write certificate verify" \
2709 -S "skip parse certificate verify"
2710
2711run_test "SNI: DTLS, client auth override: none -> optional" \
2712 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2713 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2714 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2715 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2716 0 \
2717 -S "skip write certificate request" \
2718 -C "skip parse certificate request" \
2719 -c "got a certificate request" \
2720 -C "skip write certificate" \
2721 -C "skip write certificate verify" \
2722 -S "skip parse certificate verify"
2723
2724run_test "SNI: DTLS, client auth override: optional -> none" \
2725 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2726 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2727 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2728 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2729 0 \
2730 -s "skip write certificate request" \
2731 -C "skip parse certificate request" \
2732 -c "got no certificate request" \
2733 -c "skip write certificate" \
2734 -c "skip write certificate verify" \
2735 -s "skip parse certificate verify"
2736
2737run_test "SNI: DTLS, CA no override" \
2738 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2739 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2740 ca_file=data_files/test-ca.crt \
2741 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2742 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2743 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2744 1 \
2745 -S "skip write certificate request" \
2746 -C "skip parse certificate request" \
2747 -c "got a certificate request" \
2748 -C "skip write certificate" \
2749 -C "skip write certificate verify" \
2750 -S "skip parse certificate verify" \
2751 -s "x509_verify_cert() returned" \
2752 -s "! The certificate is not correctly signed by the trusted CA" \
2753 -S "The certificate has been revoked (is on a CRL)"
2754
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002755run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00002756 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2757 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2758 ca_file=data_files/test-ca.crt \
2759 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2760 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2761 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2762 0 \
2763 -S "skip write certificate request" \
2764 -C "skip parse certificate request" \
2765 -c "got a certificate request" \
2766 -C "skip write certificate" \
2767 -C "skip write certificate verify" \
2768 -S "skip parse certificate verify" \
2769 -S "x509_verify_cert() returned" \
2770 -S "! The certificate is not correctly signed by the trusted CA" \
2771 -S "The certificate has been revoked (is on a CRL)"
2772
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002773run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00002774 "$P_SRV debug_level=3 auth_mode=optional \
2775 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2776 ca_file=data_files/test-ca.crt \
2777 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2778 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2779 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2780 1 \
2781 -S "skip write certificate request" \
2782 -C "skip parse certificate request" \
2783 -c "got a certificate request" \
2784 -C "skip write certificate" \
2785 -C "skip write certificate verify" \
2786 -S "skip parse certificate verify" \
2787 -s "x509_verify_cert() returned" \
2788 -S "! The certificate is not correctly signed by the trusted CA" \
2789 -s "The certificate has been revoked (is on a CRL)"
2790
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002791# Tests for non-blocking I/O: exercise a variety of handshake flows
2792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002793run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002794 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2795 "$P_CLI nbio=2 tickets=0" \
2796 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002797 -S "mbedtls_ssl_handshake returned" \
2798 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002799 -c "Read from server: .* bytes read"
2800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002801run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002802 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2803 "$P_CLI nbio=2 tickets=0" \
2804 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002805 -S "mbedtls_ssl_handshake returned" \
2806 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002807 -c "Read from server: .* bytes read"
2808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002809run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002810 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2811 "$P_CLI nbio=2 tickets=1" \
2812 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002813 -S "mbedtls_ssl_handshake returned" \
2814 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002815 -c "Read from server: .* bytes read"
2816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002817run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002818 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2819 "$P_CLI nbio=2 tickets=1" \
2820 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002821 -S "mbedtls_ssl_handshake returned" \
2822 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002823 -c "Read from server: .* bytes read"
2824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002825run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002826 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2827 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2828 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002829 -S "mbedtls_ssl_handshake returned" \
2830 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002831 -c "Read from server: .* bytes read"
2832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002833run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002834 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2835 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2836 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002837 -S "mbedtls_ssl_handshake returned" \
2838 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002839 -c "Read from server: .* bytes read"
2840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002841run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002842 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2843 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2844 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002845 -S "mbedtls_ssl_handshake returned" \
2846 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002847 -c "Read from server: .* bytes read"
2848
Hanno Becker00076712017-11-15 16:39:08 +00002849# Tests for event-driven I/O: exercise a variety of handshake flows
2850
2851run_test "Event-driven I/O: basic handshake" \
2852 "$P_SRV event=1 tickets=0 auth_mode=none" \
2853 "$P_CLI event=1 tickets=0" \
2854 0 \
2855 -S "mbedtls_ssl_handshake returned" \
2856 -C "mbedtls_ssl_handshake returned" \
2857 -c "Read from server: .* bytes read"
2858
2859run_test "Event-driven I/O: client auth" \
2860 "$P_SRV event=1 tickets=0 auth_mode=required" \
2861 "$P_CLI event=1 tickets=0" \
2862 0 \
2863 -S "mbedtls_ssl_handshake returned" \
2864 -C "mbedtls_ssl_handshake returned" \
2865 -c "Read from server: .* bytes read"
2866
2867run_test "Event-driven I/O: ticket" \
2868 "$P_SRV event=1 tickets=1 auth_mode=none" \
2869 "$P_CLI event=1 tickets=1" \
2870 0 \
2871 -S "mbedtls_ssl_handshake returned" \
2872 -C "mbedtls_ssl_handshake returned" \
2873 -c "Read from server: .* bytes read"
2874
2875run_test "Event-driven I/O: ticket + client auth" \
2876 "$P_SRV event=1 tickets=1 auth_mode=required" \
2877 "$P_CLI event=1 tickets=1" \
2878 0 \
2879 -S "mbedtls_ssl_handshake returned" \
2880 -C "mbedtls_ssl_handshake returned" \
2881 -c "Read from server: .* bytes read"
2882
2883run_test "Event-driven I/O: ticket + client auth + resume" \
2884 "$P_SRV event=1 tickets=1 auth_mode=required" \
2885 "$P_CLI event=1 tickets=1 reconnect=1" \
2886 0 \
2887 -S "mbedtls_ssl_handshake returned" \
2888 -C "mbedtls_ssl_handshake returned" \
2889 -c "Read from server: .* bytes read"
2890
2891run_test "Event-driven I/O: ticket + resume" \
2892 "$P_SRV event=1 tickets=1 auth_mode=none" \
2893 "$P_CLI event=1 tickets=1 reconnect=1" \
2894 0 \
2895 -S "mbedtls_ssl_handshake returned" \
2896 -C "mbedtls_ssl_handshake returned" \
2897 -c "Read from server: .* bytes read"
2898
2899run_test "Event-driven I/O: session-id resume" \
2900 "$P_SRV event=1 tickets=0 auth_mode=none" \
2901 "$P_CLI event=1 tickets=0 reconnect=1" \
2902 0 \
2903 -S "mbedtls_ssl_handshake returned" \
2904 -C "mbedtls_ssl_handshake returned" \
2905 -c "Read from server: .* bytes read"
2906
Hanno Becker6a33f592018-03-13 11:38:46 +00002907run_test "Event-driven I/O, DTLS: basic handshake" \
2908 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2909 "$P_CLI dtls=1 event=1 tickets=0" \
2910 0 \
2911 -c "Read from server: .* bytes read"
2912
2913run_test "Event-driven I/O, DTLS: client auth" \
2914 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
2915 "$P_CLI dtls=1 event=1 tickets=0" \
2916 0 \
2917 -c "Read from server: .* bytes read"
2918
2919run_test "Event-driven I/O, DTLS: ticket" \
2920 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2921 "$P_CLI dtls=1 event=1 tickets=1" \
2922 0 \
2923 -c "Read from server: .* bytes read"
2924
2925run_test "Event-driven I/O, DTLS: ticket + client auth" \
2926 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2927 "$P_CLI dtls=1 event=1 tickets=1" \
2928 0 \
2929 -c "Read from server: .* bytes read"
2930
2931run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
2932 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2933 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2934 0 \
2935 -c "Read from server: .* bytes read"
2936
2937run_test "Event-driven I/O, DTLS: ticket + resume" \
2938 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2939 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2940 0 \
2941 -c "Read from server: .* bytes read"
2942
2943run_test "Event-driven I/O, DTLS: session-id resume" \
2944 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2945 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
2946 0 \
2947 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00002948
2949# This test demonstrates the need for the mbedtls_ssl_check_pending function.
2950# During session resumption, the client will send its ApplicationData record
2951# within the same datagram as the Finished messages. In this situation, the
2952# server MUST NOT idle on the underlying transport after handshake completion,
2953# because the ApplicationData request has already been queued internally.
2954run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00002955 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00002956 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
2957 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
2958 0 \
2959 -c "Read from server: .* bytes read"
2960
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002961# Tests for version negotiation
2962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002963run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002964 "$P_SRV" \
2965 "$P_CLI" \
2966 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002967 -S "mbedtls_ssl_handshake returned" \
2968 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002969 -s "Protocol is TLSv1.2" \
2970 -c "Protocol is TLSv1.2"
2971
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002972run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002973 "$P_SRV" \
2974 "$P_CLI max_version=tls1_1" \
2975 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002976 -S "mbedtls_ssl_handshake returned" \
2977 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002978 -s "Protocol is TLSv1.1" \
2979 -c "Protocol is TLSv1.1"
2980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002981run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002982 "$P_SRV max_version=tls1_1" \
2983 "$P_CLI" \
2984 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002985 -S "mbedtls_ssl_handshake returned" \
2986 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002987 -s "Protocol is TLSv1.1" \
2988 -c "Protocol is TLSv1.1"
2989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002990run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002991 "$P_SRV max_version=tls1_1" \
2992 "$P_CLI max_version=tls1_1" \
2993 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002994 -S "mbedtls_ssl_handshake returned" \
2995 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002996 -s "Protocol is TLSv1.1" \
2997 -c "Protocol is TLSv1.1"
2998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002999run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003000 "$P_SRV min_version=tls1_1" \
3001 "$P_CLI max_version=tls1_1" \
3002 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003003 -S "mbedtls_ssl_handshake returned" \
3004 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003005 -s "Protocol is TLSv1.1" \
3006 -c "Protocol is TLSv1.1"
3007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003008run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003009 "$P_SRV max_version=tls1_1" \
3010 "$P_CLI min_version=tls1_1" \
3011 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003012 -S "mbedtls_ssl_handshake returned" \
3013 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003014 -s "Protocol is TLSv1.1" \
3015 -c "Protocol is TLSv1.1"
3016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003017run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003018 "$P_SRV max_version=tls1_1" \
3019 "$P_CLI min_version=tls1_2" \
3020 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003021 -s "mbedtls_ssl_handshake returned" \
3022 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003023 -c "SSL - Handshake protocol not within min/max boundaries"
3024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003025run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003026 "$P_SRV min_version=tls1_2" \
3027 "$P_CLI max_version=tls1_1" \
3028 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003029 -s "mbedtls_ssl_handshake returned" \
3030 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003031 -s "SSL - Handshake protocol not within min/max boundaries"
3032
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003033# Tests for ALPN extension
3034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003035run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003036 "$P_SRV debug_level=3" \
3037 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003038 0 \
3039 -C "client hello, adding alpn extension" \
3040 -S "found alpn extension" \
3041 -C "got an alert message, type: \\[2:120]" \
3042 -S "server hello, adding alpn extension" \
3043 -C "found alpn extension " \
3044 -C "Application Layer Protocol is" \
3045 -S "Application Layer Protocol is"
3046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003047run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003048 "$P_SRV debug_level=3" \
3049 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003050 0 \
3051 -c "client hello, adding alpn extension" \
3052 -s "found alpn extension" \
3053 -C "got an alert message, type: \\[2:120]" \
3054 -S "server hello, adding alpn extension" \
3055 -C "found alpn extension " \
3056 -c "Application Layer Protocol is (none)" \
3057 -S "Application Layer Protocol is"
3058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003059run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003060 "$P_SRV debug_level=3 alpn=abc,1234" \
3061 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003062 0 \
3063 -C "client hello, adding alpn extension" \
3064 -S "found alpn extension" \
3065 -C "got an alert message, type: \\[2:120]" \
3066 -S "server hello, adding alpn extension" \
3067 -C "found alpn extension " \
3068 -C "Application Layer Protocol is" \
3069 -s "Application Layer Protocol is (none)"
3070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003071run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003072 "$P_SRV debug_level=3 alpn=abc,1234" \
3073 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003074 0 \
3075 -c "client hello, adding alpn extension" \
3076 -s "found alpn extension" \
3077 -C "got an alert message, type: \\[2:120]" \
3078 -s "server hello, adding alpn extension" \
3079 -c "found alpn extension" \
3080 -c "Application Layer Protocol is abc" \
3081 -s "Application Layer Protocol is abc"
3082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003083run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003084 "$P_SRV debug_level=3 alpn=abc,1234" \
3085 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003086 0 \
3087 -c "client hello, adding alpn extension" \
3088 -s "found alpn extension" \
3089 -C "got an alert message, type: \\[2:120]" \
3090 -s "server hello, adding alpn extension" \
3091 -c "found alpn extension" \
3092 -c "Application Layer Protocol is abc" \
3093 -s "Application Layer Protocol is abc"
3094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003095run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003096 "$P_SRV debug_level=3 alpn=abc,1234" \
3097 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003098 0 \
3099 -c "client hello, adding alpn extension" \
3100 -s "found alpn extension" \
3101 -C "got an alert message, type: \\[2:120]" \
3102 -s "server hello, adding alpn extension" \
3103 -c "found alpn extension" \
3104 -c "Application Layer Protocol is 1234" \
3105 -s "Application Layer Protocol is 1234"
3106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003107run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003108 "$P_SRV debug_level=3 alpn=abc,123" \
3109 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003110 1 \
3111 -c "client hello, adding alpn extension" \
3112 -s "found alpn extension" \
3113 -c "got an alert message, type: \\[2:120]" \
3114 -S "server hello, adding alpn extension" \
3115 -C "found alpn extension" \
3116 -C "Application Layer Protocol is 1234" \
3117 -S "Application Layer Protocol is 1234"
3118
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003119
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003120# Tests for keyUsage in leaf certificates, part 1:
3121# server-side certificate/suite selection
3122
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003123run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003124 "$P_SRV key_file=data_files/server2.key \
3125 crt_file=data_files/server2.ku-ds.crt" \
3126 "$P_CLI" \
3127 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003128 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003129
3130
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003131run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003132 "$P_SRV key_file=data_files/server2.key \
3133 crt_file=data_files/server2.ku-ke.crt" \
3134 "$P_CLI" \
3135 0 \
3136 -c "Ciphersuite is TLS-RSA-WITH-"
3137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003138run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003139 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003140 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003141 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003142 1 \
3143 -C "Ciphersuite is "
3144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003145run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003146 "$P_SRV key_file=data_files/server5.key \
3147 crt_file=data_files/server5.ku-ds.crt" \
3148 "$P_CLI" \
3149 0 \
3150 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3151
3152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003153run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003154 "$P_SRV key_file=data_files/server5.key \
3155 crt_file=data_files/server5.ku-ka.crt" \
3156 "$P_CLI" \
3157 0 \
3158 -c "Ciphersuite is TLS-ECDH-"
3159
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003160run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003161 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003162 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003163 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003164 1 \
3165 -C "Ciphersuite is "
3166
3167# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003168# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003169
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003170run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003171 "$O_SRV -key data_files/server2.key \
3172 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003173 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003174 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3175 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003176 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003177 -C "Processing of the Certificate handshake message failed" \
3178 -c "Ciphersuite is TLS-"
3179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003180run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003181 "$O_SRV -key data_files/server2.key \
3182 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003183 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003184 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3185 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003186 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003187 -C "Processing of the Certificate handshake message failed" \
3188 -c "Ciphersuite is TLS-"
3189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003190run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003191 "$O_SRV -key data_files/server2.key \
3192 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003193 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003194 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3195 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003196 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003197 -C "Processing of the Certificate handshake message failed" \
3198 -c "Ciphersuite is TLS-"
3199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003200run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003201 "$O_SRV -key data_files/server2.key \
3202 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003203 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003204 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3205 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003206 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003207 -c "Processing of the Certificate handshake message failed" \
3208 -C "Ciphersuite is TLS-"
3209
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003210run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3211 "$O_SRV -key data_files/server2.key \
3212 -cert data_files/server2.ku-ke.crt" \
3213 "$P_CLI debug_level=1 auth_mode=optional \
3214 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3215 0 \
3216 -c "bad certificate (usage extensions)" \
3217 -C "Processing of the Certificate handshake message failed" \
3218 -c "Ciphersuite is TLS-" \
3219 -c "! Usage does not match the keyUsage extension"
3220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003221run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003222 "$O_SRV -key data_files/server2.key \
3223 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003224 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003225 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3226 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003227 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003228 -C "Processing of the Certificate handshake message failed" \
3229 -c "Ciphersuite is TLS-"
3230
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003231run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003232 "$O_SRV -key data_files/server2.key \
3233 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003234 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003235 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3236 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003237 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003238 -c "Processing of the Certificate handshake message failed" \
3239 -C "Ciphersuite is TLS-"
3240
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003241run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3242 "$O_SRV -key data_files/server2.key \
3243 -cert data_files/server2.ku-ds.crt" \
3244 "$P_CLI debug_level=1 auth_mode=optional \
3245 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3246 0 \
3247 -c "bad certificate (usage extensions)" \
3248 -C "Processing of the Certificate handshake message failed" \
3249 -c "Ciphersuite is TLS-" \
3250 -c "! Usage does not match the keyUsage extension"
3251
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003252# Tests for keyUsage in leaf certificates, part 3:
3253# server-side checking of client cert
3254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003255run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003256 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003257 "$O_CLI -key data_files/server2.key \
3258 -cert data_files/server2.ku-ds.crt" \
3259 0 \
3260 -S "bad certificate (usage extensions)" \
3261 -S "Processing of the Certificate handshake message failed"
3262
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003263run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003264 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003265 "$O_CLI -key data_files/server2.key \
3266 -cert data_files/server2.ku-ke.crt" \
3267 0 \
3268 -s "bad certificate (usage extensions)" \
3269 -S "Processing of the Certificate handshake message failed"
3270
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003271run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003272 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003273 "$O_CLI -key data_files/server2.key \
3274 -cert data_files/server2.ku-ke.crt" \
3275 1 \
3276 -s "bad certificate (usage extensions)" \
3277 -s "Processing of the Certificate handshake message failed"
3278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003279run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003280 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003281 "$O_CLI -key data_files/server5.key \
3282 -cert data_files/server5.ku-ds.crt" \
3283 0 \
3284 -S "bad certificate (usage extensions)" \
3285 -S "Processing of the Certificate handshake message failed"
3286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003287run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003288 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003289 "$O_CLI -key data_files/server5.key \
3290 -cert data_files/server5.ku-ka.crt" \
3291 0 \
3292 -s "bad certificate (usage extensions)" \
3293 -S "Processing of the Certificate handshake message failed"
3294
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003295# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003297run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003298 "$P_SRV key_file=data_files/server5.key \
3299 crt_file=data_files/server5.eku-srv.crt" \
3300 "$P_CLI" \
3301 0
3302
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003303run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003304 "$P_SRV key_file=data_files/server5.key \
3305 crt_file=data_files/server5.eku-srv.crt" \
3306 "$P_CLI" \
3307 0
3308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003309run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003310 "$P_SRV key_file=data_files/server5.key \
3311 crt_file=data_files/server5.eku-cs_any.crt" \
3312 "$P_CLI" \
3313 0
3314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003315run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003316 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003317 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003318 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003319 1
3320
3321# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003323run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003324 "$O_SRV -key data_files/server5.key \
3325 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003326 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003327 0 \
3328 -C "bad certificate (usage extensions)" \
3329 -C "Processing of the Certificate handshake message failed" \
3330 -c "Ciphersuite is TLS-"
3331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003332run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003333 "$O_SRV -key data_files/server5.key \
3334 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003335 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003336 0 \
3337 -C "bad certificate (usage extensions)" \
3338 -C "Processing of the Certificate handshake message failed" \
3339 -c "Ciphersuite is TLS-"
3340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003341run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003342 "$O_SRV -key data_files/server5.key \
3343 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003344 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003345 0 \
3346 -C "bad certificate (usage extensions)" \
3347 -C "Processing of the Certificate handshake message failed" \
3348 -c "Ciphersuite is TLS-"
3349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003350run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003351 "$O_SRV -key data_files/server5.key \
3352 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003353 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003354 1 \
3355 -c "bad certificate (usage extensions)" \
3356 -c "Processing of the Certificate handshake message failed" \
3357 -C "Ciphersuite is TLS-"
3358
3359# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003361run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003362 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003363 "$O_CLI -key data_files/server5.key \
3364 -cert data_files/server5.eku-cli.crt" \
3365 0 \
3366 -S "bad certificate (usage extensions)" \
3367 -S "Processing of the Certificate handshake message failed"
3368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003369run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003370 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003371 "$O_CLI -key data_files/server5.key \
3372 -cert data_files/server5.eku-srv_cli.crt" \
3373 0 \
3374 -S "bad certificate (usage extensions)" \
3375 -S "Processing of the Certificate handshake message failed"
3376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003377run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003378 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003379 "$O_CLI -key data_files/server5.key \
3380 -cert data_files/server5.eku-cs_any.crt" \
3381 0 \
3382 -S "bad certificate (usage extensions)" \
3383 -S "Processing of the Certificate handshake message failed"
3384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003385run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003386 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003387 "$O_CLI -key data_files/server5.key \
3388 -cert data_files/server5.eku-cs.crt" \
3389 0 \
3390 -s "bad certificate (usage extensions)" \
3391 -S "Processing of the Certificate handshake message failed"
3392
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003393run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003394 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003395 "$O_CLI -key data_files/server5.key \
3396 -cert data_files/server5.eku-cs.crt" \
3397 1 \
3398 -s "bad certificate (usage extensions)" \
3399 -s "Processing of the Certificate handshake message failed"
3400
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003401# Tests for DHM parameters loading
3402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003403run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003404 "$P_SRV" \
3405 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3406 debug_level=3" \
3407 0 \
3408 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003409 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003411run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003412 "$P_SRV dhm_file=data_files/dhparams.pem" \
3413 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3414 debug_level=3" \
3415 0 \
3416 -c "value of 'DHM: P ' (1024 bits)" \
3417 -c "value of 'DHM: G ' (2 bits)"
3418
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003419# Tests for DHM client-side size checking
3420
3421run_test "DHM size: server default, client default, OK" \
3422 "$P_SRV" \
3423 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3424 debug_level=1" \
3425 0 \
3426 -C "DHM prime too short:"
3427
3428run_test "DHM size: server default, client 2048, OK" \
3429 "$P_SRV" \
3430 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3431 debug_level=1 dhmlen=2048" \
3432 0 \
3433 -C "DHM prime too short:"
3434
3435run_test "DHM size: server 1024, client default, OK" \
3436 "$P_SRV dhm_file=data_files/dhparams.pem" \
3437 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3438 debug_level=1" \
3439 0 \
3440 -C "DHM prime too short:"
3441
3442run_test "DHM size: server 1000, client default, rejected" \
3443 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3444 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3445 debug_level=1" \
3446 1 \
3447 -c "DHM prime too short:"
3448
3449run_test "DHM size: server default, client 2049, rejected" \
3450 "$P_SRV" \
3451 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3452 debug_level=1 dhmlen=2049" \
3453 1 \
3454 -c "DHM prime too short:"
3455
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003456# Tests for PSK callback
3457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003458run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003459 "$P_SRV psk=abc123 psk_identity=foo" \
3460 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3461 psk_identity=foo psk=abc123" \
3462 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003463 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003464 -S "SSL - Unknown identity received" \
3465 -S "SSL - Verification of the message MAC failed"
3466
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003467run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003468 "$P_SRV" \
3469 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3470 psk_identity=foo psk=abc123" \
3471 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003472 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003473 -S "SSL - Unknown identity received" \
3474 -S "SSL - Verification of the message MAC failed"
3475
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003476run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003477 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3478 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3479 psk_identity=foo psk=abc123" \
3480 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003481 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003482 -s "SSL - Unknown identity received" \
3483 -S "SSL - Verification of the message MAC failed"
3484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003485run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003486 "$P_SRV psk_list=abc,dead,def,beef" \
3487 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3488 psk_identity=abc psk=dead" \
3489 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003490 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003491 -S "SSL - Unknown identity received" \
3492 -S "SSL - Verification of the message MAC failed"
3493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003494run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003495 "$P_SRV psk_list=abc,dead,def,beef" \
3496 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3497 psk_identity=def psk=beef" \
3498 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003499 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003500 -S "SSL - Unknown identity received" \
3501 -S "SSL - Verification of the message MAC failed"
3502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003503run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003504 "$P_SRV psk_list=abc,dead,def,beef" \
3505 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3506 psk_identity=ghi psk=beef" \
3507 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003508 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003509 -s "SSL - Unknown identity received" \
3510 -S "SSL - Verification of the message MAC failed"
3511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003512run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003513 "$P_SRV psk_list=abc,dead,def,beef" \
3514 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3515 psk_identity=abc psk=beef" \
3516 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003517 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003518 -S "SSL - Unknown identity received" \
3519 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003520
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003521# Tests for EC J-PAKE
3522
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003523requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003524run_test "ECJPAKE: client not configured" \
3525 "$P_SRV debug_level=3" \
3526 "$P_CLI debug_level=3" \
3527 0 \
3528 -C "add ciphersuite: c0ff" \
3529 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003530 -S "found ecjpake kkpp extension" \
3531 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003532 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003533 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003534 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003535 -S "None of the common ciphersuites is usable"
3536
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003537requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003538run_test "ECJPAKE: server not configured" \
3539 "$P_SRV debug_level=3" \
3540 "$P_CLI debug_level=3 ecjpake_pw=bla \
3541 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3542 1 \
3543 -c "add ciphersuite: c0ff" \
3544 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003545 -s "found ecjpake kkpp extension" \
3546 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003547 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003548 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003549 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003550 -s "None of the common ciphersuites is usable"
3551
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003552requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003553run_test "ECJPAKE: working, TLS" \
3554 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3555 "$P_CLI debug_level=3 ecjpake_pw=bla \
3556 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003557 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003558 -c "add ciphersuite: c0ff" \
3559 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003560 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003561 -s "found ecjpake kkpp extension" \
3562 -S "skip ecjpake kkpp extension" \
3563 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003564 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003565 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003566 -S "None of the common ciphersuites is usable" \
3567 -S "SSL - Verification of the message MAC failed"
3568
Janos Follath74537a62016-09-02 13:45:28 +01003569server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003570requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003571run_test "ECJPAKE: password mismatch, TLS" \
3572 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3573 "$P_CLI debug_level=3 ecjpake_pw=bad \
3574 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3575 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003576 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003577 -s "SSL - Verification of the message MAC failed"
3578
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003579requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003580run_test "ECJPAKE: working, DTLS" \
3581 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3582 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3583 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3584 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003585 -c "re-using cached ecjpake parameters" \
3586 -S "SSL - Verification of the message MAC failed"
3587
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003588requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003589run_test "ECJPAKE: working, DTLS, no cookie" \
3590 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3591 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3592 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3593 0 \
3594 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003595 -S "SSL - Verification of the message MAC failed"
3596
Janos Follath74537a62016-09-02 13:45:28 +01003597server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003598requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003599run_test "ECJPAKE: password mismatch, DTLS" \
3600 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3601 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3602 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3603 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003604 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003605 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003606
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003607# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003608requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003609run_test "ECJPAKE: working, DTLS, nolog" \
3610 "$P_SRV dtls=1 ecjpake_pw=bla" \
3611 "$P_CLI dtls=1 ecjpake_pw=bla \
3612 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3613 0
3614
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003615# Tests for ciphersuites per version
3616
Janos Follathe2681a42016-03-07 15:57:05 +00003617requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003618run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003619 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-3DES-EDE-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 +02003620 "$P_CLI force_version=ssl3" \
3621 0 \
3622 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003624run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003625 "$P_SRV arc4=1 version_suites=TLS-RSA-WITH-3DES-EDE-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 +01003626 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003627 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003628 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003629
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003630run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003631 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-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 +02003632 "$P_CLI force_version=tls1_1" \
3633 0 \
3634 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003636run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003637 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-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 +02003638 "$P_CLI force_version=tls1_2" \
3639 0 \
3640 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3641
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003642# Test for ClientHello without extensions
3643
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003644requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003645run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003646 "$P_SRV debug_level=3" \
3647 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3648 0 \
3649 -s "dumping 'client hello extensions' (0 bytes)"
3650
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003651requires_gnutls
3652run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3653 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3654 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3655 0 \
3656 -s "dumping 'client hello extensions' (0 bytes)"
3657
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003658# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003659
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003660run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003661 "$P_SRV" \
3662 "$P_CLI request_size=100" \
3663 0 \
3664 -s "Read from client: 100 bytes read$"
3665
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003666run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003667 "$P_SRV" \
3668 "$P_CLI request_size=500" \
3669 0 \
3670 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003671
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003672# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003673
Janos Follathe2681a42016-03-07 15:57:05 +00003674requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003675run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003676 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003677 "$P_CLI request_size=1 force_version=ssl3 \
3678 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3679 0 \
3680 -s "Read from client: 1 bytes read"
3681
Janos Follathe2681a42016-03-07 15:57:05 +00003682requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003683run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003684 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003685 "$P_CLI request_size=1 force_version=ssl3 \
3686 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3687 0 \
3688 -s "Read from client: 1 bytes read"
3689
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003690run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003691 "$P_SRV" \
3692 "$P_CLI request_size=1 force_version=tls1 \
3693 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3694 0 \
3695 -s "Read from client: 1 bytes read"
3696
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003697run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003698 "$P_SRV" \
3699 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3700 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3701 0 \
3702 -s "Read from client: 1 bytes read"
3703
Hanno Becker32c55012017-11-10 08:42:54 +00003704requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003705run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003706 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003707 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003708 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003709 0 \
3710 -s "Read from client: 1 bytes read"
3711
Hanno Becker32c55012017-11-10 08:42:54 +00003712requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003713run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003714 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003715 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003716 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003717 0 \
3718 -s "Read from client: 1 bytes read"
3719
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003720run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003721 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003722 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003723 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3724 0 \
3725 -s "Read from client: 1 bytes read"
3726
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003727run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003728 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3729 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003730 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003731 0 \
3732 -s "Read from client: 1 bytes read"
3733
3734requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003735run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003736 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003737 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003738 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003739 0 \
3740 -s "Read from client: 1 bytes read"
3741
Hanno Becker8501f982017-11-10 08:59:04 +00003742requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003743run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003744 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3745 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3746 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003747 0 \
3748 -s "Read from client: 1 bytes read"
3749
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003750run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003751 "$P_SRV" \
3752 "$P_CLI request_size=1 force_version=tls1_1 \
3753 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3754 0 \
3755 -s "Read from client: 1 bytes read"
3756
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003757run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003758 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003759 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003760 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003761 0 \
3762 -s "Read from client: 1 bytes read"
3763
3764requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003765run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003766 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003767 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003768 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003769 0 \
3770 -s "Read from client: 1 bytes read"
3771
3772requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003773run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003774 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003775 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003776 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003777 0 \
3778 -s "Read from client: 1 bytes read"
3779
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003780run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003781 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003782 "$P_CLI request_size=1 force_version=tls1_1 \
3783 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3784 0 \
3785 -s "Read from client: 1 bytes read"
3786
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003787run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003788 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003789 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003791 0 \
3792 -s "Read from client: 1 bytes read"
3793
Hanno Becker8501f982017-11-10 08:59:04 +00003794requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003795run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003796 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003797 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003798 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003799 0 \
3800 -s "Read from client: 1 bytes read"
3801
Hanno Becker32c55012017-11-10 08:42:54 +00003802requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003803run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003804 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003805 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003806 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003807 0 \
3808 -s "Read from client: 1 bytes read"
3809
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003810run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003811 "$P_SRV" \
3812 "$P_CLI request_size=1 force_version=tls1_2 \
3813 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3814 0 \
3815 -s "Read from client: 1 bytes read"
3816
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003817run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003818 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003819 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003820 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003821 0 \
3822 -s "Read from client: 1 bytes read"
3823
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003824run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003825 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003826 "$P_CLI request_size=1 force_version=tls1_2 \
3827 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003828 0 \
3829 -s "Read from client: 1 bytes read"
3830
Hanno Becker32c55012017-11-10 08:42:54 +00003831requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003832run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003833 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003834 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003835 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003836 0 \
3837 -s "Read from client: 1 bytes read"
3838
Hanno Becker8501f982017-11-10 08:59:04 +00003839requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003840run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003841 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003842 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003843 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003844 0 \
3845 -s "Read from client: 1 bytes read"
3846
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003847run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003848 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003849 "$P_CLI request_size=1 force_version=tls1_2 \
3850 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3851 0 \
3852 -s "Read from client: 1 bytes read"
3853
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003854run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003855 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003856 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003857 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003858 0 \
3859 -s "Read from client: 1 bytes read"
3860
Hanno Becker32c55012017-11-10 08:42:54 +00003861requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003862run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003863 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003864 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003865 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003866 0 \
3867 -s "Read from client: 1 bytes read"
3868
Hanno Becker8501f982017-11-10 08:59:04 +00003869requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003870run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003871 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003872 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003873 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003874 0 \
3875 -s "Read from client: 1 bytes read"
3876
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003877run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003878 "$P_SRV" \
3879 "$P_CLI request_size=1 force_version=tls1_2 \
3880 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3881 0 \
3882 -s "Read from client: 1 bytes read"
3883
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003884run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003885 "$P_SRV" \
3886 "$P_CLI request_size=1 force_version=tls1_2 \
3887 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3888 0 \
3889 -s "Read from client: 1 bytes read"
3890
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003891# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00003892
3893requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003894run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003895 "$P_SRV dtls=1 force_version=dtls1" \
3896 "$P_CLI dtls=1 request_size=1 \
3897 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3898 0 \
3899 -s "Read from client: 1 bytes read"
3900
3901requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003902run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00003903 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3904 "$P_CLI dtls=1 request_size=1 \
3905 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3906 0 \
3907 -s "Read from client: 1 bytes read"
3908
3909requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3910requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003911run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003912 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3913 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003914 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3915 0 \
3916 -s "Read from client: 1 bytes read"
3917
3918requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3919requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003920run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003921 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003922 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003923 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003924 0 \
3925 -s "Read from client: 1 bytes read"
3926
3927requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003928run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00003929 "$P_SRV dtls=1 force_version=dtls1_2" \
3930 "$P_CLI dtls=1 request_size=1 \
3931 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3932 0 \
3933 -s "Read from client: 1 bytes read"
3934
3935requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003936run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003937 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003938 "$P_CLI dtls=1 request_size=1 \
3939 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3940 0 \
3941 -s "Read from client: 1 bytes read"
3942
3943requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3944requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003945run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003946 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003947 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003948 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003949 0 \
3950 -s "Read from client: 1 bytes read"
3951
3952requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3953requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003954run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003955 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003956 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003957 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003958 0 \
3959 -s "Read from client: 1 bytes read"
3960
Andrzej Kurekc19fc552018-06-19 09:37:30 -04003961# Tests for small server packets
3962
3963requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3964run_test "Small server packet SSLv3 BlockCipher" \
3965 "$P_SRV response_size=1 min_version=ssl3" \
3966 "$P_CLI force_version=ssl3 \
3967 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3968 0 \
3969 -c "Read from server: 1 bytes read"
3970
3971requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3972run_test "Small server packet SSLv3 StreamCipher" \
3973 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3974 "$P_CLI force_version=ssl3 \
3975 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3976 0 \
3977 -c "Read from server: 1 bytes read"
3978
3979run_test "Small server packet TLS 1.0 BlockCipher" \
3980 "$P_SRV response_size=1" \
3981 "$P_CLI force_version=tls1 \
3982 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3983 0 \
3984 -c "Read from server: 1 bytes read"
3985
3986run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
3987 "$P_SRV response_size=1" \
3988 "$P_CLI force_version=tls1 etm=0 \
3989 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3990 0 \
3991 -c "Read from server: 1 bytes read"
3992
3993requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3994run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
3995 "$P_SRV response_size=1 trunc_hmac=1" \
3996 "$P_CLI force_version=tls1 \
3997 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
3998 0 \
3999 -c "Read from server: 1 bytes read"
4000
4001requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4002run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4003 "$P_SRV response_size=1 trunc_hmac=1" \
4004 "$P_CLI force_version=tls1 \
4005 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4006 0 \
4007 -c "Read from server: 1 bytes read"
4008
4009run_test "Small server packet TLS 1.0 StreamCipher" \
4010 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4011 "$P_CLI force_version=tls1 \
4012 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4013 0 \
4014 -c "Read from server: 1 bytes read"
4015
4016run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4017 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4018 "$P_CLI force_version=tls1 \
4019 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4020 0 \
4021 -c "Read from server: 1 bytes read"
4022
4023requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4024run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4025 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4026 "$P_CLI force_version=tls1 \
4027 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4028 0 \
4029 -c "Read from server: 1 bytes read"
4030
4031requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4032run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4033 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4034 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4035 trunc_hmac=1 etm=0" \
4036 0 \
4037 -c "Read from server: 1 bytes read"
4038
4039run_test "Small server packet TLS 1.1 BlockCipher" \
4040 "$P_SRV response_size=1" \
4041 "$P_CLI force_version=tls1_1 \
4042 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4043 0 \
4044 -c "Read from server: 1 bytes read"
4045
4046run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4047 "$P_SRV response_size=1" \
4048 "$P_CLI force_version=tls1_1 \
4049 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4050 0 \
4051 -c "Read from server: 1 bytes read"
4052
4053requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4054run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4055 "$P_SRV response_size=1 trunc_hmac=1" \
4056 "$P_CLI force_version=tls1_1 \
4057 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4058 0 \
4059 -c "Read from server: 1 bytes read"
4060
4061requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4062run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4063 "$P_SRV response_size=1 trunc_hmac=1" \
4064 "$P_CLI force_version=tls1_1 \
4065 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4066 0 \
4067 -c "Read from server: 1 bytes read"
4068
4069run_test "Small server packet TLS 1.1 StreamCipher" \
4070 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4071 "$P_CLI force_version=tls1_1 \
4072 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4073 0 \
4074 -c "Read from server: 1 bytes read"
4075
4076run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4077 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4078 "$P_CLI force_version=tls1_1 \
4079 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4080 0 \
4081 -c "Read from server: 1 bytes read"
4082
4083requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4084run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4085 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4086 "$P_CLI force_version=tls1_1 \
4087 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4088 0 \
4089 -c "Read from server: 1 bytes read"
4090
4091requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4092run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4093 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4094 "$P_CLI force_version=tls1_1 \
4095 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4096 0 \
4097 -c "Read from server: 1 bytes read"
4098
4099run_test "Small server packet TLS 1.2 BlockCipher" \
4100 "$P_SRV response_size=1" \
4101 "$P_CLI force_version=tls1_2 \
4102 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4103 0 \
4104 -c "Read from server: 1 bytes read"
4105
4106run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4107 "$P_SRV response_size=1" \
4108 "$P_CLI force_version=tls1_2 \
4109 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4110 0 \
4111 -c "Read from server: 1 bytes read"
4112
4113run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4114 "$P_SRV response_size=1" \
4115 "$P_CLI force_version=tls1_2 \
4116 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4117 0 \
4118 -c "Read from server: 1 bytes read"
4119
4120requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4121run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4122 "$P_SRV response_size=1 trunc_hmac=1" \
4123 "$P_CLI force_version=tls1_2 \
4124 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4125 0 \
4126 -c "Read from server: 1 bytes read"
4127
4128requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4129run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4130 "$P_SRV response_size=1 trunc_hmac=1" \
4131 "$P_CLI force_version=tls1_2 \
4132 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4133 0 \
4134 -c "Read from server: 1 bytes read"
4135
4136run_test "Small server packet TLS 1.2 StreamCipher" \
4137 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4138 "$P_CLI force_version=tls1_2 \
4139 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4140 0 \
4141 -c "Read from server: 1 bytes read"
4142
4143run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4144 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4145 "$P_CLI force_version=tls1_2 \
4146 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4147 0 \
4148 -c "Read from server: 1 bytes read"
4149
4150requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4151run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4152 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4153 "$P_CLI force_version=tls1_2 \
4154 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4155 0 \
4156 -c "Read from server: 1 bytes read"
4157
4158requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4159run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4160 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4161 "$P_CLI force_version=tls1_2 \
4162 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4163 0 \
4164 -c "Read from server: 1 bytes read"
4165
4166run_test "Small server packet TLS 1.2 AEAD" \
4167 "$P_SRV response_size=1" \
4168 "$P_CLI force_version=tls1_2 \
4169 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4170 0 \
4171 -c "Read from server: 1 bytes read"
4172
4173run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4174 "$P_SRV response_size=1" \
4175 "$P_CLI force_version=tls1_2 \
4176 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4177 0 \
4178 -c "Read from server: 1 bytes read"
4179
4180# Tests for small server packets in DTLS
4181
4182requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4183run_test "Small server packet DTLS 1.0" \
4184 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4185 "$P_CLI dtls=1 \
4186 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4187 0 \
4188 -c "Read from server: 1 bytes read"
4189
4190requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4191run_test "Small server packet DTLS 1.0, without EtM" \
4192 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4193 "$P_CLI dtls=1 \
4194 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4195 0 \
4196 -c "Read from server: 1 bytes read"
4197
4198requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4199requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4200run_test "Small server packet DTLS 1.0, truncated hmac" \
4201 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4202 "$P_CLI dtls=1 trunc_hmac=1 \
4203 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4204 0 \
4205 -c "Read from server: 1 bytes read"
4206
4207requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4208requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4209run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4210 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4211 "$P_CLI dtls=1 \
4212 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4213 0 \
4214 -c "Read from server: 1 bytes read"
4215
4216requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4217run_test "Small server packet DTLS 1.2" \
4218 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4219 "$P_CLI dtls=1 \
4220 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4221 0 \
4222 -c "Read from server: 1 bytes read"
4223
4224requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4225run_test "Small server packet DTLS 1.2, without EtM" \
4226 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4227 "$P_CLI dtls=1 \
4228 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4229 0 \
4230 -c "Read from server: 1 bytes read"
4231
4232requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4233requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4234run_test "Small server packet DTLS 1.2, truncated hmac" \
4235 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4236 "$P_CLI dtls=1 \
4237 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4238 0 \
4239 -c "Read from server: 1 bytes read"
4240
4241requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4242requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4243run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4244 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4245 "$P_CLI dtls=1 \
4246 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4247 0 \
4248 -c "Read from server: 1 bytes read"
4249
Janos Follath00efff72016-05-06 13:48:23 +01004250# A test for extensions in SSLv3
4251
4252requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4253run_test "SSLv3 with extensions, server side" \
4254 "$P_SRV min_version=ssl3 debug_level=3" \
4255 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4256 0 \
4257 -S "dumping 'client hello extensions'" \
4258 -S "server hello, total extension length:"
4259
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004260# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004261
Janos Follathe2681a42016-03-07 15:57:05 +00004262requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004263run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004264 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004265 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004266 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4267 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004268 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004269 -s "Read from client: 16384 bytes read"
4270
Janos Follathe2681a42016-03-07 15:57:05 +00004271requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004272run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004273 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004274 "$P_CLI request_size=16384 force_version=ssl3 \
4275 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4276 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004277 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004278 -s "Read from client: 16384 bytes read"
4279
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004280run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004281 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004282 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004283 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4284 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004285 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004286 -s "Read from client: 16384 bytes read"
4287
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004288run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004289 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004290 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4291 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4292 0 \
4293 -s "Read from client: 16384 bytes read"
4294
Hanno Becker32c55012017-11-10 08:42:54 +00004295requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004296run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004297 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004298 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004299 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004300 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004301 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004302 -s "Read from client: 16384 bytes read"
4303
Hanno Becker32c55012017-11-10 08:42:54 +00004304requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004305run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004306 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004307 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004308 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004309 0 \
4310 -s "Read from client: 16384 bytes read"
4311
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004312run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004313 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004314 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004315 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4316 0 \
4317 -s "Read from client: 16384 bytes read"
4318
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004319run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004320 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4321 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004322 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004323 0 \
4324 -s "Read from client: 16384 bytes read"
4325
4326requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004327run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004328 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004329 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004330 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004331 0 \
4332 -s "Read from client: 16384 bytes read"
4333
Hanno Becker278fc7a2017-11-10 09:16:28 +00004334requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004335run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004336 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004337 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004338 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004339 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004340 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004341 -s "Read from client: 16384 bytes read"
4342
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004343run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004344 "$P_SRV" \
4345 "$P_CLI request_size=16384 force_version=tls1_1 \
4346 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4347 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004348 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004349 -s "Read from client: 16384 bytes read"
4350
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004351run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004352 "$P_SRV" \
4353 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4354 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004355 0 \
4356 -s "Read from client: 16384 bytes read"
4357
Hanno Becker32c55012017-11-10 08:42:54 +00004358requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004359run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004360 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004361 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004362 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004363 0 \
4364 -s "Read from client: 16384 bytes read"
4365
Hanno Becker32c55012017-11-10 08:42:54 +00004366requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004367run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004368 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004369 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004370 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004371 0 \
4372 -s "Read from client: 16384 bytes read"
4373
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004374run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004375 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4376 "$P_CLI request_size=16384 force_version=tls1_1 \
4377 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4378 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004379 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004380 -s "Read from client: 16384 bytes read"
4381
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004382run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004383 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004384 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004385 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004386 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004387 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004388 -s "Read from client: 16384 bytes read"
4389
Hanno Becker278fc7a2017-11-10 09:16:28 +00004390requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004391run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004392 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004393 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004394 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004395 0 \
4396 -s "Read from client: 16384 bytes read"
4397
Hanno Becker278fc7a2017-11-10 09:16:28 +00004398requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004399run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004400 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004401 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004402 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004403 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004404 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004405 -s "Read from client: 16384 bytes read"
4406
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004407run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004408 "$P_SRV" \
4409 "$P_CLI request_size=16384 force_version=tls1_2 \
4410 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4411 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004412 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004413 -s "Read from client: 16384 bytes read"
4414
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004415run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004416 "$P_SRV" \
4417 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4418 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4419 0 \
4420 -s "Read from client: 16384 bytes read"
4421
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004422run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004423 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004424 "$P_CLI request_size=16384 force_version=tls1_2 \
4425 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004426 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004427 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004428 -s "Read from client: 16384 bytes read"
4429
Hanno Becker32c55012017-11-10 08:42:54 +00004430requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004431run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004432 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004433 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004434 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004435 0 \
4436 -s "Read from client: 16384 bytes read"
4437
Hanno Becker278fc7a2017-11-10 09:16:28 +00004438requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004439run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004440 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004441 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004442 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004443 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004444 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004445 -s "Read from client: 16384 bytes read"
4446
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004447run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004448 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004449 "$P_CLI request_size=16384 force_version=tls1_2 \
4450 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4451 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004452 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004453 -s "Read from client: 16384 bytes read"
4454
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004455run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004456 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004457 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004458 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4459 0 \
4460 -s "Read from client: 16384 bytes read"
4461
Hanno Becker32c55012017-11-10 08:42:54 +00004462requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004463run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004464 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004465 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004466 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004467 0 \
4468 -s "Read from client: 16384 bytes read"
4469
Hanno Becker278fc7a2017-11-10 09:16:28 +00004470requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004471run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004472 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004473 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004474 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004475 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004476 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004477 -s "Read from client: 16384 bytes read"
4478
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004479run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004480 "$P_SRV" \
4481 "$P_CLI request_size=16384 force_version=tls1_2 \
4482 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4483 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004484 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004485 -s "Read from client: 16384 bytes read"
4486
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004487run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004488 "$P_SRV" \
4489 "$P_CLI request_size=16384 force_version=tls1_2 \
4490 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4491 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004492 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004493 -s "Read from client: 16384 bytes read"
4494
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004495# Test for large server packets
4496
4497requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4498run_test "Large server packet SSLv3 BlockCipher" \
4499 "$P_SRV response_size=16384 min_version=ssl3" \
4500 "$P_CLI force_version=ssl3 recsplit=0 \
4501 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4502 0 \
4503 -c "Read from server: 16384 bytes read"
4504
4505requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4506run_test "Large server packet SSLv3 StreamCipher" \
4507 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4508 "$P_CLI force_version=ssl3 \
4509 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4510 0 \
4511 -c "Read from server: 16384 bytes read"
4512
4513# Checking next 2 tests logs for 1n-1 split against BEAST too
4514run_test "Large server packet TLS 1.0 BlockCipher" \
4515 "$P_SRV response_size=16384" \
4516 "$P_CLI force_version=tls1 recsplit=0 \
4517 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4518 0 \
4519 -c "Read from server: 1 bytes read"\
4520 -c "16383 bytes read"\
4521 -C "Read from server: 16384 bytes read"
4522
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004523run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
4524 "$P_SRV response_size=16384" \
4525 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
4526 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4527 0 \
4528 -c "Read from server: 1 bytes read"\
4529 -c "16383 bytes read"\
4530 -C "Read from server: 16384 bytes read"
4531
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004532requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4533run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
4534 "$P_SRV response_size=16384" \
4535 "$P_CLI force_version=tls1 recsplit=0 \
4536 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4537 trunc_hmac=1" \
4538 0 \
4539 -c "Read from server: 1 bytes read"\
4540 -c "16383 bytes read"\
4541 -C "Read from server: 16384 bytes read"
4542
4543requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4544run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
4545 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4546 "$P_CLI force_version=tls1 \
4547 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4548 trunc_hmac=1" \
4549 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004550 -s "16384 bytes written in 1 fragments" \
4551 -c "Read from server: 16384 bytes read"
4552
4553run_test "Large server packet TLS 1.0 StreamCipher" \
4554 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4555 "$P_CLI force_version=tls1 \
4556 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4557 0 \
4558 -s "16384 bytes written in 1 fragments" \
4559 -c "Read from server: 16384 bytes read"
4560
4561run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
4562 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4563 "$P_CLI force_version=tls1 \
4564 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4565 0 \
4566 -s "16384 bytes written in 1 fragments" \
4567 -c "Read from server: 16384 bytes read"
4568
4569requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4570run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
4571 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4572 "$P_CLI force_version=tls1 \
4573 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4574 0 \
4575 -s "16384 bytes written in 1 fragments" \
4576 -c "Read from server: 16384 bytes read"
4577
4578requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4579run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4580 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4581 "$P_CLI force_version=tls1 \
4582 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4583 0 \
4584 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004585 -c "Read from server: 16384 bytes read"
4586
4587run_test "Large server packet TLS 1.1 BlockCipher" \
4588 "$P_SRV response_size=16384" \
4589 "$P_CLI force_version=tls1_1 \
4590 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4591 0 \
4592 -c "Read from server: 16384 bytes read"
4593
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004594run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
4595 "$P_SRV response_size=16384" \
4596 "$P_CLI force_version=tls1_1 etm=0 \
4597 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004598 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004599 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004600 -c "Read from server: 16384 bytes read"
4601
4602requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4603run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
4604 "$P_SRV response_size=16384" \
4605 "$P_CLI force_version=tls1_1 \
4606 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4607 trunc_hmac=1" \
4608 0 \
4609 -c "Read from server: 16384 bytes read"
4610
4611requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004612run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4613 "$P_SRV response_size=16384 trunc_hmac=1" \
4614 "$P_CLI force_version=tls1_1 \
4615 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4616 0 \
4617 -s "16384 bytes written in 1 fragments" \
4618 -c "Read from server: 16384 bytes read"
4619
4620run_test "Large server packet TLS 1.1 StreamCipher" \
4621 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4622 "$P_CLI force_version=tls1_1 \
4623 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4624 0 \
4625 -c "Read from server: 16384 bytes read"
4626
4627run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
4628 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4629 "$P_CLI force_version=tls1_1 \
4630 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4631 0 \
4632 -s "16384 bytes written in 1 fragments" \
4633 -c "Read from server: 16384 bytes read"
4634
4635requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004636run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
4637 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4638 "$P_CLI force_version=tls1_1 \
4639 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4640 trunc_hmac=1" \
4641 0 \
4642 -c "Read from server: 16384 bytes read"
4643
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004644run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4645 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4646 "$P_CLI force_version=tls1_1 \
4647 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4648 0 \
4649 -s "16384 bytes written in 1 fragments" \
4650 -c "Read from server: 16384 bytes read"
4651
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004652run_test "Large server packet TLS 1.2 BlockCipher" \
4653 "$P_SRV response_size=16384" \
4654 "$P_CLI force_version=tls1_2 \
4655 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4656 0 \
4657 -c "Read from server: 16384 bytes read"
4658
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004659run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
4660 "$P_SRV response_size=16384" \
4661 "$P_CLI force_version=tls1_2 etm=0 \
4662 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4663 0 \
4664 -s "16384 bytes written in 1 fragments" \
4665 -c "Read from server: 16384 bytes read"
4666
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004667run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
4668 "$P_SRV response_size=16384" \
4669 "$P_CLI force_version=tls1_2 \
4670 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4671 0 \
4672 -c "Read from server: 16384 bytes read"
4673
4674requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4675run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
4676 "$P_SRV response_size=16384" \
4677 "$P_CLI force_version=tls1_2 \
4678 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4679 trunc_hmac=1" \
4680 0 \
4681 -c "Read from server: 16384 bytes read"
4682
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004683run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4684 "$P_SRV response_size=16384 trunc_hmac=1" \
4685 "$P_CLI force_version=tls1_2 \
4686 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4687 0 \
4688 -s "16384 bytes written in 1 fragments" \
4689 -c "Read from server: 16384 bytes read"
4690
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004691run_test "Large server packet TLS 1.2 StreamCipher" \
4692 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4693 "$P_CLI force_version=tls1_2 \
4694 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4695 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004696 -s "16384 bytes written in 1 fragments" \
4697 -c "Read from server: 16384 bytes read"
4698
4699run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
4700 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4701 "$P_CLI force_version=tls1_2 \
4702 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4703 0 \
4704 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004705 -c "Read from server: 16384 bytes read"
4706
4707requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4708run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
4709 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4710 "$P_CLI force_version=tls1_2 \
4711 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4712 trunc_hmac=1" \
4713 0 \
4714 -c "Read from server: 16384 bytes read"
4715
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004716requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4717run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4718 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4719 "$P_CLI force_version=tls1_2 \
4720 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4721 0 \
4722 -s "16384 bytes written in 1 fragments" \
4723 -c "Read from server: 16384 bytes read"
4724
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004725run_test "Large server packet TLS 1.2 AEAD" \
4726 "$P_SRV response_size=16384" \
4727 "$P_CLI force_version=tls1_2 \
4728 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4729 0 \
4730 -c "Read from server: 16384 bytes read"
4731
4732run_test "Large server packet TLS 1.2 AEAD shorter tag" \
4733 "$P_SRV response_size=16384" \
4734 "$P_CLI force_version=tls1_2 \
4735 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4736 0 \
4737 -c "Read from server: 16384 bytes read"
4738
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004739# Tests of asynchronous private key support in SSL
4740
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004741requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004742run_test "SSL async private: sign, delay=0" \
4743 "$P_SRV \
4744 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004745 "$P_CLI" \
4746 0 \
4747 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004748 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004749
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004750requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004751run_test "SSL async private: sign, delay=1" \
4752 "$P_SRV \
4753 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004754 "$P_CLI" \
4755 0 \
4756 -s "Async sign callback: using key slot " \
4757 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004758 -s "Async resume (slot [0-9]): sign done, status=0"
4759
Gilles Peskine12d0cc12018-04-26 15:06:56 +02004760requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4761run_test "SSL async private: sign, delay=2" \
4762 "$P_SRV \
4763 async_operations=s async_private_delay1=2 async_private_delay2=2" \
4764 "$P_CLI" \
4765 0 \
4766 -s "Async sign callback: using key slot " \
4767 -U "Async sign callback: using key slot " \
4768 -s "Async resume (slot [0-9]): call 1 more times." \
4769 -s "Async resume (slot [0-9]): call 0 more times." \
4770 -s "Async resume (slot [0-9]): sign done, status=0"
4771
Gilles Peskined3268832018-04-26 06:23:59 +02004772# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
4773# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
4774requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4775requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4776run_test "SSL async private: sign, RSA, TLS 1.1" \
4777 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
4778 async_operations=s async_private_delay1=0 async_private_delay2=0" \
4779 "$P_CLI force_version=tls1_1" \
4780 0 \
4781 -s "Async sign callback: using key slot " \
4782 -s "Async resume (slot [0-9]): sign done, status=0"
4783
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004784requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02004785run_test "SSL async private: sign, SNI" \
4786 "$P_SRV debug_level=3 \
4787 async_operations=s async_private_delay1=0 async_private_delay2=0 \
4788 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4789 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4790 "$P_CLI server_name=polarssl.example" \
4791 0 \
4792 -s "Async sign callback: using key slot " \
4793 -s "Async resume (slot [0-9]): sign done, status=0" \
4794 -s "parse ServerName extension" \
4795 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4796 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4797
4798requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004799run_test "SSL async private: decrypt, delay=0" \
4800 "$P_SRV \
4801 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4802 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4803 0 \
4804 -s "Async decrypt callback: using key slot " \
4805 -s "Async resume (slot [0-9]): decrypt done, status=0"
4806
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004807requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004808run_test "SSL async private: decrypt, delay=1" \
4809 "$P_SRV \
4810 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4811 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4812 0 \
4813 -s "Async decrypt callback: using key slot " \
4814 -s "Async resume (slot [0-9]): call 0 more times." \
4815 -s "Async resume (slot [0-9]): decrypt done, status=0"
4816
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004817requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004818run_test "SSL async private: decrypt RSA-PSK, delay=0" \
4819 "$P_SRV psk=abc123 \
4820 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4821 "$P_CLI psk=abc123 \
4822 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4823 0 \
4824 -s "Async decrypt callback: using key slot " \
4825 -s "Async resume (slot [0-9]): decrypt done, status=0"
4826
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004827requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004828run_test "SSL async private: decrypt RSA-PSK, delay=1" \
4829 "$P_SRV psk=abc123 \
4830 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4831 "$P_CLI psk=abc123 \
4832 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4833 0 \
4834 -s "Async decrypt callback: using key slot " \
4835 -s "Async resume (slot [0-9]): call 0 more times." \
4836 -s "Async resume (slot [0-9]): decrypt done, status=0"
4837
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004838requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004839run_test "SSL async private: sign callback not present" \
4840 "$P_SRV \
4841 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4842 "$P_CLI; [ \$? -eq 1 ] &&
4843 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4844 0 \
4845 -S "Async sign callback" \
4846 -s "! mbedtls_ssl_handshake returned" \
4847 -s "The own private key or pre-shared key is not set, but needed" \
4848 -s "Async resume (slot [0-9]): decrypt done, status=0" \
4849 -s "Successful connection"
4850
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004851requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004852run_test "SSL async private: decrypt callback not present" \
4853 "$P_SRV debug_level=1 \
4854 async_operations=s async_private_delay1=1 async_private_delay2=1" \
4855 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
4856 [ \$? -eq 1 ] && $P_CLI" \
4857 0 \
4858 -S "Async decrypt callback" \
4859 -s "! mbedtls_ssl_handshake returned" \
4860 -s "got no RSA private key" \
4861 -s "Async resume (slot [0-9]): sign done, status=0" \
4862 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004863
4864# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004865requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004866run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004867 "$P_SRV \
4868 async_operations=s async_private_delay1=1 \
4869 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4870 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004871 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4872 0 \
4873 -s "Async sign callback: using key slot 0," \
4874 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004875 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004876
4877# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004878requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004879run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004880 "$P_SRV \
4881 async_operations=s async_private_delay2=1 \
4882 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4883 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004884 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4885 0 \
4886 -s "Async sign callback: using key slot 0," \
4887 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004888 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004889
4890# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004891requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02004892run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004893 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02004894 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004895 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4896 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004897 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4898 0 \
4899 -s "Async sign callback: using key slot 1," \
4900 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004901 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004902
4903# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004904requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004905run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004906 "$P_SRV \
4907 async_operations=s async_private_delay1=1 \
4908 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4909 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004910 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4911 0 \
4912 -s "Async sign callback: no key matches this certificate."
4913
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004914requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004915run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004916 "$P_SRV \
4917 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4918 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004919 "$P_CLI" \
4920 1 \
4921 -s "Async sign callback: injected error" \
4922 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004923 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004924 -s "! mbedtls_ssl_handshake returned"
4925
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004926requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004927run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004928 "$P_SRV \
4929 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4930 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004931 "$P_CLI" \
4932 1 \
4933 -s "Async sign callback: using key slot " \
4934 -S "Async resume" \
4935 -s "Async cancel"
4936
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004937requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004938run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004939 "$P_SRV \
4940 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4941 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004942 "$P_CLI" \
4943 1 \
4944 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004945 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004946 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004947 -s "! mbedtls_ssl_handshake returned"
4948
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004949requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004950run_test "SSL async private: decrypt, error in start" \
4951 "$P_SRV \
4952 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4953 async_private_error=1" \
4954 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4955 1 \
4956 -s "Async decrypt callback: injected error" \
4957 -S "Async resume" \
4958 -S "Async cancel" \
4959 -s "! mbedtls_ssl_handshake returned"
4960
4961requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4962run_test "SSL async private: decrypt, cancel after start" \
4963 "$P_SRV \
4964 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4965 async_private_error=2" \
4966 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4967 1 \
4968 -s "Async decrypt callback: using key slot " \
4969 -S "Async resume" \
4970 -s "Async cancel"
4971
4972requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4973run_test "SSL async private: decrypt, error in resume" \
4974 "$P_SRV \
4975 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4976 async_private_error=3" \
4977 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4978 1 \
4979 -s "Async decrypt callback: using key slot " \
4980 -s "Async resume callback: decrypt done but injected error" \
4981 -S "Async cancel" \
4982 -s "! mbedtls_ssl_handshake returned"
4983
4984requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004985run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004986 "$P_SRV \
4987 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4988 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004989 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4990 0 \
4991 -s "Async cancel" \
4992 -s "! mbedtls_ssl_handshake returned" \
4993 -s "Async resume" \
4994 -s "Successful connection"
4995
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004996requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004997run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004998 "$P_SRV \
4999 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5000 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005001 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5002 0 \
5003 -s "! mbedtls_ssl_handshake returned" \
5004 -s "Async resume" \
5005 -s "Successful connection"
5006
5007# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005008requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005009run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005010 "$P_SRV \
5011 async_operations=s async_private_delay1=1 async_private_error=-2 \
5012 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5013 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005014 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5015 [ \$? -eq 1 ] &&
5016 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5017 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005018 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005019 -S "Async resume" \
5020 -s "Async cancel" \
5021 -s "! mbedtls_ssl_handshake returned" \
5022 -s "Async sign callback: no key matches this certificate." \
5023 -s "Successful connection"
5024
5025# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005026requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005027run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005028 "$P_SRV \
5029 async_operations=s async_private_delay1=1 async_private_error=-3 \
5030 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5031 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005032 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5033 [ \$? -eq 1 ] &&
5034 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5035 0 \
5036 -s "Async resume" \
5037 -s "! mbedtls_ssl_handshake returned" \
5038 -s "Async sign callback: no key matches this certificate." \
5039 -s "Successful connection"
5040
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005041requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005042requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005043run_test "SSL async private: renegotiation: client-initiated; sign" \
5044 "$P_SRV \
5045 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005046 exchanges=2 renegotiation=1" \
5047 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5048 0 \
5049 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005050 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005051
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005052requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005053requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005054run_test "SSL async private: renegotiation: server-initiated; sign" \
5055 "$P_SRV \
5056 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005057 exchanges=2 renegotiation=1 renegotiate=1" \
5058 "$P_CLI exchanges=2 renegotiation=1" \
5059 0 \
5060 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005061 -s "Async resume (slot [0-9]): sign done, status=0"
5062
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005063requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005064requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5065run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5066 "$P_SRV \
5067 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5068 exchanges=2 renegotiation=1" \
5069 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5070 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5071 0 \
5072 -s "Async decrypt callback: using key slot " \
5073 -s "Async resume (slot [0-9]): decrypt done, status=0"
5074
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005075requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005076requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5077run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5078 "$P_SRV \
5079 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5080 exchanges=2 renegotiation=1 renegotiate=1" \
5081 "$P_CLI exchanges=2 renegotiation=1 \
5082 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5083 0 \
5084 -s "Async decrypt callback: using key slot " \
5085 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005086
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005087# Tests for DTLS HelloVerifyRequest
5088
5089run_test "DTLS cookie: enabled" \
5090 "$P_SRV dtls=1 debug_level=2" \
5091 "$P_CLI dtls=1 debug_level=2" \
5092 0 \
5093 -s "cookie verification failed" \
5094 -s "cookie verification passed" \
5095 -S "cookie verification skipped" \
5096 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005097 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005098 -S "SSL - The requested feature is not available"
5099
5100run_test "DTLS cookie: disabled" \
5101 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5102 "$P_CLI dtls=1 debug_level=2" \
5103 0 \
5104 -S "cookie verification failed" \
5105 -S "cookie verification passed" \
5106 -s "cookie verification skipped" \
5107 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005108 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005109 -S "SSL - The requested feature is not available"
5110
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005111run_test "DTLS cookie: default (failing)" \
5112 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5113 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5114 1 \
5115 -s "cookie verification failed" \
5116 -S "cookie verification passed" \
5117 -S "cookie verification skipped" \
5118 -C "received hello verify request" \
5119 -S "hello verification requested" \
5120 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005121
5122requires_ipv6
5123run_test "DTLS cookie: enabled, IPv6" \
5124 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5125 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5126 0 \
5127 -s "cookie verification failed" \
5128 -s "cookie verification passed" \
5129 -S "cookie verification skipped" \
5130 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005131 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005132 -S "SSL - The requested feature is not available"
5133
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005134run_test "DTLS cookie: enabled, nbio" \
5135 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5136 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5137 0 \
5138 -s "cookie verification failed" \
5139 -s "cookie verification passed" \
5140 -S "cookie verification skipped" \
5141 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005142 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005143 -S "SSL - The requested feature is not available"
5144
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005145# Tests for client reconnecting from the same port with DTLS
5146
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005147not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005148run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005149 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
5150 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005151 0 \
5152 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005153 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005154 -S "Client initiated reconnection from same port"
5155
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005156not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005157run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005158 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
5159 "$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 +02005160 0 \
5161 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005162 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005163 -s "Client initiated reconnection from same port"
5164
Paul Bakker362689d2016-05-13 10:33:25 +01005165not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5166run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005167 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5168 "$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 +02005169 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005170 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005171 -s "Client initiated reconnection from same port"
5172
Paul Bakker362689d2016-05-13 10:33:25 +01005173only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5174run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5175 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5176 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5177 0 \
5178 -S "The operation timed out" \
5179 -s "Client initiated reconnection from same port"
5180
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005181run_test "DTLS client reconnect from same port: no cookies" \
5182 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005183 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5184 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005185 -s "The operation timed out" \
5186 -S "Client initiated reconnection from same port"
5187
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005188# Tests for various cases of client authentication with DTLS
5189# (focused on handshake flows and message parsing)
5190
5191run_test "DTLS client auth: required" \
5192 "$P_SRV dtls=1 auth_mode=required" \
5193 "$P_CLI dtls=1" \
5194 0 \
5195 -s "Verifying peer X.509 certificate... ok"
5196
5197run_test "DTLS client auth: optional, client has no cert" \
5198 "$P_SRV dtls=1 auth_mode=optional" \
5199 "$P_CLI dtls=1 crt_file=none key_file=none" \
5200 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005201 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005202
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005203run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005204 "$P_SRV dtls=1 auth_mode=none" \
5205 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5206 0 \
5207 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005208 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005209
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005210run_test "DTLS wrong PSK: badmac alert" \
5211 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5212 "$P_CLI dtls=1 psk=abc124" \
5213 1 \
5214 -s "SSL - Verification of the message MAC failed" \
5215 -c "SSL - A fatal alert message was received from our peer"
5216
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005217# Tests for receiving fragmented handshake messages with DTLS
5218
5219requires_gnutls
5220run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5221 "$G_SRV -u --mtu 2048 -a" \
5222 "$P_CLI dtls=1 debug_level=2" \
5223 0 \
5224 -C "found fragmented DTLS handshake message" \
5225 -C "error"
5226
5227requires_gnutls
5228run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5229 "$G_SRV -u --mtu 512" \
5230 "$P_CLI dtls=1 debug_level=2" \
5231 0 \
5232 -c "found fragmented DTLS handshake message" \
5233 -C "error"
5234
5235requires_gnutls
5236run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5237 "$G_SRV -u --mtu 128" \
5238 "$P_CLI dtls=1 debug_level=2" \
5239 0 \
5240 -c "found fragmented DTLS handshake message" \
5241 -C "error"
5242
5243requires_gnutls
5244run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5245 "$G_SRV -u --mtu 128" \
5246 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5247 0 \
5248 -c "found fragmented DTLS handshake message" \
5249 -C "error"
5250
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005251requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005252requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005253run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5254 "$G_SRV -u --mtu 256" \
5255 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5256 0 \
5257 -c "found fragmented DTLS handshake message" \
5258 -c "client hello, adding renegotiation extension" \
5259 -c "found renegotiation extension" \
5260 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005261 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005262 -C "error" \
5263 -s "Extra-header:"
5264
5265requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005266requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005267run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5268 "$G_SRV -u --mtu 256" \
5269 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5270 0 \
5271 -c "found fragmented DTLS handshake message" \
5272 -c "client hello, adding renegotiation extension" \
5273 -c "found renegotiation extension" \
5274 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005275 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005276 -C "error" \
5277 -s "Extra-header:"
5278
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005279run_test "DTLS reassembly: no fragmentation (openssl server)" \
5280 "$O_SRV -dtls1 -mtu 2048" \
5281 "$P_CLI dtls=1 debug_level=2" \
5282 0 \
5283 -C "found fragmented DTLS handshake message" \
5284 -C "error"
5285
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005286run_test "DTLS reassembly: some fragmentation (openssl server)" \
5287 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005288 "$P_CLI dtls=1 debug_level=2" \
5289 0 \
5290 -c "found fragmented DTLS handshake message" \
5291 -C "error"
5292
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005293run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005294 "$O_SRV -dtls1 -mtu 256" \
5295 "$P_CLI dtls=1 debug_level=2" \
5296 0 \
5297 -c "found fragmented DTLS handshake message" \
5298 -C "error"
5299
5300run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5301 "$O_SRV -dtls1 -mtu 256" \
5302 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5303 0 \
5304 -c "found fragmented DTLS handshake message" \
5305 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005306
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005307# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005308
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005309not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005310run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005311 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005312 "$P_SRV dtls=1 debug_level=2" \
5313 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005314 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005315 -C "replayed record" \
5316 -S "replayed record" \
5317 -C "record from another epoch" \
5318 -S "record from another epoch" \
5319 -C "discarding invalid record" \
5320 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005321 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005322 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005323 -c "HTTP/1.0 200 OK"
5324
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005325not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005326run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005327 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005328 "$P_SRV dtls=1 debug_level=2" \
5329 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005330 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005331 -c "replayed record" \
5332 -s "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01005333 -c "record from another epoch" \
5334 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005335 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005336 -s "Extra-header:" \
5337 -c "HTTP/1.0 200 OK"
5338
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005339run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
5340 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005341 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
5342 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005343 0 \
5344 -c "replayed record" \
5345 -S "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01005346 -c "record from another epoch" \
5347 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005348 -c "resend" \
5349 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005350 -s "Extra-header:" \
5351 -c "HTTP/1.0 200 OK"
5352
Hanno Becker72a4f032017-11-15 16:39:20 +00005353run_test "DTLS proxy: multiple records in same datagram" \
Hanno Becker8d832182018-03-15 10:14:19 +00005354 -p "$P_PXY pack=50" \
Hanno Becker72a4f032017-11-15 16:39:20 +00005355 "$P_SRV dtls=1 debug_level=2" \
5356 "$P_CLI dtls=1 debug_level=2" \
5357 0 \
5358 -c "next record in same datagram" \
5359 -s "next record in same datagram"
5360
5361run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
Hanno Becker8d832182018-03-15 10:14:19 +00005362 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker72a4f032017-11-15 16:39:20 +00005363 "$P_SRV dtls=1 debug_level=2" \
5364 "$P_CLI dtls=1 debug_level=2" \
5365 0 \
5366 -c "next record in same datagram" \
5367 -s "next record in same datagram"
5368
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005369run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005370 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005371 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005372 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005373 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005374 -c "discarding invalid record (mac)" \
5375 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005376 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005377 -c "HTTP/1.0 200 OK" \
5378 -S "too many records with bad MAC" \
5379 -S "Verification of the message MAC failed"
5380
5381run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
5382 -p "$P_PXY bad_ad=1" \
5383 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
5384 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5385 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005386 -C "discarding invalid record (mac)" \
5387 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005388 -S "Extra-header:" \
5389 -C "HTTP/1.0 200 OK" \
5390 -s "too many records with bad MAC" \
5391 -s "Verification of the message MAC failed"
5392
5393run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
5394 -p "$P_PXY bad_ad=1" \
5395 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
5396 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5397 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005398 -c "discarding invalid record (mac)" \
5399 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005400 -s "Extra-header:" \
5401 -c "HTTP/1.0 200 OK" \
5402 -S "too many records with bad MAC" \
5403 -S "Verification of the message MAC failed"
5404
5405run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
5406 -p "$P_PXY bad_ad=1" \
5407 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
5408 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
5409 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005410 -c "discarding invalid record (mac)" \
5411 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005412 -s "Extra-header:" \
5413 -c "HTTP/1.0 200 OK" \
5414 -s "too many records with bad MAC" \
5415 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005416
5417run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005418 -p "$P_PXY delay_ccs=1" \
5419 "$P_SRV dtls=1 debug_level=1" \
5420 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005421 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005422 -c "record from another epoch" \
5423 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005424 -s "Extra-header:" \
5425 -c "HTTP/1.0 200 OK"
5426
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005427# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005428
Janos Follath74537a62016-09-02 13:45:28 +01005429client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005430run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005431 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005432 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5433 psk=abc123" \
5434 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005435 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5436 0 \
5437 -s "Extra-header:" \
5438 -c "HTTP/1.0 200 OK"
5439
Janos Follath74537a62016-09-02 13:45:28 +01005440client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005441run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
5442 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005443 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
5444 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005445 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5446 0 \
5447 -s "Extra-header:" \
5448 -c "HTTP/1.0 200 OK"
5449
Janos Follath74537a62016-09-02 13:45:28 +01005450client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005451run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
5452 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005453 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
5454 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005455 0 \
5456 -s "Extra-header:" \
5457 -c "HTTP/1.0 200 OK"
5458
Janos Follath74537a62016-09-02 13:45:28 +01005459client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005460run_test "DTLS proxy: 3d, FS, client auth" \
5461 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005462 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
5463 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005464 0 \
5465 -s "Extra-header:" \
5466 -c "HTTP/1.0 200 OK"
5467
Janos Follath74537a62016-09-02 13:45:28 +01005468client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005469run_test "DTLS proxy: 3d, FS, ticket" \
5470 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005471 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
5472 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005473 0 \
5474 -s "Extra-header:" \
5475 -c "HTTP/1.0 200 OK"
5476
Janos Follath74537a62016-09-02 13:45:28 +01005477client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005478run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
5479 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005480 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
5481 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005482 0 \
5483 -s "Extra-header:" \
5484 -c "HTTP/1.0 200 OK"
5485
Janos Follath74537a62016-09-02 13:45:28 +01005486client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005487run_test "DTLS proxy: 3d, max handshake, nbio" \
5488 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005489 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
5490 auth_mode=required" \
5491 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005492 0 \
5493 -s "Extra-header:" \
5494 -c "HTTP/1.0 200 OK"
5495
Janos Follath74537a62016-09-02 13:45:28 +01005496client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005497run_test "DTLS proxy: 3d, min handshake, resumption" \
5498 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5499 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5500 psk=abc123 debug_level=3" \
5501 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5502 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5503 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5504 0 \
5505 -s "a session has been resumed" \
5506 -c "a session has been resumed" \
5507 -s "Extra-header:" \
5508 -c "HTTP/1.0 200 OK"
5509
Janos Follath74537a62016-09-02 13:45:28 +01005510client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005511run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
5512 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5513 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5514 psk=abc123 debug_level=3 nbio=2" \
5515 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5516 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5517 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
5518 0 \
5519 -s "a session has been resumed" \
5520 -c "a session has been resumed" \
5521 -s "Extra-header:" \
5522 -c "HTTP/1.0 200 OK"
5523
Janos Follath74537a62016-09-02 13:45:28 +01005524client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005525requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005526run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005527 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005528 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5529 psk=abc123 renegotiation=1 debug_level=2" \
5530 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5531 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005532 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5533 0 \
5534 -c "=> renegotiate" \
5535 -s "=> renegotiate" \
5536 -s "Extra-header:" \
5537 -c "HTTP/1.0 200 OK"
5538
Janos Follath74537a62016-09-02 13:45:28 +01005539client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005540requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005541run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
5542 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005543 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5544 psk=abc123 renegotiation=1 debug_level=2" \
5545 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5546 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005547 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5548 0 \
5549 -c "=> renegotiate" \
5550 -s "=> renegotiate" \
5551 -s "Extra-header:" \
5552 -c "HTTP/1.0 200 OK"
5553
Janos Follath74537a62016-09-02 13:45:28 +01005554client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005555requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005556run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005557 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005558 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005559 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005560 debug_level=2" \
5561 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005562 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005563 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5564 0 \
5565 -c "=> renegotiate" \
5566 -s "=> renegotiate" \
5567 -s "Extra-header:" \
5568 -c "HTTP/1.0 200 OK"
5569
Janos Follath74537a62016-09-02 13:45:28 +01005570client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005571requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005572run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005573 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005574 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005575 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005576 debug_level=2 nbio=2" \
5577 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005578 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005579 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5580 0 \
5581 -c "=> renegotiate" \
5582 -s "=> renegotiate" \
5583 -s "Extra-header:" \
5584 -c "HTTP/1.0 200 OK"
5585
Janos Follath74537a62016-09-02 13:45:28 +01005586client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005587not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005588run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005589 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5590 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005591 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005592 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005593 -c "HTTP/1.0 200 OK"
5594
Janos Follath74537a62016-09-02 13:45:28 +01005595client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005596not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005597run_test "DTLS proxy: 3d, openssl server, fragmentation" \
5598 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5599 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005600 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005601 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005602 -c "HTTP/1.0 200 OK"
5603
Janos Follath74537a62016-09-02 13:45:28 +01005604client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005605not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005606run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
5607 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5608 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005609 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005610 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005611 -c "HTTP/1.0 200 OK"
5612
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005613requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005614client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005615not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005616run_test "DTLS proxy: 3d, gnutls server" \
5617 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5618 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005619 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005620 0 \
5621 -s "Extra-header:" \
5622 -c "Extra-header:"
5623
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005624requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005625client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005626not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005627run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
5628 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5629 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005630 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005631 0 \
5632 -s "Extra-header:" \
5633 -c "Extra-header:"
5634
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005635requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005636client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005637not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005638run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
5639 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5640 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005641 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005642 0 \
5643 -s "Extra-header:" \
5644 -c "Extra-header:"
5645
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01005646# Final report
5647
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005648echo "------------------------------------------------------------------------"
5649
5650if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005651 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005652else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005653 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005654fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02005655PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02005656echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005657
5658exit $FAILS