blob: 5a83bbc5ae86f153a4a18a2e946186dab261040c [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200125# skip next test if the flag is enabled in config.h
126requires_config_disabled() {
127 if grep "^#define $1" $CONFIG_H > /dev/null; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200132# skip next test if OpenSSL doesn't support FALLBACK_SCSV
133requires_openssl_with_fallback_scsv() {
134 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
135 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
136 then
137 OPENSSL_HAS_FBSCSV="YES"
138 else
139 OPENSSL_HAS_FBSCSV="NO"
140 fi
141 fi
142 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
143 SKIP_NEXT="YES"
144 fi
145}
146
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200147# skip next test if GnuTLS isn't available
148requires_gnutls() {
149 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200150 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151 GNUTLS_AVAILABLE="YES"
152 else
153 GNUTLS_AVAILABLE="NO"
154 fi
155 fi
156 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200161# skip next test if IPv6 isn't available on this host
162requires_ipv6() {
163 if [ -z "${HAS_IPV6:-}" ]; then
164 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
165 SRV_PID=$!
166 sleep 1
167 kill $SRV_PID >/dev/null 2>&1
168 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
169 HAS_IPV6="NO"
170 else
171 HAS_IPV6="YES"
172 fi
173 rm -r $SRV_OUT
174 fi
175
176 if [ "$HAS_IPV6" = "NO" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200181# skip the next test if valgrind is in use
182not_with_valgrind() {
183 if [ "$MEMCHECK" -gt 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Paul Bakker362689d2016-05-13 10:33:25 +0100188# skip the next test if valgrind is NOT in use
189only_with_valgrind() {
190 if [ "$MEMCHECK" -eq 0 ]; then
191 SKIP_NEXT="YES"
192 fi
193}
194
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200195# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100196client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200197 CLI_DELAY_FACTOR=$1
198}
199
Janos Follath74537a62016-09-02 13:45:28 +0100200# wait for the given seconds after the client finished in the next test
201server_needs_more_time() {
202 SRV_DELAY_SECONDS=$1
203}
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205# print_name <name>
206print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100207 TESTS=$(( $TESTS + 1 ))
208 LINE=""
209
210 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
211 LINE="$TESTS "
212 fi
213
214 LINE="$LINE$1"
215 printf "$LINE "
216 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100217 for i in `seq 1 $LEN`; do printf '.'; done
218 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100220}
221
222# fail <message>
223fail() {
224 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100225 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200227 mv $SRV_OUT o-srv-${TESTS}.log
228 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if [ -n "$PXY_CMD" ]; then
230 mv $PXY_OUT o-pxy-${TESTS}.log
231 fi
232 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100233
Azim Khan03da1212018-03-29 11:04:20 +0100234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot -o "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200235 echo " ! server output:"
236 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200237 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200238 echo " ! client output:"
239 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200240 if [ -n "$PXY_CMD" ]; then
241 echo " ! ========================================================"
242 echo " ! proxy output:"
243 cat o-pxy-${TESTS}.log
244 fi
245 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200246 fi
247
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200248 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249}
250
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251# is_polar <cmd_line>
252is_polar() {
253 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
254}
255
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200256# openssl s_server doesn't have -www with DTLS
257check_osrv_dtls() {
258 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
259 NEEDS_INPUT=1
260 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
261 else
262 NEEDS_INPUT=0
263 fi
264}
265
266# provide input to commands that need it
267provide_input() {
268 if [ $NEEDS_INPUT -eq 0 ]; then
269 return
270 fi
271
272 while true; do
273 echo "HTTP/1.0 200 OK"
274 sleep 1
275 done
276}
277
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100278# has_mem_err <log_file_name>
279has_mem_err() {
280 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
281 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
282 then
283 return 1 # false: does not have errors
284 else
285 return 0 # true: has errors
286 fi
287}
288
Gilles Peskine418b5362017-12-14 18:58:42 +0100289# Wait for process $2 to be listening on port $1
290if type lsof >/dev/null 2>/dev/null; then
291 wait_server_start() {
292 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200293 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100294 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200295 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100296 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200297 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100298 # Make a tight loop, server normally takes less than 1s to start.
299 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
300 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
301 echo "SERVERSTART TIMEOUT"
302 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
303 break
304 fi
305 # Linux and *BSD support decimal arguments to sleep. On other
306 # OSes this may be a tight loop.
307 sleep 0.1 2>/dev/null || true
308 done
309 }
310else
Gilles Peskine7163a6a2018-06-29 15:48:13 +0200311 echo "Warning: lsof not available, wait_server_start = sleep"
Gilles Peskine418b5362017-12-14 18:58:42 +0100312 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200313 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100314 }
315fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200316
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100317# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100318# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100319# acceptable bounds
320check_server_hello_time() {
321 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100322 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100323 # Get the Unix timestamp for now
324 CUR_TIME=$(date +'%s')
325 THRESHOLD_IN_SECS=300
326
327 # Check if the ServerHello time was printed
328 if [ -z "$SERVER_HELLO_TIME" ]; then
329 return 1
330 fi
331
332 # Check the time in ServerHello is within acceptable bounds
333 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
334 # The time in ServerHello is at least 5 minutes before now
335 return 1
336 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100337 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100338 return 1
339 else
340 return 0
341 fi
342}
343
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200344# wait for client to terminate and set CLI_EXIT
345# must be called right after starting the client
346wait_client_done() {
347 CLI_PID=$!
348
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200349 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
350 CLI_DELAY_FACTOR=1
351
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200352 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200353 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200354
355 wait $CLI_PID
356 CLI_EXIT=$?
357
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200358 kill $DOG_PID >/dev/null 2>&1
359 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200360
361 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100362
363 sleep $SRV_DELAY_SECONDS
364 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200365}
366
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200367# check if the given command uses dtls and sets global variable DTLS
368detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200369 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200370 DTLS=1
371 else
372 DTLS=0
373 fi
374}
375
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200376# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100377# Options: -s pattern pattern that must be present in server output
378# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100379# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100380# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100381# -S pattern pattern that must be absent in server output
382# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100383# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100384# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100385run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100386 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200387 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100388
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100389 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
390 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200391 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100392 return
393 fi
394
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100396
Paul Bakkerb7584a52016-05-10 10:50:43 +0100397 # Do we only run numbered tests?
398 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
399 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
400 else
401 SKIP_NEXT="YES"
402 fi
403
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200404 # should we skip?
405 if [ "X$SKIP_NEXT" = "XYES" ]; then
406 SKIP_NEXT="NO"
407 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200408 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200409 return
410 fi
411
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200412 # does this test use a proxy?
413 if [ "X$1" = "X-p" ]; then
414 PXY_CMD="$2"
415 shift 2
416 else
417 PXY_CMD=""
418 fi
419
420 # get commands and client output
421 SRV_CMD="$1"
422 CLI_CMD="$2"
423 CLI_EXPECT="$3"
424 shift 3
425
426 # fix client port
427 if [ -n "$PXY_CMD" ]; then
428 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
429 else
430 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
431 fi
432
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200433 # update DTLS variable
434 detect_dtls "$SRV_CMD"
435
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100436 # prepend valgrind to our commands if active
437 if [ "$MEMCHECK" -gt 0 ]; then
438 if is_polar "$SRV_CMD"; then
439 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
440 fi
441 if is_polar "$CLI_CMD"; then
442 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
443 fi
444 fi
445
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200446 TIMES_LEFT=2
447 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200448 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200449
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200450 # run the commands
451 if [ -n "$PXY_CMD" ]; then
452 echo "$PXY_CMD" > $PXY_OUT
453 $PXY_CMD >> $PXY_OUT 2>&1 &
454 PXY_PID=$!
455 # assume proxy starts faster than server
456 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200457
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200458 check_osrv_dtls
459 echo "$SRV_CMD" > $SRV_OUT
460 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
461 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100462 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200463
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200464 echo "$CLI_CMD" > $CLI_OUT
465 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
466 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100467
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200468 # terminate the server (and the proxy)
469 kill $SRV_PID
470 wait $SRV_PID
471 if [ -n "$PXY_CMD" ]; then
472 kill $PXY_PID >/dev/null 2>&1
473 wait $PXY_PID
474 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100475
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200476 # retry only on timeouts
477 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
478 printf "RETRY "
479 else
480 TIMES_LEFT=0
481 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200482 done
483
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100484 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200485 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100486 # expected client exit to incorrectly succeed in case of catastrophic
487 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100488 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200489 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100490 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100491 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100492 return
493 fi
494 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100495 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200496 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100497 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100498 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100499 return
500 fi
501 fi
502
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100503 # check server exit code
504 if [ $? != 0 ]; then
505 fail "server fail"
506 return
507 fi
508
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100509 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100510 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
511 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100512 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200513 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100514 return
515 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100516
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100517 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200518 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100519 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100520 while [ $# -gt 0 ]
521 do
522 case $1 in
523 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100524 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100525 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100526 return
527 fi
528 ;;
529
530 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100531 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100532 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100533 return
534 fi
535 ;;
536
537 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100538 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100539 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100540 return
541 fi
542 ;;
543
544 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100545 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100546 fail "pattern '$2' MUST NOT be present in the Client output"
547 return
548 fi
549 ;;
550
551 # The filtering in the following two options (-u and -U) do the following
552 # - ignore valgrind output
553 # - filter out everything but lines right after the pattern occurances
554 # - keep one of each non-unique line
555 # - count how many lines remain
556 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
557 # if there were no duplicates.
558 "-U")
559 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
560 fail "lines following pattern '$2' must be unique in Server output"
561 return
562 fi
563 ;;
564
565 "-u")
566 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
567 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100568 return
569 fi
570 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100571 "-F")
572 if ! $2 "$SRV_OUT"; then
573 fail "function call to '$2' failed on Server output"
574 return
575 fi
576 ;;
577 "-f")
578 if ! $2 "$CLI_OUT"; then
579 fail "function call to '$2' failed on Client output"
580 return
581 fi
582 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100583
584 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200585 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100586 exit 1
587 esac
588 shift 2
589 done
590
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100591 # check valgrind's results
592 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200593 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100594 fail "Server has memory errors"
595 return
596 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200597 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100598 fail "Client has memory errors"
599 return
600 fi
601 fi
602
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100603 # if we're here, everything is ok
604 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100605 if [ "$PRESERVE_LOGS" -gt 0 ]; then
606 mv $SRV_OUT o-srv-${TESTS}.log
607 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Beckerdc6c0e42018-08-20 12:21:35 +0100608 if [ -n "$PXY_CMD" ]; then
609 mv $PXY_OUT o-pxy-${TESTS}.log
610 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100611 fi
612
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200613 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100614}
615
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100616cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200618 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
619 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
620 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
621 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100622 exit 1
623}
624
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100625#
626# MAIN
627#
628
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000629if cd $( dirname $0 ); then :; else
630 echo "cd $( dirname $0 ) failed" >&2
631 exit 1
632fi
633
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100634get_options "$@"
635
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100636# sanity checks, avoid an avalanche of errors
637if [ ! -x "$P_SRV" ]; then
638 echo "Command '$P_SRV' is not an executable file"
639 exit 1
640fi
641if [ ! -x "$P_CLI" ]; then
642 echo "Command '$P_CLI' is not an executable file"
643 exit 1
644fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200645if [ ! -x "$P_PXY" ]; then
646 echo "Command '$P_PXY' is not an executable file"
647 exit 1
648fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100649if [ "$MEMCHECK" -gt 0 ]; then
650 if which valgrind >/dev/null 2>&1; then :; else
651 echo "Memcheck not possible. Valgrind not found"
652 exit 1
653 fi
654fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100655if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
656 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100657 exit 1
658fi
659
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200660# used by watchdog
661MAIN_PID="$$"
662
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100663# We use somewhat arbitrary delays for tests:
664# - how long do we wait for the server to start (when lsof not available)?
665# - how long do we allow for the client to finish?
666# (not to check performance, just to avoid waiting indefinitely)
667# Things are slower with valgrind, so give extra time here.
668#
669# Note: without lsof, there is a trade-off between the running time of this
670# script and the risk of spurious errors because we didn't wait long enough.
671# The watchdog delay on the other hand doesn't affect normal running time of
672# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200673if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100674 START_DELAY=6
675 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200676else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100677 START_DELAY=2
678 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200679fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100680
681# some particular tests need more time:
682# - for the client, we multiply the usual watchdog limit by a factor
683# - for the server, we sleep for a number of seconds after the client exits
684# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200685CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100686SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200687
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200688# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000689# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200690P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
691P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100692P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200693O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200694O_CLI="$O_CLI -connect localhost:+SRV_PORT"
695G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000696G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200697
Gilles Peskine62469d92017-05-10 10:13:59 +0200698# Allow SHA-1, because many of our test certificates use it
699P_SRV="$P_SRV allow_sha1=1"
700P_CLI="$P_CLI allow_sha1=1"
701
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200702# Also pick a unique name for intermediate files
703SRV_OUT="srv_out.$$"
704CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200705PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200706SESSION="session.$$"
707
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200708SKIP_NEXT="NO"
709
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100710trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100711
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200712# Basic test
713
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200714# Checks that:
715# - things work with all ciphersuites active (used with config-full in all.sh)
716# - the expected (highest security) parameters are selected
717# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200718run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200719 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200720 "$P_CLI" \
721 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200722 -s "Protocol is TLSv1.2" \
723 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
724 -s "client hello v3, signature_algorithm ext: 6" \
725 -s "ECDHE curve: secp521r1" \
726 -S "error" \
727 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200728
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000729run_test "Default, DTLS" \
730 "$P_SRV dtls=1" \
731 "$P_CLI dtls=1" \
732 0 \
733 -s "Protocol is DTLSv1.2" \
734 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
735
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100736# Test current time in ServerHello
737requires_config_enabled MBEDTLS_HAVE_TIME
738run_test "Default, ServerHello contains gmt_unix_time" \
739 "$P_SRV debug_level=3" \
740 "$P_CLI debug_level=3" \
741 0 \
742 -s "Protocol is TLSv1.2" \
743 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
744 -s "client hello v3, signature_algorithm ext: 6" \
745 -s "ECDHE curve: secp521r1" \
746 -S "error" \
747 -C "error" \
748 -f "check_server_hello_time" \
749 -F "check_server_hello_time"
750
Simon Butcher8e004102016-10-14 00:48:33 +0100751# Test for uniqueness of IVs in AEAD ciphersuites
752run_test "Unique IV in GCM" \
753 "$P_SRV exchanges=20 debug_level=4" \
754 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
755 0 \
756 -u "IV used" \
757 -U "IV used"
758
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100759# Tests for rc4 option
760
Simon Butchera410af52016-05-19 22:12:18 +0100761requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100762run_test "RC4: server disabled, client enabled" \
763 "$P_SRV" \
764 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
765 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100766 -s "SSL - The server has no ciphersuites in common"
767
Simon Butchera410af52016-05-19 22:12:18 +0100768requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100769run_test "RC4: server half, client enabled" \
770 "$P_SRV arc4=1" \
771 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
772 1 \
773 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100774
775run_test "RC4: server enabled, client disabled" \
776 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
777 "$P_CLI" \
778 1 \
779 -s "SSL - The server has no ciphersuites in common"
780
781run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100782 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100783 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
784 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100785 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100786 -S "SSL - The server has no ciphersuites in common"
787
Gilles Peskinebc70a182017-05-09 15:59:24 +0200788# Tests for SHA-1 support
789
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200790requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200791run_test "SHA-1 forbidden by default in server certificate" \
792 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
793 "$P_CLI debug_level=2 allow_sha1=0" \
794 1 \
795 -c "The certificate is signed with an unacceptable hash"
796
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200797requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
798run_test "SHA-1 forbidden by default in server certificate" \
799 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
800 "$P_CLI debug_level=2 allow_sha1=0" \
801 0
802
Gilles Peskinebc70a182017-05-09 15:59:24 +0200803run_test "SHA-1 explicitly allowed in server certificate" \
804 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
805 "$P_CLI allow_sha1=1" \
806 0
807
808run_test "SHA-256 allowed by default in server certificate" \
809 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
810 "$P_CLI allow_sha1=0" \
811 0
812
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200813requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200814run_test "SHA-1 forbidden by default in client certificate" \
815 "$P_SRV auth_mode=required allow_sha1=0" \
816 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
817 1 \
818 -s "The certificate is signed with an unacceptable hash"
819
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200820requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
821run_test "SHA-1 forbidden by default in client certificate" \
822 "$P_SRV auth_mode=required allow_sha1=0" \
823 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
824 0
825
Gilles Peskinebc70a182017-05-09 15:59:24 +0200826run_test "SHA-1 explicitly allowed in client certificate" \
827 "$P_SRV auth_mode=required allow_sha1=1" \
828 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
829 0
830
831run_test "SHA-256 allowed by default in client certificate" \
832 "$P_SRV auth_mode=required allow_sha1=0" \
833 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
834 0
835
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100836# Tests for Truncated HMAC extension
837
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100838run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200839 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100840 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100841 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000842 -s "dumping 'expected mac' (20 bytes)" \
843 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100844
Hanno Becker32c55012017-11-10 08:42:54 +0000845requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100846run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200847 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000848 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100849 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000850 -s "dumping 'expected mac' (20 bytes)" \
851 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100852
Hanno Becker32c55012017-11-10 08:42:54 +0000853requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100854run_test "Truncated HMAC: client enabled, server default" \
855 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000856 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100857 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000858 -s "dumping 'expected mac' (20 bytes)" \
859 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100860
Hanno Becker32c55012017-11-10 08:42:54 +0000861requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100862run_test "Truncated HMAC: client enabled, server disabled" \
863 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000864 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100865 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000866 -s "dumping 'expected mac' (20 bytes)" \
867 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100868
Hanno Becker32c55012017-11-10 08:42:54 +0000869requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000870run_test "Truncated HMAC: client disabled, server enabled" \
871 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000872 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000873 0 \
874 -s "dumping 'expected mac' (20 bytes)" \
875 -S "dumping 'expected mac' (10 bytes)"
876
877requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100878run_test "Truncated HMAC: client enabled, server enabled" \
879 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000880 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100881 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000882 -S "dumping 'expected mac' (20 bytes)" \
883 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100884
Hanno Becker4c4f4102017-11-10 09:16:05 +0000885run_test "Truncated HMAC, DTLS: client default, server default" \
886 "$P_SRV dtls=1 debug_level=4" \
887 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
888 0 \
889 -s "dumping 'expected mac' (20 bytes)" \
890 -S "dumping 'expected mac' (10 bytes)"
891
892requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
893run_test "Truncated HMAC, DTLS: client disabled, server default" \
894 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000895 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000896 0 \
897 -s "dumping 'expected mac' (20 bytes)" \
898 -S "dumping 'expected mac' (10 bytes)"
899
900requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
901run_test "Truncated HMAC, DTLS: client enabled, server default" \
902 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000903 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000904 0 \
905 -s "dumping 'expected mac' (20 bytes)" \
906 -S "dumping 'expected mac' (10 bytes)"
907
908requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
909run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
910 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000911 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000912 0 \
913 -s "dumping 'expected mac' (20 bytes)" \
914 -S "dumping 'expected mac' (10 bytes)"
915
916requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
917run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
918 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000919 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000920 0 \
921 -s "dumping 'expected mac' (20 bytes)" \
922 -S "dumping 'expected mac' (10 bytes)"
923
924requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
925run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
926 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000927 "$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 +0100928 0 \
929 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100930 -s "dumping 'expected mac' (10 bytes)"
931
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100932# Tests for Encrypt-then-MAC extension
933
934run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100935 "$P_SRV debug_level=3 \
936 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100937 "$P_CLI debug_level=3" \
938 0 \
939 -c "client hello, adding encrypt_then_mac extension" \
940 -s "found encrypt then mac extension" \
941 -s "server hello, adding encrypt then mac extension" \
942 -c "found encrypt_then_mac extension" \
943 -c "using encrypt then mac" \
944 -s "using encrypt then mac"
945
946run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100947 "$P_SRV debug_level=3 etm=0 \
948 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100949 "$P_CLI debug_level=3 etm=1" \
950 0 \
951 -c "client hello, adding encrypt_then_mac extension" \
952 -s "found encrypt then mac extension" \
953 -S "server hello, adding encrypt then mac extension" \
954 -C "found encrypt_then_mac extension" \
955 -C "using encrypt then mac" \
956 -S "using encrypt then mac"
957
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100958run_test "Encrypt then MAC: client enabled, aead cipher" \
959 "$P_SRV debug_level=3 etm=1 \
960 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
961 "$P_CLI debug_level=3 etm=1" \
962 0 \
963 -c "client hello, adding encrypt_then_mac extension" \
964 -s "found encrypt then mac extension" \
965 -S "server hello, adding encrypt then mac extension" \
966 -C "found encrypt_then_mac extension" \
967 -C "using encrypt then mac" \
968 -S "using encrypt then mac"
969
970run_test "Encrypt then MAC: client enabled, stream cipher" \
971 "$P_SRV debug_level=3 etm=1 \
972 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100973 "$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 +0100974 0 \
975 -c "client hello, adding encrypt_then_mac extension" \
976 -s "found encrypt then mac extension" \
977 -S "server hello, adding encrypt then mac extension" \
978 -C "found encrypt_then_mac extension" \
979 -C "using encrypt then mac" \
980 -S "using encrypt then mac"
981
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100982run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100983 "$P_SRV debug_level=3 etm=1 \
984 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100985 "$P_CLI debug_level=3 etm=0" \
986 0 \
987 -C "client hello, adding encrypt_then_mac extension" \
988 -S "found encrypt then mac extension" \
989 -S "server hello, adding encrypt then mac extension" \
990 -C "found encrypt_then_mac extension" \
991 -C "using encrypt then mac" \
992 -S "using encrypt then mac"
993
Janos Follathe2681a42016-03-07 15:57:05 +0000994requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100995run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100996 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100997 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100998 "$P_CLI debug_level=3 force_version=ssl3" \
999 0 \
1000 -C "client hello, adding encrypt_then_mac extension" \
1001 -S "found encrypt then mac extension" \
1002 -S "server hello, adding encrypt then mac extension" \
1003 -C "found encrypt_then_mac extension" \
1004 -C "using encrypt then mac" \
1005 -S "using encrypt then mac"
1006
Janos Follathe2681a42016-03-07 15:57:05 +00001007requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001008run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001009 "$P_SRV debug_level=3 force_version=ssl3 \
1010 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001011 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001012 0 \
1013 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001014 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001015 -S "server hello, adding encrypt then mac extension" \
1016 -C "found encrypt_then_mac extension" \
1017 -C "using encrypt then mac" \
1018 -S "using encrypt then mac"
1019
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001020# Tests for Extended Master Secret extension
1021
1022run_test "Extended Master Secret: default" \
1023 "$P_SRV debug_level=3" \
1024 "$P_CLI debug_level=3" \
1025 0 \
1026 -c "client hello, adding extended_master_secret extension" \
1027 -s "found extended master secret extension" \
1028 -s "server hello, adding extended master secret extension" \
1029 -c "found extended_master_secret extension" \
1030 -c "using extended master secret" \
1031 -s "using extended master secret"
1032
1033run_test "Extended Master Secret: client enabled, server disabled" \
1034 "$P_SRV debug_level=3 extended_ms=0" \
1035 "$P_CLI debug_level=3 extended_ms=1" \
1036 0 \
1037 -c "client hello, adding extended_master_secret extension" \
1038 -s "found extended master secret extension" \
1039 -S "server hello, adding extended master secret extension" \
1040 -C "found extended_master_secret extension" \
1041 -C "using extended master secret" \
1042 -S "using extended master secret"
1043
1044run_test "Extended Master Secret: client disabled, server enabled" \
1045 "$P_SRV debug_level=3 extended_ms=1" \
1046 "$P_CLI debug_level=3 extended_ms=0" \
1047 0 \
1048 -C "client hello, adding extended_master_secret extension" \
1049 -S "found extended master secret extension" \
1050 -S "server hello, adding extended master secret extension" \
1051 -C "found extended_master_secret extension" \
1052 -C "using extended master secret" \
1053 -S "using extended master secret"
1054
Janos Follathe2681a42016-03-07 15:57:05 +00001055requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001056run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001057 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001058 "$P_CLI debug_level=3 force_version=ssl3" \
1059 0 \
1060 -C "client hello, adding extended_master_secret extension" \
1061 -S "found extended master secret extension" \
1062 -S "server hello, adding extended master secret extension" \
1063 -C "found extended_master_secret extension" \
1064 -C "using extended master secret" \
1065 -S "using extended master secret"
1066
Janos Follathe2681a42016-03-07 15:57:05 +00001067requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001068run_test "Extended Master Secret: client enabled, server SSLv3" \
1069 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001070 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001071 0 \
1072 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001073 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001074 -S "server hello, adding extended master secret extension" \
1075 -C "found extended_master_secret extension" \
1076 -C "using extended master secret" \
1077 -S "using extended master secret"
1078
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001079# Tests for FALLBACK_SCSV
1080
1081run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001082 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001083 "$P_CLI debug_level=3 force_version=tls1_1" \
1084 0 \
1085 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001086 -S "received FALLBACK_SCSV" \
1087 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001088 -C "is a fatal alert message (msg 86)"
1089
1090run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001091 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001092 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1093 0 \
1094 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001095 -S "received FALLBACK_SCSV" \
1096 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001097 -C "is a fatal alert message (msg 86)"
1098
1099run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001100 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001101 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001102 1 \
1103 -c "adding FALLBACK_SCSV" \
1104 -s "received FALLBACK_SCSV" \
1105 -s "inapropriate fallback" \
1106 -c "is a fatal alert message (msg 86)"
1107
1108run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001109 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001110 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001111 0 \
1112 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001113 -s "received FALLBACK_SCSV" \
1114 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001115 -C "is a fatal alert message (msg 86)"
1116
1117requires_openssl_with_fallback_scsv
1118run_test "Fallback SCSV: default, openssl server" \
1119 "$O_SRV" \
1120 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1121 0 \
1122 -C "adding FALLBACK_SCSV" \
1123 -C "is a fatal alert message (msg 86)"
1124
1125requires_openssl_with_fallback_scsv
1126run_test "Fallback SCSV: enabled, openssl server" \
1127 "$O_SRV" \
1128 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1129 1 \
1130 -c "adding FALLBACK_SCSV" \
1131 -c "is a fatal alert message (msg 86)"
1132
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001133requires_openssl_with_fallback_scsv
1134run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001135 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001136 "$O_CLI -tls1_1" \
1137 0 \
1138 -S "received FALLBACK_SCSV" \
1139 -S "inapropriate fallback"
1140
1141requires_openssl_with_fallback_scsv
1142run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001143 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001144 "$O_CLI -tls1_1 -fallback_scsv" \
1145 1 \
1146 -s "received FALLBACK_SCSV" \
1147 -s "inapropriate fallback"
1148
1149requires_openssl_with_fallback_scsv
1150run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001151 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001152 "$O_CLI -fallback_scsv" \
1153 0 \
1154 -s "received FALLBACK_SCSV" \
1155 -S "inapropriate fallback"
1156
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001157# Test sending and receiving empty application data records
1158
1159run_test "Encrypt then MAC: empty application data record" \
1160 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1161 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1162 0 \
1163 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1164 -s "dumping 'input payload after decrypt' (0 bytes)" \
1165 -c "0 bytes written in 1 fragments"
1166
1167run_test "Default, no Encrypt then MAC: empty application data record" \
1168 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1169 "$P_CLI auth_mode=none etm=0 request_size=0" \
1170 0 \
1171 -s "dumping 'input payload after decrypt' (0 bytes)" \
1172 -c "0 bytes written in 1 fragments"
1173
1174run_test "Encrypt then MAC, DTLS: empty application data record" \
1175 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1176 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1177 0 \
1178 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1179 -s "dumping 'input payload after decrypt' (0 bytes)" \
1180 -c "0 bytes written in 1 fragments"
1181
1182run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
1183 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1184 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1185 0 \
1186 -s "dumping 'input payload after decrypt' (0 bytes)" \
1187 -c "0 bytes written in 1 fragments"
1188
Gilles Peskined50177f2017-05-16 17:53:03 +02001189## ClientHello generated with
1190## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1191## then manually twiddling the ciphersuite list.
1192## The ClientHello content is spelled out below as a hex string as
1193## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1194## The expected response is an inappropriate_fallback alert.
1195requires_openssl_with_fallback_scsv
1196run_test "Fallback SCSV: beginning of list" \
1197 "$P_SRV debug_level=2" \
1198 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1199 0 \
1200 -s "received FALLBACK_SCSV" \
1201 -s "inapropriate fallback"
1202
1203requires_openssl_with_fallback_scsv
1204run_test "Fallback SCSV: end of list" \
1205 "$P_SRV debug_level=2" \
1206 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1207 0 \
1208 -s "received FALLBACK_SCSV" \
1209 -s "inapropriate fallback"
1210
1211## Here the expected response is a valid ServerHello prefix, up to the random.
1212requires_openssl_with_fallback_scsv
1213run_test "Fallback SCSV: not in list" \
1214 "$P_SRV debug_level=2" \
1215 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1216 0 \
1217 -S "received FALLBACK_SCSV" \
1218 -S "inapropriate fallback"
1219
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001220# Tests for CBC 1/n-1 record splitting
1221
1222run_test "CBC Record splitting: TLS 1.2, no splitting" \
1223 "$P_SRV" \
1224 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1225 request_size=123 force_version=tls1_2" \
1226 0 \
1227 -s "Read from client: 123 bytes read" \
1228 -S "Read from client: 1 bytes read" \
1229 -S "122 bytes read"
1230
1231run_test "CBC Record splitting: TLS 1.1, no splitting" \
1232 "$P_SRV" \
1233 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1234 request_size=123 force_version=tls1_1" \
1235 0 \
1236 -s "Read from client: 123 bytes read" \
1237 -S "Read from client: 1 bytes read" \
1238 -S "122 bytes read"
1239
1240run_test "CBC Record splitting: TLS 1.0, splitting" \
1241 "$P_SRV" \
1242 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1243 request_size=123 force_version=tls1" \
1244 0 \
1245 -S "Read from client: 123 bytes read" \
1246 -s "Read from client: 1 bytes read" \
1247 -s "122 bytes read"
1248
Janos Follathe2681a42016-03-07 15:57:05 +00001249requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001250run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001251 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001252 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1253 request_size=123 force_version=ssl3" \
1254 0 \
1255 -S "Read from client: 123 bytes read" \
1256 -s "Read from client: 1 bytes read" \
1257 -s "122 bytes read"
1258
1259run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001260 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001261 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1262 request_size=123 force_version=tls1" \
1263 0 \
1264 -s "Read from client: 123 bytes read" \
1265 -S "Read from client: 1 bytes read" \
1266 -S "122 bytes read"
1267
1268run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1269 "$P_SRV" \
1270 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1271 request_size=123 force_version=tls1 recsplit=0" \
1272 0 \
1273 -s "Read from client: 123 bytes read" \
1274 -S "Read from client: 1 bytes read" \
1275 -S "122 bytes read"
1276
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001277run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1278 "$P_SRV nbio=2" \
1279 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1280 request_size=123 force_version=tls1" \
1281 0 \
1282 -S "Read from client: 123 bytes read" \
1283 -s "Read from client: 1 bytes read" \
1284 -s "122 bytes read"
1285
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001286# Tests for Session Tickets
1287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001288run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001289 "$P_SRV debug_level=3 tickets=1" \
1290 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001291 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001292 -c "client hello, adding session ticket extension" \
1293 -s "found session ticket extension" \
1294 -s "server hello, adding session ticket extension" \
1295 -c "found session_ticket extension" \
1296 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001297 -S "session successfully restored from cache" \
1298 -s "session successfully restored from ticket" \
1299 -s "a session has been resumed" \
1300 -c "a session has been resumed"
1301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001302run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001303 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1304 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001305 0 \
1306 -c "client hello, adding session ticket extension" \
1307 -s "found session ticket extension" \
1308 -s "server hello, adding session ticket extension" \
1309 -c "found session_ticket extension" \
1310 -c "parse new session ticket" \
1311 -S "session successfully restored from cache" \
1312 -s "session successfully restored from ticket" \
1313 -s "a session has been resumed" \
1314 -c "a session has been resumed"
1315
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001316run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001317 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1318 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001319 0 \
1320 -c "client hello, adding session ticket extension" \
1321 -s "found session ticket extension" \
1322 -s "server hello, adding session ticket extension" \
1323 -c "found session_ticket extension" \
1324 -c "parse new session ticket" \
1325 -S "session successfully restored from cache" \
1326 -S "session successfully restored from ticket" \
1327 -S "a session has been resumed" \
1328 -C "a session has been resumed"
1329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001330run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001331 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001332 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001333 0 \
1334 -c "client hello, adding session ticket extension" \
1335 -c "found session_ticket extension" \
1336 -c "parse new session ticket" \
1337 -c "a session has been resumed"
1338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001339run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001340 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001341 "( $O_CLI -sess_out $SESSION; \
1342 $O_CLI -sess_in $SESSION; \
1343 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001344 0 \
1345 -s "found session ticket extension" \
1346 -s "server hello, adding session ticket extension" \
1347 -S "session successfully restored from cache" \
1348 -s "session successfully restored from ticket" \
1349 -s "a session has been resumed"
1350
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001351# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001353run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001354 "$P_SRV debug_level=3 tickets=0" \
1355 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001356 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001357 -c "client hello, adding session ticket extension" \
1358 -s "found session ticket extension" \
1359 -S "server hello, adding session ticket extension" \
1360 -C "found session_ticket extension" \
1361 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001362 -s "session successfully restored from cache" \
1363 -S "session successfully restored from ticket" \
1364 -s "a session has been resumed" \
1365 -c "a session has been resumed"
1366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001367run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001368 "$P_SRV debug_level=3 tickets=1" \
1369 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001370 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001371 -C "client hello, adding session ticket extension" \
1372 -S "found session ticket extension" \
1373 -S "server hello, adding session ticket extension" \
1374 -C "found session_ticket extension" \
1375 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001376 -s "session successfully restored from cache" \
1377 -S "session successfully restored from ticket" \
1378 -s "a session has been resumed" \
1379 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001381run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001382 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1383 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001384 0 \
1385 -S "session successfully restored from cache" \
1386 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001387 -S "a session has been resumed" \
1388 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001390run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001391 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1392 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001393 0 \
1394 -s "session successfully restored from cache" \
1395 -S "session successfully restored from ticket" \
1396 -s "a session has been resumed" \
1397 -c "a session has been resumed"
1398
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001399run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001400 "$P_SRV debug_level=3 tickets=0" \
1401 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001402 0 \
1403 -s "session successfully restored from cache" \
1404 -S "session successfully restored from ticket" \
1405 -s "a session has been resumed" \
1406 -c "a session has been resumed"
1407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001408run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001409 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1410 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001411 0 \
1412 -S "session successfully restored from cache" \
1413 -S "session successfully restored from ticket" \
1414 -S "a session has been resumed" \
1415 -C "a session has been resumed"
1416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001417run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001418 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1419 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001420 0 \
1421 -s "session successfully restored from cache" \
1422 -S "session successfully restored from ticket" \
1423 -s "a session has been resumed" \
1424 -c "a session has been resumed"
1425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001426run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001427 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001428 "( $O_CLI -sess_out $SESSION; \
1429 $O_CLI -sess_in $SESSION; \
1430 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001431 0 \
1432 -s "found session ticket extension" \
1433 -S "server hello, adding session ticket extension" \
1434 -s "session successfully restored from cache" \
1435 -S "session successfully restored from ticket" \
1436 -s "a session has been resumed"
1437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001438run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001439 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001440 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001441 0 \
1442 -C "found session_ticket extension" \
1443 -C "parse new session ticket" \
1444 -c "a session has been resumed"
1445
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001446# Tests for Max Fragment Length extension
1447
Hanno Becker6428f8d2017-09-22 16:58:50 +01001448MAX_CONTENT_LEN_EXPECT='16384'
1449MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1450
1451if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1452 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1453 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1454 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1455 printf "\n"
1456 printf "The tests assume this value and if it changes, the tests in this\n"
1457 printf "script should also be adjusted.\n"
1458 printf "\n"
1459
1460 exit 1
1461fi
1462
Hanno Becker4aed27e2017-09-18 15:00:34 +01001463requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001464run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001465 "$P_SRV debug_level=3" \
1466 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001467 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001468 -c "Maximum fragment length is 16384" \
1469 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001470 -C "client hello, adding max_fragment_length extension" \
1471 -S "found max fragment length extension" \
1472 -S "server hello, max_fragment_length extension" \
1473 -C "found max_fragment_length extension"
1474
Hanno Becker4aed27e2017-09-18 15:00:34 +01001475requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001476run_test "Max fragment length: enabled, default, larger message" \
1477 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001478 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001479 0 \
1480 -c "Maximum fragment length is 16384" \
1481 -s "Maximum fragment length is 16384" \
1482 -C "client hello, adding max_fragment_length extension" \
1483 -S "found max fragment length extension" \
1484 -S "server hello, max_fragment_length extension" \
1485 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001486 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001487 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001488 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001489
1490requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1491run_test "Max fragment length, DTLS: enabled, default, larger message" \
1492 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001493 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001494 1 \
1495 -c "Maximum fragment length is 16384" \
1496 -s "Maximum fragment length is 16384" \
1497 -C "client hello, adding max_fragment_length extension" \
1498 -S "found max fragment length extension" \
1499 -S "server hello, max_fragment_length extension" \
1500 -C "found max_fragment_length extension" \
1501 -c "fragment larger than.*maximum "
1502
1503requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1504run_test "Max fragment length: disabled, larger message" \
1505 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001506 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001507 0 \
1508 -C "Maximum fragment length is 16384" \
1509 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001510 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001511 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001512 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001513
1514requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1515run_test "Max fragment length DTLS: disabled, larger message" \
1516 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001517 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001518 1 \
1519 -C "Maximum fragment length is 16384" \
1520 -S "Maximum fragment length is 16384" \
1521 -c "fragment larger than.*maximum "
1522
1523requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001524run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_SRV debug_level=3" \
1526 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001527 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001528 -c "Maximum fragment length is 4096" \
1529 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001530 -c "client hello, adding max_fragment_length extension" \
1531 -s "found max fragment length extension" \
1532 -s "server hello, max_fragment_length extension" \
1533 -c "found max_fragment_length extension"
1534
Hanno Becker4aed27e2017-09-18 15:00:34 +01001535requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001536run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001537 "$P_SRV debug_level=3 max_frag_len=4096" \
1538 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001539 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001540 -c "Maximum fragment length is 16384" \
1541 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001542 -C "client hello, adding max_fragment_length extension" \
1543 -S "found max fragment length extension" \
1544 -S "server hello, max_fragment_length extension" \
1545 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001546
Hanno Becker4aed27e2017-09-18 15:00:34 +01001547requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001548requires_gnutls
1549run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001550 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001551 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001552 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001553 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001554 -c "client hello, adding max_fragment_length extension" \
1555 -c "found max_fragment_length extension"
1556
Hanno Becker4aed27e2017-09-18 15:00:34 +01001557requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001558run_test "Max fragment length: client, message just fits" \
1559 "$P_SRV debug_level=3" \
1560 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1561 0 \
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 "2048 bytes written in 1 fragments" \
1569 -s "2048 bytes read"
1570
Hanno Becker4aed27e2017-09-18 15:00:34 +01001571requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001572run_test "Max fragment length: client, larger message" \
1573 "$P_SRV debug_level=3" \
1574 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1575 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001576 -c "Maximum fragment length is 2048" \
1577 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001578 -c "client hello, adding max_fragment_length extension" \
1579 -s "found max fragment length extension" \
1580 -s "server hello, max_fragment_length extension" \
1581 -c "found max_fragment_length extension" \
1582 -c "2345 bytes written in 2 fragments" \
1583 -s "2048 bytes read" \
1584 -s "297 bytes read"
1585
Hanno Becker4aed27e2017-09-18 15:00:34 +01001586requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001587run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001588 "$P_SRV debug_level=3 dtls=1" \
1589 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1590 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001591 -c "Maximum fragment length is 2048" \
1592 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001593 -c "client hello, adding max_fragment_length extension" \
1594 -s "found max fragment length extension" \
1595 -s "server hello, max_fragment_length extension" \
1596 -c "found max_fragment_length extension" \
1597 -c "fragment larger than.*maximum"
1598
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001599# Tests for renegotiation
1600
Hanno Becker6a243642017-10-12 15:18:45 +01001601# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001602run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001603 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001604 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001605 0 \
1606 -C "client hello, adding renegotiation extension" \
1607 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1608 -S "found renegotiation extension" \
1609 -s "server hello, secure renegotiation extension" \
1610 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001611 -C "=> renegotiate" \
1612 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001613 -S "write hello request"
1614
Hanno Becker6a243642017-10-12 15:18:45 +01001615requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001616run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001617 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001618 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001619 0 \
1620 -c "client hello, adding renegotiation extension" \
1621 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1622 -s "found renegotiation extension" \
1623 -s "server hello, secure renegotiation extension" \
1624 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001625 -c "=> renegotiate" \
1626 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001627 -S "write hello request"
1628
Hanno Becker6a243642017-10-12 15:18:45 +01001629requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001630run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001631 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001632 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001633 0 \
1634 -c "client hello, adding renegotiation extension" \
1635 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1636 -s "found renegotiation extension" \
1637 -s "server hello, secure renegotiation extension" \
1638 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001639 -c "=> renegotiate" \
1640 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001641 -s "write hello request"
1642
Janos Follathb0f148c2017-10-05 12:29:42 +01001643# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1644# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1645# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001646requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001647run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1648 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1649 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1650 0 \
1651 -c "client hello, adding renegotiation extension" \
1652 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1653 -s "found renegotiation extension" \
1654 -s "server hello, secure renegotiation extension" \
1655 -c "found renegotiation extension" \
1656 -c "=> renegotiate" \
1657 -s "=> renegotiate" \
1658 -S "write hello request" \
1659 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1660
1661# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1662# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1663# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001664requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001665run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1666 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1667 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1668 0 \
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" \
1674 -c "=> renegotiate" \
1675 -s "=> renegotiate" \
1676 -s "write hello request" \
1677 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1678
Hanno Becker6a243642017-10-12 15:18:45 +01001679requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001680run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001681 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001682 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001683 0 \
1684 -c "client hello, adding renegotiation extension" \
1685 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1686 -s "found renegotiation extension" \
1687 -s "server hello, secure renegotiation extension" \
1688 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001689 -c "=> renegotiate" \
1690 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001691 -s "write hello request"
1692
Hanno Becker6a243642017-10-12 15:18:45 +01001693requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001694run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001695 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001696 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001697 1 \
1698 -c "client hello, adding renegotiation extension" \
1699 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1700 -S "found renegotiation extension" \
1701 -s "server hello, secure renegotiation extension" \
1702 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001703 -c "=> renegotiate" \
1704 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001705 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001706 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001707 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001708
Hanno Becker6a243642017-10-12 15:18:45 +01001709requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001710run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001711 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001712 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001713 0 \
1714 -C "client hello, adding renegotiation extension" \
1715 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1716 -S "found renegotiation extension" \
1717 -s "server hello, secure renegotiation extension" \
1718 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001719 -C "=> renegotiate" \
1720 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001721 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001722 -S "SSL - An unexpected message was received from our peer" \
1723 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001724
Hanno Becker6a243642017-10-12 15:18:45 +01001725requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001727 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001728 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001729 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001730 0 \
1731 -C "client hello, adding renegotiation extension" \
1732 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1733 -S "found renegotiation extension" \
1734 -s "server hello, secure renegotiation extension" \
1735 -c "found renegotiation extension" \
1736 -C "=> renegotiate" \
1737 -S "=> renegotiate" \
1738 -s "write hello request" \
1739 -S "SSL - An unexpected message was received from our peer" \
1740 -S "failed"
1741
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001742# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001743requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001744run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001745 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001746 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001747 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001748 0 \
1749 -C "client hello, adding renegotiation extension" \
1750 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1751 -S "found renegotiation extension" \
1752 -s "server hello, secure renegotiation extension" \
1753 -c "found renegotiation extension" \
1754 -C "=> renegotiate" \
1755 -S "=> renegotiate" \
1756 -s "write hello request" \
1757 -S "SSL - An unexpected message was received from our peer" \
1758 -S "failed"
1759
Hanno Becker6a243642017-10-12 15:18:45 +01001760requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001761run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001762 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001763 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001764 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001765 0 \
1766 -C "client hello, adding renegotiation extension" \
1767 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1768 -S "found renegotiation extension" \
1769 -s "server hello, secure renegotiation extension" \
1770 -c "found renegotiation extension" \
1771 -C "=> renegotiate" \
1772 -S "=> renegotiate" \
1773 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001774 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001775
Hanno Becker6a243642017-10-12 15:18:45 +01001776requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001778 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001779 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001780 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001781 0 \
1782 -c "client hello, adding renegotiation extension" \
1783 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1784 -s "found renegotiation extension" \
1785 -s "server hello, secure renegotiation extension" \
1786 -c "found renegotiation extension" \
1787 -c "=> renegotiate" \
1788 -s "=> renegotiate" \
1789 -s "write hello request" \
1790 -S "SSL - An unexpected message was received from our peer" \
1791 -S "failed"
1792
Hanno Becker6a243642017-10-12 15:18:45 +01001793requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001794run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001795 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001796 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1797 0 \
1798 -C "client hello, adding renegotiation extension" \
1799 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1800 -S "found renegotiation extension" \
1801 -s "server hello, secure renegotiation extension" \
1802 -c "found renegotiation extension" \
1803 -S "record counter limit reached: renegotiate" \
1804 -C "=> renegotiate" \
1805 -S "=> renegotiate" \
1806 -S "write hello request" \
1807 -S "SSL - An unexpected message was received from our peer" \
1808 -S "failed"
1809
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001810# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001811requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001812run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001813 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001814 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001815 0 \
1816 -c "client hello, adding renegotiation extension" \
1817 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1818 -s "found renegotiation extension" \
1819 -s "server hello, secure renegotiation extension" \
1820 -c "found renegotiation extension" \
1821 -s "record counter limit reached: renegotiate" \
1822 -c "=> renegotiate" \
1823 -s "=> renegotiate" \
1824 -s "write hello request" \
1825 -S "SSL - An unexpected message was received from our peer" \
1826 -S "failed"
1827
Hanno Becker6a243642017-10-12 15:18:45 +01001828requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001829run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001830 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001831 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001832 0 \
1833 -c "client hello, adding renegotiation extension" \
1834 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1835 -s "found renegotiation extension" \
1836 -s "server hello, secure renegotiation extension" \
1837 -c "found renegotiation extension" \
1838 -s "record counter limit reached: renegotiate" \
1839 -c "=> renegotiate" \
1840 -s "=> renegotiate" \
1841 -s "write hello request" \
1842 -S "SSL - An unexpected message was received from our peer" \
1843 -S "failed"
1844
Hanno Becker6a243642017-10-12 15:18:45 +01001845requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001846run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001847 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001848 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1849 0 \
1850 -C "client hello, adding renegotiation extension" \
1851 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1852 -S "found renegotiation extension" \
1853 -s "server hello, secure renegotiation extension" \
1854 -c "found renegotiation extension" \
1855 -S "record counter limit reached: renegotiate" \
1856 -C "=> renegotiate" \
1857 -S "=> renegotiate" \
1858 -S "write hello request" \
1859 -S "SSL - An unexpected message was received from our peer" \
1860 -S "failed"
1861
Hanno Becker6a243642017-10-12 15:18:45 +01001862requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001863run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001864 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001865 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001866 0 \
1867 -c "client hello, adding renegotiation extension" \
1868 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1869 -s "found renegotiation extension" \
1870 -s "server hello, secure renegotiation extension" \
1871 -c "found renegotiation extension" \
1872 -c "=> renegotiate" \
1873 -s "=> renegotiate" \
1874 -S "write hello request"
1875
Hanno Becker6a243642017-10-12 15:18:45 +01001876requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001877run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001878 "$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 +02001879 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001880 0 \
1881 -c "client hello, adding renegotiation extension" \
1882 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1883 -s "found renegotiation extension" \
1884 -s "server hello, secure renegotiation extension" \
1885 -c "found renegotiation extension" \
1886 -c "=> renegotiate" \
1887 -s "=> renegotiate" \
1888 -s "write hello request"
1889
Hanno Becker6a243642017-10-12 15:18:45 +01001890requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001891run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001892 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001893 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001894 0 \
1895 -c "client hello, adding renegotiation extension" \
1896 -c "found renegotiation extension" \
1897 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001898 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001899 -C "error" \
1900 -c "HTTP/1.0 200 [Oo][Kk]"
1901
Paul Bakker539d9722015-02-08 16:18:35 +01001902requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001903requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001904run_test "Renegotiation: gnutls server strict, client-initiated" \
1905 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001906 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001907 0 \
1908 -c "client hello, adding renegotiation extension" \
1909 -c "found renegotiation extension" \
1910 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001911 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001912 -C "error" \
1913 -c "HTTP/1.0 200 [Oo][Kk]"
1914
Paul Bakker539d9722015-02-08 16:18:35 +01001915requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001916requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001917run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1918 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1919 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1920 1 \
1921 -c "client hello, adding renegotiation extension" \
1922 -C "found renegotiation extension" \
1923 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001924 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001925 -c "error" \
1926 -C "HTTP/1.0 200 [Oo][Kk]"
1927
Paul Bakker539d9722015-02-08 16:18:35 +01001928requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001929requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001930run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1931 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1932 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1933 allow_legacy=0" \
1934 1 \
1935 -c "client hello, adding renegotiation extension" \
1936 -C "found renegotiation extension" \
1937 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001938 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001939 -c "error" \
1940 -C "HTTP/1.0 200 [Oo][Kk]"
1941
Paul Bakker539d9722015-02-08 16:18:35 +01001942requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001943requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001944run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1945 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1946 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1947 allow_legacy=1" \
1948 0 \
1949 -c "client hello, adding renegotiation extension" \
1950 -C "found renegotiation extension" \
1951 -c "=> renegotiate" \
1952 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001953 -C "error" \
1954 -c "HTTP/1.0 200 [Oo][Kk]"
1955
Hanno Becker6a243642017-10-12 15:18:45 +01001956requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001957run_test "Renegotiation: DTLS, client-initiated" \
1958 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1959 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=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 -c "found renegotiation extension" \
1966 -c "=> renegotiate" \
1967 -s "=> renegotiate" \
1968 -S "write hello request"
1969
Hanno Becker6a243642017-10-12 15:18:45 +01001970requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001971run_test "Renegotiation: DTLS, server-initiated" \
1972 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001973 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1974 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001975 0 \
1976 -c "client hello, adding renegotiation extension" \
1977 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1978 -s "found renegotiation extension" \
1979 -s "server hello, secure renegotiation extension" \
1980 -c "found renegotiation extension" \
1981 -c "=> renegotiate" \
1982 -s "=> renegotiate" \
1983 -s "write hello request"
1984
Hanno Becker6a243642017-10-12 15:18:45 +01001985requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00001986run_test "Renegotiation: DTLS, renego_period overflow" \
1987 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1988 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1989 0 \
1990 -c "client hello, adding renegotiation extension" \
1991 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1992 -s "found renegotiation extension" \
1993 -s "server hello, secure renegotiation extension" \
1994 -s "record counter limit reached: renegotiate" \
1995 -c "=> renegotiate" \
1996 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01001997 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00001998
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001999requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002000requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002001run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2002 "$G_SRV -u --mtu 4096" \
2003 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2004 0 \
2005 -c "client hello, adding renegotiation extension" \
2006 -c "found renegotiation extension" \
2007 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002008 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002009 -C "error" \
2010 -s "Extra-header:"
2011
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002012# Test for the "secure renegotation" extension only (no actual renegotiation)
2013
Paul Bakker539d9722015-02-08 16:18:35 +01002014requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002015run_test "Renego ext: gnutls server strict, client default" \
2016 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2017 "$P_CLI debug_level=3" \
2018 0 \
2019 -c "found renegotiation extension" \
2020 -C "error" \
2021 -c "HTTP/1.0 200 [Oo][Kk]"
2022
Paul Bakker539d9722015-02-08 16:18:35 +01002023requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002024run_test "Renego ext: gnutls server unsafe, client default" \
2025 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2026 "$P_CLI debug_level=3" \
2027 0 \
2028 -C "found renegotiation extension" \
2029 -C "error" \
2030 -c "HTTP/1.0 200 [Oo][Kk]"
2031
Paul Bakker539d9722015-02-08 16:18:35 +01002032requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002033run_test "Renego ext: gnutls server unsafe, client break legacy" \
2034 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2035 "$P_CLI debug_level=3 allow_legacy=-1" \
2036 1 \
2037 -C "found renegotiation extension" \
2038 -c "error" \
2039 -C "HTTP/1.0 200 [Oo][Kk]"
2040
Paul Bakker539d9722015-02-08 16:18:35 +01002041requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002042run_test "Renego ext: gnutls client strict, server default" \
2043 "$P_SRV debug_level=3" \
2044 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2045 0 \
2046 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2047 -s "server hello, secure renegotiation extension"
2048
Paul Bakker539d9722015-02-08 16:18:35 +01002049requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002050run_test "Renego ext: gnutls client unsafe, server default" \
2051 "$P_SRV debug_level=3" \
2052 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2053 0 \
2054 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2055 -S "server hello, secure renegotiation extension"
2056
Paul Bakker539d9722015-02-08 16:18:35 +01002057requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002058run_test "Renego ext: gnutls client unsafe, server break legacy" \
2059 "$P_SRV debug_level=3 allow_legacy=-1" \
2060 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2061 1 \
2062 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2063 -S "server hello, secure renegotiation extension"
2064
Janos Follath0b242342016-02-17 10:11:21 +00002065# Tests for silently dropping trailing extra bytes in .der certificates
2066
2067requires_gnutls
2068run_test "DER format: no trailing bytes" \
2069 "$P_SRV crt_file=data_files/server5-der0.crt \
2070 key_file=data_files/server5.key" \
2071 "$G_CLI " \
2072 0 \
2073 -c "Handshake was completed" \
2074
2075requires_gnutls
2076run_test "DER format: with a trailing zero byte" \
2077 "$P_SRV crt_file=data_files/server5-der1a.crt \
2078 key_file=data_files/server5.key" \
2079 "$G_CLI " \
2080 0 \
2081 -c "Handshake was completed" \
2082
2083requires_gnutls
2084run_test "DER format: with a trailing random byte" \
2085 "$P_SRV crt_file=data_files/server5-der1b.crt \
2086 key_file=data_files/server5.key" \
2087 "$G_CLI " \
2088 0 \
2089 -c "Handshake was completed" \
2090
2091requires_gnutls
2092run_test "DER format: with 2 trailing random bytes" \
2093 "$P_SRV crt_file=data_files/server5-der2.crt \
2094 key_file=data_files/server5.key" \
2095 "$G_CLI " \
2096 0 \
2097 -c "Handshake was completed" \
2098
2099requires_gnutls
2100run_test "DER format: with 4 trailing random bytes" \
2101 "$P_SRV crt_file=data_files/server5-der4.crt \
2102 key_file=data_files/server5.key" \
2103 "$G_CLI " \
2104 0 \
2105 -c "Handshake was completed" \
2106
2107requires_gnutls
2108run_test "DER format: with 8 trailing random bytes" \
2109 "$P_SRV crt_file=data_files/server5-der8.crt \
2110 key_file=data_files/server5.key" \
2111 "$G_CLI " \
2112 0 \
2113 -c "Handshake was completed" \
2114
2115requires_gnutls
2116run_test "DER format: with 9 trailing random bytes" \
2117 "$P_SRV crt_file=data_files/server5-der9.crt \
2118 key_file=data_files/server5.key" \
2119 "$G_CLI " \
2120 0 \
2121 -c "Handshake was completed" \
2122
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002123# Tests for auth_mode
2124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002125run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002126 "$P_SRV crt_file=data_files/server5-badsign.crt \
2127 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002128 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002129 1 \
2130 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002131 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002132 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002133 -c "X509 - Certificate verification failed"
2134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002135run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002136 "$P_SRV crt_file=data_files/server5-badsign.crt \
2137 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002138 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002139 0 \
2140 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002141 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002142 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002143 -C "X509 - Certificate verification failed"
2144
Hanno Beckere6706e62017-05-15 16:05:15 +01002145run_test "Authentication: server goodcert, client optional, no trusted CA" \
2146 "$P_SRV" \
2147 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2148 0 \
2149 -c "x509_verify_cert() returned" \
2150 -c "! The certificate is not correctly signed by the trusted CA" \
2151 -c "! Certificate verification flags"\
2152 -C "! mbedtls_ssl_handshake returned" \
2153 -C "X509 - Certificate verification failed" \
2154 -C "SSL - No CA Chain is set, but required to operate"
2155
2156run_test "Authentication: server goodcert, client required, no trusted CA" \
2157 "$P_SRV" \
2158 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2159 1 \
2160 -c "x509_verify_cert() returned" \
2161 -c "! The certificate is not correctly signed by the trusted CA" \
2162 -c "! Certificate verification flags"\
2163 -c "! mbedtls_ssl_handshake returned" \
2164 -c "SSL - No CA Chain is set, but required to operate"
2165
2166# The purpose of the next two tests is to test the client's behaviour when receiving a server
2167# certificate with an unsupported elliptic curve. This should usually not happen because
2168# the client informs the server about the supported curves - it does, though, in the
2169# corner case of a static ECDH suite, because the server doesn't check the curve on that
2170# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2171# different means to have the server ignoring the client's supported curve list.
2172
2173requires_config_enabled MBEDTLS_ECP_C
2174run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2175 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2176 crt_file=data_files/server5.ku-ka.crt" \
2177 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2178 1 \
2179 -c "bad certificate (EC key curve)"\
2180 -c "! Certificate verification flags"\
2181 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2182
2183requires_config_enabled MBEDTLS_ECP_C
2184run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2185 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2186 crt_file=data_files/server5.ku-ka.crt" \
2187 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2188 1 \
2189 -c "bad certificate (EC key curve)"\
2190 -c "! Certificate verification flags"\
2191 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002193run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002194 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002195 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002196 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002197 0 \
2198 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002199 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002200 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002201 -C "X509 - Certificate verification failed"
2202
Simon Butcher99000142016-10-13 17:21:01 +01002203run_test "Authentication: client SHA256, server required" \
2204 "$P_SRV auth_mode=required" \
2205 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2206 key_file=data_files/server6.key \
2207 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2208 0 \
2209 -c "Supported Signature Algorithm found: 4," \
2210 -c "Supported Signature Algorithm found: 5,"
2211
2212run_test "Authentication: client SHA384, server required" \
2213 "$P_SRV auth_mode=required" \
2214 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2215 key_file=data_files/server6.key \
2216 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2217 0 \
2218 -c "Supported Signature Algorithm found: 4," \
2219 -c "Supported Signature Algorithm found: 5,"
2220
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002221requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2222run_test "Authentication: client has no cert, server required (SSLv3)" \
2223 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2224 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2225 key_file=data_files/server5.key" \
2226 1 \
2227 -S "skip write certificate request" \
2228 -C "skip parse certificate request" \
2229 -c "got a certificate request" \
2230 -c "got no certificate to send" \
2231 -S "x509_verify_cert() returned" \
2232 -s "client has no certificate" \
2233 -s "! mbedtls_ssl_handshake returned" \
2234 -c "! mbedtls_ssl_handshake returned" \
2235 -s "No client certification received from the client, but required by the authentication mode"
2236
2237run_test "Authentication: client has no cert, server required (TLS)" \
2238 "$P_SRV debug_level=3 auth_mode=required" \
2239 "$P_CLI debug_level=3 crt_file=none \
2240 key_file=data_files/server5.key" \
2241 1 \
2242 -S "skip write certificate request" \
2243 -C "skip parse certificate request" \
2244 -c "got a certificate request" \
2245 -c "= write certificate$" \
2246 -C "skip write certificate$" \
2247 -S "x509_verify_cert() returned" \
2248 -s "client has no certificate" \
2249 -s "! mbedtls_ssl_handshake returned" \
2250 -c "! mbedtls_ssl_handshake returned" \
2251 -s "No client certification received from the client, but required by the authentication mode"
2252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002253run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002254 "$P_SRV debug_level=3 auth_mode=required" \
2255 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002256 key_file=data_files/server5.key" \
2257 1 \
2258 -S "skip write certificate request" \
2259 -C "skip parse certificate request" \
2260 -c "got a certificate request" \
2261 -C "skip write certificate" \
2262 -C "skip write certificate verify" \
2263 -S "skip parse certificate verify" \
2264 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002265 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002266 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002267 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002268 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002269 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002270# We don't check that the client receives the alert because it might
2271# detect that its write end of the connection is closed and abort
2272# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002273
Janos Follath89baba22017-04-10 14:34:35 +01002274run_test "Authentication: client cert not trusted, server required" \
2275 "$P_SRV debug_level=3 auth_mode=required" \
2276 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2277 key_file=data_files/server5.key" \
2278 1 \
2279 -S "skip write certificate request" \
2280 -C "skip parse certificate request" \
2281 -c "got a certificate request" \
2282 -C "skip write certificate" \
2283 -C "skip write certificate verify" \
2284 -S "skip parse certificate verify" \
2285 -s "x509_verify_cert() returned" \
2286 -s "! The certificate is not correctly signed by the trusted CA" \
2287 -s "! mbedtls_ssl_handshake returned" \
2288 -c "! mbedtls_ssl_handshake returned" \
2289 -s "X509 - Certificate verification failed"
2290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002291run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002292 "$P_SRV debug_level=3 auth_mode=optional" \
2293 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002294 key_file=data_files/server5.key" \
2295 0 \
2296 -S "skip write certificate request" \
2297 -C "skip parse certificate request" \
2298 -c "got a certificate request" \
2299 -C "skip write certificate" \
2300 -C "skip write certificate verify" \
2301 -S "skip parse certificate verify" \
2302 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002303 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002304 -S "! mbedtls_ssl_handshake returned" \
2305 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002306 -S "X509 - Certificate verification failed"
2307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002308run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002309 "$P_SRV debug_level=3 auth_mode=none" \
2310 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002311 key_file=data_files/server5.key" \
2312 0 \
2313 -s "skip write certificate request" \
2314 -C "skip parse certificate request" \
2315 -c "got no certificate request" \
2316 -c "skip write certificate" \
2317 -c "skip write certificate verify" \
2318 -s "skip parse certificate verify" \
2319 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002320 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002321 -S "! mbedtls_ssl_handshake returned" \
2322 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002323 -S "X509 - Certificate verification failed"
2324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002325run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002326 "$P_SRV debug_level=3 auth_mode=optional" \
2327 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002328 0 \
2329 -S "skip write certificate request" \
2330 -C "skip parse certificate request" \
2331 -c "got a certificate request" \
2332 -C "skip write certificate$" \
2333 -C "got no certificate to send" \
2334 -S "SSLv3 client has no certificate" \
2335 -c "skip write certificate verify" \
2336 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002337 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002338 -S "! mbedtls_ssl_handshake returned" \
2339 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002340 -S "X509 - Certificate verification failed"
2341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002342run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002343 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002344 "$O_CLI" \
2345 0 \
2346 -S "skip write certificate request" \
2347 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002348 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002349 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002350 -S "X509 - Certificate verification failed"
2351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002352run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002353 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002354 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002355 0 \
2356 -C "skip parse certificate request" \
2357 -c "got a certificate request" \
2358 -C "skip write certificate$" \
2359 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002360 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002361
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002362run_test "Authentication: client no cert, openssl server required" \
2363 "$O_SRV -Verify 10" \
2364 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2365 1 \
2366 -C "skip parse certificate request" \
2367 -c "got a certificate request" \
2368 -C "skip write certificate$" \
2369 -c "skip write certificate verify" \
2370 -c "! mbedtls_ssl_handshake returned"
2371
Janos Follathe2681a42016-03-07 15:57:05 +00002372requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002373run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002374 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002375 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002376 0 \
2377 -S "skip write certificate request" \
2378 -C "skip parse certificate request" \
2379 -c "got a certificate request" \
2380 -C "skip write certificate$" \
2381 -c "skip write certificate verify" \
2382 -c "got no certificate to send" \
2383 -s "SSLv3 client has no certificate" \
2384 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002385 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002386 -S "! mbedtls_ssl_handshake returned" \
2387 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002388 -S "X509 - Certificate verification failed"
2389
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002390# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2391# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002392
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002393MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002394MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002395
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002396if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002397 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002398 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002399 printf "test value of ${MAX_IM_CA}. \n"
2400 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002401 printf "The tests assume this value and if it changes, the tests in this\n"
2402 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002403 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002404
2405 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002406fi
2407
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002408run_test "Authentication: server max_int chain, client default" \
2409 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2410 key_file=data_files/dir-maxpath/09.key" \
2411 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2412 0 \
2413 -C "X509 - A fatal error occured"
2414
2415run_test "Authentication: server max_int+1 chain, client default" \
2416 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2417 key_file=data_files/dir-maxpath/10.key" \
2418 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2419 1 \
2420 -c "X509 - A fatal error occured"
2421
2422run_test "Authentication: server max_int+1 chain, client optional" \
2423 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2424 key_file=data_files/dir-maxpath/10.key" \
2425 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2426 auth_mode=optional" \
2427 1 \
2428 -c "X509 - A fatal error occured"
2429
2430run_test "Authentication: server max_int+1 chain, client none" \
2431 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2432 key_file=data_files/dir-maxpath/10.key" \
2433 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2434 auth_mode=none" \
2435 0 \
2436 -C "X509 - A fatal error occured"
2437
2438run_test "Authentication: client max_int+1 chain, server default" \
2439 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2440 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2441 key_file=data_files/dir-maxpath/10.key" \
2442 0 \
2443 -S "X509 - A fatal error occured"
2444
2445run_test "Authentication: client max_int+1 chain, server optional" \
2446 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2447 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2448 key_file=data_files/dir-maxpath/10.key" \
2449 1 \
2450 -s "X509 - A fatal error occured"
2451
2452run_test "Authentication: client max_int+1 chain, server required" \
2453 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2454 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2455 key_file=data_files/dir-maxpath/10.key" \
2456 1 \
2457 -s "X509 - A fatal error occured"
2458
2459run_test "Authentication: client max_int chain, server required" \
2460 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2461 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2462 key_file=data_files/dir-maxpath/09.key" \
2463 0 \
2464 -S "X509 - A fatal error occured"
2465
Janos Follath89baba22017-04-10 14:34:35 +01002466# Tests for CA list in CertificateRequest messages
2467
2468run_test "Authentication: send CA list in CertificateRequest (default)" \
2469 "$P_SRV debug_level=3 auth_mode=required" \
2470 "$P_CLI crt_file=data_files/server6.crt \
2471 key_file=data_files/server6.key" \
2472 0 \
2473 -s "requested DN"
2474
2475run_test "Authentication: do not send CA list in CertificateRequest" \
2476 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2477 "$P_CLI crt_file=data_files/server6.crt \
2478 key_file=data_files/server6.key" \
2479 0 \
2480 -S "requested DN"
2481
2482run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2483 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2484 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2485 key_file=data_files/server5.key" \
2486 1 \
2487 -S "requested DN" \
2488 -s "x509_verify_cert() returned" \
2489 -s "! The certificate is not correctly signed by the trusted CA" \
2490 -s "! mbedtls_ssl_handshake returned" \
2491 -c "! mbedtls_ssl_handshake returned" \
2492 -s "X509 - Certificate verification failed"
2493
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002494# Tests for certificate selection based on SHA verson
2495
2496run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2497 "$P_SRV crt_file=data_files/server5.crt \
2498 key_file=data_files/server5.key \
2499 crt_file2=data_files/server5-sha1.crt \
2500 key_file2=data_files/server5.key" \
2501 "$P_CLI force_version=tls1_2" \
2502 0 \
2503 -c "signed using.*ECDSA with SHA256" \
2504 -C "signed using.*ECDSA with SHA1"
2505
2506run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2507 "$P_SRV crt_file=data_files/server5.crt \
2508 key_file=data_files/server5.key \
2509 crt_file2=data_files/server5-sha1.crt \
2510 key_file2=data_files/server5.key" \
2511 "$P_CLI force_version=tls1_1" \
2512 0 \
2513 -C "signed using.*ECDSA with SHA256" \
2514 -c "signed using.*ECDSA with SHA1"
2515
2516run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2517 "$P_SRV crt_file=data_files/server5.crt \
2518 key_file=data_files/server5.key \
2519 crt_file2=data_files/server5-sha1.crt \
2520 key_file2=data_files/server5.key" \
2521 "$P_CLI force_version=tls1" \
2522 0 \
2523 -C "signed using.*ECDSA with SHA256" \
2524 -c "signed using.*ECDSA with SHA1"
2525
2526run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2527 "$P_SRV crt_file=data_files/server5.crt \
2528 key_file=data_files/server5.key \
2529 crt_file2=data_files/server6.crt \
2530 key_file2=data_files/server6.key" \
2531 "$P_CLI force_version=tls1_1" \
2532 0 \
2533 -c "serial number.*09" \
2534 -c "signed using.*ECDSA with SHA256" \
2535 -C "signed using.*ECDSA with SHA1"
2536
2537run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2538 "$P_SRV crt_file=data_files/server6.crt \
2539 key_file=data_files/server6.key \
2540 crt_file2=data_files/server5.crt \
2541 key_file2=data_files/server5.key" \
2542 "$P_CLI force_version=tls1_1" \
2543 0 \
2544 -c "serial number.*0A" \
2545 -c "signed using.*ECDSA with SHA256" \
2546 -C "signed using.*ECDSA with SHA1"
2547
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002548# tests for SNI
2549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002550run_test "SNI: no SNI callback" \
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é-Gonnard0eb6cab2014-07-23 20:17:47 +02002553 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002554 0 \
2555 -S "parse ServerName extension" \
2556 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2557 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002559run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002560 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002561 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002562 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 +02002563 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002564 0 \
2565 -s "parse ServerName extension" \
2566 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2567 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002569run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002570 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002571 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002572 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 +02002573 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002574 0 \
2575 -s "parse ServerName extension" \
2576 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2577 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002578
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002579run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002580 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002581 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002582 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 +02002583 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002584 1 \
2585 -s "parse ServerName extension" \
2586 -s "ssl_sni_wrapper() returned" \
2587 -s "mbedtls_ssl_handshake returned" \
2588 -c "mbedtls_ssl_handshake returned" \
2589 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002590
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002591run_test "SNI: client auth no override: optional" \
2592 "$P_SRV debug_level=3 auth_mode=optional \
2593 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2594 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2595 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002596 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002597 -S "skip write certificate request" \
2598 -C "skip parse certificate request" \
2599 -c "got a certificate request" \
2600 -C "skip write certificate" \
2601 -C "skip write certificate verify" \
2602 -S "skip parse certificate verify"
2603
2604run_test "SNI: client auth override: none -> optional" \
2605 "$P_SRV debug_level=3 auth_mode=none \
2606 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2607 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2608 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002609 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002610 -S "skip write certificate request" \
2611 -C "skip parse certificate request" \
2612 -c "got a certificate request" \
2613 -C "skip write certificate" \
2614 -C "skip write certificate verify" \
2615 -S "skip parse certificate verify"
2616
2617run_test "SNI: client auth override: optional -> none" \
2618 "$P_SRV debug_level=3 auth_mode=optional \
2619 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2620 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2621 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002622 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002623 -s "skip write certificate request" \
2624 -C "skip parse certificate request" \
2625 -c "got no certificate request" \
2626 -c "skip write certificate" \
2627 -c "skip write certificate verify" \
2628 -s "skip parse certificate verify"
2629
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002630run_test "SNI: CA no override" \
2631 "$P_SRV debug_level=3 auth_mode=optional \
2632 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2633 ca_file=data_files/test-ca.crt \
2634 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2635 "$P_CLI debug_level=3 server_name=localhost \
2636 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2637 1 \
2638 -S "skip write certificate request" \
2639 -C "skip parse certificate request" \
2640 -c "got a certificate request" \
2641 -C "skip write certificate" \
2642 -C "skip write certificate verify" \
2643 -S "skip parse certificate verify" \
2644 -s "x509_verify_cert() returned" \
2645 -s "! The certificate is not correctly signed by the trusted CA" \
2646 -S "The certificate has been revoked (is on a CRL)"
2647
2648run_test "SNI: CA override" \
2649 "$P_SRV debug_level=3 auth_mode=optional \
2650 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2651 ca_file=data_files/test-ca.crt \
2652 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2653 "$P_CLI debug_level=3 server_name=localhost \
2654 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2655 0 \
2656 -S "skip write certificate request" \
2657 -C "skip parse certificate request" \
2658 -c "got a certificate request" \
2659 -C "skip write certificate" \
2660 -C "skip write certificate verify" \
2661 -S "skip parse certificate verify" \
2662 -S "x509_verify_cert() returned" \
2663 -S "! The certificate is not correctly signed by the trusted CA" \
2664 -S "The certificate has been revoked (is on a CRL)"
2665
2666run_test "SNI: CA override with CRL" \
2667 "$P_SRV debug_level=3 auth_mode=optional \
2668 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2669 ca_file=data_files/test-ca.crt \
2670 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2671 "$P_CLI debug_level=3 server_name=localhost \
2672 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2673 1 \
2674 -S "skip write certificate request" \
2675 -C "skip parse certificate request" \
2676 -c "got a certificate request" \
2677 -C "skip write certificate" \
2678 -C "skip write certificate verify" \
2679 -S "skip parse certificate verify" \
2680 -s "x509_verify_cert() returned" \
2681 -S "! The certificate is not correctly signed by the trusted CA" \
2682 -s "The certificate has been revoked (is on a CRL)"
2683
Andres AGe8b07742016-12-07 10:01:30 +00002684# Tests for SNI and DTLS
2685
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002686run_test "SNI: DTLS, no SNI callback" \
2687 "$P_SRV debug_level=3 dtls=1 \
2688 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2689 "$P_CLI server_name=localhost dtls=1" \
2690 0 \
2691 -S "parse ServerName extension" \
2692 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2693 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2694
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002695run_test "SNI: DTLS, matching cert 1" \
Andres AGe8b07742016-12-07 10:01:30 +00002696 "$P_SRV debug_level=3 dtls=1 \
2697 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2698 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2699 "$P_CLI server_name=localhost dtls=1" \
2700 0 \
2701 -s "parse ServerName extension" \
2702 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2703 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2704
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002705run_test "SNI: DTLS, matching cert 2" \
2706 "$P_SRV debug_level=3 dtls=1 \
2707 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2708 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2709 "$P_CLI server_name=polarssl.example dtls=1" \
2710 0 \
2711 -s "parse ServerName extension" \
2712 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2713 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2714
2715run_test "SNI: DTLS, no matching cert" \
2716 "$P_SRV debug_level=3 dtls=1 \
2717 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2718 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2719 "$P_CLI server_name=nonesuch.example dtls=1" \
2720 1 \
2721 -s "parse ServerName extension" \
2722 -s "ssl_sni_wrapper() returned" \
2723 -s "mbedtls_ssl_handshake returned" \
2724 -c "mbedtls_ssl_handshake returned" \
2725 -c "SSL - A fatal alert message was received from our peer"
2726
2727run_test "SNI: DTLS, client auth no override: optional" \
2728 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2729 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2730 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2731 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2732 0 \
2733 -S "skip write certificate request" \
2734 -C "skip parse certificate request" \
2735 -c "got a certificate request" \
2736 -C "skip write certificate" \
2737 -C "skip write certificate verify" \
2738 -S "skip parse certificate verify"
2739
2740run_test "SNI: DTLS, client auth override: none -> optional" \
2741 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2742 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2743 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2744 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2745 0 \
2746 -S "skip write certificate request" \
2747 -C "skip parse certificate request" \
2748 -c "got a certificate request" \
2749 -C "skip write certificate" \
2750 -C "skip write certificate verify" \
2751 -S "skip parse certificate verify"
2752
2753run_test "SNI: DTLS, client auth override: optional -> none" \
2754 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2755 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2756 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2757 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2758 0 \
2759 -s "skip write certificate request" \
2760 -C "skip parse certificate request" \
2761 -c "got no certificate request" \
2762 -c "skip write certificate" \
2763 -c "skip write certificate verify" \
2764 -s "skip parse certificate verify"
2765
2766run_test "SNI: DTLS, CA no override" \
2767 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2768 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2769 ca_file=data_files/test-ca.crt \
2770 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2771 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2772 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2773 1 \
2774 -S "skip write certificate request" \
2775 -C "skip parse certificate request" \
2776 -c "got a certificate request" \
2777 -C "skip write certificate" \
2778 -C "skip write certificate verify" \
2779 -S "skip parse certificate verify" \
2780 -s "x509_verify_cert() returned" \
2781 -s "! The certificate is not correctly signed by the trusted CA" \
2782 -S "The certificate has been revoked (is on a CRL)"
2783
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002784run_test "SNI: DTLS, CA override" \
Andres AGe8b07742016-12-07 10:01:30 +00002785 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2786 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2787 ca_file=data_files/test-ca.crt \
2788 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2789 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2790 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2791 0 \
2792 -S "skip write certificate request" \
2793 -C "skip parse certificate request" \
2794 -c "got a certificate request" \
2795 -C "skip write certificate" \
2796 -C "skip write certificate verify" \
2797 -S "skip parse certificate verify" \
2798 -S "x509_verify_cert() returned" \
2799 -S "! The certificate is not correctly signed by the trusted CA" \
2800 -S "The certificate has been revoked (is on a CRL)"
2801
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002802run_test "SNI: DTLS, CA override with CRL" \
Andres AGe8b07742016-12-07 10:01:30 +00002803 "$P_SRV debug_level=3 auth_mode=optional \
2804 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2805 ca_file=data_files/test-ca.crt \
2806 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2807 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2808 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2809 1 \
2810 -S "skip write certificate request" \
2811 -C "skip parse certificate request" \
2812 -c "got a certificate request" \
2813 -C "skip write certificate" \
2814 -C "skip write certificate verify" \
2815 -S "skip parse certificate verify" \
2816 -s "x509_verify_cert() returned" \
2817 -S "! The certificate is not correctly signed by the trusted CA" \
2818 -s "The certificate has been revoked (is on a CRL)"
2819
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002820# Tests for non-blocking I/O: exercise a variety of handshake flows
2821
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002822run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002823 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2824 "$P_CLI nbio=2 tickets=0" \
2825 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002826 -S "mbedtls_ssl_handshake returned" \
2827 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002828 -c "Read from server: .* bytes read"
2829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002830run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002831 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2832 "$P_CLI nbio=2 tickets=0" \
2833 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002834 -S "mbedtls_ssl_handshake returned" \
2835 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002836 -c "Read from server: .* bytes read"
2837
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002838run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002839 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2840 "$P_CLI nbio=2 tickets=1" \
2841 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002842 -S "mbedtls_ssl_handshake returned" \
2843 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002844 -c "Read from server: .* bytes read"
2845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002846run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002847 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2848 "$P_CLI nbio=2 tickets=1" \
2849 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002850 -S "mbedtls_ssl_handshake returned" \
2851 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002852 -c "Read from server: .* bytes read"
2853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002854run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002855 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2856 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2857 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002858 -S "mbedtls_ssl_handshake returned" \
2859 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002860 -c "Read from server: .* bytes read"
2861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002862run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002863 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2864 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2865 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002866 -S "mbedtls_ssl_handshake returned" \
2867 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002868 -c "Read from server: .* bytes read"
2869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002870run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002871 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2872 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2873 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002874 -S "mbedtls_ssl_handshake returned" \
2875 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002876 -c "Read from server: .* bytes read"
2877
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002878# Tests for version negotiation
2879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002880run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002881 "$P_SRV" \
2882 "$P_CLI" \
2883 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002884 -S "mbedtls_ssl_handshake returned" \
2885 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002886 -s "Protocol is TLSv1.2" \
2887 -c "Protocol is TLSv1.2"
2888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002889run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002890 "$P_SRV" \
2891 "$P_CLI max_version=tls1_1" \
2892 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002893 -S "mbedtls_ssl_handshake returned" \
2894 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002895 -s "Protocol is TLSv1.1" \
2896 -c "Protocol is TLSv1.1"
2897
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002898run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002899 "$P_SRV max_version=tls1_1" \
2900 "$P_CLI" \
2901 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002902 -S "mbedtls_ssl_handshake returned" \
2903 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002904 -s "Protocol is TLSv1.1" \
2905 -c "Protocol is TLSv1.1"
2906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002907run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002908 "$P_SRV max_version=tls1_1" \
2909 "$P_CLI max_version=tls1_1" \
2910 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002911 -S "mbedtls_ssl_handshake returned" \
2912 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002913 -s "Protocol is TLSv1.1" \
2914 -c "Protocol is TLSv1.1"
2915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002916run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002917 "$P_SRV min_version=tls1_1" \
2918 "$P_CLI max_version=tls1_1" \
2919 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002920 -S "mbedtls_ssl_handshake returned" \
2921 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002922 -s "Protocol is TLSv1.1" \
2923 -c "Protocol is TLSv1.1"
2924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002925run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002926 "$P_SRV max_version=tls1_1" \
2927 "$P_CLI min_version=tls1_1" \
2928 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002929 -S "mbedtls_ssl_handshake returned" \
2930 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002931 -s "Protocol is TLSv1.1" \
2932 -c "Protocol is TLSv1.1"
2933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002934run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002935 "$P_SRV max_version=tls1_1" \
2936 "$P_CLI min_version=tls1_2" \
2937 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002938 -s "mbedtls_ssl_handshake returned" \
2939 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002940 -c "SSL - Handshake protocol not within min/max boundaries"
2941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002942run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002943 "$P_SRV min_version=tls1_2" \
2944 "$P_CLI max_version=tls1_1" \
2945 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002946 -s "mbedtls_ssl_handshake returned" \
2947 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002948 -s "SSL - Handshake protocol not within min/max boundaries"
2949
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002950# Tests for ALPN extension
2951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002952run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002953 "$P_SRV debug_level=3" \
2954 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002955 0 \
2956 -C "client hello, adding alpn extension" \
2957 -S "found alpn extension" \
2958 -C "got an alert message, type: \\[2:120]" \
2959 -S "server hello, adding alpn extension" \
2960 -C "found alpn extension " \
2961 -C "Application Layer Protocol is" \
2962 -S "Application Layer Protocol is"
2963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002964run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002965 "$P_SRV debug_level=3" \
2966 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002967 0 \
2968 -c "client hello, adding alpn extension" \
2969 -s "found alpn extension" \
2970 -C "got an alert message, type: \\[2:120]" \
2971 -S "server hello, adding alpn extension" \
2972 -C "found alpn extension " \
2973 -c "Application Layer Protocol is (none)" \
2974 -S "Application Layer Protocol is"
2975
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002976run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002977 "$P_SRV debug_level=3 alpn=abc,1234" \
2978 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002979 0 \
2980 -C "client hello, adding alpn extension" \
2981 -S "found alpn extension" \
2982 -C "got an alert message, type: \\[2:120]" \
2983 -S "server hello, adding alpn extension" \
2984 -C "found alpn extension " \
2985 -C "Application Layer Protocol is" \
2986 -s "Application Layer Protocol is (none)"
2987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002988run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002989 "$P_SRV debug_level=3 alpn=abc,1234" \
2990 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002991 0 \
2992 -c "client hello, adding alpn extension" \
2993 -s "found alpn extension" \
2994 -C "got an alert message, type: \\[2:120]" \
2995 -s "server hello, adding alpn extension" \
2996 -c "found alpn extension" \
2997 -c "Application Layer Protocol is abc" \
2998 -s "Application Layer Protocol is abc"
2999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003000run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003001 "$P_SRV debug_level=3 alpn=abc,1234" \
3002 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003003 0 \
3004 -c "client hello, adding alpn extension" \
3005 -s "found alpn extension" \
3006 -C "got an alert message, type: \\[2:120]" \
3007 -s "server hello, adding alpn extension" \
3008 -c "found alpn extension" \
3009 -c "Application Layer Protocol is abc" \
3010 -s "Application Layer Protocol is abc"
3011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003012run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003013 "$P_SRV debug_level=3 alpn=abc,1234" \
3014 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003015 0 \
3016 -c "client hello, adding alpn extension" \
3017 -s "found alpn extension" \
3018 -C "got an alert message, type: \\[2:120]" \
3019 -s "server hello, adding alpn extension" \
3020 -c "found alpn extension" \
3021 -c "Application Layer Protocol is 1234" \
3022 -s "Application Layer Protocol is 1234"
3023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003024run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003025 "$P_SRV debug_level=3 alpn=abc,123" \
3026 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003027 1 \
3028 -c "client hello, adding alpn extension" \
3029 -s "found alpn extension" \
3030 -c "got an alert message, type: \\[2:120]" \
3031 -S "server hello, adding alpn extension" \
3032 -C "found alpn extension" \
3033 -C "Application Layer Protocol is 1234" \
3034 -S "Application Layer Protocol is 1234"
3035
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003036
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003037# Tests for keyUsage in leaf certificates, part 1:
3038# server-side certificate/suite selection
3039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003040run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003041 "$P_SRV key_file=data_files/server2.key \
3042 crt_file=data_files/server2.ku-ds.crt" \
3043 "$P_CLI" \
3044 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003045 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003046
3047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003048run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003049 "$P_SRV key_file=data_files/server2.key \
3050 crt_file=data_files/server2.ku-ke.crt" \
3051 "$P_CLI" \
3052 0 \
3053 -c "Ciphersuite is TLS-RSA-WITH-"
3054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003055run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003056 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003057 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003058 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003059 1 \
3060 -C "Ciphersuite is "
3061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003062run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003063 "$P_SRV key_file=data_files/server5.key \
3064 crt_file=data_files/server5.ku-ds.crt" \
3065 "$P_CLI" \
3066 0 \
3067 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3068
3069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003070run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003071 "$P_SRV key_file=data_files/server5.key \
3072 crt_file=data_files/server5.ku-ka.crt" \
3073 "$P_CLI" \
3074 0 \
3075 -c "Ciphersuite is TLS-ECDH-"
3076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003077run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003078 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003079 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003080 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003081 1 \
3082 -C "Ciphersuite is "
3083
3084# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003085# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003087run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003088 "$O_SRV -key data_files/server2.key \
3089 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003090 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003091 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3092 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003093 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003094 -C "Processing of the Certificate handshake message failed" \
3095 -c "Ciphersuite is TLS-"
3096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003097run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003098 "$O_SRV -key data_files/server2.key \
3099 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003100 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003101 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3102 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003103 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003104 -C "Processing of the Certificate handshake message failed" \
3105 -c "Ciphersuite is TLS-"
3106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003107run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003108 "$O_SRV -key data_files/server2.key \
3109 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003110 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003111 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3112 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003113 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003114 -C "Processing of the Certificate handshake message failed" \
3115 -c "Ciphersuite is TLS-"
3116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003117run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003118 "$O_SRV -key data_files/server2.key \
3119 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003120 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003121 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3122 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003123 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003124 -c "Processing of the Certificate handshake message failed" \
3125 -C "Ciphersuite is TLS-"
3126
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003127run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3128 "$O_SRV -key data_files/server2.key \
3129 -cert data_files/server2.ku-ke.crt" \
3130 "$P_CLI debug_level=1 auth_mode=optional \
3131 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3132 0 \
3133 -c "bad certificate (usage extensions)" \
3134 -C "Processing of the Certificate handshake message failed" \
3135 -c "Ciphersuite is TLS-" \
3136 -c "! Usage does not match the keyUsage extension"
3137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003138run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003139 "$O_SRV -key data_files/server2.key \
3140 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003141 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003142 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3143 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003144 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003145 -C "Processing of the Certificate handshake message failed" \
3146 -c "Ciphersuite is TLS-"
3147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003148run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003149 "$O_SRV -key data_files/server2.key \
3150 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003151 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003152 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3153 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003154 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003155 -c "Processing of the Certificate handshake message failed" \
3156 -C "Ciphersuite is TLS-"
3157
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003158run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3159 "$O_SRV -key data_files/server2.key \
3160 -cert data_files/server2.ku-ds.crt" \
3161 "$P_CLI debug_level=1 auth_mode=optional \
3162 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3163 0 \
3164 -c "bad certificate (usage extensions)" \
3165 -C "Processing of the Certificate handshake message failed" \
3166 -c "Ciphersuite is TLS-" \
3167 -c "! Usage does not match the keyUsage extension"
3168
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003169# Tests for keyUsage in leaf certificates, part 3:
3170# server-side checking of client cert
3171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003172run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003173 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003174 "$O_CLI -key data_files/server2.key \
3175 -cert data_files/server2.ku-ds.crt" \
3176 0 \
3177 -S "bad certificate (usage extensions)" \
3178 -S "Processing of the Certificate handshake message failed"
3179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003180run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003181 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003182 "$O_CLI -key data_files/server2.key \
3183 -cert data_files/server2.ku-ke.crt" \
3184 0 \
3185 -s "bad certificate (usage extensions)" \
3186 -S "Processing of the Certificate handshake message failed"
3187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003188run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003189 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003190 "$O_CLI -key data_files/server2.key \
3191 -cert data_files/server2.ku-ke.crt" \
3192 1 \
3193 -s "bad certificate (usage extensions)" \
3194 -s "Processing of the Certificate handshake message failed"
3195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003196run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003197 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003198 "$O_CLI -key data_files/server5.key \
3199 -cert data_files/server5.ku-ds.crt" \
3200 0 \
3201 -S "bad certificate (usage extensions)" \
3202 -S "Processing of the Certificate handshake message failed"
3203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003204run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003205 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003206 "$O_CLI -key data_files/server5.key \
3207 -cert data_files/server5.ku-ka.crt" \
3208 0 \
3209 -s "bad certificate (usage extensions)" \
3210 -S "Processing of the Certificate handshake message failed"
3211
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003212# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003214run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003215 "$P_SRV key_file=data_files/server5.key \
3216 crt_file=data_files/server5.eku-srv.crt" \
3217 "$P_CLI" \
3218 0
3219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003220run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003221 "$P_SRV key_file=data_files/server5.key \
3222 crt_file=data_files/server5.eku-srv.crt" \
3223 "$P_CLI" \
3224 0
3225
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003226run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003227 "$P_SRV key_file=data_files/server5.key \
3228 crt_file=data_files/server5.eku-cs_any.crt" \
3229 "$P_CLI" \
3230 0
3231
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003232run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003233 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003234 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003235 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003236 1
3237
3238# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003240run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003241 "$O_SRV -key data_files/server5.key \
3242 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003243 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003244 0 \
3245 -C "bad certificate (usage extensions)" \
3246 -C "Processing of the Certificate handshake message failed" \
3247 -c "Ciphersuite is TLS-"
3248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003249run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003250 "$O_SRV -key data_files/server5.key \
3251 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003252 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003253 0 \
3254 -C "bad certificate (usage extensions)" \
3255 -C "Processing of the Certificate handshake message failed" \
3256 -c "Ciphersuite is TLS-"
3257
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003258run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003259 "$O_SRV -key data_files/server5.key \
3260 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003261 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003262 0 \
3263 -C "bad certificate (usage extensions)" \
3264 -C "Processing of the Certificate handshake message failed" \
3265 -c "Ciphersuite is TLS-"
3266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003267run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003268 "$O_SRV -key data_files/server5.key \
3269 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003270 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003271 1 \
3272 -c "bad certificate (usage extensions)" \
3273 -c "Processing of the Certificate handshake message failed" \
3274 -C "Ciphersuite is TLS-"
3275
3276# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003278run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003279 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003280 "$O_CLI -key data_files/server5.key \
3281 -cert data_files/server5.eku-cli.crt" \
3282 0 \
3283 -S "bad certificate (usage extensions)" \
3284 -S "Processing of the Certificate handshake message failed"
3285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003286run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003287 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003288 "$O_CLI -key data_files/server5.key \
3289 -cert data_files/server5.eku-srv_cli.crt" \
3290 0 \
3291 -S "bad certificate (usage extensions)" \
3292 -S "Processing of the Certificate handshake message failed"
3293
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003294run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003295 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003296 "$O_CLI -key data_files/server5.key \
3297 -cert data_files/server5.eku-cs_any.crt" \
3298 0 \
3299 -S "bad certificate (usage extensions)" \
3300 -S "Processing of the Certificate handshake message failed"
3301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003302run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003303 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003304 "$O_CLI -key data_files/server5.key \
3305 -cert data_files/server5.eku-cs.crt" \
3306 0 \
3307 -s "bad certificate (usage extensions)" \
3308 -S "Processing of the Certificate handshake message failed"
3309
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003310run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003311 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003312 "$O_CLI -key data_files/server5.key \
3313 -cert data_files/server5.eku-cs.crt" \
3314 1 \
3315 -s "bad certificate (usage extensions)" \
3316 -s "Processing of the Certificate handshake message failed"
3317
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003318# Tests for DHM parameters loading
3319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003320run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003321 "$P_SRV" \
3322 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3323 debug_level=3" \
3324 0 \
3325 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003326 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003328run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003329 "$P_SRV dhm_file=data_files/dhparams.pem" \
3330 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3331 debug_level=3" \
3332 0 \
3333 -c "value of 'DHM: P ' (1024 bits)" \
3334 -c "value of 'DHM: G ' (2 bits)"
3335
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003336# Tests for DHM client-side size checking
3337
3338run_test "DHM size: server default, client default, OK" \
3339 "$P_SRV" \
3340 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3341 debug_level=1" \
3342 0 \
3343 -C "DHM prime too short:"
3344
3345run_test "DHM size: server default, client 2048, OK" \
3346 "$P_SRV" \
3347 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3348 debug_level=1 dhmlen=2048" \
3349 0 \
3350 -C "DHM prime too short:"
3351
3352run_test "DHM size: server 1024, client default, OK" \
3353 "$P_SRV dhm_file=data_files/dhparams.pem" \
3354 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3355 debug_level=1" \
3356 0 \
3357 -C "DHM prime too short:"
3358
3359run_test "DHM size: server 1000, client default, rejected" \
3360 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3361 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3362 debug_level=1" \
3363 1 \
3364 -c "DHM prime too short:"
3365
3366run_test "DHM size: server default, client 2049, rejected" \
3367 "$P_SRV" \
3368 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3369 debug_level=1 dhmlen=2049" \
3370 1 \
3371 -c "DHM prime too short:"
3372
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003373# Tests for PSK callback
3374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003375run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003376 "$P_SRV psk=abc123 psk_identity=foo" \
3377 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3378 psk_identity=foo psk=abc123" \
3379 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003380 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003381 -S "SSL - Unknown identity received" \
3382 -S "SSL - Verification of the message MAC failed"
3383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003384run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003385 "$P_SRV" \
3386 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3387 psk_identity=foo psk=abc123" \
3388 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003389 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003390 -S "SSL - Unknown identity received" \
3391 -S "SSL - Verification of the message MAC failed"
3392
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003393run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003394 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3395 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3396 psk_identity=foo psk=abc123" \
3397 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003398 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003399 -s "SSL - Unknown identity received" \
3400 -S "SSL - Verification of the message MAC failed"
3401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003402run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003403 "$P_SRV psk_list=abc,dead,def,beef" \
3404 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3405 psk_identity=abc psk=dead" \
3406 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003407 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003408 -S "SSL - Unknown identity received" \
3409 -S "SSL - Verification of the message MAC failed"
3410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003411run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003412 "$P_SRV psk_list=abc,dead,def,beef" \
3413 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3414 psk_identity=def psk=beef" \
3415 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003416 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003417 -S "SSL - Unknown identity received" \
3418 -S "SSL - Verification of the message MAC failed"
3419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003420run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003421 "$P_SRV psk_list=abc,dead,def,beef" \
3422 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3423 psk_identity=ghi psk=beef" \
3424 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003425 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003426 -s "SSL - Unknown identity received" \
3427 -S "SSL - Verification of the message MAC failed"
3428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003429run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003430 "$P_SRV psk_list=abc,dead,def,beef" \
3431 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3432 psk_identity=abc psk=beef" \
3433 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003434 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003435 -S "SSL - Unknown identity received" \
3436 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003437
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003438# Tests for EC J-PAKE
3439
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003440requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003441run_test "ECJPAKE: client not configured" \
3442 "$P_SRV debug_level=3" \
3443 "$P_CLI debug_level=3" \
3444 0 \
3445 -C "add ciphersuite: c0ff" \
3446 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003447 -S "found ecjpake kkpp extension" \
3448 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003449 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003450 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003451 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003452 -S "None of the common ciphersuites is usable"
3453
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003454requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003455run_test "ECJPAKE: server not configured" \
3456 "$P_SRV debug_level=3" \
3457 "$P_CLI debug_level=3 ecjpake_pw=bla \
3458 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3459 1 \
3460 -c "add ciphersuite: c0ff" \
3461 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003462 -s "found ecjpake kkpp extension" \
3463 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003464 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003465 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003466 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003467 -s "None of the common ciphersuites is usable"
3468
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003469requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003470run_test "ECJPAKE: working, TLS" \
3471 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3472 "$P_CLI debug_level=3 ecjpake_pw=bla \
3473 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003474 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003475 -c "add ciphersuite: c0ff" \
3476 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003477 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003478 -s "found ecjpake kkpp extension" \
3479 -S "skip ecjpake kkpp extension" \
3480 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003481 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003482 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003483 -S "None of the common ciphersuites is usable" \
3484 -S "SSL - Verification of the message MAC failed"
3485
Janos Follath74537a62016-09-02 13:45:28 +01003486server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003487requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003488run_test "ECJPAKE: password mismatch, TLS" \
3489 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3490 "$P_CLI debug_level=3 ecjpake_pw=bad \
3491 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3492 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003493 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003494 -s "SSL - Verification of the message MAC failed"
3495
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003496requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003497run_test "ECJPAKE: working, DTLS" \
3498 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3499 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3500 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3501 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003502 -c "re-using cached ecjpake parameters" \
3503 -S "SSL - Verification of the message MAC failed"
3504
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003505requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003506run_test "ECJPAKE: working, DTLS, no cookie" \
3507 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3508 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3509 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3510 0 \
3511 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003512 -S "SSL - Verification of the message MAC failed"
3513
Janos Follath74537a62016-09-02 13:45:28 +01003514server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003515requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003516run_test "ECJPAKE: password mismatch, DTLS" \
3517 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3518 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3519 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3520 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003521 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003522 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003523
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003524# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003525requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003526run_test "ECJPAKE: working, DTLS, nolog" \
3527 "$P_SRV dtls=1 ecjpake_pw=bla" \
3528 "$P_CLI dtls=1 ecjpake_pw=bla \
3529 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3530 0
3531
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003532# Tests for ciphersuites per version
3533
Janos Follathe2681a42016-03-07 15:57:05 +00003534requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003535run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003536 "$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 +02003537 "$P_CLI force_version=ssl3" \
3538 0 \
3539 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003541run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003542 "$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 +01003543 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003544 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003545 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003547run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003548 "$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 +02003549 "$P_CLI force_version=tls1_1" \
3550 0 \
3551 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003553run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003554 "$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 +02003555 "$P_CLI force_version=tls1_2" \
3556 0 \
3557 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3558
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003559# Test for ClientHello without extensions
3560
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003561requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003562run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003563 "$P_SRV debug_level=3" \
3564 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3565 0 \
3566 -s "dumping 'client hello extensions' (0 bytes)"
3567
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003568requires_gnutls
3569run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3570 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3571 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3572 0 \
3573 -s "dumping 'client hello extensions' (0 bytes)"
3574
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003575# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003576
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003577run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003578 "$P_SRV" \
3579 "$P_CLI request_size=100" \
3580 0 \
3581 -s "Read from client: 100 bytes read$"
3582
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003583run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003584 "$P_SRV" \
3585 "$P_CLI request_size=500" \
3586 0 \
3587 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003588
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003589# Tests for small packets
3590
Janos Follathe2681a42016-03-07 15:57:05 +00003591requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003592run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003593 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003594 "$P_CLI request_size=1 force_version=ssl3 \
3595 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3596 0 \
3597 -s "Read from client: 1 bytes read"
3598
Janos Follathe2681a42016-03-07 15:57:05 +00003599requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003600run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003601 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003602 "$P_CLI request_size=1 force_version=ssl3 \
3603 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3604 0 \
3605 -s "Read from client: 1 bytes read"
3606
3607run_test "Small packet TLS 1.0 BlockCipher" \
3608 "$P_SRV" \
3609 "$P_CLI request_size=1 force_version=tls1 \
3610 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3611 0 \
3612 -s "Read from client: 1 bytes read"
3613
Hanno Becker8501f982017-11-10 08:59:04 +00003614run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003615 "$P_SRV" \
3616 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3617 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3618 0 \
3619 -s "Read from client: 1 bytes read"
3620
Hanno Becker32c55012017-11-10 08:42:54 +00003621requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003622run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003623 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003624 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003625 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003626 0 \
3627 -s "Read from client: 1 bytes read"
3628
Hanno Becker32c55012017-11-10 08:42:54 +00003629requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003630run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003631 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003632 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003633 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003634 0 \
3635 -s "Read from client: 1 bytes read"
3636
3637run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003638 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003639 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003640 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3641 0 \
3642 -s "Read from client: 1 bytes read"
3643
3644run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3645 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3646 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003647 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003648 0 \
3649 -s "Read from client: 1 bytes read"
3650
3651requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3652run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003653 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003654 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003655 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003656 0 \
3657 -s "Read from client: 1 bytes read"
3658
Hanno Becker8501f982017-11-10 08:59:04 +00003659requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3660run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003661 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3662 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3663 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003664 0 \
3665 -s "Read from client: 1 bytes read"
3666
3667run_test "Small packet TLS 1.1 BlockCipher" \
3668 "$P_SRV" \
3669 "$P_CLI request_size=1 force_version=tls1_1 \
3670 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3671 0 \
3672 -s "Read from client: 1 bytes read"
3673
Hanno Becker8501f982017-11-10 08:59:04 +00003674run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003675 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003676 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003677 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003678 0 \
3679 -s "Read from client: 1 bytes read"
3680
3681requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3682run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003683 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003684 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003685 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003686 0 \
3687 -s "Read from client: 1 bytes read"
3688
3689requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3690run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003691 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003692 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003693 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003694 0 \
3695 -s "Read from client: 1 bytes read"
3696
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003697run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003698 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003699 "$P_CLI request_size=1 force_version=tls1_1 \
3700 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3701 0 \
3702 -s "Read from client: 1 bytes read"
3703
Hanno Becker8501f982017-11-10 08:59:04 +00003704run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3705 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003706 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003707 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003708 0 \
3709 -s "Read from client: 1 bytes read"
3710
Hanno Becker8501f982017-11-10 08:59:04 +00003711requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3712run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003713 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003714 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003715 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003716 0 \
3717 -s "Read from client: 1 bytes read"
3718
Hanno Becker32c55012017-11-10 08:42:54 +00003719requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003720run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003721 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003722 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003723 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003724 0 \
3725 -s "Read from client: 1 bytes read"
3726
3727run_test "Small packet TLS 1.2 BlockCipher" \
3728 "$P_SRV" \
3729 "$P_CLI request_size=1 force_version=tls1_2 \
3730 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3731 0 \
3732 -s "Read from client: 1 bytes read"
3733
Hanno Becker8501f982017-11-10 08:59:04 +00003734run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003735 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003736 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003737 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003738 0 \
3739 -s "Read from client: 1 bytes read"
3740
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003741run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3742 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003743 "$P_CLI request_size=1 force_version=tls1_2 \
3744 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003745 0 \
3746 -s "Read from client: 1 bytes read"
3747
Hanno Becker32c55012017-11-10 08:42:54 +00003748requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003749run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003750 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003751 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003752 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003753 0 \
3754 -s "Read from client: 1 bytes read"
3755
Hanno Becker8501f982017-11-10 08:59:04 +00003756requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3757run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003758 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003759 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003760 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003761 0 \
3762 -s "Read from client: 1 bytes read"
3763
3764run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003765 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003766 "$P_CLI request_size=1 force_version=tls1_2 \
3767 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3768 0 \
3769 -s "Read from client: 1 bytes read"
3770
Hanno Becker8501f982017-11-10 08:59:04 +00003771run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003772 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003773 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003774 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003775 0 \
3776 -s "Read from client: 1 bytes read"
3777
Hanno Becker32c55012017-11-10 08:42:54 +00003778requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003779run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003780 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003781 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003782 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003783 0 \
3784 -s "Read from client: 1 bytes read"
3785
Hanno Becker8501f982017-11-10 08:59:04 +00003786requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3787run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003788 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003789 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003791 0 \
3792 -s "Read from client: 1 bytes read"
3793
3794run_test "Small packet TLS 1.2 AEAD" \
3795 "$P_SRV" \
3796 "$P_CLI request_size=1 force_version=tls1_2 \
3797 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3798 0 \
3799 -s "Read from client: 1 bytes read"
3800
3801run_test "Small packet TLS 1.2 AEAD shorter tag" \
3802 "$P_SRV" \
3803 "$P_CLI request_size=1 force_version=tls1_2 \
3804 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3805 0 \
3806 -s "Read from client: 1 bytes read"
3807
Hanno Beckere2148042017-11-10 08:59:18 +00003808# Tests for small packets in DTLS
3809
3810requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3811run_test "Small packet DTLS 1.0" \
3812 "$P_SRV dtls=1 force_version=dtls1" \
3813 "$P_CLI dtls=1 request_size=1 \
3814 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3815 0 \
3816 -s "Read from client: 1 bytes read"
3817
3818requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3819run_test "Small packet DTLS 1.0, without EtM" \
3820 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3821 "$P_CLI dtls=1 request_size=1 \
3822 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3823 0 \
3824 -s "Read from client: 1 bytes read"
3825
3826requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3827requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3828run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003829 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3830 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003831 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3832 0 \
3833 -s "Read from client: 1 bytes read"
3834
3835requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3836requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3837run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003838 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003839 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003840 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003841 0 \
3842 -s "Read from client: 1 bytes read"
3843
3844requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3845run_test "Small packet DTLS 1.2" \
3846 "$P_SRV dtls=1 force_version=dtls1_2" \
3847 "$P_CLI dtls=1 request_size=1 \
3848 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3849 0 \
3850 -s "Read from client: 1 bytes read"
3851
3852requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3853run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003854 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003855 "$P_CLI dtls=1 request_size=1 \
3856 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3857 0 \
3858 -s "Read from client: 1 bytes read"
3859
3860requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3861requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3862run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003863 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003864 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003865 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003866 0 \
3867 -s "Read from client: 1 bytes read"
3868
3869requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3870requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3871run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003872 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003873 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003874 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003875 0 \
3876 -s "Read from client: 1 bytes read"
3877
Janos Follath00efff72016-05-06 13:48:23 +01003878# A test for extensions in SSLv3
3879
3880requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3881run_test "SSLv3 with extensions, server side" \
3882 "$P_SRV min_version=ssl3 debug_level=3" \
3883 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3884 0 \
3885 -S "dumping 'client hello extensions'" \
3886 -S "server hello, total extension length:"
3887
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003888# Test for large packets
3889
Janos Follathe2681a42016-03-07 15:57:05 +00003890requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003891run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003892 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003893 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003894 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3895 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003896 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003897 -s "Read from client: 16384 bytes read"
3898
Janos Follathe2681a42016-03-07 15:57:05 +00003899requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003900run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003901 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003902 "$P_CLI request_size=16384 force_version=ssl3 \
3903 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3904 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003905 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003906 -s "Read from client: 16384 bytes read"
3907
3908run_test "Large packet TLS 1.0 BlockCipher" \
3909 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003910 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003911 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3912 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003913 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003914 -s "Read from client: 16384 bytes read"
3915
Hanno Becker278fc7a2017-11-10 09:16:28 +00003916run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003917 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003918 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3919 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3920 0 \
3921 -s "Read from client: 16384 bytes read"
3922
Hanno Becker32c55012017-11-10 08:42:54 +00003923requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003924run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003925 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003926 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003927 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003928 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003929 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003930 -s "Read from client: 16384 bytes read"
3931
Hanno Becker32c55012017-11-10 08:42:54 +00003932requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003933run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003934 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003935 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003936 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003937 0 \
3938 -s "Read from client: 16384 bytes read"
3939
3940run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003941 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003942 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003943 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3944 0 \
3945 -s "Read from client: 16384 bytes read"
3946
3947run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3948 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3949 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003950 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003951 0 \
3952 -s "Read from client: 16384 bytes read"
3953
3954requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3955run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003956 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003957 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003958 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003959 0 \
3960 -s "Read from client: 16384 bytes read"
3961
Hanno Becker278fc7a2017-11-10 09:16:28 +00003962requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3963run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003964 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003965 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003966 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003967 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003968 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003969 -s "Read from client: 16384 bytes read"
3970
3971run_test "Large packet TLS 1.1 BlockCipher" \
3972 "$P_SRV" \
3973 "$P_CLI request_size=16384 force_version=tls1_1 \
3974 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3975 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003976 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003977 -s "Read from client: 16384 bytes read"
3978
Hanno Becker278fc7a2017-11-10 09:16:28 +00003979run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3980 "$P_SRV" \
3981 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3982 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003983 0 \
3984 -s "Read from client: 16384 bytes read"
3985
Hanno Becker32c55012017-11-10 08:42:54 +00003986requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003987run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003988 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003989 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003990 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003991 0 \
3992 -s "Read from client: 16384 bytes read"
3993
Hanno Becker32c55012017-11-10 08:42:54 +00003994requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003995run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003996 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003997 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003998 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003999 0 \
4000 -s "Read from client: 16384 bytes read"
4001
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004002run_test "Large packet TLS 1.1 StreamCipher" \
4003 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4004 "$P_CLI request_size=16384 force_version=tls1_1 \
4005 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4006 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004007 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004008 -s "Read from client: 16384 bytes read"
4009
Hanno Becker278fc7a2017-11-10 09:16:28 +00004010run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
4011 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004012 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004013 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004014 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004015 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004016 -s "Read from client: 16384 bytes read"
4017
Hanno Becker278fc7a2017-11-10 09:16:28 +00004018requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4019run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004020 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004021 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004022 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004023 0 \
4024 -s "Read from client: 16384 bytes read"
4025
Hanno Becker278fc7a2017-11-10 09:16:28 +00004026requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4027run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004028 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004029 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004030 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004031 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004032 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004033 -s "Read from client: 16384 bytes read"
4034
4035run_test "Large packet TLS 1.2 BlockCipher" \
4036 "$P_SRV" \
4037 "$P_CLI request_size=16384 force_version=tls1_2 \
4038 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4039 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004040 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004041 -s "Read from client: 16384 bytes read"
4042
Hanno Becker278fc7a2017-11-10 09:16:28 +00004043run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
4044 "$P_SRV" \
4045 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4046 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4047 0 \
4048 -s "Read from client: 16384 bytes read"
4049
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004050run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
4051 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004052 "$P_CLI request_size=16384 force_version=tls1_2 \
4053 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004054 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004055 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004056 -s "Read from client: 16384 bytes read"
4057
Hanno Becker32c55012017-11-10 08:42:54 +00004058requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004059run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004060 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004061 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004062 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004063 0 \
4064 -s "Read from client: 16384 bytes read"
4065
Hanno Becker278fc7a2017-11-10 09:16:28 +00004066requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4067run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004068 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004069 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004070 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004071 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004072 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004073 -s "Read from client: 16384 bytes read"
4074
4075run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004076 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004077 "$P_CLI request_size=16384 force_version=tls1_2 \
4078 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4079 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004080 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004081 -s "Read from client: 16384 bytes read"
4082
Hanno Becker278fc7a2017-11-10 09:16:28 +00004083run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004084 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004085 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004086 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4087 0 \
4088 -s "Read from client: 16384 bytes read"
4089
Hanno Becker32c55012017-11-10 08:42:54 +00004090requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004091run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004092 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004093 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004094 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004095 0 \
4096 -s "Read from client: 16384 bytes read"
4097
Hanno Becker278fc7a2017-11-10 09:16:28 +00004098requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4099run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004100 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004101 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004102 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004103 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004104 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004105 -s "Read from client: 16384 bytes read"
4106
4107run_test "Large packet TLS 1.2 AEAD" \
4108 "$P_SRV" \
4109 "$P_CLI request_size=16384 force_version=tls1_2 \
4110 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4111 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004112 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004113 -s "Read from client: 16384 bytes read"
4114
4115run_test "Large packet TLS 1.2 AEAD shorter tag" \
4116 "$P_SRV" \
4117 "$P_CLI request_size=16384 force_version=tls1_2 \
4118 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4119 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004120 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004121 -s "Read from client: 16384 bytes read"
4122
Ron Eldorc7f15232018-06-28 13:22:05 +03004123# Tests for ECC extensions (rfc 4492)
4124
Ron Eldor94226d82018-06-28 16:17:00 +03004125requires_config_enabled MBEDTLS_AES_C
4126requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4127requires_config_enabled MBEDTLS_SHA256_C
4128requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004129run_test "Force a non ECC ciphersuite in the client side" \
4130 "$P_SRV debug_level=3" \
Ron Eldor94226d82018-06-28 16:17:00 +03004131 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004132 0 \
4133 -C "client hello, adding supported_elliptic_curves extension" \
4134 -C "client hello, adding supported_point_formats extension" \
4135 -S "found supported elliptic curves extension" \
4136 -S "found supported point formats extension"
4137
Ron Eldor94226d82018-06-28 16:17:00 +03004138requires_config_enabled MBEDTLS_AES_C
4139requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4140requires_config_enabled MBEDTLS_SHA256_C
4141requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004142run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor94226d82018-06-28 16:17:00 +03004143 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004144 "$P_CLI debug_level=3" \
4145 0 \
4146 -C "found supported_point_formats extension" \
4147 -S "server hello, supported_point_formats extension"
4148
Ron Eldor94226d82018-06-28 16:17:00 +03004149requires_config_enabled MBEDTLS_AES_C
4150requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4151requires_config_enabled MBEDTLS_SHA256_C
4152requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004153run_test "Force an ECC ciphersuite in the client side" \
4154 "$P_SRV debug_level=3" \
4155 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4156 0 \
4157 -c "client hello, adding supported_elliptic_curves extension" \
4158 -c "client hello, adding supported_point_formats extension" \
4159 -s "found supported elliptic curves extension" \
4160 -s "found supported point formats extension"
4161
Ron Eldor94226d82018-06-28 16:17:00 +03004162requires_config_enabled MBEDTLS_AES_C
4163requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4164requires_config_enabled MBEDTLS_SHA256_C
4165requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004166run_test "Force an ECC ciphersuite in the server side" \
4167 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4168 "$P_CLI debug_level=3" \
4169 0 \
4170 -c "found supported_point_formats extension" \
4171 -s "server hello, supported_point_formats extension"
4172
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004173# Tests for DTLS HelloVerifyRequest
4174
4175run_test "DTLS cookie: enabled" \
4176 "$P_SRV dtls=1 debug_level=2" \
4177 "$P_CLI dtls=1 debug_level=2" \
4178 0 \
4179 -s "cookie verification failed" \
4180 -s "cookie verification passed" \
4181 -S "cookie verification skipped" \
4182 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004183 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004184 -S "SSL - The requested feature is not available"
4185
4186run_test "DTLS cookie: disabled" \
4187 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4188 "$P_CLI dtls=1 debug_level=2" \
4189 0 \
4190 -S "cookie verification failed" \
4191 -S "cookie verification passed" \
4192 -s "cookie verification skipped" \
4193 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004194 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004195 -S "SSL - The requested feature is not available"
4196
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004197run_test "DTLS cookie: default (failing)" \
4198 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4199 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4200 1 \
4201 -s "cookie verification failed" \
4202 -S "cookie verification passed" \
4203 -S "cookie verification skipped" \
4204 -C "received hello verify request" \
4205 -S "hello verification requested" \
4206 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004207
4208requires_ipv6
4209run_test "DTLS cookie: enabled, IPv6" \
4210 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4211 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4212 0 \
4213 -s "cookie verification failed" \
4214 -s "cookie verification passed" \
4215 -S "cookie verification skipped" \
4216 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004217 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004218 -S "SSL - The requested feature is not available"
4219
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004220run_test "DTLS cookie: enabled, nbio" \
4221 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4222 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4223 0 \
4224 -s "cookie verification failed" \
4225 -s "cookie verification passed" \
4226 -S "cookie verification skipped" \
4227 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004228 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004229 -S "SSL - The requested feature is not available"
4230
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004231# Tests for client reconnecting from the same port with DTLS
4232
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004233not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004234run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004235 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4236 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004237 0 \
4238 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004239 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004240 -S "Client initiated reconnection from same port"
4241
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004242not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004243run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004244 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4245 "$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 +02004246 0 \
4247 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004248 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004249 -s "Client initiated reconnection from same port"
4250
Paul Bakker362689d2016-05-13 10:33:25 +01004251not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4252run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004253 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4254 "$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 +02004255 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004256 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004257 -s "Client initiated reconnection from same port"
4258
Paul Bakker362689d2016-05-13 10:33:25 +01004259only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4260run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4261 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4262 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4263 0 \
4264 -S "The operation timed out" \
4265 -s "Client initiated reconnection from same port"
4266
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004267run_test "DTLS client reconnect from same port: no cookies" \
4268 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004269 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4270 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004271 -s "The operation timed out" \
4272 -S "Client initiated reconnection from same port"
4273
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004274# Tests for various cases of client authentication with DTLS
4275# (focused on handshake flows and message parsing)
4276
4277run_test "DTLS client auth: required" \
4278 "$P_SRV dtls=1 auth_mode=required" \
4279 "$P_CLI dtls=1" \
4280 0 \
4281 -s "Verifying peer X.509 certificate... ok"
4282
4283run_test "DTLS client auth: optional, client has no cert" \
4284 "$P_SRV dtls=1 auth_mode=optional" \
4285 "$P_CLI dtls=1 crt_file=none key_file=none" \
4286 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004287 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004288
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004289run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004290 "$P_SRV dtls=1 auth_mode=none" \
4291 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
4292 0 \
4293 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004294 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004295
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02004296run_test "DTLS wrong PSK: badmac alert" \
4297 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
4298 "$P_CLI dtls=1 psk=abc124" \
4299 1 \
4300 -s "SSL - Verification of the message MAC failed" \
4301 -c "SSL - A fatal alert message was received from our peer"
4302
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02004303# Tests for receiving fragmented handshake messages with DTLS
4304
4305requires_gnutls
4306run_test "DTLS reassembly: no fragmentation (gnutls server)" \
4307 "$G_SRV -u --mtu 2048 -a" \
4308 "$P_CLI dtls=1 debug_level=2" \
4309 0 \
4310 -C "found fragmented DTLS handshake message" \
4311 -C "error"
4312
4313requires_gnutls
4314run_test "DTLS reassembly: some fragmentation (gnutls server)" \
4315 "$G_SRV -u --mtu 512" \
4316 "$P_CLI dtls=1 debug_level=2" \
4317 0 \
4318 -c "found fragmented DTLS handshake message" \
4319 -C "error"
4320
4321requires_gnutls
4322run_test "DTLS reassembly: more fragmentation (gnutls server)" \
4323 "$G_SRV -u --mtu 128" \
4324 "$P_CLI dtls=1 debug_level=2" \
4325 0 \
4326 -c "found fragmented DTLS handshake message" \
4327 -C "error"
4328
4329requires_gnutls
4330run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
4331 "$G_SRV -u --mtu 128" \
4332 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4333 0 \
4334 -c "found fragmented DTLS handshake message" \
4335 -C "error"
4336
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004337requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004338requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004339run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4340 "$G_SRV -u --mtu 256" \
4341 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4342 0 \
4343 -c "found fragmented DTLS handshake message" \
4344 -c "client hello, adding renegotiation extension" \
4345 -c "found renegotiation extension" \
4346 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004347 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004348 -C "error" \
4349 -s "Extra-header:"
4350
4351requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004352requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004353run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4354 "$G_SRV -u --mtu 256" \
4355 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4356 0 \
4357 -c "found fragmented DTLS handshake message" \
4358 -c "client hello, adding renegotiation extension" \
4359 -c "found renegotiation extension" \
4360 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004361 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004362 -C "error" \
4363 -s "Extra-header:"
4364
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004365run_test "DTLS reassembly: no fragmentation (openssl server)" \
4366 "$O_SRV -dtls1 -mtu 2048" \
4367 "$P_CLI dtls=1 debug_level=2" \
4368 0 \
4369 -C "found fragmented DTLS handshake message" \
4370 -C "error"
4371
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004372run_test "DTLS reassembly: some fragmentation (openssl server)" \
4373 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004374 "$P_CLI dtls=1 debug_level=2" \
4375 0 \
4376 -c "found fragmented DTLS handshake message" \
4377 -C "error"
4378
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004379run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004380 "$O_SRV -dtls1 -mtu 256" \
4381 "$P_CLI dtls=1 debug_level=2" \
4382 0 \
4383 -c "found fragmented DTLS handshake message" \
4384 -C "error"
4385
4386run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4387 "$O_SRV -dtls1 -mtu 256" \
4388 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4389 0 \
4390 -c "found fragmented DTLS handshake message" \
4391 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004392
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004393# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004394
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004395not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004396run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004397 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004398 "$P_SRV dtls=1 debug_level=2" \
4399 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004400 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004401 -C "replayed record" \
4402 -S "replayed record" \
4403 -C "record from another epoch" \
4404 -S "record from another epoch" \
4405 -C "discarding invalid record" \
4406 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004407 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004408 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004409 -c "HTTP/1.0 200 OK"
4410
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004411not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004412run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004413 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004414 "$P_SRV dtls=1 debug_level=2" \
4415 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004416 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004417 -c "replayed record" \
4418 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004419 -c "discarding invalid record" \
4420 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004421 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004422 -s "Extra-header:" \
4423 -c "HTTP/1.0 200 OK"
4424
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004425run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4426 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004427 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4428 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004429 0 \
4430 -c "replayed record" \
4431 -S "replayed record" \
4432 -c "discarding invalid record" \
4433 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004434 -c "resend" \
4435 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004436 -s "Extra-header:" \
4437 -c "HTTP/1.0 200 OK"
4438
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004439run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004440 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004441 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004442 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004443 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004444 -c "discarding invalid record (mac)" \
4445 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004446 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004447 -c "HTTP/1.0 200 OK" \
4448 -S "too many records with bad MAC" \
4449 -S "Verification of the message MAC failed"
4450
4451run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4452 -p "$P_PXY bad_ad=1" \
4453 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4454 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4455 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004456 -C "discarding invalid record (mac)" \
4457 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004458 -S "Extra-header:" \
4459 -C "HTTP/1.0 200 OK" \
4460 -s "too many records with bad MAC" \
4461 -s "Verification of the message MAC failed"
4462
4463run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4464 -p "$P_PXY bad_ad=1" \
4465 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4466 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4467 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004468 -c "discarding invalid record (mac)" \
4469 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004470 -s "Extra-header:" \
4471 -c "HTTP/1.0 200 OK" \
4472 -S "too many records with bad MAC" \
4473 -S "Verification of the message MAC failed"
4474
4475run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4476 -p "$P_PXY bad_ad=1" \
4477 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4478 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4479 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004480 -c "discarding invalid record (mac)" \
4481 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004482 -s "Extra-header:" \
4483 -c "HTTP/1.0 200 OK" \
4484 -s "too many records with bad MAC" \
4485 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004486
4487run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004488 -p "$P_PXY delay_ccs=1" \
4489 "$P_SRV dtls=1 debug_level=1" \
4490 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004491 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004492 -c "record from another epoch" \
4493 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004494 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004495 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004496 -s "Extra-header:" \
4497 -c "HTTP/1.0 200 OK"
4498
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004499# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004500
Janos Follath74537a62016-09-02 13:45:28 +01004501client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004502run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004503 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004504 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4505 psk=abc123" \
4506 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004507 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4508 0 \
4509 -s "Extra-header:" \
4510 -c "HTTP/1.0 200 OK"
4511
Janos Follath74537a62016-09-02 13:45:28 +01004512client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004513run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4514 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004515 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4516 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004517 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4518 0 \
4519 -s "Extra-header:" \
4520 -c "HTTP/1.0 200 OK"
4521
Janos Follath74537a62016-09-02 13:45:28 +01004522client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004523run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4524 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004525 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4526 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004527 0 \
4528 -s "Extra-header:" \
4529 -c "HTTP/1.0 200 OK"
4530
Janos Follath74537a62016-09-02 13:45:28 +01004531client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004532run_test "DTLS proxy: 3d, FS, client auth" \
4533 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004534 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4535 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004536 0 \
4537 -s "Extra-header:" \
4538 -c "HTTP/1.0 200 OK"
4539
Janos Follath74537a62016-09-02 13:45:28 +01004540client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004541run_test "DTLS proxy: 3d, FS, ticket" \
4542 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004543 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4544 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004545 0 \
4546 -s "Extra-header:" \
4547 -c "HTTP/1.0 200 OK"
4548
Janos Follath74537a62016-09-02 13:45:28 +01004549client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004550run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4551 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004552 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4553 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004554 0 \
4555 -s "Extra-header:" \
4556 -c "HTTP/1.0 200 OK"
4557
Janos Follath74537a62016-09-02 13:45:28 +01004558client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004559run_test "DTLS proxy: 3d, max handshake, nbio" \
4560 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004561 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4562 auth_mode=required" \
4563 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004564 0 \
4565 -s "Extra-header:" \
4566 -c "HTTP/1.0 200 OK"
4567
Janos Follath74537a62016-09-02 13:45:28 +01004568client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004569run_test "DTLS proxy: 3d, min handshake, resumption" \
4570 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4571 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4572 psk=abc123 debug_level=3" \
4573 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4574 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4575 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4576 0 \
4577 -s "a session has been resumed" \
4578 -c "a session has been resumed" \
4579 -s "Extra-header:" \
4580 -c "HTTP/1.0 200 OK"
4581
Janos Follath74537a62016-09-02 13:45:28 +01004582client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004583run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4584 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4585 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4586 psk=abc123 debug_level=3 nbio=2" \
4587 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4588 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4589 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4590 0 \
4591 -s "a session has been resumed" \
4592 -c "a session has been resumed" \
4593 -s "Extra-header:" \
4594 -c "HTTP/1.0 200 OK"
4595
Janos Follath74537a62016-09-02 13:45:28 +01004596client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004597requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004598run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004599 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004600 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4601 psk=abc123 renegotiation=1 debug_level=2" \
4602 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4603 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004604 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4605 0 \
4606 -c "=> renegotiate" \
4607 -s "=> renegotiate" \
4608 -s "Extra-header:" \
4609 -c "HTTP/1.0 200 OK"
4610
Janos Follath74537a62016-09-02 13:45:28 +01004611client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004612requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004613run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4614 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004615 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4616 psk=abc123 renegotiation=1 debug_level=2" \
4617 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4618 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004619 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4620 0 \
4621 -c "=> renegotiate" \
4622 -s "=> renegotiate" \
4623 -s "Extra-header:" \
4624 -c "HTTP/1.0 200 OK"
4625
Janos Follath74537a62016-09-02 13:45:28 +01004626client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004627requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004628run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004629 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004630 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004631 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004632 debug_level=2" \
4633 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004634 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004635 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4636 0 \
4637 -c "=> renegotiate" \
4638 -s "=> renegotiate" \
4639 -s "Extra-header:" \
4640 -c "HTTP/1.0 200 OK"
4641
Janos Follath74537a62016-09-02 13:45:28 +01004642client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004643requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004644run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004645 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004646 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004647 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004648 debug_level=2 nbio=2" \
4649 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004650 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004651 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4652 0 \
4653 -c "=> renegotiate" \
4654 -s "=> renegotiate" \
4655 -s "Extra-header:" \
4656 -c "HTTP/1.0 200 OK"
4657
Janos Follath74537a62016-09-02 13:45:28 +01004658client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004659not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004660run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004661 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4662 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004663 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004664 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004665 -c "HTTP/1.0 200 OK"
4666
Janos Follath74537a62016-09-02 13:45:28 +01004667client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004668not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004669run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4670 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4671 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004672 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004673 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004674 -c "HTTP/1.0 200 OK"
4675
Janos Follath74537a62016-09-02 13:45:28 +01004676client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004677not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004678run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4679 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4680 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004681 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004682 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004683 -c "HTTP/1.0 200 OK"
4684
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004685requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004686client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004687not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004688run_test "DTLS proxy: 3d, gnutls server" \
4689 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4690 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004691 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004692 0 \
4693 -s "Extra-header:" \
4694 -c "Extra-header:"
4695
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004696requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004697client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004698not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004699run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4700 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4701 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004702 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004703 0 \
4704 -s "Extra-header:" \
4705 -c "Extra-header:"
4706
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004707requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004708client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004709not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004710run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4711 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4712 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004713 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004714 0 \
4715 -s "Extra-header:" \
4716 -c "Extra-header:"
4717
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004718# Final report
4719
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004720echo "------------------------------------------------------------------------"
4721
4722if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004723 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004724else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004725 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004726fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004727PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004728echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004729
4730exit $FAILS