blob: 81f024b9c3dab059cfaff16f92d0acded19f30a0 [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
608 fi
609
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200610 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100611}
612
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100613cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200614 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200615 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
616 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
617 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
618 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100619 exit 1
620}
621
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100622#
623# MAIN
624#
625
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000626if cd $( dirname $0 ); then :; else
627 echo "cd $( dirname $0 ) failed" >&2
628 exit 1
629fi
630
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100631get_options "$@"
632
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100633# sanity checks, avoid an avalanche of errors
634if [ ! -x "$P_SRV" ]; then
635 echo "Command '$P_SRV' is not an executable file"
636 exit 1
637fi
638if [ ! -x "$P_CLI" ]; then
639 echo "Command '$P_CLI' is not an executable file"
640 exit 1
641fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200642if [ ! -x "$P_PXY" ]; then
643 echo "Command '$P_PXY' is not an executable file"
644 exit 1
645fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100646if [ "$MEMCHECK" -gt 0 ]; then
647 if which valgrind >/dev/null 2>&1; then :; else
648 echo "Memcheck not possible. Valgrind not found"
649 exit 1
650 fi
651fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100652if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
653 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100654 exit 1
655fi
656
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200657# used by watchdog
658MAIN_PID="$$"
659
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100660# We use somewhat arbitrary delays for tests:
661# - how long do we wait for the server to start (when lsof not available)?
662# - how long do we allow for the client to finish?
663# (not to check performance, just to avoid waiting indefinitely)
664# Things are slower with valgrind, so give extra time here.
665#
666# Note: without lsof, there is a trade-off between the running time of this
667# script and the risk of spurious errors because we didn't wait long enough.
668# The watchdog delay on the other hand doesn't affect normal running time of
669# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200670if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100671 START_DELAY=6
672 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200673else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100674 START_DELAY=2
675 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200676fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100677
678# some particular tests need more time:
679# - for the client, we multiply the usual watchdog limit by a factor
680# - for the server, we sleep for a number of seconds after the client exits
681# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200682CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100683SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200684
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200685# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000686# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200687P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
688P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100689P_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 +0200690O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200691O_CLI="$O_CLI -connect localhost:+SRV_PORT"
692G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000693G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200694
Gilles Peskine62469d92017-05-10 10:13:59 +0200695# Allow SHA-1, because many of our test certificates use it
696P_SRV="$P_SRV allow_sha1=1"
697P_CLI="$P_CLI allow_sha1=1"
698
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200699# Also pick a unique name for intermediate files
700SRV_OUT="srv_out.$$"
701CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200702PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200703SESSION="session.$$"
704
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200705SKIP_NEXT="NO"
706
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100707trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100708
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200709# Basic test
710
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200711# Checks that:
712# - things work with all ciphersuites active (used with config-full in all.sh)
713# - the expected (highest security) parameters are selected
714# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200715run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200716 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200717 "$P_CLI" \
718 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200719 -s "Protocol is TLSv1.2" \
720 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
721 -s "client hello v3, signature_algorithm ext: 6" \
722 -s "ECDHE curve: secp521r1" \
723 -S "error" \
724 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200725
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000726run_test "Default, DTLS" \
727 "$P_SRV dtls=1" \
728 "$P_CLI dtls=1" \
729 0 \
730 -s "Protocol is DTLSv1.2" \
731 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
732
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100733# Test current time in ServerHello
734requires_config_enabled MBEDTLS_HAVE_TIME
735run_test "Default, ServerHello contains gmt_unix_time" \
736 "$P_SRV debug_level=3" \
737 "$P_CLI debug_level=3" \
738 0 \
739 -s "Protocol is TLSv1.2" \
740 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
741 -s "client hello v3, signature_algorithm ext: 6" \
742 -s "ECDHE curve: secp521r1" \
743 -S "error" \
744 -C "error" \
745 -f "check_server_hello_time" \
746 -F "check_server_hello_time"
747
Simon Butcher8e004102016-10-14 00:48:33 +0100748# Test for uniqueness of IVs in AEAD ciphersuites
749run_test "Unique IV in GCM" \
750 "$P_SRV exchanges=20 debug_level=4" \
751 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
752 0 \
753 -u "IV used" \
754 -U "IV used"
755
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100756# Tests for rc4 option
757
Simon Butchera410af52016-05-19 22:12:18 +0100758requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100759run_test "RC4: server disabled, client enabled" \
760 "$P_SRV" \
761 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
762 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100763 -s "SSL - The server has no ciphersuites in common"
764
Simon Butchera410af52016-05-19 22:12:18 +0100765requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100766run_test "RC4: server half, client enabled" \
767 "$P_SRV arc4=1" \
768 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
769 1 \
770 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100771
772run_test "RC4: server enabled, client disabled" \
773 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
774 "$P_CLI" \
775 1 \
776 -s "SSL - The server has no ciphersuites in common"
777
778run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100779 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100780 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
781 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100782 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100783 -S "SSL - The server has no ciphersuites in common"
784
Hanno Becker3a333a52018-08-17 09:54:10 +0100785# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
786
787requires_gnutls
788requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
789run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
790 "$G_SRV"\
791 "$P_CLI force_version=tls1_1" \
792 0
793
794requires_gnutls
795requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
796run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
797 "$G_SRV"\
798 "$P_CLI force_version=tls1" \
799 0
800
Gilles Peskinebc70a182017-05-09 15:59:24 +0200801# Tests for SHA-1 support
802
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200803requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200804run_test "SHA-1 forbidden by default in server certificate" \
805 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
806 "$P_CLI debug_level=2 allow_sha1=0" \
807 1 \
808 -c "The certificate is signed with an unacceptable hash"
809
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200810requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
811run_test "SHA-1 forbidden by default in server certificate" \
812 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
813 "$P_CLI debug_level=2 allow_sha1=0" \
814 0
815
Gilles Peskinebc70a182017-05-09 15:59:24 +0200816run_test "SHA-1 explicitly allowed in server certificate" \
817 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
818 "$P_CLI allow_sha1=1" \
819 0
820
821run_test "SHA-256 allowed by default in server certificate" \
822 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
823 "$P_CLI allow_sha1=0" \
824 0
825
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200826requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200827run_test "SHA-1 forbidden by default in client certificate" \
828 "$P_SRV auth_mode=required allow_sha1=0" \
829 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
830 1 \
831 -s "The certificate is signed with an unacceptable hash"
832
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200833requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
834run_test "SHA-1 forbidden by default in client certificate" \
835 "$P_SRV auth_mode=required allow_sha1=0" \
836 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
837 0
838
Gilles Peskinebc70a182017-05-09 15:59:24 +0200839run_test "SHA-1 explicitly allowed in client certificate" \
840 "$P_SRV auth_mode=required allow_sha1=1" \
841 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
842 0
843
844run_test "SHA-256 allowed by default in client certificate" \
845 "$P_SRV auth_mode=required allow_sha1=0" \
846 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
847 0
848
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100849# Tests for Truncated HMAC extension
850
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100851run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200852 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100853 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100854 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000855 -s "dumping 'expected mac' (20 bytes)" \
856 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100857
Hanno Becker32c55012017-11-10 08:42:54 +0000858requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100859run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200860 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000861 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100862 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000863 -s "dumping 'expected mac' (20 bytes)" \
864 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100865
Hanno Becker32c55012017-11-10 08:42:54 +0000866requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100867run_test "Truncated HMAC: client enabled, server default" \
868 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000869 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100870 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000871 -s "dumping 'expected mac' (20 bytes)" \
872 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100873
Hanno Becker32c55012017-11-10 08:42:54 +0000874requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100875run_test "Truncated HMAC: client enabled, server disabled" \
876 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000877 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100878 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000879 -s "dumping 'expected mac' (20 bytes)" \
880 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100881
Hanno Becker32c55012017-11-10 08:42:54 +0000882requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000883run_test "Truncated HMAC: client disabled, server enabled" \
884 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000885 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000886 0 \
887 -s "dumping 'expected mac' (20 bytes)" \
888 -S "dumping 'expected mac' (10 bytes)"
889
890requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100891run_test "Truncated HMAC: client enabled, server enabled" \
892 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000893 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100894 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000895 -S "dumping 'expected mac' (20 bytes)" \
896 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100897
Hanno Becker4c4f4102017-11-10 09:16:05 +0000898run_test "Truncated HMAC, DTLS: client default, server default" \
899 "$P_SRV dtls=1 debug_level=4" \
900 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
901 0 \
902 -s "dumping 'expected mac' (20 bytes)" \
903 -S "dumping 'expected mac' (10 bytes)"
904
905requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
906run_test "Truncated HMAC, DTLS: client disabled, server default" \
907 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000908 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000909 0 \
910 -s "dumping 'expected mac' (20 bytes)" \
911 -S "dumping 'expected mac' (10 bytes)"
912
913requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
914run_test "Truncated HMAC, DTLS: client enabled, server default" \
915 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000916 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000917 0 \
918 -s "dumping 'expected mac' (20 bytes)" \
919 -S "dumping 'expected mac' (10 bytes)"
920
921requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
922run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
923 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000924 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000925 0 \
926 -s "dumping 'expected mac' (20 bytes)" \
927 -S "dumping 'expected mac' (10 bytes)"
928
929requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
930run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
931 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000932 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000933 0 \
934 -s "dumping 'expected mac' (20 bytes)" \
935 -S "dumping 'expected mac' (10 bytes)"
936
937requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
938run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
939 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000940 "$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 +0100941 0 \
942 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100943 -s "dumping 'expected mac' (10 bytes)"
944
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100945# Tests for Encrypt-then-MAC extension
946
947run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100948 "$P_SRV debug_level=3 \
949 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100950 "$P_CLI debug_level=3" \
951 0 \
952 -c "client hello, adding encrypt_then_mac extension" \
953 -s "found encrypt then mac extension" \
954 -s "server hello, adding encrypt then mac extension" \
955 -c "found encrypt_then_mac extension" \
956 -c "using encrypt then mac" \
957 -s "using encrypt then mac"
958
959run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100960 "$P_SRV debug_level=3 etm=0 \
961 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100962 "$P_CLI debug_level=3 etm=1" \
963 0 \
964 -c "client hello, adding encrypt_then_mac extension" \
965 -s "found encrypt then mac extension" \
966 -S "server hello, adding encrypt then mac extension" \
967 -C "found encrypt_then_mac extension" \
968 -C "using encrypt then mac" \
969 -S "using encrypt then mac"
970
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100971run_test "Encrypt then MAC: client enabled, aead cipher" \
972 "$P_SRV debug_level=3 etm=1 \
973 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
974 "$P_CLI debug_level=3 etm=1" \
975 0 \
976 -c "client hello, adding encrypt_then_mac extension" \
977 -s "found encrypt then mac extension" \
978 -S "server hello, adding encrypt then mac extension" \
979 -C "found encrypt_then_mac extension" \
980 -C "using encrypt then mac" \
981 -S "using encrypt then mac"
982
983run_test "Encrypt then MAC: client enabled, stream cipher" \
984 "$P_SRV debug_level=3 etm=1 \
985 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100986 "$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 +0100987 0 \
988 -c "client hello, adding encrypt_then_mac extension" \
989 -s "found encrypt then mac extension" \
990 -S "server hello, adding encrypt then mac extension" \
991 -C "found encrypt_then_mac extension" \
992 -C "using encrypt then mac" \
993 -S "using encrypt then mac"
994
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100995run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100996 "$P_SRV debug_level=3 etm=1 \
997 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100998 "$P_CLI debug_level=3 etm=0" \
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 SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001009 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001010 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001011 "$P_CLI debug_level=3 force_version=ssl3" \
1012 0 \
1013 -C "client hello, adding encrypt_then_mac extension" \
1014 -S "found encrypt then mac extension" \
1015 -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
Janos Follathe2681a42016-03-07 15:57:05 +00001020requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001021run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001022 "$P_SRV debug_level=3 force_version=ssl3 \
1023 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001024 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001025 0 \
1026 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001027 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001028 -S "server hello, adding encrypt then mac extension" \
1029 -C "found encrypt_then_mac extension" \
1030 -C "using encrypt then mac" \
1031 -S "using encrypt then mac"
1032
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001033# Tests for Extended Master Secret extension
1034
1035run_test "Extended Master Secret: default" \
1036 "$P_SRV debug_level=3" \
1037 "$P_CLI debug_level=3" \
1038 0 \
1039 -c "client hello, adding extended_master_secret extension" \
1040 -s "found extended master secret extension" \
1041 -s "server hello, adding extended master secret extension" \
1042 -c "found extended_master_secret extension" \
1043 -c "using extended master secret" \
1044 -s "using extended master secret"
1045
1046run_test "Extended Master Secret: client enabled, server disabled" \
1047 "$P_SRV debug_level=3 extended_ms=0" \
1048 "$P_CLI debug_level=3 extended_ms=1" \
1049 0 \
1050 -c "client hello, adding extended_master_secret extension" \
1051 -s "found extended master secret extension" \
1052 -S "server hello, adding extended master secret extension" \
1053 -C "found extended_master_secret extension" \
1054 -C "using extended master secret" \
1055 -S "using extended master secret"
1056
1057run_test "Extended Master Secret: client disabled, server enabled" \
1058 "$P_SRV debug_level=3 extended_ms=1" \
1059 "$P_CLI debug_level=3 extended_ms=0" \
1060 0 \
1061 -C "client hello, adding extended_master_secret extension" \
1062 -S "found extended master secret extension" \
1063 -S "server hello, adding extended master secret extension" \
1064 -C "found extended_master_secret extension" \
1065 -C "using extended master secret" \
1066 -S "using extended master secret"
1067
Janos Follathe2681a42016-03-07 15:57:05 +00001068requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001069run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001070 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001071 "$P_CLI debug_level=3 force_version=ssl3" \
1072 0 \
1073 -C "client hello, adding extended_master_secret extension" \
1074 -S "found extended master secret extension" \
1075 -S "server hello, adding extended master secret extension" \
1076 -C "found extended_master_secret extension" \
1077 -C "using extended master secret" \
1078 -S "using extended master secret"
1079
Janos Follathe2681a42016-03-07 15:57:05 +00001080requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001081run_test "Extended Master Secret: client enabled, server SSLv3" \
1082 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001083 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001084 0 \
1085 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001086 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001087 -S "server hello, adding extended master secret extension" \
1088 -C "found extended_master_secret extension" \
1089 -C "using extended master secret" \
1090 -S "using extended master secret"
1091
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001092# Tests for FALLBACK_SCSV
1093
1094run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001095 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001096 "$P_CLI debug_level=3 force_version=tls1_1" \
1097 0 \
1098 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001099 -S "received FALLBACK_SCSV" \
1100 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001101 -C "is a fatal alert message (msg 86)"
1102
1103run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001104 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001105 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1106 0 \
1107 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001108 -S "received FALLBACK_SCSV" \
1109 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001110 -C "is a fatal alert message (msg 86)"
1111
1112run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001113 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001114 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001115 1 \
1116 -c "adding FALLBACK_SCSV" \
1117 -s "received FALLBACK_SCSV" \
1118 -s "inapropriate fallback" \
1119 -c "is a fatal alert message (msg 86)"
1120
1121run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001122 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001123 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001124 0 \
1125 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001126 -s "received FALLBACK_SCSV" \
1127 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001128 -C "is a fatal alert message (msg 86)"
1129
1130requires_openssl_with_fallback_scsv
1131run_test "Fallback SCSV: default, openssl server" \
1132 "$O_SRV" \
1133 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1134 0 \
1135 -C "adding FALLBACK_SCSV" \
1136 -C "is a fatal alert message (msg 86)"
1137
1138requires_openssl_with_fallback_scsv
1139run_test "Fallback SCSV: enabled, openssl server" \
1140 "$O_SRV" \
1141 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1142 1 \
1143 -c "adding FALLBACK_SCSV" \
1144 -c "is a fatal alert message (msg 86)"
1145
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001146requires_openssl_with_fallback_scsv
1147run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001148 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001149 "$O_CLI -tls1_1" \
1150 0 \
1151 -S "received FALLBACK_SCSV" \
1152 -S "inapropriate fallback"
1153
1154requires_openssl_with_fallback_scsv
1155run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001156 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001157 "$O_CLI -tls1_1 -fallback_scsv" \
1158 1 \
1159 -s "received FALLBACK_SCSV" \
1160 -s "inapropriate fallback"
1161
1162requires_openssl_with_fallback_scsv
1163run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001164 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001165 "$O_CLI -fallback_scsv" \
1166 0 \
1167 -s "received FALLBACK_SCSV" \
1168 -S "inapropriate fallback"
1169
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001170# Test sending and receiving empty application data records
1171
1172run_test "Encrypt then MAC: empty application data record" \
1173 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1174 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1175 0 \
1176 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1177 -s "dumping 'input payload after decrypt' (0 bytes)" \
1178 -c "0 bytes written in 1 fragments"
1179
1180run_test "Default, no Encrypt then MAC: empty application data record" \
1181 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1182 "$P_CLI auth_mode=none etm=0 request_size=0" \
1183 0 \
1184 -s "dumping 'input payload after decrypt' (0 bytes)" \
1185 -c "0 bytes written in 1 fragments"
1186
1187run_test "Encrypt then MAC, DTLS: empty application data record" \
1188 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1189 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1190 0 \
1191 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1192 -s "dumping 'input payload after decrypt' (0 bytes)" \
1193 -c "0 bytes written in 1 fragments"
1194
1195run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
1196 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1197 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1198 0 \
1199 -s "dumping 'input payload after decrypt' (0 bytes)" \
1200 -c "0 bytes written in 1 fragments"
1201
Gilles Peskined50177f2017-05-16 17:53:03 +02001202## ClientHello generated with
1203## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1204## then manually twiddling the ciphersuite list.
1205## The ClientHello content is spelled out below as a hex string as
1206## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1207## The expected response is an inappropriate_fallback alert.
1208requires_openssl_with_fallback_scsv
1209run_test "Fallback SCSV: beginning of list" \
1210 "$P_SRV debug_level=2" \
1211 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1212 0 \
1213 -s "received FALLBACK_SCSV" \
1214 -s "inapropriate fallback"
1215
1216requires_openssl_with_fallback_scsv
1217run_test "Fallback SCSV: end of list" \
1218 "$P_SRV debug_level=2" \
1219 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1220 0 \
1221 -s "received FALLBACK_SCSV" \
1222 -s "inapropriate fallback"
1223
1224## Here the expected response is a valid ServerHello prefix, up to the random.
1225requires_openssl_with_fallback_scsv
1226run_test "Fallback SCSV: not in list" \
1227 "$P_SRV debug_level=2" \
1228 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1229 0 \
1230 -S "received FALLBACK_SCSV" \
1231 -S "inapropriate fallback"
1232
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001233# Tests for CBC 1/n-1 record splitting
1234
1235run_test "CBC Record splitting: TLS 1.2, no splitting" \
1236 "$P_SRV" \
1237 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1238 request_size=123 force_version=tls1_2" \
1239 0 \
1240 -s "Read from client: 123 bytes read" \
1241 -S "Read from client: 1 bytes read" \
1242 -S "122 bytes read"
1243
1244run_test "CBC Record splitting: TLS 1.1, no splitting" \
1245 "$P_SRV" \
1246 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1247 request_size=123 force_version=tls1_1" \
1248 0 \
1249 -s "Read from client: 123 bytes read" \
1250 -S "Read from client: 1 bytes read" \
1251 -S "122 bytes read"
1252
1253run_test "CBC Record splitting: TLS 1.0, splitting" \
1254 "$P_SRV" \
1255 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1256 request_size=123 force_version=tls1" \
1257 0 \
1258 -S "Read from client: 123 bytes read" \
1259 -s "Read from client: 1 bytes read" \
1260 -s "122 bytes read"
1261
Janos Follathe2681a42016-03-07 15:57:05 +00001262requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001263run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001264 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001265 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1266 request_size=123 force_version=ssl3" \
1267 0 \
1268 -S "Read from client: 123 bytes read" \
1269 -s "Read from client: 1 bytes read" \
1270 -s "122 bytes read"
1271
1272run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001273 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001274 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1275 request_size=123 force_version=tls1" \
1276 0 \
1277 -s "Read from client: 123 bytes read" \
1278 -S "Read from client: 1 bytes read" \
1279 -S "122 bytes read"
1280
1281run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1282 "$P_SRV" \
1283 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1284 request_size=123 force_version=tls1 recsplit=0" \
1285 0 \
1286 -s "Read from client: 123 bytes read" \
1287 -S "Read from client: 1 bytes read" \
1288 -S "122 bytes read"
1289
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001290run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1291 "$P_SRV nbio=2" \
1292 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1293 request_size=123 force_version=tls1" \
1294 0 \
1295 -S "Read from client: 123 bytes read" \
1296 -s "Read from client: 1 bytes read" \
1297 -s "122 bytes read"
1298
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001299# Tests for Session Tickets
1300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001301run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001302 "$P_SRV debug_level=3 tickets=1" \
1303 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001304 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001305 -c "client hello, adding session ticket extension" \
1306 -s "found session ticket extension" \
1307 -s "server hello, adding session ticket extension" \
1308 -c "found session_ticket extension" \
1309 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001310 -S "session successfully restored from cache" \
1311 -s "session successfully restored from ticket" \
1312 -s "a session has been resumed" \
1313 -c "a session has been resumed"
1314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001315run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001316 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1317 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001318 0 \
1319 -c "client hello, adding session ticket extension" \
1320 -s "found session ticket extension" \
1321 -s "server hello, adding session ticket extension" \
1322 -c "found session_ticket extension" \
1323 -c "parse new session ticket" \
1324 -S "session successfully restored from cache" \
1325 -s "session successfully restored from ticket" \
1326 -s "a session has been resumed" \
1327 -c "a session has been resumed"
1328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001329run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001330 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1331 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001332 0 \
1333 -c "client hello, adding session ticket extension" \
1334 -s "found session ticket extension" \
1335 -s "server hello, adding session ticket extension" \
1336 -c "found session_ticket extension" \
1337 -c "parse new session ticket" \
1338 -S "session successfully restored from cache" \
1339 -S "session successfully restored from ticket" \
1340 -S "a session has been resumed" \
1341 -C "a session has been resumed"
1342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001343run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001344 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001345 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001346 0 \
1347 -c "client hello, adding session ticket extension" \
1348 -c "found session_ticket extension" \
1349 -c "parse new session ticket" \
1350 -c "a session has been resumed"
1351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001352run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001353 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001354 "( $O_CLI -sess_out $SESSION; \
1355 $O_CLI -sess_in $SESSION; \
1356 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001357 0 \
1358 -s "found session ticket extension" \
1359 -s "server hello, adding session ticket extension" \
1360 -S "session successfully restored from cache" \
1361 -s "session successfully restored from ticket" \
1362 -s "a session has been resumed"
1363
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001364# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001365
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001366run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001367 "$P_SRV debug_level=3 tickets=0" \
1368 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001369 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001370 -c "client hello, adding session ticket extension" \
1371 -s "found session ticket extension" \
1372 -S "server hello, adding session ticket extension" \
1373 -C "found session_ticket extension" \
1374 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001375 -s "session successfully restored from cache" \
1376 -S "session successfully restored from ticket" \
1377 -s "a session has been resumed" \
1378 -c "a session has been resumed"
1379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001380run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_SRV debug_level=3 tickets=1" \
1382 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001383 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001384 -C "client hello, adding session ticket extension" \
1385 -S "found session ticket extension" \
1386 -S "server hello, adding session ticket extension" \
1387 -C "found session_ticket extension" \
1388 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001389 -s "session successfully restored from cache" \
1390 -S "session successfully restored from ticket" \
1391 -s "a session has been resumed" \
1392 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001394run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001395 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1396 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001397 0 \
1398 -S "session successfully restored from cache" \
1399 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001400 -S "a session has been resumed" \
1401 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001403run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001404 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1405 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001406 0 \
1407 -s "session successfully restored from cache" \
1408 -S "session successfully restored from ticket" \
1409 -s "a session has been resumed" \
1410 -c "a session has been resumed"
1411
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001412run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001413 "$P_SRV debug_level=3 tickets=0" \
1414 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001415 0 \
1416 -s "session successfully restored from cache" \
1417 -S "session successfully restored from ticket" \
1418 -s "a session has been resumed" \
1419 -c "a session has been resumed"
1420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001421run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001422 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1423 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001424 0 \
1425 -S "session successfully restored from cache" \
1426 -S "session successfully restored from ticket" \
1427 -S "a session has been resumed" \
1428 -C "a session has been resumed"
1429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001430run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001431 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1432 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001433 0 \
1434 -s "session successfully restored from cache" \
1435 -S "session successfully restored from ticket" \
1436 -s "a session has been resumed" \
1437 -c "a session has been resumed"
1438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001439run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001440 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001441 "( $O_CLI -sess_out $SESSION; \
1442 $O_CLI -sess_in $SESSION; \
1443 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001444 0 \
1445 -s "found session ticket extension" \
1446 -S "server hello, adding session ticket extension" \
1447 -s "session successfully restored from cache" \
1448 -S "session successfully restored from ticket" \
1449 -s "a session has been resumed"
1450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001451run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001452 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001453 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001454 0 \
1455 -C "found session_ticket extension" \
1456 -C "parse new session ticket" \
1457 -c "a session has been resumed"
1458
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001459# Tests for Max Fragment Length extension
1460
Hanno Becker6428f8d2017-09-22 16:58:50 +01001461MAX_CONTENT_LEN_EXPECT='16384'
1462MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1463
1464if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1465 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1466 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1467 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1468 printf "\n"
1469 printf "The tests assume this value and if it changes, the tests in this\n"
1470 printf "script should also be adjusted.\n"
1471 printf "\n"
1472
1473 exit 1
1474fi
1475
Hanno Becker4aed27e2017-09-18 15:00:34 +01001476requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001477run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001478 "$P_SRV debug_level=3" \
1479 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001480 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001481 -c "Maximum fragment length is 16384" \
1482 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001483 -C "client hello, adding max_fragment_length extension" \
1484 -S "found max fragment length extension" \
1485 -S "server hello, max_fragment_length extension" \
1486 -C "found max_fragment_length extension"
1487
Hanno Becker4aed27e2017-09-18 15:00:34 +01001488requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001489run_test "Max fragment length: enabled, default, larger message" \
1490 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001491 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001492 0 \
1493 -c "Maximum fragment length is 16384" \
1494 -s "Maximum fragment length is 16384" \
1495 -C "client hello, adding max_fragment_length extension" \
1496 -S "found max fragment length extension" \
1497 -S "server hello, max_fragment_length extension" \
1498 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001499 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001500 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001501 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001502
1503requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1504run_test "Max fragment length, DTLS: enabled, default, larger message" \
1505 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001506 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001507 1 \
1508 -c "Maximum fragment length is 16384" \
1509 -s "Maximum fragment length is 16384" \
1510 -C "client hello, adding max_fragment_length extension" \
1511 -S "found max fragment length extension" \
1512 -S "server hello, max_fragment_length extension" \
1513 -C "found max_fragment_length extension" \
1514 -c "fragment larger than.*maximum "
1515
1516requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1517run_test "Max fragment length: disabled, larger message" \
1518 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001519 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001520 0 \
1521 -C "Maximum fragment length is 16384" \
1522 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001523 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001524 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001525 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001526
1527requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1528run_test "Max fragment length DTLS: disabled, larger message" \
1529 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001530 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001531 1 \
1532 -C "Maximum fragment length is 16384" \
1533 -S "Maximum fragment length is 16384" \
1534 -c "fragment larger than.*maximum "
1535
1536requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001537run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001538 "$P_SRV debug_level=3" \
1539 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001540 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001541 -c "Maximum fragment length is 4096" \
1542 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001543 -c "client hello, adding max_fragment_length extension" \
1544 -s "found max fragment length extension" \
1545 -s "server hello, max_fragment_length extension" \
1546 -c "found max_fragment_length extension"
1547
Hanno Becker4aed27e2017-09-18 15:00:34 +01001548requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001549run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001550 "$P_SRV debug_level=3 max_frag_len=4096" \
1551 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001552 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001553 -c "Maximum fragment length is 16384" \
1554 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001555 -C "client hello, adding max_fragment_length extension" \
1556 -S "found max fragment length extension" \
1557 -S "server hello, max_fragment_length extension" \
1558 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001559
Hanno Becker4aed27e2017-09-18 15:00:34 +01001560requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001561requires_gnutls
1562run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001563 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001564 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001565 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001566 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001567 -c "client hello, adding max_fragment_length extension" \
1568 -c "found max_fragment_length extension"
1569
Hanno Becker4aed27e2017-09-18 15:00:34 +01001570requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001571run_test "Max fragment length: client, message just fits" \
1572 "$P_SRV debug_level=3" \
1573 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1574 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001575 -c "Maximum fragment length is 2048" \
1576 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001577 -c "client hello, adding max_fragment_length extension" \
1578 -s "found max fragment length extension" \
1579 -s "server hello, max_fragment_length extension" \
1580 -c "found max_fragment_length extension" \
1581 -c "2048 bytes written in 1 fragments" \
1582 -s "2048 bytes read"
1583
Hanno Becker4aed27e2017-09-18 15:00:34 +01001584requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001585run_test "Max fragment length: client, larger message" \
1586 "$P_SRV debug_level=3" \
1587 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1588 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001589 -c "Maximum fragment length is 2048" \
1590 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001591 -c "client hello, adding max_fragment_length extension" \
1592 -s "found max fragment length extension" \
1593 -s "server hello, max_fragment_length extension" \
1594 -c "found max_fragment_length extension" \
1595 -c "2345 bytes written in 2 fragments" \
1596 -s "2048 bytes read" \
1597 -s "297 bytes read"
1598
Hanno Becker4aed27e2017-09-18 15:00:34 +01001599requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001600run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001601 "$P_SRV debug_level=3 dtls=1" \
1602 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1603 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001604 -c "Maximum fragment length is 2048" \
1605 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001606 -c "client hello, adding max_fragment_length extension" \
1607 -s "found max fragment length extension" \
1608 -s "server hello, max_fragment_length extension" \
1609 -c "found max_fragment_length extension" \
1610 -c "fragment larger than.*maximum"
1611
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001612# Tests for renegotiation
1613
Hanno Becker6a243642017-10-12 15:18:45 +01001614# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001615run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001616 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001617 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001618 0 \
1619 -C "client hello, adding renegotiation extension" \
1620 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1621 -S "found renegotiation extension" \
1622 -s "server hello, secure renegotiation extension" \
1623 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001624 -C "=> renegotiate" \
1625 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001626 -S "write hello request"
1627
Hanno Becker6a243642017-10-12 15:18:45 +01001628requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001629run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001630 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001631 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001632 0 \
1633 -c "client hello, adding renegotiation extension" \
1634 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1635 -s "found renegotiation extension" \
1636 -s "server hello, secure renegotiation extension" \
1637 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001638 -c "=> renegotiate" \
1639 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001640 -S "write hello request"
1641
Hanno Becker6a243642017-10-12 15:18:45 +01001642requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001643run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001644 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001645 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001646 0 \
1647 -c "client hello, adding renegotiation extension" \
1648 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1649 -s "found renegotiation extension" \
1650 -s "server hello, secure renegotiation extension" \
1651 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001652 -c "=> renegotiate" \
1653 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001654 -s "write hello request"
1655
Janos Follathb0f148c2017-10-05 12:29:42 +01001656# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1657# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1658# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001659requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001660run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1661 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1662 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1663 0 \
1664 -c "client hello, adding renegotiation extension" \
1665 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1666 -s "found renegotiation extension" \
1667 -s "server hello, secure renegotiation extension" \
1668 -c "found renegotiation extension" \
1669 -c "=> renegotiate" \
1670 -s "=> renegotiate" \
1671 -S "write hello request" \
1672 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1673
1674# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1675# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1676# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001677requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001678run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1679 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1680 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1681 0 \
1682 -c "client hello, adding renegotiation extension" \
1683 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1684 -s "found renegotiation extension" \
1685 -s "server hello, secure renegotiation extension" \
1686 -c "found renegotiation extension" \
1687 -c "=> renegotiate" \
1688 -s "=> renegotiate" \
1689 -s "write hello request" \
1690 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1691
Hanno Becker6a243642017-10-12 15:18:45 +01001692requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001693run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001694 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001695 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001696 0 \
1697 -c "client hello, adding renegotiation extension" \
1698 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1699 -s "found renegotiation extension" \
1700 -s "server hello, secure renegotiation extension" \
1701 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001702 -c "=> renegotiate" \
1703 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001704 -s "write hello request"
1705
Hanno Becker6a243642017-10-12 15:18:45 +01001706requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001707run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001708 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001709 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001710 1 \
1711 -c "client hello, adding renegotiation extension" \
1712 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1713 -S "found renegotiation extension" \
1714 -s "server hello, secure renegotiation extension" \
1715 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001716 -c "=> renegotiate" \
1717 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001718 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001719 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001720 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001721
Hanno Becker6a243642017-10-12 15:18:45 +01001722requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001723run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001724 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001725 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001726 0 \
1727 -C "client hello, adding renegotiation extension" \
1728 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1729 -S "found renegotiation extension" \
1730 -s "server hello, secure renegotiation extension" \
1731 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001732 -C "=> renegotiate" \
1733 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001734 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001735 -S "SSL - An unexpected message was received from our peer" \
1736 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001737
Hanno Becker6a243642017-10-12 15:18:45 +01001738requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001739run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001740 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001741 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001742 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001743 0 \
1744 -C "client hello, adding renegotiation extension" \
1745 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1746 -S "found renegotiation extension" \
1747 -s "server hello, secure renegotiation extension" \
1748 -c "found renegotiation extension" \
1749 -C "=> renegotiate" \
1750 -S "=> renegotiate" \
1751 -s "write hello request" \
1752 -S "SSL - An unexpected message was received from our peer" \
1753 -S "failed"
1754
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001755# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001756requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001757run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001758 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001759 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001760 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001761 0 \
1762 -C "client hello, adding renegotiation extension" \
1763 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1764 -S "found renegotiation extension" \
1765 -s "server hello, secure renegotiation extension" \
1766 -c "found renegotiation extension" \
1767 -C "=> renegotiate" \
1768 -S "=> renegotiate" \
1769 -s "write hello request" \
1770 -S "SSL - An unexpected message was received from our peer" \
1771 -S "failed"
1772
Hanno Becker6a243642017-10-12 15:18:45 +01001773requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001774run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001775 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001776 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001777 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001778 0 \
1779 -C "client hello, adding renegotiation extension" \
1780 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1781 -S "found renegotiation extension" \
1782 -s "server hello, secure renegotiation extension" \
1783 -c "found renegotiation extension" \
1784 -C "=> renegotiate" \
1785 -S "=> renegotiate" \
1786 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001787 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001788
Hanno Becker6a243642017-10-12 15:18:45 +01001789requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001790run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001791 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001792 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001793 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001794 0 \
1795 -c "client hello, adding renegotiation extension" \
1796 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1797 -s "found renegotiation extension" \
1798 -s "server hello, secure renegotiation extension" \
1799 -c "found renegotiation extension" \
1800 -c "=> renegotiate" \
1801 -s "=> renegotiate" \
1802 -s "write hello request" \
1803 -S "SSL - An unexpected message was received from our peer" \
1804 -S "failed"
1805
Hanno Becker6a243642017-10-12 15:18:45 +01001806requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001807run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001808 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001809 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1810 0 \
1811 -C "client hello, adding renegotiation extension" \
1812 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1813 -S "found renegotiation extension" \
1814 -s "server hello, secure renegotiation extension" \
1815 -c "found renegotiation extension" \
1816 -S "record counter limit reached: renegotiate" \
1817 -C "=> renegotiate" \
1818 -S "=> renegotiate" \
1819 -S "write hello request" \
1820 -S "SSL - An unexpected message was received from our peer" \
1821 -S "failed"
1822
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001823# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001824requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001825run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001826 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001827 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001828 0 \
1829 -c "client hello, adding renegotiation extension" \
1830 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1831 -s "found renegotiation extension" \
1832 -s "server hello, secure renegotiation extension" \
1833 -c "found renegotiation extension" \
1834 -s "record counter limit reached: renegotiate" \
1835 -c "=> renegotiate" \
1836 -s "=> renegotiate" \
1837 -s "write hello request" \
1838 -S "SSL - An unexpected message was received from our peer" \
1839 -S "failed"
1840
Hanno Becker6a243642017-10-12 15:18:45 +01001841requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001842run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001843 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001844 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001845 0 \
1846 -c "client hello, adding renegotiation extension" \
1847 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1848 -s "found renegotiation extension" \
1849 -s "server hello, secure renegotiation extension" \
1850 -c "found renegotiation extension" \
1851 -s "record counter limit reached: renegotiate" \
1852 -c "=> renegotiate" \
1853 -s "=> renegotiate" \
1854 -s "write hello request" \
1855 -S "SSL - An unexpected message was received from our peer" \
1856 -S "failed"
1857
Hanno Becker6a243642017-10-12 15:18:45 +01001858requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001859run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001860 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001861 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1862 0 \
1863 -C "client hello, adding renegotiation extension" \
1864 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1865 -S "found renegotiation extension" \
1866 -s "server hello, secure renegotiation extension" \
1867 -c "found renegotiation extension" \
1868 -S "record counter limit reached: renegotiate" \
1869 -C "=> renegotiate" \
1870 -S "=> renegotiate" \
1871 -S "write hello request" \
1872 -S "SSL - An unexpected message was received from our peer" \
1873 -S "failed"
1874
Hanno Becker6a243642017-10-12 15:18:45 +01001875requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001876run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001877 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001878 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001879 0 \
1880 -c "client hello, adding renegotiation extension" \
1881 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1882 -s "found renegotiation extension" \
1883 -s "server hello, secure renegotiation extension" \
1884 -c "found renegotiation extension" \
1885 -c "=> renegotiate" \
1886 -s "=> renegotiate" \
1887 -S "write hello request"
1888
Hanno Becker6a243642017-10-12 15:18:45 +01001889requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001890run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001891 "$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 +02001892 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001893 0 \
1894 -c "client hello, adding renegotiation extension" \
1895 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1896 -s "found renegotiation extension" \
1897 -s "server hello, secure renegotiation extension" \
1898 -c "found renegotiation extension" \
1899 -c "=> renegotiate" \
1900 -s "=> renegotiate" \
1901 -s "write hello request"
1902
Hanno Becker6a243642017-10-12 15:18:45 +01001903requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001904run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001905 "$O_SRV -www" \
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 strict, client-initiated" \
1918 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001919 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001920 0 \
1921 -c "client hello, adding renegotiation extension" \
1922 -c "found renegotiation extension" \
1923 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001924 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001925 -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-initiated default" \
1931 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1932 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1933 1 \
1934 -c "client hello, adding renegotiation extension" \
1935 -C "found renegotiation extension" \
1936 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001937 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001938 -c "error" \
1939 -C "HTTP/1.0 200 [Oo][Kk]"
1940
Paul Bakker539d9722015-02-08 16:18:35 +01001941requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001942requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001943run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1944 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1945 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1946 allow_legacy=0" \
1947 1 \
1948 -c "client hello, adding renegotiation extension" \
1949 -C "found renegotiation extension" \
1950 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001951 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001952 -c "error" \
1953 -C "HTTP/1.0 200 [Oo][Kk]"
1954
Paul Bakker539d9722015-02-08 16:18:35 +01001955requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001956requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001957run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1958 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1959 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1960 allow_legacy=1" \
1961 0 \
1962 -c "client hello, adding renegotiation extension" \
1963 -C "found renegotiation extension" \
1964 -c "=> renegotiate" \
1965 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001966 -C "error" \
1967 -c "HTTP/1.0 200 [Oo][Kk]"
1968
Hanno Becker6a243642017-10-12 15:18:45 +01001969requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001970run_test "Renegotiation: DTLS, client-initiated" \
1971 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1972 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1973 0 \
1974 -c "client hello, adding renegotiation extension" \
1975 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1976 -s "found renegotiation extension" \
1977 -s "server hello, secure renegotiation extension" \
1978 -c "found renegotiation extension" \
1979 -c "=> renegotiate" \
1980 -s "=> renegotiate" \
1981 -S "write hello request"
1982
Hanno Becker6a243642017-10-12 15:18:45 +01001983requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001984run_test "Renegotiation: DTLS, server-initiated" \
1985 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001986 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1987 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001988 0 \
1989 -c "client hello, adding renegotiation extension" \
1990 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1991 -s "found renegotiation extension" \
1992 -s "server hello, secure renegotiation extension" \
1993 -c "found renegotiation extension" \
1994 -c "=> renegotiate" \
1995 -s "=> renegotiate" \
1996 -s "write hello request"
1997
Hanno Becker6a243642017-10-12 15:18:45 +01001998requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00001999run_test "Renegotiation: DTLS, renego_period overflow" \
2000 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2001 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2002 0 \
2003 -c "client hello, adding renegotiation extension" \
2004 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2005 -s "found renegotiation extension" \
2006 -s "server hello, secure renegotiation extension" \
2007 -s "record counter limit reached: renegotiate" \
2008 -c "=> renegotiate" \
2009 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002010 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002011
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002012requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002013requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002014run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2015 "$G_SRV -u --mtu 4096" \
2016 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2017 0 \
2018 -c "client hello, adding renegotiation extension" \
2019 -c "found renegotiation extension" \
2020 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002021 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002022 -C "error" \
2023 -s "Extra-header:"
2024
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002025# Test for the "secure renegotation" extension only (no actual renegotiation)
2026
Paul Bakker539d9722015-02-08 16:18:35 +01002027requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002028run_test "Renego ext: gnutls server strict, client default" \
2029 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2030 "$P_CLI debug_level=3" \
2031 0 \
2032 -c "found renegotiation extension" \
2033 -C "error" \
2034 -c "HTTP/1.0 200 [Oo][Kk]"
2035
Paul Bakker539d9722015-02-08 16:18:35 +01002036requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002037run_test "Renego ext: gnutls server unsafe, client default" \
2038 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2039 "$P_CLI debug_level=3" \
2040 0 \
2041 -C "found renegotiation extension" \
2042 -C "error" \
2043 -c "HTTP/1.0 200 [Oo][Kk]"
2044
Paul Bakker539d9722015-02-08 16:18:35 +01002045requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002046run_test "Renego ext: gnutls server unsafe, client break legacy" \
2047 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2048 "$P_CLI debug_level=3 allow_legacy=-1" \
2049 1 \
2050 -C "found renegotiation extension" \
2051 -c "error" \
2052 -C "HTTP/1.0 200 [Oo][Kk]"
2053
Paul Bakker539d9722015-02-08 16:18:35 +01002054requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002055run_test "Renego ext: gnutls client strict, server default" \
2056 "$P_SRV debug_level=3" \
2057 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2058 0 \
2059 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2060 -s "server hello, secure renegotiation extension"
2061
Paul Bakker539d9722015-02-08 16:18:35 +01002062requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002063run_test "Renego ext: gnutls client unsafe, server default" \
2064 "$P_SRV debug_level=3" \
2065 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2066 0 \
2067 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2068 -S "server hello, secure renegotiation extension"
2069
Paul Bakker539d9722015-02-08 16:18:35 +01002070requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002071run_test "Renego ext: gnutls client unsafe, server break legacy" \
2072 "$P_SRV debug_level=3 allow_legacy=-1" \
2073 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2074 1 \
2075 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2076 -S "server hello, secure renegotiation extension"
2077
Janos Follath0b242342016-02-17 10:11:21 +00002078# Tests for silently dropping trailing extra bytes in .der certificates
2079
2080requires_gnutls
2081run_test "DER format: no trailing bytes" \
2082 "$P_SRV crt_file=data_files/server5-der0.crt \
2083 key_file=data_files/server5.key" \
2084 "$G_CLI " \
2085 0 \
2086 -c "Handshake was completed" \
2087
2088requires_gnutls
2089run_test "DER format: with a trailing zero byte" \
2090 "$P_SRV crt_file=data_files/server5-der1a.crt \
2091 key_file=data_files/server5.key" \
2092 "$G_CLI " \
2093 0 \
2094 -c "Handshake was completed" \
2095
2096requires_gnutls
2097run_test "DER format: with a trailing random byte" \
2098 "$P_SRV crt_file=data_files/server5-der1b.crt \
2099 key_file=data_files/server5.key" \
2100 "$G_CLI " \
2101 0 \
2102 -c "Handshake was completed" \
2103
2104requires_gnutls
2105run_test "DER format: with 2 trailing random bytes" \
2106 "$P_SRV crt_file=data_files/server5-der2.crt \
2107 key_file=data_files/server5.key" \
2108 "$G_CLI " \
2109 0 \
2110 -c "Handshake was completed" \
2111
2112requires_gnutls
2113run_test "DER format: with 4 trailing random bytes" \
2114 "$P_SRV crt_file=data_files/server5-der4.crt \
2115 key_file=data_files/server5.key" \
2116 "$G_CLI " \
2117 0 \
2118 -c "Handshake was completed" \
2119
2120requires_gnutls
2121run_test "DER format: with 8 trailing random bytes" \
2122 "$P_SRV crt_file=data_files/server5-der8.crt \
2123 key_file=data_files/server5.key" \
2124 "$G_CLI " \
2125 0 \
2126 -c "Handshake was completed" \
2127
2128requires_gnutls
2129run_test "DER format: with 9 trailing random bytes" \
2130 "$P_SRV crt_file=data_files/server5-der9.crt \
2131 key_file=data_files/server5.key" \
2132 "$G_CLI " \
2133 0 \
2134 -c "Handshake was completed" \
2135
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002136# Tests for auth_mode
2137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002138run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002139 "$P_SRV crt_file=data_files/server5-badsign.crt \
2140 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002141 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002142 1 \
2143 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002144 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002145 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002146 -c "X509 - Certificate verification failed"
2147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002148run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002149 "$P_SRV crt_file=data_files/server5-badsign.crt \
2150 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002151 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002152 0 \
2153 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002154 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002155 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002156 -C "X509 - Certificate verification failed"
2157
Hanno Beckere6706e62017-05-15 16:05:15 +01002158run_test "Authentication: server goodcert, client optional, no trusted CA" \
2159 "$P_SRV" \
2160 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2161 0 \
2162 -c "x509_verify_cert() returned" \
2163 -c "! The certificate is not correctly signed by the trusted CA" \
2164 -c "! Certificate verification flags"\
2165 -C "! mbedtls_ssl_handshake returned" \
2166 -C "X509 - Certificate verification failed" \
2167 -C "SSL - No CA Chain is set, but required to operate"
2168
2169run_test "Authentication: server goodcert, client required, no trusted CA" \
2170 "$P_SRV" \
2171 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2172 1 \
2173 -c "x509_verify_cert() returned" \
2174 -c "! The certificate is not correctly signed by the trusted CA" \
2175 -c "! Certificate verification flags"\
2176 -c "! mbedtls_ssl_handshake returned" \
2177 -c "SSL - No CA Chain is set, but required to operate"
2178
2179# The purpose of the next two tests is to test the client's behaviour when receiving a server
2180# certificate with an unsupported elliptic curve. This should usually not happen because
2181# the client informs the server about the supported curves - it does, though, in the
2182# corner case of a static ECDH suite, because the server doesn't check the curve on that
2183# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2184# different means to have the server ignoring the client's supported curve list.
2185
2186requires_config_enabled MBEDTLS_ECP_C
2187run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2188 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2189 crt_file=data_files/server5.ku-ka.crt" \
2190 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2191 1 \
2192 -c "bad certificate (EC key curve)"\
2193 -c "! Certificate verification flags"\
2194 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2195
2196requires_config_enabled MBEDTLS_ECP_C
2197run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2198 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2199 crt_file=data_files/server5.ku-ka.crt" \
2200 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2201 1 \
2202 -c "bad certificate (EC key curve)"\
2203 -c "! Certificate verification flags"\
2204 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002206run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002207 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002208 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002209 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002210 0 \
2211 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002212 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002213 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002214 -C "X509 - Certificate verification failed"
2215
Simon Butcher99000142016-10-13 17:21:01 +01002216run_test "Authentication: client SHA256, server required" \
2217 "$P_SRV auth_mode=required" \
2218 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2219 key_file=data_files/server6.key \
2220 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2221 0 \
2222 -c "Supported Signature Algorithm found: 4," \
2223 -c "Supported Signature Algorithm found: 5,"
2224
2225run_test "Authentication: client SHA384, server required" \
2226 "$P_SRV auth_mode=required" \
2227 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2228 key_file=data_files/server6.key \
2229 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2230 0 \
2231 -c "Supported Signature Algorithm found: 4," \
2232 -c "Supported Signature Algorithm found: 5,"
2233
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002234requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2235run_test "Authentication: client has no cert, server required (SSLv3)" \
2236 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2237 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2238 key_file=data_files/server5.key" \
2239 1 \
2240 -S "skip write certificate request" \
2241 -C "skip parse certificate request" \
2242 -c "got a certificate request" \
2243 -c "got no certificate to send" \
2244 -S "x509_verify_cert() returned" \
2245 -s "client has no certificate" \
2246 -s "! mbedtls_ssl_handshake returned" \
2247 -c "! mbedtls_ssl_handshake returned" \
2248 -s "No client certification received from the client, but required by the authentication mode"
2249
2250run_test "Authentication: client has no cert, server required (TLS)" \
2251 "$P_SRV debug_level=3 auth_mode=required" \
2252 "$P_CLI debug_level=3 crt_file=none \
2253 key_file=data_files/server5.key" \
2254 1 \
2255 -S "skip write certificate request" \
2256 -C "skip parse certificate request" \
2257 -c "got a certificate request" \
2258 -c "= write certificate$" \
2259 -C "skip write certificate$" \
2260 -S "x509_verify_cert() returned" \
2261 -s "client has no certificate" \
2262 -s "! mbedtls_ssl_handshake returned" \
2263 -c "! mbedtls_ssl_handshake returned" \
2264 -s "No client certification received from the client, but required by the authentication mode"
2265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002266run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002267 "$P_SRV debug_level=3 auth_mode=required" \
2268 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002269 key_file=data_files/server5.key" \
2270 1 \
2271 -S "skip write certificate request" \
2272 -C "skip parse certificate request" \
2273 -c "got a certificate request" \
2274 -C "skip write certificate" \
2275 -C "skip write certificate verify" \
2276 -S "skip parse certificate verify" \
2277 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002278 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002279 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002280 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002281 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002282 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002283# We don't check that the client receives the alert because it might
2284# detect that its write end of the connection is closed and abort
2285# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002286
Janos Follath89baba22017-04-10 14:34:35 +01002287run_test "Authentication: client cert not trusted, server required" \
2288 "$P_SRV debug_level=3 auth_mode=required" \
2289 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2290 key_file=data_files/server5.key" \
2291 1 \
2292 -S "skip write certificate request" \
2293 -C "skip parse certificate request" \
2294 -c "got a certificate request" \
2295 -C "skip write certificate" \
2296 -C "skip write certificate verify" \
2297 -S "skip parse certificate verify" \
2298 -s "x509_verify_cert() returned" \
2299 -s "! The certificate is not correctly signed by the trusted CA" \
2300 -s "! mbedtls_ssl_handshake returned" \
2301 -c "! mbedtls_ssl_handshake returned" \
2302 -s "X509 - Certificate verification failed"
2303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002304run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002305 "$P_SRV debug_level=3 auth_mode=optional" \
2306 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002307 key_file=data_files/server5.key" \
2308 0 \
2309 -S "skip write certificate request" \
2310 -C "skip parse certificate request" \
2311 -c "got a certificate request" \
2312 -C "skip write certificate" \
2313 -C "skip write certificate verify" \
2314 -S "skip parse certificate verify" \
2315 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002316 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002317 -S "! mbedtls_ssl_handshake returned" \
2318 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002319 -S "X509 - Certificate verification failed"
2320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002321run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002322 "$P_SRV debug_level=3 auth_mode=none" \
2323 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002324 key_file=data_files/server5.key" \
2325 0 \
2326 -s "skip write certificate request" \
2327 -C "skip parse certificate request" \
2328 -c "got no certificate request" \
2329 -c "skip write certificate" \
2330 -c "skip write certificate verify" \
2331 -s "skip parse certificate verify" \
2332 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002333 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002334 -S "! mbedtls_ssl_handshake returned" \
2335 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002336 -S "X509 - Certificate verification failed"
2337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002338run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002339 "$P_SRV debug_level=3 auth_mode=optional" \
2340 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002341 0 \
2342 -S "skip write certificate request" \
2343 -C "skip parse certificate request" \
2344 -c "got a certificate request" \
2345 -C "skip write certificate$" \
2346 -C "got no certificate to send" \
2347 -S "SSLv3 client has no certificate" \
2348 -c "skip write certificate verify" \
2349 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002350 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002351 -S "! mbedtls_ssl_handshake returned" \
2352 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002353 -S "X509 - Certificate verification failed"
2354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002355run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002356 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002357 "$O_CLI" \
2358 0 \
2359 -S "skip write certificate request" \
2360 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002361 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002362 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002363 -S "X509 - Certificate verification failed"
2364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002365run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002366 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002367 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002368 0 \
2369 -C "skip parse certificate request" \
2370 -c "got a certificate request" \
2371 -C "skip write certificate$" \
2372 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002373 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002374
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002375run_test "Authentication: client no cert, openssl server required" \
2376 "$O_SRV -Verify 10" \
2377 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2378 1 \
2379 -C "skip parse certificate request" \
2380 -c "got a certificate request" \
2381 -C "skip write certificate$" \
2382 -c "skip write certificate verify" \
2383 -c "! mbedtls_ssl_handshake returned"
2384
Janos Follathe2681a42016-03-07 15:57:05 +00002385requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002386run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002387 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002388 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002389 0 \
2390 -S "skip write certificate request" \
2391 -C "skip parse certificate request" \
2392 -c "got a certificate request" \
2393 -C "skip write certificate$" \
2394 -c "skip write certificate verify" \
2395 -c "got no certificate to send" \
2396 -s "SSLv3 client has no certificate" \
2397 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002398 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002399 -S "! mbedtls_ssl_handshake returned" \
2400 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002401 -S "X509 - Certificate verification failed"
2402
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002403# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2404# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002405
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002406MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002407MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002408
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002409if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002410 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002411 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002412 printf "test value of ${MAX_IM_CA}. \n"
2413 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002414 printf "The tests assume this value and if it changes, the tests in this\n"
2415 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002416 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002417
2418 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002419fi
2420
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002421run_test "Authentication: server max_int chain, client default" \
2422 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2423 key_file=data_files/dir-maxpath/09.key" \
2424 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2425 0 \
2426 -C "X509 - A fatal error occured"
2427
2428run_test "Authentication: server max_int+1 chain, client default" \
2429 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2430 key_file=data_files/dir-maxpath/10.key" \
2431 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2432 1 \
2433 -c "X509 - A fatal error occured"
2434
2435run_test "Authentication: server max_int+1 chain, client optional" \
2436 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2437 key_file=data_files/dir-maxpath/10.key" \
2438 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2439 auth_mode=optional" \
2440 1 \
2441 -c "X509 - A fatal error occured"
2442
2443run_test "Authentication: server max_int+1 chain, client none" \
2444 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2445 key_file=data_files/dir-maxpath/10.key" \
2446 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2447 auth_mode=none" \
2448 0 \
2449 -C "X509 - A fatal error occured"
2450
2451run_test "Authentication: client max_int+1 chain, server default" \
2452 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2453 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2454 key_file=data_files/dir-maxpath/10.key" \
2455 0 \
2456 -S "X509 - A fatal error occured"
2457
2458run_test "Authentication: client max_int+1 chain, server optional" \
2459 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2460 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2461 key_file=data_files/dir-maxpath/10.key" \
2462 1 \
2463 -s "X509 - A fatal error occured"
2464
2465run_test "Authentication: client max_int+1 chain, server required" \
2466 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2467 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2468 key_file=data_files/dir-maxpath/10.key" \
2469 1 \
2470 -s "X509 - A fatal error occured"
2471
2472run_test "Authentication: client max_int chain, server required" \
2473 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2474 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2475 key_file=data_files/dir-maxpath/09.key" \
2476 0 \
2477 -S "X509 - A fatal error occured"
2478
Janos Follath89baba22017-04-10 14:34:35 +01002479# Tests for CA list in CertificateRequest messages
2480
2481run_test "Authentication: send CA list in CertificateRequest (default)" \
2482 "$P_SRV debug_level=3 auth_mode=required" \
2483 "$P_CLI crt_file=data_files/server6.crt \
2484 key_file=data_files/server6.key" \
2485 0 \
2486 -s "requested DN"
2487
2488run_test "Authentication: do not send CA list in CertificateRequest" \
2489 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2490 "$P_CLI crt_file=data_files/server6.crt \
2491 key_file=data_files/server6.key" \
2492 0 \
2493 -S "requested DN"
2494
2495run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2496 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2497 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2498 key_file=data_files/server5.key" \
2499 1 \
2500 -S "requested DN" \
2501 -s "x509_verify_cert() returned" \
2502 -s "! The certificate is not correctly signed by the trusted CA" \
2503 -s "! mbedtls_ssl_handshake returned" \
2504 -c "! mbedtls_ssl_handshake returned" \
2505 -s "X509 - Certificate verification failed"
2506
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002507# Tests for certificate selection based on SHA verson
2508
2509run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2510 "$P_SRV crt_file=data_files/server5.crt \
2511 key_file=data_files/server5.key \
2512 crt_file2=data_files/server5-sha1.crt \
2513 key_file2=data_files/server5.key" \
2514 "$P_CLI force_version=tls1_2" \
2515 0 \
2516 -c "signed using.*ECDSA with SHA256" \
2517 -C "signed using.*ECDSA with SHA1"
2518
2519run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2520 "$P_SRV crt_file=data_files/server5.crt \
2521 key_file=data_files/server5.key \
2522 crt_file2=data_files/server5-sha1.crt \
2523 key_file2=data_files/server5.key" \
2524 "$P_CLI force_version=tls1_1" \
2525 0 \
2526 -C "signed using.*ECDSA with SHA256" \
2527 -c "signed using.*ECDSA with SHA1"
2528
2529run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2530 "$P_SRV crt_file=data_files/server5.crt \
2531 key_file=data_files/server5.key \
2532 crt_file2=data_files/server5-sha1.crt \
2533 key_file2=data_files/server5.key" \
2534 "$P_CLI force_version=tls1" \
2535 0 \
2536 -C "signed using.*ECDSA with SHA256" \
2537 -c "signed using.*ECDSA with SHA1"
2538
2539run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2540 "$P_SRV crt_file=data_files/server5.crt \
2541 key_file=data_files/server5.key \
2542 crt_file2=data_files/server6.crt \
2543 key_file2=data_files/server6.key" \
2544 "$P_CLI force_version=tls1_1" \
2545 0 \
2546 -c "serial number.*09" \
2547 -c "signed using.*ECDSA with SHA256" \
2548 -C "signed using.*ECDSA with SHA1"
2549
2550run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2551 "$P_SRV crt_file=data_files/server6.crt \
2552 key_file=data_files/server6.key \
2553 crt_file2=data_files/server5.crt \
2554 key_file2=data_files/server5.key" \
2555 "$P_CLI force_version=tls1_1" \
2556 0 \
2557 -c "serial number.*0A" \
2558 -c "signed using.*ECDSA with SHA256" \
2559 -C "signed using.*ECDSA with SHA1"
2560
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002561# tests for SNI
2562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002563run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002564 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002565 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002566 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002567 0 \
2568 -S "parse ServerName extension" \
2569 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2570 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002571
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002572run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002573 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002574 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002575 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 +02002576 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002577 0 \
2578 -s "parse ServerName extension" \
2579 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2580 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002582run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002583 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002584 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002585 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 +02002586 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002587 0 \
2588 -s "parse ServerName extension" \
2589 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2590 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002592run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002593 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002594 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002595 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 +02002596 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002597 1 \
2598 -s "parse ServerName extension" \
2599 -s "ssl_sni_wrapper() returned" \
2600 -s "mbedtls_ssl_handshake returned" \
2601 -c "mbedtls_ssl_handshake returned" \
2602 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002603
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002604run_test "SNI: client auth no override: optional" \
2605 "$P_SRV debug_level=3 auth_mode=optional \
2606 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2607 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
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: none -> optional" \
2618 "$P_SRV debug_level=3 auth_mode=none \
2619 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2620 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
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 a certificate request" \
2626 -C "skip write certificate" \
2627 -C "skip write certificate verify" \
2628 -S "skip parse certificate verify"
2629
2630run_test "SNI: client auth override: optional -> none" \
2631 "$P_SRV debug_level=3 auth_mode=optional \
2632 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2633 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2634 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002635 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002636 -s "skip write certificate request" \
2637 -C "skip parse certificate request" \
2638 -c "got no certificate request" \
2639 -c "skip write certificate" \
2640 -c "skip write certificate verify" \
2641 -s "skip parse certificate verify"
2642
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002643run_test "SNI: CA no override" \
2644 "$P_SRV debug_level=3 auth_mode=optional \
2645 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2646 ca_file=data_files/test-ca.crt \
2647 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2648 "$P_CLI debug_level=3 server_name=localhost \
2649 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2650 1 \
2651 -S "skip write certificate request" \
2652 -C "skip parse certificate request" \
2653 -c "got a certificate request" \
2654 -C "skip write certificate" \
2655 -C "skip write certificate verify" \
2656 -S "skip parse certificate verify" \
2657 -s "x509_verify_cert() returned" \
2658 -s "! The certificate is not correctly signed by the trusted CA" \
2659 -S "The certificate has been revoked (is on a CRL)"
2660
2661run_test "SNI: CA override" \
2662 "$P_SRV debug_level=3 auth_mode=optional \
2663 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2664 ca_file=data_files/test-ca.crt \
2665 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2666 "$P_CLI debug_level=3 server_name=localhost \
2667 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2668 0 \
2669 -S "skip write certificate request" \
2670 -C "skip parse certificate request" \
2671 -c "got a certificate request" \
2672 -C "skip write certificate" \
2673 -C "skip write certificate verify" \
2674 -S "skip parse certificate verify" \
2675 -S "x509_verify_cert() returned" \
2676 -S "! The certificate is not correctly signed by the trusted CA" \
2677 -S "The certificate has been revoked (is on a CRL)"
2678
2679run_test "SNI: CA override with CRL" \
2680 "$P_SRV debug_level=3 auth_mode=optional \
2681 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2682 ca_file=data_files/test-ca.crt \
2683 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2684 "$P_CLI debug_level=3 server_name=localhost \
2685 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2686 1 \
2687 -S "skip write certificate request" \
2688 -C "skip parse certificate request" \
2689 -c "got a certificate request" \
2690 -C "skip write certificate" \
2691 -C "skip write certificate verify" \
2692 -S "skip parse certificate verify" \
2693 -s "x509_verify_cert() returned" \
2694 -S "! The certificate is not correctly signed by the trusted CA" \
2695 -s "The certificate has been revoked (is on a CRL)"
2696
Andres AGe8b07742016-12-07 10:01:30 +00002697# Tests for SNI and DTLS
2698
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002699run_test "SNI: DTLS, no SNI callback" \
2700 "$P_SRV debug_level=3 dtls=1 \
2701 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2702 "$P_CLI server_name=localhost dtls=1" \
2703 0 \
2704 -S "parse ServerName extension" \
2705 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2706 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2707
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002708run_test "SNI: DTLS, matching cert 1" \
Andres AGe8b07742016-12-07 10:01:30 +00002709 "$P_SRV debug_level=3 dtls=1 \
2710 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2711 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2712 "$P_CLI server_name=localhost dtls=1" \
2713 0 \
2714 -s "parse ServerName extension" \
2715 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2716 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2717
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002718run_test "SNI: DTLS, matching cert 2" \
2719 "$P_SRV debug_level=3 dtls=1 \
2720 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2721 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2722 "$P_CLI server_name=polarssl.example dtls=1" \
2723 0 \
2724 -s "parse ServerName extension" \
2725 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2726 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2727
2728run_test "SNI: DTLS, no matching cert" \
2729 "$P_SRV debug_level=3 dtls=1 \
2730 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2731 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2732 "$P_CLI server_name=nonesuch.example dtls=1" \
2733 1 \
2734 -s "parse ServerName extension" \
2735 -s "ssl_sni_wrapper() returned" \
2736 -s "mbedtls_ssl_handshake returned" \
2737 -c "mbedtls_ssl_handshake returned" \
2738 -c "SSL - A fatal alert message was received from our peer"
2739
2740run_test "SNI: DTLS, client auth no override: optional" \
2741 "$P_SRV debug_level=3 auth_mode=optional 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,-,-,-" \
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: none -> optional" \
2754 "$P_SRV debug_level=3 auth_mode=none 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,-,-,optional" \
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 a certificate request" \
2762 -C "skip write certificate" \
2763 -C "skip write certificate verify" \
2764 -S "skip parse certificate verify"
2765
2766run_test "SNI: DTLS, client auth override: optional -> none" \
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 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2770 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2771 0 \
2772 -s "skip write certificate request" \
2773 -C "skip parse certificate request" \
2774 -c "got no certificate request" \
2775 -c "skip write certificate" \
2776 -c "skip write certificate verify" \
2777 -s "skip parse certificate verify"
2778
2779run_test "SNI: DTLS, CA no override" \
2780 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2781 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2782 ca_file=data_files/test-ca.crt \
2783 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2784 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2785 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2786 1 \
2787 -S "skip write certificate request" \
2788 -C "skip parse certificate request" \
2789 -c "got a certificate request" \
2790 -C "skip write certificate" \
2791 -C "skip write certificate verify" \
2792 -S "skip parse certificate verify" \
2793 -s "x509_verify_cert() returned" \
2794 -s "! The certificate is not correctly signed by the trusted CA" \
2795 -S "The certificate has been revoked (is on a CRL)"
2796
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002797run_test "SNI: DTLS, CA override" \
Andres AGe8b07742016-12-07 10:01:30 +00002798 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2799 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2800 ca_file=data_files/test-ca.crt \
2801 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2802 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2803 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2804 0 \
2805 -S "skip write certificate request" \
2806 -C "skip parse certificate request" \
2807 -c "got a certificate request" \
2808 -C "skip write certificate" \
2809 -C "skip write certificate verify" \
2810 -S "skip parse certificate verify" \
2811 -S "x509_verify_cert() returned" \
2812 -S "! The certificate is not correctly signed by the trusted CA" \
2813 -S "The certificate has been revoked (is on a CRL)"
2814
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002815run_test "SNI: DTLS, CA override with CRL" \
Andres AGe8b07742016-12-07 10:01:30 +00002816 "$P_SRV debug_level=3 auth_mode=optional \
2817 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2818 ca_file=data_files/test-ca.crt \
2819 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2820 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2821 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2822 1 \
2823 -S "skip write certificate request" \
2824 -C "skip parse certificate request" \
2825 -c "got a certificate request" \
2826 -C "skip write certificate" \
2827 -C "skip write certificate verify" \
2828 -S "skip parse certificate verify" \
2829 -s "x509_verify_cert() returned" \
2830 -S "! The certificate is not correctly signed by the trusted CA" \
2831 -s "The certificate has been revoked (is on a CRL)"
2832
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002833# Tests for non-blocking I/O: exercise a variety of handshake flows
2834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002835run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002836 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2837 "$P_CLI nbio=2 tickets=0" \
2838 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002839 -S "mbedtls_ssl_handshake returned" \
2840 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002841 -c "Read from server: .* bytes read"
2842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002843run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002844 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2845 "$P_CLI nbio=2 tickets=0" \
2846 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002847 -S "mbedtls_ssl_handshake returned" \
2848 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002849 -c "Read from server: .* bytes read"
2850
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002851run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002852 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2853 "$P_CLI nbio=2 tickets=1" \
2854 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002855 -S "mbedtls_ssl_handshake returned" \
2856 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002857 -c "Read from server: .* bytes read"
2858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002859run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002860 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2861 "$P_CLI nbio=2 tickets=1" \
2862 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002863 -S "mbedtls_ssl_handshake returned" \
2864 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002865 -c "Read from server: .* bytes read"
2866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002867run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002868 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2869 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2870 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002871 -S "mbedtls_ssl_handshake returned" \
2872 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002873 -c "Read from server: .* bytes read"
2874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002875run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002876 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2877 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2878 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002879 -S "mbedtls_ssl_handshake returned" \
2880 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002881 -c "Read from server: .* bytes read"
2882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002883run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002884 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2885 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2886 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002887 -S "mbedtls_ssl_handshake returned" \
2888 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002889 -c "Read from server: .* bytes read"
2890
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002891# Tests for version negotiation
2892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002893run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002894 "$P_SRV" \
2895 "$P_CLI" \
2896 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002897 -S "mbedtls_ssl_handshake returned" \
2898 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002899 -s "Protocol is TLSv1.2" \
2900 -c "Protocol is TLSv1.2"
2901
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002902run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002903 "$P_SRV" \
2904 "$P_CLI max_version=tls1_1" \
2905 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002906 -S "mbedtls_ssl_handshake returned" \
2907 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002908 -s "Protocol is TLSv1.1" \
2909 -c "Protocol is TLSv1.1"
2910
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002911run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002912 "$P_SRV max_version=tls1_1" \
2913 "$P_CLI" \
2914 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002915 -S "mbedtls_ssl_handshake returned" \
2916 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002917 -s "Protocol is TLSv1.1" \
2918 -c "Protocol is TLSv1.1"
2919
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002920run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002921 "$P_SRV max_version=tls1_1" \
2922 "$P_CLI max_version=tls1_1" \
2923 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002924 -S "mbedtls_ssl_handshake returned" \
2925 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002926 -s "Protocol is TLSv1.1" \
2927 -c "Protocol is TLSv1.1"
2928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002929run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002930 "$P_SRV min_version=tls1_1" \
2931 "$P_CLI max_version=tls1_1" \
2932 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002933 -S "mbedtls_ssl_handshake returned" \
2934 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002935 -s "Protocol is TLSv1.1" \
2936 -c "Protocol is TLSv1.1"
2937
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002938run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002939 "$P_SRV max_version=tls1_1" \
2940 "$P_CLI min_version=tls1_1" \
2941 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002942 -S "mbedtls_ssl_handshake returned" \
2943 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002944 -s "Protocol is TLSv1.1" \
2945 -c "Protocol is TLSv1.1"
2946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002947run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002948 "$P_SRV max_version=tls1_1" \
2949 "$P_CLI min_version=tls1_2" \
2950 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002951 -s "mbedtls_ssl_handshake returned" \
2952 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002953 -c "SSL - Handshake protocol not within min/max boundaries"
2954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002955run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002956 "$P_SRV min_version=tls1_2" \
2957 "$P_CLI max_version=tls1_1" \
2958 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002959 -s "mbedtls_ssl_handshake returned" \
2960 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002961 -s "SSL - Handshake protocol not within min/max boundaries"
2962
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002963# Tests for ALPN extension
2964
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002965run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002966 "$P_SRV debug_level=3" \
2967 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002968 0 \
2969 -C "client hello, adding alpn extension" \
2970 -S "found alpn extension" \
2971 -C "got an alert message, type: \\[2:120]" \
2972 -S "server hello, adding alpn extension" \
2973 -C "found alpn extension " \
2974 -C "Application Layer Protocol is" \
2975 -S "Application Layer Protocol is"
2976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002977run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002978 "$P_SRV debug_level=3" \
2979 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002980 0 \
2981 -c "client hello, adding alpn extension" \
2982 -s "found alpn extension" \
2983 -C "got an alert message, type: \\[2:120]" \
2984 -S "server hello, adding alpn extension" \
2985 -C "found alpn extension " \
2986 -c "Application Layer Protocol is (none)" \
2987 -S "Application Layer Protocol is"
2988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002989run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002990 "$P_SRV debug_level=3 alpn=abc,1234" \
2991 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002992 0 \
2993 -C "client hello, adding alpn extension" \
2994 -S "found alpn extension" \
2995 -C "got an alert message, type: \\[2:120]" \
2996 -S "server hello, adding alpn extension" \
2997 -C "found alpn extension " \
2998 -C "Application Layer Protocol is" \
2999 -s "Application Layer Protocol is (none)"
3000
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003001run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003002 "$P_SRV debug_level=3 alpn=abc,1234" \
3003 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003004 0 \
3005 -c "client hello, adding alpn extension" \
3006 -s "found alpn extension" \
3007 -C "got an alert message, type: \\[2:120]" \
3008 -s "server hello, adding alpn extension" \
3009 -c "found alpn extension" \
3010 -c "Application Layer Protocol is abc" \
3011 -s "Application Layer Protocol is abc"
3012
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003013run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003014 "$P_SRV debug_level=3 alpn=abc,1234" \
3015 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003016 0 \
3017 -c "client hello, adding alpn extension" \
3018 -s "found alpn extension" \
3019 -C "got an alert message, type: \\[2:120]" \
3020 -s "server hello, adding alpn extension" \
3021 -c "found alpn extension" \
3022 -c "Application Layer Protocol is abc" \
3023 -s "Application Layer Protocol is abc"
3024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003025run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003026 "$P_SRV debug_level=3 alpn=abc,1234" \
3027 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003028 0 \
3029 -c "client hello, adding alpn extension" \
3030 -s "found alpn extension" \
3031 -C "got an alert message, type: \\[2:120]" \
3032 -s "server hello, adding alpn extension" \
3033 -c "found alpn extension" \
3034 -c "Application Layer Protocol is 1234" \
3035 -s "Application Layer Protocol is 1234"
3036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003037run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003038 "$P_SRV debug_level=3 alpn=abc,123" \
3039 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003040 1 \
3041 -c "client hello, adding alpn extension" \
3042 -s "found alpn extension" \
3043 -c "got an alert message, type: \\[2:120]" \
3044 -S "server hello, adding alpn extension" \
3045 -C "found alpn extension" \
3046 -C "Application Layer Protocol is 1234" \
3047 -S "Application Layer Protocol is 1234"
3048
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003049
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003050# Tests for keyUsage in leaf certificates, part 1:
3051# server-side certificate/suite selection
3052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003053run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003054 "$P_SRV key_file=data_files/server2.key \
3055 crt_file=data_files/server2.ku-ds.crt" \
3056 "$P_CLI" \
3057 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003058 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003059
3060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003061run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003062 "$P_SRV key_file=data_files/server2.key \
3063 crt_file=data_files/server2.ku-ke.crt" \
3064 "$P_CLI" \
3065 0 \
3066 -c "Ciphersuite is TLS-RSA-WITH-"
3067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003068run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003069 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003070 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003071 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003072 1 \
3073 -C "Ciphersuite is "
3074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003075run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003076 "$P_SRV key_file=data_files/server5.key \
3077 crt_file=data_files/server5.ku-ds.crt" \
3078 "$P_CLI" \
3079 0 \
3080 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3081
3082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003083run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003084 "$P_SRV key_file=data_files/server5.key \
3085 crt_file=data_files/server5.ku-ka.crt" \
3086 "$P_CLI" \
3087 0 \
3088 -c "Ciphersuite is TLS-ECDH-"
3089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003090run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003091 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003092 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003093 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003094 1 \
3095 -C "Ciphersuite is "
3096
3097# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003098# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003100run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003101 "$O_SRV -key data_files/server2.key \
3102 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003103 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003104 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3105 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003106 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003107 -C "Processing of the Certificate handshake message failed" \
3108 -c "Ciphersuite is TLS-"
3109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003110run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003111 "$O_SRV -key data_files/server2.key \
3112 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003113 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003114 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3115 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003116 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003117 -C "Processing of the Certificate handshake message failed" \
3118 -c "Ciphersuite is TLS-"
3119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003120run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003121 "$O_SRV -key data_files/server2.key \
3122 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003123 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003124 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3125 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003126 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003127 -C "Processing of the Certificate handshake message failed" \
3128 -c "Ciphersuite is TLS-"
3129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003130run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003131 "$O_SRV -key data_files/server2.key \
3132 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003133 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003134 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3135 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003136 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003137 -c "Processing of the Certificate handshake message failed" \
3138 -C "Ciphersuite is TLS-"
3139
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003140run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3141 "$O_SRV -key data_files/server2.key \
3142 -cert data_files/server2.ku-ke.crt" \
3143 "$P_CLI debug_level=1 auth_mode=optional \
3144 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3145 0 \
3146 -c "bad certificate (usage extensions)" \
3147 -C "Processing of the Certificate handshake message failed" \
3148 -c "Ciphersuite is TLS-" \
3149 -c "! Usage does not match the keyUsage extension"
3150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003151run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003152 "$O_SRV -key data_files/server2.key \
3153 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003154 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003155 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3156 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003157 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003158 -C "Processing of the Certificate handshake message failed" \
3159 -c "Ciphersuite is TLS-"
3160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003161run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003162 "$O_SRV -key data_files/server2.key \
3163 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003164 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003165 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3166 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003167 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003168 -c "Processing of the Certificate handshake message failed" \
3169 -C "Ciphersuite is TLS-"
3170
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003171run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3172 "$O_SRV -key data_files/server2.key \
3173 -cert data_files/server2.ku-ds.crt" \
3174 "$P_CLI debug_level=1 auth_mode=optional \
3175 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3176 0 \
3177 -c "bad certificate (usage extensions)" \
3178 -C "Processing of the Certificate handshake message failed" \
3179 -c "Ciphersuite is TLS-" \
3180 -c "! Usage does not match the keyUsage extension"
3181
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003182# Tests for keyUsage in leaf certificates, part 3:
3183# server-side checking of client cert
3184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003185run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003186 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003187 "$O_CLI -key data_files/server2.key \
3188 -cert data_files/server2.ku-ds.crt" \
3189 0 \
3190 -S "bad certificate (usage extensions)" \
3191 -S "Processing of the Certificate handshake message failed"
3192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003193run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003194 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003195 "$O_CLI -key data_files/server2.key \
3196 -cert data_files/server2.ku-ke.crt" \
3197 0 \
3198 -s "bad certificate (usage extensions)" \
3199 -S "Processing of the Certificate handshake message failed"
3200
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003201run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003202 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003203 "$O_CLI -key data_files/server2.key \
3204 -cert data_files/server2.ku-ke.crt" \
3205 1 \
3206 -s "bad certificate (usage extensions)" \
3207 -s "Processing of the Certificate handshake message failed"
3208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003209run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003210 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003211 "$O_CLI -key data_files/server5.key \
3212 -cert data_files/server5.ku-ds.crt" \
3213 0 \
3214 -S "bad certificate (usage extensions)" \
3215 -S "Processing of the Certificate handshake message failed"
3216
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003217run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003218 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003219 "$O_CLI -key data_files/server5.key \
3220 -cert data_files/server5.ku-ka.crt" \
3221 0 \
3222 -s "bad certificate (usage extensions)" \
3223 -S "Processing of the Certificate handshake message failed"
3224
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003225# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003227run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003228 "$P_SRV key_file=data_files/server5.key \
3229 crt_file=data_files/server5.eku-srv.crt" \
3230 "$P_CLI" \
3231 0
3232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003233run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003234 "$P_SRV key_file=data_files/server5.key \
3235 crt_file=data_files/server5.eku-srv.crt" \
3236 "$P_CLI" \
3237 0
3238
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003239run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003240 "$P_SRV key_file=data_files/server5.key \
3241 crt_file=data_files/server5.eku-cs_any.crt" \
3242 "$P_CLI" \
3243 0
3244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003245run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003246 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003247 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003248 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003249 1
3250
3251# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003253run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003254 "$O_SRV -key data_files/server5.key \
3255 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003256 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003257 0 \
3258 -C "bad certificate (usage extensions)" \
3259 -C "Processing of the Certificate handshake message failed" \
3260 -c "Ciphersuite is TLS-"
3261
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003262run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003263 "$O_SRV -key data_files/server5.key \
3264 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003265 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003266 0 \
3267 -C "bad certificate (usage extensions)" \
3268 -C "Processing of the Certificate handshake message failed" \
3269 -c "Ciphersuite is TLS-"
3270
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003271run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003272 "$O_SRV -key data_files/server5.key \
3273 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003274 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003275 0 \
3276 -C "bad certificate (usage extensions)" \
3277 -C "Processing of the Certificate handshake message failed" \
3278 -c "Ciphersuite is TLS-"
3279
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003280run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003281 "$O_SRV -key data_files/server5.key \
3282 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003283 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003284 1 \
3285 -c "bad certificate (usage extensions)" \
3286 -c "Processing of the Certificate handshake message failed" \
3287 -C "Ciphersuite is TLS-"
3288
3289# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003291run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003292 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003293 "$O_CLI -key data_files/server5.key \
3294 -cert data_files/server5.eku-cli.crt" \
3295 0 \
3296 -S "bad certificate (usage extensions)" \
3297 -S "Processing of the Certificate handshake message failed"
3298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003299run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003300 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003301 "$O_CLI -key data_files/server5.key \
3302 -cert data_files/server5.eku-srv_cli.crt" \
3303 0 \
3304 -S "bad certificate (usage extensions)" \
3305 -S "Processing of the Certificate handshake message failed"
3306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003307run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003308 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003309 "$O_CLI -key data_files/server5.key \
3310 -cert data_files/server5.eku-cs_any.crt" \
3311 0 \
3312 -S "bad certificate (usage extensions)" \
3313 -S "Processing of the Certificate handshake message failed"
3314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003315run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003316 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003317 "$O_CLI -key data_files/server5.key \
3318 -cert data_files/server5.eku-cs.crt" \
3319 0 \
3320 -s "bad certificate (usage extensions)" \
3321 -S "Processing of the Certificate handshake message failed"
3322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003323run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003324 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003325 "$O_CLI -key data_files/server5.key \
3326 -cert data_files/server5.eku-cs.crt" \
3327 1 \
3328 -s "bad certificate (usage extensions)" \
3329 -s "Processing of the Certificate handshake message failed"
3330
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003331# Tests for DHM parameters loading
3332
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003333run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003334 "$P_SRV" \
3335 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3336 debug_level=3" \
3337 0 \
3338 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003339 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003341run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003342 "$P_SRV dhm_file=data_files/dhparams.pem" \
3343 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3344 debug_level=3" \
3345 0 \
3346 -c "value of 'DHM: P ' (1024 bits)" \
3347 -c "value of 'DHM: G ' (2 bits)"
3348
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003349# Tests for DHM client-side size checking
3350
3351run_test "DHM size: server default, client default, OK" \
3352 "$P_SRV" \
3353 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3354 debug_level=1" \
3355 0 \
3356 -C "DHM prime too short:"
3357
3358run_test "DHM size: server default, client 2048, OK" \
3359 "$P_SRV" \
3360 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3361 debug_level=1 dhmlen=2048" \
3362 0 \
3363 -C "DHM prime too short:"
3364
3365run_test "DHM size: server 1024, client default, OK" \
3366 "$P_SRV dhm_file=data_files/dhparams.pem" \
3367 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3368 debug_level=1" \
3369 0 \
3370 -C "DHM prime too short:"
3371
3372run_test "DHM size: server 1000, client default, rejected" \
3373 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3374 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3375 debug_level=1" \
3376 1 \
3377 -c "DHM prime too short:"
3378
3379run_test "DHM size: server default, client 2049, rejected" \
3380 "$P_SRV" \
3381 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3382 debug_level=1 dhmlen=2049" \
3383 1 \
3384 -c "DHM prime too short:"
3385
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003386# Tests for PSK callback
3387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003388run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003389 "$P_SRV psk=abc123 psk_identity=foo" \
3390 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3391 psk_identity=foo psk=abc123" \
3392 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003393 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003394 -S "SSL - Unknown identity received" \
3395 -S "SSL - Verification of the message MAC failed"
3396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003397run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003398 "$P_SRV" \
3399 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3400 psk_identity=foo psk=abc123" \
3401 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003402 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003403 -S "SSL - Unknown identity received" \
3404 -S "SSL - Verification of the message MAC failed"
3405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003406run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003407 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3408 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3409 psk_identity=foo psk=abc123" \
3410 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003411 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003412 -s "SSL - Unknown identity received" \
3413 -S "SSL - Verification of the message MAC failed"
3414
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003415run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003416 "$P_SRV psk_list=abc,dead,def,beef" \
3417 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3418 psk_identity=abc psk=dead" \
3419 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003420 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003421 -S "SSL - Unknown identity received" \
3422 -S "SSL - Verification of the message MAC failed"
3423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003424run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003425 "$P_SRV psk_list=abc,dead,def,beef" \
3426 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3427 psk_identity=def psk=beef" \
3428 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003429 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003430 -S "SSL - Unknown identity received" \
3431 -S "SSL - Verification of the message MAC failed"
3432
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003433run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003434 "$P_SRV psk_list=abc,dead,def,beef" \
3435 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3436 psk_identity=ghi psk=beef" \
3437 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003438 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003439 -s "SSL - Unknown identity received" \
3440 -S "SSL - Verification of the message MAC failed"
3441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003442run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003443 "$P_SRV psk_list=abc,dead,def,beef" \
3444 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3445 psk_identity=abc psk=beef" \
3446 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003447 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003448 -S "SSL - Unknown identity received" \
3449 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003450
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003451# Tests for EC J-PAKE
3452
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003453requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003454run_test "ECJPAKE: client not configured" \
3455 "$P_SRV debug_level=3" \
3456 "$P_CLI debug_level=3" \
3457 0 \
3458 -C "add ciphersuite: c0ff" \
3459 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003460 -S "found ecjpake kkpp extension" \
3461 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003462 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003463 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003464 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003465 -S "None of the common ciphersuites is usable"
3466
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003467requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003468run_test "ECJPAKE: server not configured" \
3469 "$P_SRV debug_level=3" \
3470 "$P_CLI debug_level=3 ecjpake_pw=bla \
3471 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3472 1 \
3473 -c "add ciphersuite: c0ff" \
3474 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003475 -s "found ecjpake kkpp extension" \
3476 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003477 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003478 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003479 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003480 -s "None of the common ciphersuites is usable"
3481
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003482requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003483run_test "ECJPAKE: working, TLS" \
3484 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3485 "$P_CLI debug_level=3 ecjpake_pw=bla \
3486 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003487 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003488 -c "add ciphersuite: c0ff" \
3489 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003490 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003491 -s "found ecjpake kkpp extension" \
3492 -S "skip ecjpake kkpp extension" \
3493 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003494 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003495 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003496 -S "None of the common ciphersuites is usable" \
3497 -S "SSL - Verification of the message MAC failed"
3498
Janos Follath74537a62016-09-02 13:45:28 +01003499server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003500requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003501run_test "ECJPAKE: password mismatch, TLS" \
3502 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3503 "$P_CLI debug_level=3 ecjpake_pw=bad \
3504 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3505 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003506 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003507 -s "SSL - Verification of the message MAC failed"
3508
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003509requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003510run_test "ECJPAKE: working, DTLS" \
3511 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3512 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3513 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3514 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003515 -c "re-using cached ecjpake parameters" \
3516 -S "SSL - Verification of the message MAC failed"
3517
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003518requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003519run_test "ECJPAKE: working, DTLS, no cookie" \
3520 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3521 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3522 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3523 0 \
3524 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003525 -S "SSL - Verification of the message MAC failed"
3526
Janos Follath74537a62016-09-02 13:45:28 +01003527server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003528requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003529run_test "ECJPAKE: password mismatch, DTLS" \
3530 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3531 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3532 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3533 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003534 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003535 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003536
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003537# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003538requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003539run_test "ECJPAKE: working, DTLS, nolog" \
3540 "$P_SRV dtls=1 ecjpake_pw=bla" \
3541 "$P_CLI dtls=1 ecjpake_pw=bla \
3542 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3543 0
3544
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003545# Tests for ciphersuites per version
3546
Janos Follathe2681a42016-03-07 15:57:05 +00003547requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003548run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003549 "$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 +02003550 "$P_CLI force_version=ssl3" \
3551 0 \
3552 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3553
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003554run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003555 "$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 +01003556 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003557 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003558 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003560run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003561 "$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 +02003562 "$P_CLI force_version=tls1_1" \
3563 0 \
3564 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003566run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003567 "$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 +02003568 "$P_CLI force_version=tls1_2" \
3569 0 \
3570 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3571
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003572# Test for ClientHello without extensions
3573
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003574requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003575run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003576 "$P_SRV debug_level=3" \
3577 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3578 0 \
3579 -s "dumping 'client hello extensions' (0 bytes)"
3580
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003581requires_gnutls
3582run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3583 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3584 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3585 0 \
3586 -s "dumping 'client hello extensions' (0 bytes)"
3587
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003588# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003589
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003590run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003591 "$P_SRV" \
3592 "$P_CLI request_size=100" \
3593 0 \
3594 -s "Read from client: 100 bytes read$"
3595
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003596run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003597 "$P_SRV" \
3598 "$P_CLI request_size=500" \
3599 0 \
3600 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003601
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003602# Tests for small packets
3603
Janos Follathe2681a42016-03-07 15:57:05 +00003604requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003605run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003606 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003607 "$P_CLI request_size=1 force_version=ssl3 \
3608 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3609 0 \
3610 -s "Read from client: 1 bytes read"
3611
Janos Follathe2681a42016-03-07 15:57:05 +00003612requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003613run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003614 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003615 "$P_CLI request_size=1 force_version=ssl3 \
3616 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3617 0 \
3618 -s "Read from client: 1 bytes read"
3619
3620run_test "Small packet TLS 1.0 BlockCipher" \
3621 "$P_SRV" \
3622 "$P_CLI request_size=1 force_version=tls1 \
3623 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3624 0 \
3625 -s "Read from client: 1 bytes read"
3626
Hanno Becker8501f982017-11-10 08:59:04 +00003627run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003628 "$P_SRV" \
3629 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3630 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3631 0 \
3632 -s "Read from client: 1 bytes read"
3633
Hanno Becker32c55012017-11-10 08:42:54 +00003634requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003635run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003636 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003637 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003638 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003639 0 \
3640 -s "Read from client: 1 bytes read"
3641
Hanno Becker32c55012017-11-10 08:42:54 +00003642requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003643run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003644 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003645 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003646 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003647 0 \
3648 -s "Read from client: 1 bytes read"
3649
3650run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003651 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003652 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003653 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3654 0 \
3655 -s "Read from client: 1 bytes read"
3656
3657run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3658 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3659 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003660 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003661 0 \
3662 -s "Read from client: 1 bytes read"
3663
3664requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3665run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003666 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003667 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003668 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003669 0 \
3670 -s "Read from client: 1 bytes read"
3671
Hanno Becker8501f982017-11-10 08:59:04 +00003672requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3673run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003674 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3675 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3676 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003677 0 \
3678 -s "Read from client: 1 bytes read"
3679
3680run_test "Small packet TLS 1.1 BlockCipher" \
3681 "$P_SRV" \
3682 "$P_CLI request_size=1 force_version=tls1_1 \
3683 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3684 0 \
3685 -s "Read from client: 1 bytes read"
3686
Hanno Becker8501f982017-11-10 08:59:04 +00003687run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003688 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003689 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003690 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003691 0 \
3692 -s "Read from client: 1 bytes read"
3693
3694requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3695run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003696 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003697 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003698 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003699 0 \
3700 -s "Read from client: 1 bytes read"
3701
3702requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3703run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003704 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003705 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003706 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003707 0 \
3708 -s "Read from client: 1 bytes read"
3709
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003710run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003711 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003712 "$P_CLI request_size=1 force_version=tls1_1 \
3713 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3714 0 \
3715 -s "Read from client: 1 bytes read"
3716
Hanno Becker8501f982017-11-10 08:59:04 +00003717run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3718 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003719 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003720 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003721 0 \
3722 -s "Read from client: 1 bytes read"
3723
Hanno Becker8501f982017-11-10 08:59:04 +00003724requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3725run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003726 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003727 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003728 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003729 0 \
3730 -s "Read from client: 1 bytes read"
3731
Hanno Becker32c55012017-11-10 08:42:54 +00003732requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003733run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003734 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003735 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003736 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003737 0 \
3738 -s "Read from client: 1 bytes read"
3739
3740run_test "Small packet TLS 1.2 BlockCipher" \
3741 "$P_SRV" \
3742 "$P_CLI request_size=1 force_version=tls1_2 \
3743 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3744 0 \
3745 -s "Read from client: 1 bytes read"
3746
Hanno Becker8501f982017-11-10 08:59:04 +00003747run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003748 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003749 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003750 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003751 0 \
3752 -s "Read from client: 1 bytes read"
3753
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003754run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3755 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003756 "$P_CLI request_size=1 force_version=tls1_2 \
3757 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003758 0 \
3759 -s "Read from client: 1 bytes read"
3760
Hanno Becker32c55012017-11-10 08:42:54 +00003761requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003762run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003763 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003764 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003765 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003766 0 \
3767 -s "Read from client: 1 bytes read"
3768
Hanno Becker8501f982017-11-10 08:59:04 +00003769requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3770run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003771 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003772 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003773 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003774 0 \
3775 -s "Read from client: 1 bytes read"
3776
3777run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003778 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003779 "$P_CLI request_size=1 force_version=tls1_2 \
3780 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3781 0 \
3782 -s "Read from client: 1 bytes read"
3783
Hanno Becker8501f982017-11-10 08:59:04 +00003784run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003785 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003786 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003787 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003788 0 \
3789 -s "Read from client: 1 bytes read"
3790
Hanno Becker32c55012017-11-10 08:42:54 +00003791requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003792run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003793 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003794 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003795 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003796 0 \
3797 -s "Read from client: 1 bytes read"
3798
Hanno Becker8501f982017-11-10 08:59:04 +00003799requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3800run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003801 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003802 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003803 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003804 0 \
3805 -s "Read from client: 1 bytes read"
3806
3807run_test "Small packet TLS 1.2 AEAD" \
3808 "$P_SRV" \
3809 "$P_CLI request_size=1 force_version=tls1_2 \
3810 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3811 0 \
3812 -s "Read from client: 1 bytes read"
3813
3814run_test "Small packet TLS 1.2 AEAD shorter tag" \
3815 "$P_SRV" \
3816 "$P_CLI request_size=1 force_version=tls1_2 \
3817 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3818 0 \
3819 -s "Read from client: 1 bytes read"
3820
Hanno Beckere2148042017-11-10 08:59:18 +00003821# Tests for small packets in DTLS
3822
3823requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3824run_test "Small packet DTLS 1.0" \
3825 "$P_SRV dtls=1 force_version=dtls1" \
3826 "$P_CLI dtls=1 request_size=1 \
3827 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3828 0 \
3829 -s "Read from client: 1 bytes read"
3830
3831requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3832run_test "Small packet DTLS 1.0, without EtM" \
3833 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3834 "$P_CLI dtls=1 request_size=1 \
3835 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3836 0 \
3837 -s "Read from client: 1 bytes read"
3838
3839requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3840requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3841run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003842 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3843 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003844 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3845 0 \
3846 -s "Read from client: 1 bytes read"
3847
3848requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3849requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3850run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003851 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003852 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003853 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003854 0 \
3855 -s "Read from client: 1 bytes read"
3856
3857requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3858run_test "Small packet DTLS 1.2" \
3859 "$P_SRV dtls=1 force_version=dtls1_2" \
3860 "$P_CLI dtls=1 request_size=1 \
3861 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3862 0 \
3863 -s "Read from client: 1 bytes read"
3864
3865requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3866run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003867 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003868 "$P_CLI dtls=1 request_size=1 \
3869 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3870 0 \
3871 -s "Read from client: 1 bytes read"
3872
3873requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3874requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3875run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003876 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003877 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003878 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003879 0 \
3880 -s "Read from client: 1 bytes read"
3881
3882requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3883requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3884run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003885 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003886 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003887 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003888 0 \
3889 -s "Read from client: 1 bytes read"
3890
Janos Follath00efff72016-05-06 13:48:23 +01003891# A test for extensions in SSLv3
3892
3893requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3894run_test "SSLv3 with extensions, server side" \
3895 "$P_SRV min_version=ssl3 debug_level=3" \
3896 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3897 0 \
3898 -S "dumping 'client hello extensions'" \
3899 -S "server hello, total extension length:"
3900
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003901# Test for large packets
3902
Janos Follathe2681a42016-03-07 15:57:05 +00003903requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003904run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003905 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003906 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003907 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3908 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003909 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003910 -s "Read from client: 16384 bytes read"
3911
Janos Follathe2681a42016-03-07 15:57:05 +00003912requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003913run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003914 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003915 "$P_CLI request_size=16384 force_version=ssl3 \
3916 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3917 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003918 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003919 -s "Read from client: 16384 bytes read"
3920
3921run_test "Large packet TLS 1.0 BlockCipher" \
3922 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003923 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003924 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3925 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003926 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003927 -s "Read from client: 16384 bytes read"
3928
Hanno Becker278fc7a2017-11-10 09:16:28 +00003929run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003930 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003931 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3932 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3933 0 \
3934 -s "Read from client: 16384 bytes read"
3935
Hanno Becker32c55012017-11-10 08:42:54 +00003936requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003937run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003938 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003939 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003940 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003941 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003942 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003943 -s "Read from client: 16384 bytes read"
3944
Hanno Becker32c55012017-11-10 08:42:54 +00003945requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003946run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003947 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003948 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003949 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003950 0 \
3951 -s "Read from client: 16384 bytes read"
3952
3953run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003954 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003955 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003956 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3957 0 \
3958 -s "Read from client: 16384 bytes read"
3959
3960run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3961 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3962 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003963 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003964 0 \
3965 -s "Read from client: 16384 bytes read"
3966
3967requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3968run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003969 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003970 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003971 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003972 0 \
3973 -s "Read from client: 16384 bytes read"
3974
Hanno Becker278fc7a2017-11-10 09:16:28 +00003975requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3976run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003977 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003978 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003979 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003980 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003981 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003982 -s "Read from client: 16384 bytes read"
3983
3984run_test "Large packet TLS 1.1 BlockCipher" \
3985 "$P_SRV" \
3986 "$P_CLI request_size=16384 force_version=tls1_1 \
3987 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3988 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003989 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003990 -s "Read from client: 16384 bytes read"
3991
Hanno Becker278fc7a2017-11-10 09:16:28 +00003992run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3993 "$P_SRV" \
3994 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3995 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003996 0 \
3997 -s "Read from client: 16384 bytes read"
3998
Hanno Becker32c55012017-11-10 08:42:54 +00003999requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004000run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004001 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004002 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004003 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004004 0 \
4005 -s "Read from client: 16384 bytes read"
4006
Hanno Becker32c55012017-11-10 08:42:54 +00004007requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004008run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004009 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004010 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004011 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004012 0 \
4013 -s "Read from client: 16384 bytes read"
4014
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004015run_test "Large packet TLS 1.1 StreamCipher" \
4016 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4017 "$P_CLI request_size=16384 force_version=tls1_1 \
4018 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4019 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004020 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004021 -s "Read from client: 16384 bytes read"
4022
Hanno Becker278fc7a2017-11-10 09:16:28 +00004023run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
4024 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004025 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004026 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004027 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004028 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004029 -s "Read from client: 16384 bytes read"
4030
Hanno Becker278fc7a2017-11-10 09:16:28 +00004031requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4032run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004033 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004034 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004035 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004036 0 \
4037 -s "Read from client: 16384 bytes read"
4038
Hanno Becker278fc7a2017-11-10 09:16:28 +00004039requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4040run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004041 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004042 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004043 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004044 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004045 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004046 -s "Read from client: 16384 bytes read"
4047
4048run_test "Large packet TLS 1.2 BlockCipher" \
4049 "$P_SRV" \
4050 "$P_CLI request_size=16384 force_version=tls1_2 \
4051 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4052 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004053 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004054 -s "Read from client: 16384 bytes read"
4055
Hanno Becker278fc7a2017-11-10 09:16:28 +00004056run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
4057 "$P_SRV" \
4058 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4059 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4060 0 \
4061 -s "Read from client: 16384 bytes read"
4062
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004063run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
4064 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004065 "$P_CLI request_size=16384 force_version=tls1_2 \
4066 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004067 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004068 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004069 -s "Read from client: 16384 bytes read"
4070
Hanno Becker32c55012017-11-10 08:42:54 +00004071requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004072run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004073 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004074 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004075 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004076 0 \
4077 -s "Read from client: 16384 bytes read"
4078
Hanno Becker278fc7a2017-11-10 09:16:28 +00004079requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4080run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004081 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004082 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004083 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004084 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004085 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004086 -s "Read from client: 16384 bytes read"
4087
4088run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004089 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004090 "$P_CLI request_size=16384 force_version=tls1_2 \
4091 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4092 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004093 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004094 -s "Read from client: 16384 bytes read"
4095
Hanno Becker278fc7a2017-11-10 09:16:28 +00004096run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004097 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004098 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004099 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4100 0 \
4101 -s "Read from client: 16384 bytes read"
4102
Hanno Becker32c55012017-11-10 08:42:54 +00004103requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004104run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004105 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004106 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004107 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004108 0 \
4109 -s "Read from client: 16384 bytes read"
4110
Hanno Becker278fc7a2017-11-10 09:16:28 +00004111requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4112run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004113 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004114 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004115 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004116 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004117 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004118 -s "Read from client: 16384 bytes read"
4119
4120run_test "Large packet TLS 1.2 AEAD" \
4121 "$P_SRV" \
4122 "$P_CLI request_size=16384 force_version=tls1_2 \
4123 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4124 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004125 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004126 -s "Read from client: 16384 bytes read"
4127
4128run_test "Large packet TLS 1.2 AEAD shorter tag" \
4129 "$P_SRV" \
4130 "$P_CLI request_size=16384 force_version=tls1_2 \
4131 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4132 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004133 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004134 -s "Read from client: 16384 bytes read"
4135
Ron Eldorc7f15232018-06-28 13:22:05 +03004136# Tests for ECC extensions (rfc 4492)
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 client side" \
4143 "$P_SRV debug_level=3" \
Ron Eldor94226d82018-06-28 16:17:00 +03004144 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004145 0 \
4146 -C "client hello, adding supported_elliptic_curves extension" \
4147 -C "client hello, adding supported_point_formats extension" \
4148 -S "found supported elliptic curves extension" \
4149 -S "found supported point formats extension"
4150
Ron Eldor94226d82018-06-28 16:17:00 +03004151requires_config_enabled MBEDTLS_AES_C
4152requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4153requires_config_enabled MBEDTLS_SHA256_C
4154requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004155run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor94226d82018-06-28 16:17:00 +03004156 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004157 "$P_CLI debug_level=3" \
4158 0 \
4159 -C "found supported_point_formats extension" \
4160 -S "server hello, 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 client side" \
4167 "$P_SRV debug_level=3" \
4168 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4169 0 \
4170 -c "client hello, adding supported_elliptic_curves extension" \
4171 -c "client hello, adding supported_point_formats extension" \
4172 -s "found supported elliptic curves extension" \
4173 -s "found supported point formats extension"
4174
Ron Eldor94226d82018-06-28 16:17:00 +03004175requires_config_enabled MBEDTLS_AES_C
4176requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4177requires_config_enabled MBEDTLS_SHA256_C
4178requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004179run_test "Force an ECC ciphersuite in the server side" \
4180 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4181 "$P_CLI debug_level=3" \
4182 0 \
4183 -c "found supported_point_formats extension" \
4184 -s "server hello, supported_point_formats extension"
4185
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004186# Tests for DTLS HelloVerifyRequest
4187
4188run_test "DTLS cookie: enabled" \
4189 "$P_SRV dtls=1 debug_level=2" \
4190 "$P_CLI dtls=1 debug_level=2" \
4191 0 \
4192 -s "cookie verification failed" \
4193 -s "cookie verification passed" \
4194 -S "cookie verification skipped" \
4195 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004196 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004197 -S "SSL - The requested feature is not available"
4198
4199run_test "DTLS cookie: disabled" \
4200 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4201 "$P_CLI dtls=1 debug_level=2" \
4202 0 \
4203 -S "cookie verification failed" \
4204 -S "cookie verification passed" \
4205 -s "cookie verification skipped" \
4206 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004207 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004208 -S "SSL - The requested feature is not available"
4209
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004210run_test "DTLS cookie: default (failing)" \
4211 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4212 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4213 1 \
4214 -s "cookie verification failed" \
4215 -S "cookie verification passed" \
4216 -S "cookie verification skipped" \
4217 -C "received hello verify request" \
4218 -S "hello verification requested" \
4219 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004220
4221requires_ipv6
4222run_test "DTLS cookie: enabled, IPv6" \
4223 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4224 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4225 0 \
4226 -s "cookie verification failed" \
4227 -s "cookie verification passed" \
4228 -S "cookie verification skipped" \
4229 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004230 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004231 -S "SSL - The requested feature is not available"
4232
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004233run_test "DTLS cookie: enabled, nbio" \
4234 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4235 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4236 0 \
4237 -s "cookie verification failed" \
4238 -s "cookie verification passed" \
4239 -S "cookie verification skipped" \
4240 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004241 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004242 -S "SSL - The requested feature is not available"
4243
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004244# Tests for client reconnecting from the same port with DTLS
4245
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004246not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004247run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004248 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4249 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004250 0 \
4251 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004252 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004253 -S "Client initiated reconnection from same port"
4254
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004255not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004256run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004257 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4258 "$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 +02004259 0 \
4260 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004261 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004262 -s "Client initiated reconnection from same port"
4263
Paul Bakker362689d2016-05-13 10:33:25 +01004264not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4265run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004266 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4267 "$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 +02004268 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004269 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004270 -s "Client initiated reconnection from same port"
4271
Paul Bakker362689d2016-05-13 10:33:25 +01004272only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4273run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4274 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4275 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4276 0 \
4277 -S "The operation timed out" \
4278 -s "Client initiated reconnection from same port"
4279
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004280run_test "DTLS client reconnect from same port: no cookies" \
4281 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004282 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4283 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004284 -s "The operation timed out" \
4285 -S "Client initiated reconnection from same port"
4286
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004287# Tests for various cases of client authentication with DTLS
4288# (focused on handshake flows and message parsing)
4289
4290run_test "DTLS client auth: required" \
4291 "$P_SRV dtls=1 auth_mode=required" \
4292 "$P_CLI dtls=1" \
4293 0 \
4294 -s "Verifying peer X.509 certificate... ok"
4295
4296run_test "DTLS client auth: optional, client has no cert" \
4297 "$P_SRV dtls=1 auth_mode=optional" \
4298 "$P_CLI dtls=1 crt_file=none key_file=none" \
4299 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004300 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004301
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004302run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004303 "$P_SRV dtls=1 auth_mode=none" \
4304 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
4305 0 \
4306 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004307 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004308
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02004309run_test "DTLS wrong PSK: badmac alert" \
4310 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
4311 "$P_CLI dtls=1 psk=abc124" \
4312 1 \
4313 -s "SSL - Verification of the message MAC failed" \
4314 -c "SSL - A fatal alert message was received from our peer"
4315
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02004316# Tests for receiving fragmented handshake messages with DTLS
4317
4318requires_gnutls
4319run_test "DTLS reassembly: no fragmentation (gnutls server)" \
4320 "$G_SRV -u --mtu 2048 -a" \
4321 "$P_CLI dtls=1 debug_level=2" \
4322 0 \
4323 -C "found fragmented DTLS handshake message" \
4324 -C "error"
4325
4326requires_gnutls
4327run_test "DTLS reassembly: some fragmentation (gnutls server)" \
4328 "$G_SRV -u --mtu 512" \
4329 "$P_CLI dtls=1 debug_level=2" \
4330 0 \
4331 -c "found fragmented DTLS handshake message" \
4332 -C "error"
4333
4334requires_gnutls
4335run_test "DTLS reassembly: more fragmentation (gnutls server)" \
4336 "$G_SRV -u --mtu 128" \
4337 "$P_CLI dtls=1 debug_level=2" \
4338 0 \
4339 -c "found fragmented DTLS handshake message" \
4340 -C "error"
4341
4342requires_gnutls
4343run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
4344 "$G_SRV -u --mtu 128" \
4345 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4346 0 \
4347 -c "found fragmented DTLS handshake message" \
4348 -C "error"
4349
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004350requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004351requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004352run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4353 "$G_SRV -u --mtu 256" \
4354 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4355 0 \
4356 -c "found fragmented DTLS handshake message" \
4357 -c "client hello, adding renegotiation extension" \
4358 -c "found renegotiation extension" \
4359 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004360 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004361 -C "error" \
4362 -s "Extra-header:"
4363
4364requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004365requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004366run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4367 "$G_SRV -u --mtu 256" \
4368 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4369 0 \
4370 -c "found fragmented DTLS handshake message" \
4371 -c "client hello, adding renegotiation extension" \
4372 -c "found renegotiation extension" \
4373 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004374 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004375 -C "error" \
4376 -s "Extra-header:"
4377
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004378run_test "DTLS reassembly: no fragmentation (openssl server)" \
4379 "$O_SRV -dtls1 -mtu 2048" \
4380 "$P_CLI dtls=1 debug_level=2" \
4381 0 \
4382 -C "found fragmented DTLS handshake message" \
4383 -C "error"
4384
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004385run_test "DTLS reassembly: some fragmentation (openssl server)" \
4386 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004387 "$P_CLI dtls=1 debug_level=2" \
4388 0 \
4389 -c "found fragmented DTLS handshake message" \
4390 -C "error"
4391
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004392run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004393 "$O_SRV -dtls1 -mtu 256" \
4394 "$P_CLI dtls=1 debug_level=2" \
4395 0 \
4396 -c "found fragmented DTLS handshake message" \
4397 -C "error"
4398
4399run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4400 "$O_SRV -dtls1 -mtu 256" \
4401 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4402 0 \
4403 -c "found fragmented DTLS handshake message" \
4404 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004405
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004406# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004407
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004408not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004409run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004410 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004411 "$P_SRV dtls=1 debug_level=2" \
4412 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004413 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004414 -C "replayed record" \
4415 -S "replayed record" \
4416 -C "record from another epoch" \
4417 -S "record from another epoch" \
4418 -C "discarding invalid record" \
4419 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004420 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004421 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004422 -c "HTTP/1.0 200 OK"
4423
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004424not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004425run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004426 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004427 "$P_SRV dtls=1 debug_level=2" \
4428 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004429 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004430 -c "replayed record" \
4431 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004432 -c "discarding invalid record" \
4433 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004434 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004435 -s "Extra-header:" \
4436 -c "HTTP/1.0 200 OK"
4437
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004438run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4439 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004440 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4441 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004442 0 \
4443 -c "replayed record" \
4444 -S "replayed record" \
4445 -c "discarding invalid record" \
4446 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004447 -c "resend" \
4448 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004449 -s "Extra-header:" \
4450 -c "HTTP/1.0 200 OK"
4451
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004452run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004453 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004454 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004455 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004456 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004457 -c "discarding invalid record (mac)" \
4458 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004459 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004460 -c "HTTP/1.0 200 OK" \
4461 -S "too many records with bad MAC" \
4462 -S "Verification of the message MAC failed"
4463
4464run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4465 -p "$P_PXY bad_ad=1" \
4466 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4467 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4468 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004469 -C "discarding invalid record (mac)" \
4470 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004471 -S "Extra-header:" \
4472 -C "HTTP/1.0 200 OK" \
4473 -s "too many records with bad MAC" \
4474 -s "Verification of the message MAC failed"
4475
4476run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4477 -p "$P_PXY bad_ad=1" \
4478 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4479 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4480 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004481 -c "discarding invalid record (mac)" \
4482 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004483 -s "Extra-header:" \
4484 -c "HTTP/1.0 200 OK" \
4485 -S "too many records with bad MAC" \
4486 -S "Verification of the message MAC failed"
4487
4488run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4489 -p "$P_PXY bad_ad=1" \
4490 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4491 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4492 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004493 -c "discarding invalid record (mac)" \
4494 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004495 -s "Extra-header:" \
4496 -c "HTTP/1.0 200 OK" \
4497 -s "too many records with bad MAC" \
4498 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004499
4500run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004501 -p "$P_PXY delay_ccs=1" \
4502 "$P_SRV dtls=1 debug_level=1" \
4503 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004504 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004505 -c "record from another epoch" \
4506 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004507 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004508 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004509 -s "Extra-header:" \
4510 -c "HTTP/1.0 200 OK"
4511
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004512# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004513
Janos Follath74537a62016-09-02 13:45:28 +01004514client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004515run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004516 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004517 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4518 psk=abc123" \
4519 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004520 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4521 0 \
4522 -s "Extra-header:" \
4523 -c "HTTP/1.0 200 OK"
4524
Janos Follath74537a62016-09-02 13:45:28 +01004525client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004526run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4527 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004528 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4529 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004530 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4531 0 \
4532 -s "Extra-header:" \
4533 -c "HTTP/1.0 200 OK"
4534
Janos Follath74537a62016-09-02 13:45:28 +01004535client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004536run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4537 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004538 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4539 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004540 0 \
4541 -s "Extra-header:" \
4542 -c "HTTP/1.0 200 OK"
4543
Janos Follath74537a62016-09-02 13:45:28 +01004544client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004545run_test "DTLS proxy: 3d, FS, client auth" \
4546 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004547 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4548 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004549 0 \
4550 -s "Extra-header:" \
4551 -c "HTTP/1.0 200 OK"
4552
Janos Follath74537a62016-09-02 13:45:28 +01004553client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004554run_test "DTLS proxy: 3d, FS, ticket" \
4555 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004556 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4557 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004558 0 \
4559 -s "Extra-header:" \
4560 -c "HTTP/1.0 200 OK"
4561
Janos Follath74537a62016-09-02 13:45:28 +01004562client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004563run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4564 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004565 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4566 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004567 0 \
4568 -s "Extra-header:" \
4569 -c "HTTP/1.0 200 OK"
4570
Janos Follath74537a62016-09-02 13:45:28 +01004571client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004572run_test "DTLS proxy: 3d, max handshake, nbio" \
4573 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004574 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4575 auth_mode=required" \
4576 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004577 0 \
4578 -s "Extra-header:" \
4579 -c "HTTP/1.0 200 OK"
4580
Janos Follath74537a62016-09-02 13:45:28 +01004581client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004582run_test "DTLS proxy: 3d, min handshake, resumption" \
4583 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4584 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4585 psk=abc123 debug_level=3" \
4586 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4587 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4588 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4589 0 \
4590 -s "a session has been resumed" \
4591 -c "a session has been resumed" \
4592 -s "Extra-header:" \
4593 -c "HTTP/1.0 200 OK"
4594
Janos Follath74537a62016-09-02 13:45:28 +01004595client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004596run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4597 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4598 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4599 psk=abc123 debug_level=3 nbio=2" \
4600 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4601 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4602 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4603 0 \
4604 -s "a session has been resumed" \
4605 -c "a session has been resumed" \
4606 -s "Extra-header:" \
4607 -c "HTTP/1.0 200 OK"
4608
Janos Follath74537a62016-09-02 13:45:28 +01004609client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004610requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004611run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004612 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004613 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4614 psk=abc123 renegotiation=1 debug_level=2" \
4615 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4616 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004617 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4618 0 \
4619 -c "=> renegotiate" \
4620 -s "=> renegotiate" \
4621 -s "Extra-header:" \
4622 -c "HTTP/1.0 200 OK"
4623
Janos Follath74537a62016-09-02 13:45:28 +01004624client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004625requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004626run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4627 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004628 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4629 psk=abc123 renegotiation=1 debug_level=2" \
4630 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4631 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004632 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4633 0 \
4634 -c "=> renegotiate" \
4635 -s "=> renegotiate" \
4636 -s "Extra-header:" \
4637 -c "HTTP/1.0 200 OK"
4638
Janos Follath74537a62016-09-02 13:45:28 +01004639client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004640requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004641run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004642 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004643 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004644 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004645 debug_level=2" \
4646 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004647 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004648 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4649 0 \
4650 -c "=> renegotiate" \
4651 -s "=> renegotiate" \
4652 -s "Extra-header:" \
4653 -c "HTTP/1.0 200 OK"
4654
Janos Follath74537a62016-09-02 13:45:28 +01004655client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004656requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004657run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004658 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004659 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004660 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004661 debug_level=2 nbio=2" \
4662 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004663 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004664 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4665 0 \
4666 -c "=> renegotiate" \
4667 -s "=> renegotiate" \
4668 -s "Extra-header:" \
4669 -c "HTTP/1.0 200 OK"
4670
Janos Follath74537a62016-09-02 13:45:28 +01004671client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004672not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004673run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004674 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4675 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004676 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004677 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004678 -c "HTTP/1.0 200 OK"
4679
Janos Follath74537a62016-09-02 13:45:28 +01004680client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004681not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004682run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4683 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4684 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004685 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004686 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004687 -c "HTTP/1.0 200 OK"
4688
Janos Follath74537a62016-09-02 13:45:28 +01004689client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004690not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004691run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4692 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4693 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004694 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004695 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004696 -c "HTTP/1.0 200 OK"
4697
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004698requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004699client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004700not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004701run_test "DTLS proxy: 3d, gnutls server" \
4702 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4703 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004704 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004705 0 \
4706 -s "Extra-header:" \
4707 -c "Extra-header:"
4708
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004709requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004710client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004711not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004712run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4713 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4714 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004715 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004716 0 \
4717 -s "Extra-header:" \
4718 -c "Extra-header:"
4719
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004720requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004721client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004722not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004723run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4724 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4725 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004726 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004727 0 \
4728 -s "Extra-header:" \
4729 -c "Extra-header:"
4730
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004731# Final report
4732
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004733echo "------------------------------------------------------------------------"
4734
4735if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004736 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004737else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004738 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004739fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004740PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004741echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004742
4743exit $FAILS