blob: a70ace3ddd27e9e48b48ead62a7e357984db8f77 [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
Gilles Peskinebc70a182017-05-09 15:59:24 +0200785# Tests for SHA-1 support
786
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200787requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200788run_test "SHA-1 forbidden by default in server certificate" \
789 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
790 "$P_CLI debug_level=2 allow_sha1=0" \
791 1 \
792 -c "The certificate is signed with an unacceptable hash"
793
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200794requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
795run_test "SHA-1 forbidden by default in server certificate" \
796 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
797 "$P_CLI debug_level=2 allow_sha1=0" \
798 0
799
Gilles Peskinebc70a182017-05-09 15:59:24 +0200800run_test "SHA-1 explicitly allowed in server certificate" \
801 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
802 "$P_CLI allow_sha1=1" \
803 0
804
805run_test "SHA-256 allowed by default in server certificate" \
806 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
807 "$P_CLI allow_sha1=0" \
808 0
809
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200810requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200811run_test "SHA-1 forbidden by default in client certificate" \
812 "$P_SRV auth_mode=required allow_sha1=0" \
813 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
814 1 \
815 -s "The certificate is signed with an unacceptable hash"
816
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200817requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
818run_test "SHA-1 forbidden by default in client certificate" \
819 "$P_SRV auth_mode=required allow_sha1=0" \
820 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
821 0
822
Gilles Peskinebc70a182017-05-09 15:59:24 +0200823run_test "SHA-1 explicitly allowed in client certificate" \
824 "$P_SRV auth_mode=required allow_sha1=1" \
825 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
826 0
827
828run_test "SHA-256 allowed by default in client certificate" \
829 "$P_SRV auth_mode=required allow_sha1=0" \
830 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
831 0
832
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100833# Tests for Truncated HMAC extension
834
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100835run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200836 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100837 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100838 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000839 -s "dumping 'expected mac' (20 bytes)" \
840 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100841
Hanno Becker32c55012017-11-10 08:42:54 +0000842requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100843run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200844 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000845 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100846 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000847 -s "dumping 'expected mac' (20 bytes)" \
848 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100849
Hanno Becker32c55012017-11-10 08:42:54 +0000850requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100851run_test "Truncated HMAC: client enabled, server default" \
852 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000853 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +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é-Gonnarde117a8f2015-01-09 12:39:35 +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 enabled, server disabled" \
860 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000861 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +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
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000867run_test "Truncated HMAC: client disabled, server enabled" \
868 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000869 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000870 0 \
871 -s "dumping 'expected mac' (20 bytes)" \
872 -S "dumping 'expected mac' (10 bytes)"
873
874requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100875run_test "Truncated HMAC: client enabled, server enabled" \
876 "$P_SRV debug_level=4 trunc_hmac=1" \
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é-Gonnardf7c52012014-02-20 11:43:46 +0100881
Hanno Becker4c4f4102017-11-10 09:16:05 +0000882run_test "Truncated HMAC, DTLS: client default, server default" \
883 "$P_SRV dtls=1 debug_level=4" \
884 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
885 0 \
886 -s "dumping 'expected mac' (20 bytes)" \
887 -S "dumping 'expected mac' (10 bytes)"
888
889requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
890run_test "Truncated HMAC, DTLS: client disabled, server default" \
891 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000892 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000893 0 \
894 -s "dumping 'expected mac' (20 bytes)" \
895 -S "dumping 'expected mac' (10 bytes)"
896
897requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
898run_test "Truncated HMAC, DTLS: client enabled, server default" \
899 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000900 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000901 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 enabled, server disabled" \
907 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000908 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
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 disabled, server enabled" \
915 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000916 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
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 enabled" \
923 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000924 "$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 +0100925 0 \
926 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100927 -s "dumping 'expected mac' (10 bytes)"
928
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100929# Tests for Encrypt-then-MAC extension
930
931run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100932 "$P_SRV debug_level=3 \
933 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100934 "$P_CLI debug_level=3" \
935 0 \
936 -c "client hello, adding encrypt_then_mac extension" \
937 -s "found encrypt then mac extension" \
938 -s "server hello, adding encrypt then mac extension" \
939 -c "found encrypt_then_mac extension" \
940 -c "using encrypt then mac" \
941 -s "using encrypt then mac"
942
943run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100944 "$P_SRV debug_level=3 etm=0 \
945 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100946 "$P_CLI debug_level=3 etm=1" \
947 0 \
948 -c "client hello, adding encrypt_then_mac extension" \
949 -s "found encrypt then mac extension" \
950 -S "server hello, adding encrypt then mac extension" \
951 -C "found encrypt_then_mac extension" \
952 -C "using encrypt then mac" \
953 -S "using encrypt then mac"
954
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100955run_test "Encrypt then MAC: client enabled, aead cipher" \
956 "$P_SRV debug_level=3 etm=1 \
957 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
958 "$P_CLI debug_level=3 etm=1" \
959 0 \
960 -c "client hello, adding encrypt_then_mac extension" \
961 -s "found encrypt then mac extension" \
962 -S "server hello, adding encrypt then mac extension" \
963 -C "found encrypt_then_mac extension" \
964 -C "using encrypt then mac" \
965 -S "using encrypt then mac"
966
967run_test "Encrypt then MAC: client enabled, stream cipher" \
968 "$P_SRV debug_level=3 etm=1 \
969 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100970 "$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 +0100971 0 \
972 -c "client hello, adding encrypt_then_mac extension" \
973 -s "found encrypt then mac extension" \
974 -S "server hello, adding encrypt then mac extension" \
975 -C "found encrypt_then_mac extension" \
976 -C "using encrypt then mac" \
977 -S "using encrypt then mac"
978
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100979run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100980 "$P_SRV debug_level=3 etm=1 \
981 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100982 "$P_CLI debug_level=3 etm=0" \
983 0 \
984 -C "client hello, adding encrypt_then_mac extension" \
985 -S "found encrypt then mac extension" \
986 -S "server hello, adding encrypt then mac extension" \
987 -C "found encrypt_then_mac extension" \
988 -C "using encrypt then mac" \
989 -S "using encrypt then mac"
990
Janos Follathe2681a42016-03-07 15:57:05 +0000991requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100992run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100993 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100994 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100995 "$P_CLI debug_level=3 force_version=ssl3" \
996 0 \
997 -C "client hello, adding encrypt_then_mac extension" \
998 -S "found encrypt then mac extension" \
999 -S "server hello, adding encrypt then mac extension" \
1000 -C "found encrypt_then_mac extension" \
1001 -C "using encrypt then mac" \
1002 -S "using encrypt then mac"
1003
Janos Follathe2681a42016-03-07 15:57:05 +00001004requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001005run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001006 "$P_SRV debug_level=3 force_version=ssl3 \
1007 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001008 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001009 0 \
1010 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001011 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001012 -S "server hello, adding encrypt then mac extension" \
1013 -C "found encrypt_then_mac extension" \
1014 -C "using encrypt then mac" \
1015 -S "using encrypt then mac"
1016
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001017# Tests for Extended Master Secret extension
1018
1019run_test "Extended Master Secret: default" \
1020 "$P_SRV debug_level=3" \
1021 "$P_CLI debug_level=3" \
1022 0 \
1023 -c "client hello, adding extended_master_secret extension" \
1024 -s "found extended master secret extension" \
1025 -s "server hello, adding extended master secret extension" \
1026 -c "found extended_master_secret extension" \
1027 -c "using extended master secret" \
1028 -s "using extended master secret"
1029
1030run_test "Extended Master Secret: client enabled, server disabled" \
1031 "$P_SRV debug_level=3 extended_ms=0" \
1032 "$P_CLI debug_level=3 extended_ms=1" \
1033 0 \
1034 -c "client hello, adding extended_master_secret extension" \
1035 -s "found extended master secret extension" \
1036 -S "server hello, adding extended master secret extension" \
1037 -C "found extended_master_secret extension" \
1038 -C "using extended master secret" \
1039 -S "using extended master secret"
1040
1041run_test "Extended Master Secret: client disabled, server enabled" \
1042 "$P_SRV debug_level=3 extended_ms=1" \
1043 "$P_CLI debug_level=3 extended_ms=0" \
1044 0 \
1045 -C "client hello, adding extended_master_secret extension" \
1046 -S "found extended master secret extension" \
1047 -S "server hello, adding extended master secret extension" \
1048 -C "found extended_master_secret extension" \
1049 -C "using extended master secret" \
1050 -S "using extended master secret"
1051
Janos Follathe2681a42016-03-07 15:57:05 +00001052requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001053run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001054 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001055 "$P_CLI debug_level=3 force_version=ssl3" \
1056 0 \
1057 -C "client hello, adding extended_master_secret extension" \
1058 -S "found extended master secret extension" \
1059 -S "server hello, adding extended master secret extension" \
1060 -C "found extended_master_secret extension" \
1061 -C "using extended master secret" \
1062 -S "using extended master secret"
1063
Janos Follathe2681a42016-03-07 15:57:05 +00001064requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001065run_test "Extended Master Secret: client enabled, server SSLv3" \
1066 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001067 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001068 0 \
1069 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001070 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001071 -S "server hello, adding extended master secret extension" \
1072 -C "found extended_master_secret extension" \
1073 -C "using extended master secret" \
1074 -S "using extended master secret"
1075
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001076# Tests for FALLBACK_SCSV
1077
1078run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001079 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001080 "$P_CLI debug_level=3 force_version=tls1_1" \
1081 0 \
1082 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001083 -S "received FALLBACK_SCSV" \
1084 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001085 -C "is a fatal alert message (msg 86)"
1086
1087run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001088 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001089 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1090 0 \
1091 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001092 -S "received FALLBACK_SCSV" \
1093 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001094 -C "is a fatal alert message (msg 86)"
1095
1096run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001097 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001098 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001099 1 \
1100 -c "adding FALLBACK_SCSV" \
1101 -s "received FALLBACK_SCSV" \
1102 -s "inapropriate fallback" \
1103 -c "is a fatal alert message (msg 86)"
1104
1105run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001106 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001107 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001108 0 \
1109 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001110 -s "received FALLBACK_SCSV" \
1111 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001112 -C "is a fatal alert message (msg 86)"
1113
1114requires_openssl_with_fallback_scsv
1115run_test "Fallback SCSV: default, openssl server" \
1116 "$O_SRV" \
1117 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1118 0 \
1119 -C "adding FALLBACK_SCSV" \
1120 -C "is a fatal alert message (msg 86)"
1121
1122requires_openssl_with_fallback_scsv
1123run_test "Fallback SCSV: enabled, openssl server" \
1124 "$O_SRV" \
1125 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1126 1 \
1127 -c "adding FALLBACK_SCSV" \
1128 -c "is a fatal alert message (msg 86)"
1129
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001130requires_openssl_with_fallback_scsv
1131run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001132 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001133 "$O_CLI -tls1_1" \
1134 0 \
1135 -S "received FALLBACK_SCSV" \
1136 -S "inapropriate fallback"
1137
1138requires_openssl_with_fallback_scsv
1139run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001140 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001141 "$O_CLI -tls1_1 -fallback_scsv" \
1142 1 \
1143 -s "received FALLBACK_SCSV" \
1144 -s "inapropriate fallback"
1145
1146requires_openssl_with_fallback_scsv
1147run_test "Fallback SCSV: enabled, max version, 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 -fallback_scsv" \
1150 0 \
1151 -s "received FALLBACK_SCSV" \
1152 -S "inapropriate fallback"
1153
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001154# Test sending and receiving empty application data records
1155
1156run_test "Encrypt then MAC: empty application data record" \
1157 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1158 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1159 0 \
1160 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1161 -s "dumping 'input payload after decrypt' (0 bytes)" \
1162 -c "0 bytes written in 1 fragments"
1163
1164run_test "Default, no Encrypt then MAC: empty application data record" \
1165 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1166 "$P_CLI auth_mode=none etm=0 request_size=0" \
1167 0 \
1168 -s "dumping 'input payload after decrypt' (0 bytes)" \
1169 -c "0 bytes written in 1 fragments"
1170
1171run_test "Encrypt then MAC, DTLS: empty application data record" \
1172 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1173 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1174 0 \
1175 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1176 -s "dumping 'input payload after decrypt' (0 bytes)" \
1177 -c "0 bytes written in 1 fragments"
1178
1179run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
1180 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1181 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1182 0 \
1183 -s "dumping 'input payload after decrypt' (0 bytes)" \
1184 -c "0 bytes written in 1 fragments"
1185
Gilles Peskined50177f2017-05-16 17:53:03 +02001186## ClientHello generated with
1187## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1188## then manually twiddling the ciphersuite list.
1189## The ClientHello content is spelled out below as a hex string as
1190## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1191## The expected response is an inappropriate_fallback alert.
1192requires_openssl_with_fallback_scsv
1193run_test "Fallback SCSV: beginning of list" \
1194 "$P_SRV debug_level=2" \
1195 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1196 0 \
1197 -s "received FALLBACK_SCSV" \
1198 -s "inapropriate fallback"
1199
1200requires_openssl_with_fallback_scsv
1201run_test "Fallback SCSV: end of list" \
1202 "$P_SRV debug_level=2" \
1203 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1204 0 \
1205 -s "received FALLBACK_SCSV" \
1206 -s "inapropriate fallback"
1207
1208## Here the expected response is a valid ServerHello prefix, up to the random.
1209requires_openssl_with_fallback_scsv
1210run_test "Fallback SCSV: not in list" \
1211 "$P_SRV debug_level=2" \
1212 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1213 0 \
1214 -S "received FALLBACK_SCSV" \
1215 -S "inapropriate fallback"
1216
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001217# Tests for CBC 1/n-1 record splitting
1218
1219run_test "CBC Record splitting: TLS 1.2, no splitting" \
1220 "$P_SRV" \
1221 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1222 request_size=123 force_version=tls1_2" \
1223 0 \
1224 -s "Read from client: 123 bytes read" \
1225 -S "Read from client: 1 bytes read" \
1226 -S "122 bytes read"
1227
1228run_test "CBC Record splitting: TLS 1.1, no splitting" \
1229 "$P_SRV" \
1230 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1231 request_size=123 force_version=tls1_1" \
1232 0 \
1233 -s "Read from client: 123 bytes read" \
1234 -S "Read from client: 1 bytes read" \
1235 -S "122 bytes read"
1236
1237run_test "CBC Record splitting: TLS 1.0, splitting" \
1238 "$P_SRV" \
1239 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1240 request_size=123 force_version=tls1" \
1241 0 \
1242 -S "Read from client: 123 bytes read" \
1243 -s "Read from client: 1 bytes read" \
1244 -s "122 bytes read"
1245
Janos Follathe2681a42016-03-07 15:57:05 +00001246requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001247run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001248 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001249 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1250 request_size=123 force_version=ssl3" \
1251 0 \
1252 -S "Read from client: 123 bytes read" \
1253 -s "Read from client: 1 bytes read" \
1254 -s "122 bytes read"
1255
1256run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001257 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001258 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1259 request_size=123 force_version=tls1" \
1260 0 \
1261 -s "Read from client: 123 bytes read" \
1262 -S "Read from client: 1 bytes read" \
1263 -S "122 bytes read"
1264
1265run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1266 "$P_SRV" \
1267 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1268 request_size=123 force_version=tls1 recsplit=0" \
1269 0 \
1270 -s "Read from client: 123 bytes read" \
1271 -S "Read from client: 1 bytes read" \
1272 -S "122 bytes read"
1273
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001274run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1275 "$P_SRV nbio=2" \
1276 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1277 request_size=123 force_version=tls1" \
1278 0 \
1279 -S "Read from client: 123 bytes read" \
1280 -s "Read from client: 1 bytes read" \
1281 -s "122 bytes read"
1282
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001283# Tests for Session Tickets
1284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001285run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001286 "$P_SRV debug_level=3 tickets=1" \
1287 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001288 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001289 -c "client hello, adding session ticket extension" \
1290 -s "found session ticket extension" \
1291 -s "server hello, adding session ticket extension" \
1292 -c "found session_ticket extension" \
1293 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001294 -S "session successfully restored from cache" \
1295 -s "session successfully restored from ticket" \
1296 -s "a session has been resumed" \
1297 -c "a session has been resumed"
1298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001299run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001300 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1301 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001302 0 \
1303 -c "client hello, adding session ticket extension" \
1304 -s "found session ticket extension" \
1305 -s "server hello, adding session ticket extension" \
1306 -c "found session_ticket extension" \
1307 -c "parse new session ticket" \
1308 -S "session successfully restored from cache" \
1309 -s "session successfully restored from ticket" \
1310 -s "a session has been resumed" \
1311 -c "a session has been resumed"
1312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001313run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001314 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1315 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001316 0 \
1317 -c "client hello, adding session ticket extension" \
1318 -s "found session ticket extension" \
1319 -s "server hello, adding session ticket extension" \
1320 -c "found session_ticket extension" \
1321 -c "parse new session ticket" \
1322 -S "session successfully restored from cache" \
1323 -S "session successfully restored from ticket" \
1324 -S "a session has been resumed" \
1325 -C "a session has been resumed"
1326
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001327run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001328 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001329 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001330 0 \
1331 -c "client hello, adding session ticket extension" \
1332 -c "found session_ticket extension" \
1333 -c "parse new session ticket" \
1334 -c "a session has been resumed"
1335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001336run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001337 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001338 "( $O_CLI -sess_out $SESSION; \
1339 $O_CLI -sess_in $SESSION; \
1340 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001341 0 \
1342 -s "found session ticket extension" \
1343 -s "server hello, adding session ticket extension" \
1344 -S "session successfully restored from cache" \
1345 -s "session successfully restored from ticket" \
1346 -s "a session has been resumed"
1347
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001348# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001350run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001351 "$P_SRV debug_level=3 tickets=0" \
1352 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001353 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001354 -c "client hello, adding session ticket extension" \
1355 -s "found session ticket extension" \
1356 -S "server hello, adding session ticket extension" \
1357 -C "found session_ticket extension" \
1358 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001359 -s "session successfully restored from cache" \
1360 -S "session successfully restored from ticket" \
1361 -s "a session has been resumed" \
1362 -c "a session has been resumed"
1363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001364run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001365 "$P_SRV debug_level=3 tickets=1" \
1366 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001367 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001368 -C "client hello, adding session ticket extension" \
1369 -S "found session ticket extension" \
1370 -S "server hello, adding session ticket extension" \
1371 -C "found session_ticket extension" \
1372 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001373 -s "session successfully restored from cache" \
1374 -S "session successfully restored from ticket" \
1375 -s "a session has been resumed" \
1376 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001378run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001379 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1380 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001381 0 \
1382 -S "session successfully restored from cache" \
1383 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001384 -S "a session has been resumed" \
1385 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001387run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001388 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1389 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001390 0 \
1391 -s "session successfully restored from cache" \
1392 -S "session successfully restored from ticket" \
1393 -s "a session has been resumed" \
1394 -c "a session has been resumed"
1395
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001396run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001397 "$P_SRV debug_level=3 tickets=0" \
1398 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001399 0 \
1400 -s "session successfully restored from cache" \
1401 -S "session successfully restored from ticket" \
1402 -s "a session has been resumed" \
1403 -c "a session has been resumed"
1404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001405run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001406 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1407 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001408 0 \
1409 -S "session successfully restored from cache" \
1410 -S "session successfully restored from ticket" \
1411 -S "a session has been resumed" \
1412 -C "a session has been resumed"
1413
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001414run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001415 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1416 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001417 0 \
1418 -s "session successfully restored from cache" \
1419 -S "session successfully restored from ticket" \
1420 -s "a session has been resumed" \
1421 -c "a session has been resumed"
1422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001423run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001424 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001425 "( $O_CLI -sess_out $SESSION; \
1426 $O_CLI -sess_in $SESSION; \
1427 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001428 0 \
1429 -s "found session ticket extension" \
1430 -S "server hello, adding session ticket extension" \
1431 -s "session successfully restored from cache" \
1432 -S "session successfully restored from ticket" \
1433 -s "a session has been resumed"
1434
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001435run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001436 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001437 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001438 0 \
1439 -C "found session_ticket extension" \
1440 -C "parse new session ticket" \
1441 -c "a session has been resumed"
1442
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001443# Tests for Max Fragment Length extension
1444
Hanno Becker6428f8d2017-09-22 16:58:50 +01001445MAX_CONTENT_LEN_EXPECT='16384'
1446MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1447
1448if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1449 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1450 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1451 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1452 printf "\n"
1453 printf "The tests assume this value and if it changes, the tests in this\n"
1454 printf "script should also be adjusted.\n"
1455 printf "\n"
1456
1457 exit 1
1458fi
1459
Hanno Becker4aed27e2017-09-18 15:00:34 +01001460requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001461run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001462 "$P_SRV debug_level=3" \
1463 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001464 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001465 -c "Maximum fragment length is 16384" \
1466 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001467 -C "client hello, adding max_fragment_length extension" \
1468 -S "found max fragment length extension" \
1469 -S "server hello, max_fragment_length extension" \
1470 -C "found max_fragment_length extension"
1471
Hanno Becker4aed27e2017-09-18 15:00:34 +01001472requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001473run_test "Max fragment length: enabled, default, larger message" \
1474 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001475 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001476 0 \
1477 -c "Maximum fragment length is 16384" \
1478 -s "Maximum fragment length is 16384" \
1479 -C "client hello, adding max_fragment_length extension" \
1480 -S "found max fragment length extension" \
1481 -S "server hello, max_fragment_length extension" \
1482 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001483 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001484 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001485 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001486
1487requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1488run_test "Max fragment length, DTLS: enabled, default, larger message" \
1489 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001490 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001491 1 \
1492 -c "Maximum fragment length is 16384" \
1493 -s "Maximum fragment length is 16384" \
1494 -C "client hello, adding max_fragment_length extension" \
1495 -S "found max fragment length extension" \
1496 -S "server hello, max_fragment_length extension" \
1497 -C "found max_fragment_length extension" \
1498 -c "fragment larger than.*maximum "
1499
1500requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1501run_test "Max fragment length: disabled, larger message" \
1502 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001503 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001504 0 \
1505 -C "Maximum fragment length is 16384" \
1506 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001507 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001508 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001509 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001510
1511requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1512run_test "Max fragment length DTLS: disabled, larger message" \
1513 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001514 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001515 1 \
1516 -C "Maximum fragment length is 16384" \
1517 -S "Maximum fragment length is 16384" \
1518 -c "fragment larger than.*maximum "
1519
1520requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001521run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001522 "$P_SRV debug_level=3" \
1523 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001524 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001525 -c "Maximum fragment length is 4096" \
1526 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001527 -c "client hello, adding max_fragment_length extension" \
1528 -s "found max fragment length extension" \
1529 -s "server hello, max_fragment_length extension" \
1530 -c "found max_fragment_length extension"
1531
Hanno Becker4aed27e2017-09-18 15:00:34 +01001532requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001533run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001534 "$P_SRV debug_level=3 max_frag_len=4096" \
1535 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001536 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001537 -c "Maximum fragment length is 16384" \
1538 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001539 -C "client hello, adding max_fragment_length extension" \
1540 -S "found max fragment length extension" \
1541 -S "server hello, max_fragment_length extension" \
1542 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001543
Hanno Becker4aed27e2017-09-18 15:00:34 +01001544requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001545requires_gnutls
1546run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001547 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001548 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001549 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001550 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001551 -c "client hello, adding max_fragment_length extension" \
1552 -c "found max_fragment_length extension"
1553
Hanno Becker4aed27e2017-09-18 15:00:34 +01001554requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001555run_test "Max fragment length: client, message just fits" \
1556 "$P_SRV debug_level=3" \
1557 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1558 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001559 -c "Maximum fragment length is 2048" \
1560 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001561 -c "client hello, adding max_fragment_length extension" \
1562 -s "found max fragment length extension" \
1563 -s "server hello, max_fragment_length extension" \
1564 -c "found max_fragment_length extension" \
1565 -c "2048 bytes written in 1 fragments" \
1566 -s "2048 bytes read"
1567
Hanno Becker4aed27e2017-09-18 15:00:34 +01001568requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001569run_test "Max fragment length: client, larger message" \
1570 "$P_SRV debug_level=3" \
1571 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1572 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001573 -c "Maximum fragment length is 2048" \
1574 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001575 -c "client hello, adding max_fragment_length extension" \
1576 -s "found max fragment length extension" \
1577 -s "server hello, max_fragment_length extension" \
1578 -c "found max_fragment_length extension" \
1579 -c "2345 bytes written in 2 fragments" \
1580 -s "2048 bytes read" \
1581 -s "297 bytes read"
1582
Hanno Becker4aed27e2017-09-18 15:00:34 +01001583requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001584run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001585 "$P_SRV debug_level=3 dtls=1" \
1586 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1587 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001588 -c "Maximum fragment length is 2048" \
1589 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001590 -c "client hello, adding max_fragment_length extension" \
1591 -s "found max fragment length extension" \
1592 -s "server hello, max_fragment_length extension" \
1593 -c "found max_fragment_length extension" \
1594 -c "fragment larger than.*maximum"
1595
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001596# Tests for renegotiation
1597
Hanno Becker6a243642017-10-12 15:18:45 +01001598# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001599run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001600 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001601 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001602 0 \
1603 -C "client hello, adding renegotiation extension" \
1604 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1605 -S "found renegotiation extension" \
1606 -s "server hello, secure renegotiation extension" \
1607 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001608 -C "=> renegotiate" \
1609 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001610 -S "write hello request"
1611
Hanno Becker6a243642017-10-12 15:18:45 +01001612requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001613run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001614 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001615 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001616 0 \
1617 -c "client hello, adding renegotiation extension" \
1618 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1619 -s "found renegotiation extension" \
1620 -s "server hello, secure renegotiation extension" \
1621 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001622 -c "=> renegotiate" \
1623 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001624 -S "write hello request"
1625
Hanno Becker6a243642017-10-12 15:18:45 +01001626requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001627run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001628 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001629 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001630 0 \
1631 -c "client hello, adding renegotiation extension" \
1632 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1633 -s "found renegotiation extension" \
1634 -s "server hello, secure renegotiation extension" \
1635 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001636 -c "=> renegotiate" \
1637 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001638 -s "write hello request"
1639
Janos Follathb0f148c2017-10-05 12:29:42 +01001640# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1641# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1642# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001643requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001644run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1645 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1646 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1647 0 \
1648 -c "client hello, adding renegotiation extension" \
1649 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1650 -s "found renegotiation extension" \
1651 -s "server hello, secure renegotiation extension" \
1652 -c "found renegotiation extension" \
1653 -c "=> renegotiate" \
1654 -s "=> renegotiate" \
1655 -S "write hello request" \
1656 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1657
1658# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1659# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1660# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001661requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001662run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1663 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1664 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1665 0 \
1666 -c "client hello, adding renegotiation extension" \
1667 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1668 -s "found renegotiation extension" \
1669 -s "server hello, secure renegotiation extension" \
1670 -c "found renegotiation extension" \
1671 -c "=> renegotiate" \
1672 -s "=> renegotiate" \
1673 -s "write hello request" \
1674 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1675
Hanno Becker6a243642017-10-12 15:18:45 +01001676requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001677run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001678 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001679 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001680 0 \
1681 -c "client hello, adding renegotiation extension" \
1682 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1683 -s "found renegotiation extension" \
1684 -s "server hello, secure renegotiation extension" \
1685 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001686 -c "=> renegotiate" \
1687 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001688 -s "write hello request"
1689
Hanno Becker6a243642017-10-12 15:18:45 +01001690requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001691run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001692 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001693 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001694 1 \
1695 -c "client hello, adding renegotiation extension" \
1696 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1697 -S "found renegotiation extension" \
1698 -s "server hello, secure renegotiation extension" \
1699 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001700 -c "=> renegotiate" \
1701 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001702 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001703 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001704 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001705
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: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001708 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001709 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001710 0 \
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é-Gonnard780d6712014-02-20 17:19:59 +01001718 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001719 -S "SSL - An unexpected message was received from our peer" \
1720 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +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, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001724 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001725 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001726 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001727 0 \
1728 -C "client hello, adding renegotiation extension" \
1729 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1730 -S "found renegotiation extension" \
1731 -s "server hello, secure renegotiation extension" \
1732 -c "found renegotiation extension" \
1733 -C "=> renegotiate" \
1734 -S "=> renegotiate" \
1735 -s "write hello request" \
1736 -S "SSL - An unexpected message was received from our peer" \
1737 -S "failed"
1738
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001739# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001740requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001741run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001742 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001743 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001744 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001745 0 \
1746 -C "client hello, adding renegotiation extension" \
1747 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1748 -S "found renegotiation extension" \
1749 -s "server hello, secure renegotiation extension" \
1750 -c "found renegotiation extension" \
1751 -C "=> renegotiate" \
1752 -S "=> renegotiate" \
1753 -s "write hello request" \
1754 -S "SSL - An unexpected message was received from our peer" \
1755 -S "failed"
1756
Hanno Becker6a243642017-10-12 15:18:45 +01001757requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001758run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001759 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001760 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001761 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001762 0 \
1763 -C "client hello, adding renegotiation extension" \
1764 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1765 -S "found renegotiation extension" \
1766 -s "server hello, secure renegotiation extension" \
1767 -c "found renegotiation extension" \
1768 -C "=> renegotiate" \
1769 -S "=> renegotiate" \
1770 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001771 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001772
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-accepted, 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=1" \
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" \
1787 -S "SSL - An unexpected message was received from our peer" \
1788 -S "failed"
1789
Hanno Becker6a243642017-10-12 15:18:45 +01001790requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001791run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001792 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001793 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1794 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 -S "record counter limit reached: renegotiate" \
1801 -C "=> renegotiate" \
1802 -S "=> renegotiate" \
1803 -S "write hello request" \
1804 -S "SSL - An unexpected message was received from our peer" \
1805 -S "failed"
1806
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001807# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001808requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001809run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001810 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001811 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001812 0 \
1813 -c "client hello, adding renegotiation extension" \
1814 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1815 -s "found renegotiation extension" \
1816 -s "server hello, secure renegotiation extension" \
1817 -c "found renegotiation extension" \
1818 -s "record counter limit reached: renegotiate" \
1819 -c "=> renegotiate" \
1820 -s "=> renegotiate" \
1821 -s "write hello request" \
1822 -S "SSL - An unexpected message was received from our peer" \
1823 -S "failed"
1824
Hanno Becker6a243642017-10-12 15:18:45 +01001825requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001826run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001827 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001828 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001829 0 \
1830 -c "client hello, adding renegotiation extension" \
1831 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1832 -s "found renegotiation extension" \
1833 -s "server hello, secure renegotiation extension" \
1834 -c "found renegotiation extension" \
1835 -s "record counter limit reached: renegotiate" \
1836 -c "=> renegotiate" \
1837 -s "=> renegotiate" \
1838 -s "write hello request" \
1839 -S "SSL - An unexpected message was received from our peer" \
1840 -S "failed"
1841
Hanno Becker6a243642017-10-12 15:18:45 +01001842requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001843run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001844 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001845 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1846 0 \
1847 -C "client hello, adding renegotiation extension" \
1848 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1849 -S "found renegotiation extension" \
1850 -s "server hello, secure renegotiation extension" \
1851 -c "found renegotiation extension" \
1852 -S "record counter limit reached: renegotiate" \
1853 -C "=> renegotiate" \
1854 -S "=> renegotiate" \
1855 -S "write hello request" \
1856 -S "SSL - An unexpected message was received from our peer" \
1857 -S "failed"
1858
Hanno Becker6a243642017-10-12 15:18:45 +01001859requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001860run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001861 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001862 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001863 0 \
1864 -c "client hello, adding renegotiation extension" \
1865 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1866 -s "found renegotiation extension" \
1867 -s "server hello, secure renegotiation extension" \
1868 -c "found renegotiation extension" \
1869 -c "=> renegotiate" \
1870 -s "=> renegotiate" \
1871 -S "write hello request"
1872
Hanno Becker6a243642017-10-12 15:18:45 +01001873requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001874run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001875 "$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 +02001876 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001877 0 \
1878 -c "client hello, adding renegotiation extension" \
1879 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1880 -s "found renegotiation extension" \
1881 -s "server hello, secure renegotiation extension" \
1882 -c "found renegotiation extension" \
1883 -c "=> renegotiate" \
1884 -s "=> renegotiate" \
1885 -s "write hello request"
1886
Hanno Becker6a243642017-10-12 15:18:45 +01001887requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001888run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001889 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001890 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001891 0 \
1892 -c "client hello, adding renegotiation extension" \
1893 -c "found renegotiation extension" \
1894 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001895 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001896 -C "error" \
1897 -c "HTTP/1.0 200 [Oo][Kk]"
1898
Paul Bakker539d9722015-02-08 16:18:35 +01001899requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001900requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001901run_test "Renegotiation: gnutls server strict, client-initiated" \
1902 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001903 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001904 0 \
1905 -c "client hello, adding renegotiation extension" \
1906 -c "found renegotiation extension" \
1907 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001908 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001909 -C "error" \
1910 -c "HTTP/1.0 200 [Oo][Kk]"
1911
Paul Bakker539d9722015-02-08 16:18:35 +01001912requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001913requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001914run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1915 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1916 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1917 1 \
1918 -c "client hello, adding renegotiation extension" \
1919 -C "found renegotiation extension" \
1920 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001921 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001922 -c "error" \
1923 -C "HTTP/1.0 200 [Oo][Kk]"
1924
Paul Bakker539d9722015-02-08 16:18:35 +01001925requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001926requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001927run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1928 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1929 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1930 allow_legacy=0" \
1931 1 \
1932 -c "client hello, adding renegotiation extension" \
1933 -C "found renegotiation extension" \
1934 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001935 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001936 -c "error" \
1937 -C "HTTP/1.0 200 [Oo][Kk]"
1938
Paul Bakker539d9722015-02-08 16:18:35 +01001939requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001940requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001941run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1942 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1943 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1944 allow_legacy=1" \
1945 0 \
1946 -c "client hello, adding renegotiation extension" \
1947 -C "found renegotiation extension" \
1948 -c "=> renegotiate" \
1949 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001950 -C "error" \
1951 -c "HTTP/1.0 200 [Oo][Kk]"
1952
Hanno Becker6a243642017-10-12 15:18:45 +01001953requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001954run_test "Renegotiation: DTLS, client-initiated" \
1955 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1956 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1957 0 \
1958 -c "client hello, adding renegotiation extension" \
1959 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1960 -s "found renegotiation extension" \
1961 -s "server hello, secure renegotiation extension" \
1962 -c "found renegotiation extension" \
1963 -c "=> renegotiate" \
1964 -s "=> renegotiate" \
1965 -S "write hello request"
1966
Hanno Becker6a243642017-10-12 15:18:45 +01001967requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001968run_test "Renegotiation: DTLS, server-initiated" \
1969 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001970 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1971 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001972 0 \
1973 -c "client hello, adding renegotiation extension" \
1974 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1975 -s "found renegotiation extension" \
1976 -s "server hello, secure renegotiation extension" \
1977 -c "found renegotiation extension" \
1978 -c "=> renegotiate" \
1979 -s "=> renegotiate" \
1980 -s "write hello request"
1981
Hanno Becker6a243642017-10-12 15:18:45 +01001982requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00001983run_test "Renegotiation: DTLS, renego_period overflow" \
1984 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1985 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1986 0 \
1987 -c "client hello, adding renegotiation extension" \
1988 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1989 -s "found renegotiation extension" \
1990 -s "server hello, secure renegotiation extension" \
1991 -s "record counter limit reached: renegotiate" \
1992 -c "=> renegotiate" \
1993 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01001994 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00001995
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001996requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001997requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001998run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1999 "$G_SRV -u --mtu 4096" \
2000 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2001 0 \
2002 -c "client hello, adding renegotiation extension" \
2003 -c "found renegotiation extension" \
2004 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002005 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002006 -C "error" \
2007 -s "Extra-header:"
2008
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002009# Test for the "secure renegotation" extension only (no actual renegotiation)
2010
Paul Bakker539d9722015-02-08 16:18:35 +01002011requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002012run_test "Renego ext: gnutls server strict, client default" \
2013 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2014 "$P_CLI debug_level=3" \
2015 0 \
2016 -c "found renegotiation extension" \
2017 -C "error" \
2018 -c "HTTP/1.0 200 [Oo][Kk]"
2019
Paul Bakker539d9722015-02-08 16:18:35 +01002020requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002021run_test "Renego ext: gnutls server unsafe, client default" \
2022 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2023 "$P_CLI debug_level=3" \
2024 0 \
2025 -C "found renegotiation extension" \
2026 -C "error" \
2027 -c "HTTP/1.0 200 [Oo][Kk]"
2028
Paul Bakker539d9722015-02-08 16:18:35 +01002029requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002030run_test "Renego ext: gnutls server unsafe, client break legacy" \
2031 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2032 "$P_CLI debug_level=3 allow_legacy=-1" \
2033 1 \
2034 -C "found renegotiation extension" \
2035 -c "error" \
2036 -C "HTTP/1.0 200 [Oo][Kk]"
2037
Paul Bakker539d9722015-02-08 16:18:35 +01002038requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002039run_test "Renego ext: gnutls client strict, server default" \
2040 "$P_SRV debug_level=3" \
2041 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2042 0 \
2043 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2044 -s "server hello, secure renegotiation extension"
2045
Paul Bakker539d9722015-02-08 16:18:35 +01002046requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002047run_test "Renego ext: gnutls client unsafe, server default" \
2048 "$P_SRV debug_level=3" \
2049 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2050 0 \
2051 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2052 -S "server hello, secure renegotiation extension"
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 unsafe, server break legacy" \
2056 "$P_SRV debug_level=3 allow_legacy=-1" \
2057 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2058 1 \
2059 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2060 -S "server hello, secure renegotiation extension"
2061
Janos Follath0b242342016-02-17 10:11:21 +00002062# Tests for silently dropping trailing extra bytes in .der certificates
2063
2064requires_gnutls
2065run_test "DER format: no trailing bytes" \
2066 "$P_SRV crt_file=data_files/server5-der0.crt \
2067 key_file=data_files/server5.key" \
2068 "$G_CLI " \
2069 0 \
2070 -c "Handshake was completed" \
2071
2072requires_gnutls
2073run_test "DER format: with a trailing zero byte" \
2074 "$P_SRV crt_file=data_files/server5-der1a.crt \
2075 key_file=data_files/server5.key" \
2076 "$G_CLI " \
2077 0 \
2078 -c "Handshake was completed" \
2079
2080requires_gnutls
2081run_test "DER format: with a trailing random byte" \
2082 "$P_SRV crt_file=data_files/server5-der1b.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 2 trailing random bytes" \
2090 "$P_SRV crt_file=data_files/server5-der2.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 4 trailing random bytes" \
2098 "$P_SRV crt_file=data_files/server5-der4.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 8 trailing random bytes" \
2106 "$P_SRV crt_file=data_files/server5-der8.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 9 trailing random bytes" \
2114 "$P_SRV crt_file=data_files/server5-der9.crt \
2115 key_file=data_files/server5.key" \
2116 "$G_CLI " \
2117 0 \
2118 -c "Handshake was completed" \
2119
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002120# Tests for auth_mode
2121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002122run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002123 "$P_SRV crt_file=data_files/server5-badsign.crt \
2124 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002125 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002126 1 \
2127 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002128 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002129 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002130 -c "X509 - Certificate verification failed"
2131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002132run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002133 "$P_SRV crt_file=data_files/server5-badsign.crt \
2134 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002135 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002136 0 \
2137 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002138 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002139 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002140 -C "X509 - Certificate verification failed"
2141
Hanno Beckere6706e62017-05-15 16:05:15 +01002142run_test "Authentication: server goodcert, client optional, no trusted CA" \
2143 "$P_SRV" \
2144 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2145 0 \
2146 -c "x509_verify_cert() returned" \
2147 -c "! The certificate is not correctly signed by the trusted CA" \
2148 -c "! Certificate verification flags"\
2149 -C "! mbedtls_ssl_handshake returned" \
2150 -C "X509 - Certificate verification failed" \
2151 -C "SSL - No CA Chain is set, but required to operate"
2152
2153run_test "Authentication: server goodcert, client required, no trusted CA" \
2154 "$P_SRV" \
2155 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2156 1 \
2157 -c "x509_verify_cert() returned" \
2158 -c "! The certificate is not correctly signed by the trusted CA" \
2159 -c "! Certificate verification flags"\
2160 -c "! mbedtls_ssl_handshake returned" \
2161 -c "SSL - No CA Chain is set, but required to operate"
2162
2163# The purpose of the next two tests is to test the client's behaviour when receiving a server
2164# certificate with an unsupported elliptic curve. This should usually not happen because
2165# the client informs the server about the supported curves - it does, though, in the
2166# corner case of a static ECDH suite, because the server doesn't check the curve on that
2167# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2168# different means to have the server ignoring the client's supported curve list.
2169
2170requires_config_enabled MBEDTLS_ECP_C
2171run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2172 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2173 crt_file=data_files/server5.ku-ka.crt" \
2174 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2175 1 \
2176 -c "bad certificate (EC key curve)"\
2177 -c "! Certificate verification flags"\
2178 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2179
2180requires_config_enabled MBEDTLS_ECP_C
2181run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2182 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2183 crt_file=data_files/server5.ku-ka.crt" \
2184 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2185 1 \
2186 -c "bad certificate (EC key curve)"\
2187 -c "! Certificate verification flags"\
2188 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002190run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002191 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002192 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002193 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002194 0 \
2195 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002196 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002197 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002198 -C "X509 - Certificate verification failed"
2199
Simon Butcher99000142016-10-13 17:21:01 +01002200run_test "Authentication: client SHA256, server required" \
2201 "$P_SRV auth_mode=required" \
2202 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2203 key_file=data_files/server6.key \
2204 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2205 0 \
2206 -c "Supported Signature Algorithm found: 4," \
2207 -c "Supported Signature Algorithm found: 5,"
2208
2209run_test "Authentication: client SHA384, server required" \
2210 "$P_SRV auth_mode=required" \
2211 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2212 key_file=data_files/server6.key \
2213 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2214 0 \
2215 -c "Supported Signature Algorithm found: 4," \
2216 -c "Supported Signature Algorithm found: 5,"
2217
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002218requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2219run_test "Authentication: client has no cert, server required (SSLv3)" \
2220 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2221 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2222 key_file=data_files/server5.key" \
2223 1 \
2224 -S "skip write certificate request" \
2225 -C "skip parse certificate request" \
2226 -c "got a certificate request" \
2227 -c "got no certificate to send" \
2228 -S "x509_verify_cert() returned" \
2229 -s "client has no certificate" \
2230 -s "! mbedtls_ssl_handshake returned" \
2231 -c "! mbedtls_ssl_handshake returned" \
2232 -s "No client certification received from the client, but required by the authentication mode"
2233
2234run_test "Authentication: client has no cert, server required (TLS)" \
2235 "$P_SRV debug_level=3 auth_mode=required" \
2236 "$P_CLI debug_level=3 crt_file=none \
2237 key_file=data_files/server5.key" \
2238 1 \
2239 -S "skip write certificate request" \
2240 -C "skip parse certificate request" \
2241 -c "got a certificate request" \
2242 -c "= write certificate$" \
2243 -C "skip write certificate$" \
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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002250run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002251 "$P_SRV debug_level=3 auth_mode=required" \
2252 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002253 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 "skip write certificate" \
2259 -C "skip write certificate verify" \
2260 -S "skip parse certificate verify" \
2261 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002262 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002263 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002264 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002265 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002266 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002267# We don't check that the client receives the alert because it might
2268# detect that its write end of the connection is closed and abort
2269# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002270
Janos Follath89baba22017-04-10 14:34:35 +01002271run_test "Authentication: client cert not trusted, server required" \
2272 "$P_SRV debug_level=3 auth_mode=required" \
2273 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2274 key_file=data_files/server5.key" \
2275 1 \
2276 -S "skip write certificate request" \
2277 -C "skip parse certificate request" \
2278 -c "got a certificate request" \
2279 -C "skip write certificate" \
2280 -C "skip write certificate verify" \
2281 -S "skip parse certificate verify" \
2282 -s "x509_verify_cert() returned" \
2283 -s "! The certificate is not correctly signed by the trusted CA" \
2284 -s "! mbedtls_ssl_handshake returned" \
2285 -c "! mbedtls_ssl_handshake returned" \
2286 -s "X509 - Certificate verification failed"
2287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002288run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002289 "$P_SRV debug_level=3 auth_mode=optional" \
2290 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002291 key_file=data_files/server5.key" \
2292 0 \
2293 -S "skip write certificate request" \
2294 -C "skip parse certificate request" \
2295 -c "got a certificate request" \
2296 -C "skip write certificate" \
2297 -C "skip write certificate verify" \
2298 -S "skip parse certificate verify" \
2299 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002300 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002301 -S "! mbedtls_ssl_handshake returned" \
2302 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002303 -S "X509 - Certificate verification failed"
2304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002305run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002306 "$P_SRV debug_level=3 auth_mode=none" \
2307 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002308 key_file=data_files/server5.key" \
2309 0 \
2310 -s "skip write certificate request" \
2311 -C "skip parse certificate request" \
2312 -c "got no certificate request" \
2313 -c "skip write certificate" \
2314 -c "skip write certificate verify" \
2315 -s "skip parse certificate verify" \
2316 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002317 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002318 -S "! mbedtls_ssl_handshake returned" \
2319 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002320 -S "X509 - Certificate verification failed"
2321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002322run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002323 "$P_SRV debug_level=3 auth_mode=optional" \
2324 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002325 0 \
2326 -S "skip write certificate request" \
2327 -C "skip parse certificate request" \
2328 -c "got a certificate request" \
2329 -C "skip write certificate$" \
2330 -C "got no certificate to send" \
2331 -S "SSLv3 client has no certificate" \
2332 -c "skip write certificate verify" \
2333 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002334 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002335 -S "! mbedtls_ssl_handshake returned" \
2336 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002337 -S "X509 - Certificate verification failed"
2338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002339run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002340 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002341 "$O_CLI" \
2342 0 \
2343 -S "skip write certificate request" \
2344 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002345 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002346 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002347 -S "X509 - Certificate verification failed"
2348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002349run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002350 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002351 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002352 0 \
2353 -C "skip parse certificate request" \
2354 -c "got a certificate request" \
2355 -C "skip write certificate$" \
2356 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002357 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002358
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002359run_test "Authentication: client no cert, openssl server required" \
2360 "$O_SRV -Verify 10" \
2361 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2362 1 \
2363 -C "skip parse certificate request" \
2364 -c "got a certificate request" \
2365 -C "skip write certificate$" \
2366 -c "skip write certificate verify" \
2367 -c "! mbedtls_ssl_handshake returned"
2368
Janos Follathe2681a42016-03-07 15:57:05 +00002369requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002370run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002371 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002372 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002373 0 \
2374 -S "skip write certificate request" \
2375 -C "skip parse certificate request" \
2376 -c "got a certificate request" \
2377 -C "skip write certificate$" \
2378 -c "skip write certificate verify" \
2379 -c "got no certificate to send" \
2380 -s "SSLv3 client has no certificate" \
2381 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002382 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002383 -S "! mbedtls_ssl_handshake returned" \
2384 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002385 -S "X509 - Certificate verification failed"
2386
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002387# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2388# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002389
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002390MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002391MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002392
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002393if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002394 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002395 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002396 printf "test value of ${MAX_IM_CA}. \n"
2397 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002398 printf "The tests assume this value and if it changes, the tests in this\n"
2399 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002400 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002401
2402 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002403fi
2404
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002405run_test "Authentication: server max_int chain, client default" \
2406 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2407 key_file=data_files/dir-maxpath/09.key" \
2408 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2409 0 \
2410 -C "X509 - A fatal error occured"
2411
2412run_test "Authentication: server max_int+1 chain, client default" \
2413 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2414 key_file=data_files/dir-maxpath/10.key" \
2415 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2416 1 \
2417 -c "X509 - A fatal error occured"
2418
2419run_test "Authentication: server max_int+1 chain, client optional" \
2420 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2421 key_file=data_files/dir-maxpath/10.key" \
2422 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2423 auth_mode=optional" \
2424 1 \
2425 -c "X509 - A fatal error occured"
2426
2427run_test "Authentication: server max_int+1 chain, client none" \
2428 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2429 key_file=data_files/dir-maxpath/10.key" \
2430 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2431 auth_mode=none" \
2432 0 \
2433 -C "X509 - A fatal error occured"
2434
2435run_test "Authentication: client max_int+1 chain, server default" \
2436 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2437 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2438 key_file=data_files/dir-maxpath/10.key" \
2439 0 \
2440 -S "X509 - A fatal error occured"
2441
2442run_test "Authentication: client max_int+1 chain, server optional" \
2443 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2444 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2445 key_file=data_files/dir-maxpath/10.key" \
2446 1 \
2447 -s "X509 - A fatal error occured"
2448
2449run_test "Authentication: client max_int+1 chain, server required" \
2450 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2451 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2452 key_file=data_files/dir-maxpath/10.key" \
2453 1 \
2454 -s "X509 - A fatal error occured"
2455
2456run_test "Authentication: client max_int chain, server required" \
2457 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2458 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2459 key_file=data_files/dir-maxpath/09.key" \
2460 0 \
2461 -S "X509 - A fatal error occured"
2462
Janos Follath89baba22017-04-10 14:34:35 +01002463# Tests for CA list in CertificateRequest messages
2464
2465run_test "Authentication: send CA list in CertificateRequest (default)" \
2466 "$P_SRV debug_level=3 auth_mode=required" \
2467 "$P_CLI crt_file=data_files/server6.crt \
2468 key_file=data_files/server6.key" \
2469 0 \
2470 -s "requested DN"
2471
2472run_test "Authentication: do not send CA list in CertificateRequest" \
2473 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2474 "$P_CLI crt_file=data_files/server6.crt \
2475 key_file=data_files/server6.key" \
2476 0 \
2477 -S "requested DN"
2478
2479run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2480 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2481 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2482 key_file=data_files/server5.key" \
2483 1 \
2484 -S "requested DN" \
2485 -s "x509_verify_cert() returned" \
2486 -s "! The certificate is not correctly signed by the trusted CA" \
2487 -s "! mbedtls_ssl_handshake returned" \
2488 -c "! mbedtls_ssl_handshake returned" \
2489 -s "X509 - Certificate verification failed"
2490
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002491# Tests for certificate selection based on SHA verson
2492
2493run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2494 "$P_SRV crt_file=data_files/server5.crt \
2495 key_file=data_files/server5.key \
2496 crt_file2=data_files/server5-sha1.crt \
2497 key_file2=data_files/server5.key" \
2498 "$P_CLI force_version=tls1_2" \
2499 0 \
2500 -c "signed using.*ECDSA with SHA256" \
2501 -C "signed using.*ECDSA with SHA1"
2502
2503run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2504 "$P_SRV crt_file=data_files/server5.crt \
2505 key_file=data_files/server5.key \
2506 crt_file2=data_files/server5-sha1.crt \
2507 key_file2=data_files/server5.key" \
2508 "$P_CLI force_version=tls1_1" \
2509 0 \
2510 -C "signed using.*ECDSA with SHA256" \
2511 -c "signed using.*ECDSA with SHA1"
2512
2513run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2514 "$P_SRV crt_file=data_files/server5.crt \
2515 key_file=data_files/server5.key \
2516 crt_file2=data_files/server5-sha1.crt \
2517 key_file2=data_files/server5.key" \
2518 "$P_CLI force_version=tls1" \
2519 0 \
2520 -C "signed using.*ECDSA with SHA256" \
2521 -c "signed using.*ECDSA with SHA1"
2522
2523run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2524 "$P_SRV crt_file=data_files/server5.crt \
2525 key_file=data_files/server5.key \
2526 crt_file2=data_files/server6.crt \
2527 key_file2=data_files/server6.key" \
2528 "$P_CLI force_version=tls1_1" \
2529 0 \
2530 -c "serial number.*09" \
2531 -c "signed using.*ECDSA with SHA256" \
2532 -C "signed using.*ECDSA with SHA1"
2533
2534run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2535 "$P_SRV crt_file=data_files/server6.crt \
2536 key_file=data_files/server6.key \
2537 crt_file2=data_files/server5.crt \
2538 key_file2=data_files/server5.key" \
2539 "$P_CLI force_version=tls1_1" \
2540 0 \
2541 -c "serial number.*0A" \
2542 -c "signed using.*ECDSA with SHA256" \
2543 -C "signed using.*ECDSA with SHA1"
2544
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002545# tests for SNI
2546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002547run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002548 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002549 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002550 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002551 0 \
2552 -S "parse ServerName extension" \
2553 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2554 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002556run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002557 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002558 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002559 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 +02002560 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002561 0 \
2562 -s "parse ServerName extension" \
2563 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2564 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002566run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002567 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002568 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002569 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 +02002570 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002571 0 \
2572 -s "parse ServerName extension" \
2573 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2574 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002575
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002576run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002577 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002578 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002579 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 +02002580 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002581 1 \
2582 -s "parse ServerName extension" \
2583 -s "ssl_sni_wrapper() returned" \
2584 -s "mbedtls_ssl_handshake returned" \
2585 -c "mbedtls_ssl_handshake returned" \
2586 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002587
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002588run_test "SNI: client auth no override: optional" \
2589 "$P_SRV debug_level=3 auth_mode=optional \
2590 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2591 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2592 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002593 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002594 -S "skip write certificate request" \
2595 -C "skip parse certificate request" \
2596 -c "got a certificate request" \
2597 -C "skip write certificate" \
2598 -C "skip write certificate verify" \
2599 -S "skip parse certificate verify"
2600
2601run_test "SNI: client auth override: none -> optional" \
2602 "$P_SRV debug_level=3 auth_mode=none \
2603 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2604 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2605 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002606 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002607 -S "skip write certificate request" \
2608 -C "skip parse certificate request" \
2609 -c "got a certificate request" \
2610 -C "skip write certificate" \
2611 -C "skip write certificate verify" \
2612 -S "skip parse certificate verify"
2613
2614run_test "SNI: client auth override: optional -> none" \
2615 "$P_SRV debug_level=3 auth_mode=optional \
2616 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2617 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2618 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002619 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002620 -s "skip write certificate request" \
2621 -C "skip parse certificate request" \
2622 -c "got no certificate request" \
2623 -c "skip write certificate" \
2624 -c "skip write certificate verify" \
2625 -s "skip parse certificate verify"
2626
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002627run_test "SNI: CA no override" \
2628 "$P_SRV debug_level=3 auth_mode=optional \
2629 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2630 ca_file=data_files/test-ca.crt \
2631 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2632 "$P_CLI debug_level=3 server_name=localhost \
2633 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2634 1 \
2635 -S "skip write certificate request" \
2636 -C "skip parse certificate request" \
2637 -c "got a certificate request" \
2638 -C "skip write certificate" \
2639 -C "skip write certificate verify" \
2640 -S "skip parse certificate verify" \
2641 -s "x509_verify_cert() returned" \
2642 -s "! The certificate is not correctly signed by the trusted CA" \
2643 -S "The certificate has been revoked (is on a CRL)"
2644
2645run_test "SNI: CA override" \
2646 "$P_SRV debug_level=3 auth_mode=optional \
2647 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2648 ca_file=data_files/test-ca.crt \
2649 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2650 "$P_CLI debug_level=3 server_name=localhost \
2651 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2652 0 \
2653 -S "skip write certificate request" \
2654 -C "skip parse certificate request" \
2655 -c "got a certificate request" \
2656 -C "skip write certificate" \
2657 -C "skip write certificate verify" \
2658 -S "skip parse certificate verify" \
2659 -S "x509_verify_cert() returned" \
2660 -S "! The certificate is not correctly signed by the trusted CA" \
2661 -S "The certificate has been revoked (is on a CRL)"
2662
2663run_test "SNI: CA override with CRL" \
2664 "$P_SRV debug_level=3 auth_mode=optional \
2665 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2666 ca_file=data_files/test-ca.crt \
2667 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2668 "$P_CLI debug_level=3 server_name=localhost \
2669 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2670 1 \
2671 -S "skip write certificate request" \
2672 -C "skip parse certificate request" \
2673 -c "got a certificate request" \
2674 -C "skip write certificate" \
2675 -C "skip write certificate verify" \
2676 -S "skip parse certificate verify" \
2677 -s "x509_verify_cert() returned" \
2678 -S "! The certificate is not correctly signed by the trusted CA" \
2679 -s "The certificate has been revoked (is on a CRL)"
2680
Andres AGe8b07742016-12-07 10:01:30 +00002681# Tests for SNI and DTLS
2682
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002683run_test "SNI: DTLS, no SNI callback" \
2684 "$P_SRV debug_level=3 dtls=1 \
2685 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2686 "$P_CLI server_name=localhost dtls=1" \
2687 0 \
2688 -S "parse ServerName extension" \
2689 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2690 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2691
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002692run_test "SNI: DTLS, matching cert 1" \
Andres AGe8b07742016-12-07 10:01:30 +00002693 "$P_SRV debug_level=3 dtls=1 \
2694 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2695 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2696 "$P_CLI server_name=localhost dtls=1" \
2697 0 \
2698 -s "parse ServerName extension" \
2699 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2700 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2701
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002702run_test "SNI: DTLS, matching cert 2" \
2703 "$P_SRV debug_level=3 dtls=1 \
2704 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2705 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2706 "$P_CLI server_name=polarssl.example dtls=1" \
2707 0 \
2708 -s "parse ServerName extension" \
2709 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2710 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2711
2712run_test "SNI: DTLS, no matching cert" \
2713 "$P_SRV debug_level=3 dtls=1 \
2714 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2715 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2716 "$P_CLI server_name=nonesuch.example dtls=1" \
2717 1 \
2718 -s "parse ServerName extension" \
2719 -s "ssl_sni_wrapper() returned" \
2720 -s "mbedtls_ssl_handshake returned" \
2721 -c "mbedtls_ssl_handshake returned" \
2722 -c "SSL - A fatal alert message was received from our peer"
2723
2724run_test "SNI: DTLS, client auth no override: optional" \
2725 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2726 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2727 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2728 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2729 0 \
2730 -S "skip write certificate request" \
2731 -C "skip parse certificate request" \
2732 -c "got a certificate request" \
2733 -C "skip write certificate" \
2734 -C "skip write certificate verify" \
2735 -S "skip parse certificate verify"
2736
2737run_test "SNI: DTLS, client auth override: none -> optional" \
2738 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2739 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2740 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2741 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2742 0 \
2743 -S "skip write certificate request" \
2744 -C "skip parse certificate request" \
2745 -c "got a certificate request" \
2746 -C "skip write certificate" \
2747 -C "skip write certificate verify" \
2748 -S "skip parse certificate verify"
2749
2750run_test "SNI: DTLS, client auth override: optional -> none" \
2751 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2752 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2753 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2754 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2755 0 \
2756 -s "skip write certificate request" \
2757 -C "skip parse certificate request" \
2758 -c "got no certificate request" \
2759 -c "skip write certificate" \
2760 -c "skip write certificate verify" \
2761 -s "skip parse certificate verify"
2762
2763run_test "SNI: DTLS, CA no override" \
2764 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2765 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2766 ca_file=data_files/test-ca.crt \
2767 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2768 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2769 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2770 1 \
2771 -S "skip write certificate request" \
2772 -C "skip parse certificate request" \
2773 -c "got a certificate request" \
2774 -C "skip write certificate" \
2775 -C "skip write certificate verify" \
2776 -S "skip parse certificate verify" \
2777 -s "x509_verify_cert() returned" \
2778 -s "! The certificate is not correctly signed by the trusted CA" \
2779 -S "The certificate has been revoked (is on a CRL)"
2780
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002781run_test "SNI: DTLS, CA override" \
Andres AGe8b07742016-12-07 10:01:30 +00002782 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2783 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2784 ca_file=data_files/test-ca.crt \
2785 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2786 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2787 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2788 0 \
2789 -S "skip write certificate request" \
2790 -C "skip parse certificate request" \
2791 -c "got a certificate request" \
2792 -C "skip write certificate" \
2793 -C "skip write certificate verify" \
2794 -S "skip parse certificate verify" \
2795 -S "x509_verify_cert() returned" \
2796 -S "! The certificate is not correctly signed by the trusted CA" \
2797 -S "The certificate has been revoked (is on a CRL)"
2798
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002799run_test "SNI: DTLS, CA override with CRL" \
Andres AGe8b07742016-12-07 10:01:30 +00002800 "$P_SRV debug_level=3 auth_mode=optional \
2801 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2802 ca_file=data_files/test-ca.crt \
2803 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2804 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2805 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2806 1 \
2807 -S "skip write certificate request" \
2808 -C "skip parse certificate request" \
2809 -c "got a certificate request" \
2810 -C "skip write certificate" \
2811 -C "skip write certificate verify" \
2812 -S "skip parse certificate verify" \
2813 -s "x509_verify_cert() returned" \
2814 -S "! The certificate is not correctly signed by the trusted CA" \
2815 -s "The certificate has been revoked (is on a CRL)"
2816
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002817# Tests for non-blocking I/O: exercise a variety of handshake flows
2818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002819run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002820 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2821 "$P_CLI nbio=2 tickets=0" \
2822 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002823 -S "mbedtls_ssl_handshake returned" \
2824 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002825 -c "Read from server: .* bytes read"
2826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002827run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002828 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2829 "$P_CLI nbio=2 tickets=0" \
2830 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002831 -S "mbedtls_ssl_handshake returned" \
2832 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002833 -c "Read from server: .* bytes read"
2834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002835run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002836 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2837 "$P_CLI nbio=2 tickets=1" \
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: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002844 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2845 "$P_CLI nbio=2 tickets=1" \
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 + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002852 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2853 "$P_CLI nbio=2 tickets=1 reconnect=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 + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002860 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2861 "$P_CLI nbio=2 tickets=1 reconnect=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: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002868 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2869 "$P_CLI nbio=2 tickets=0 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é-Gonnardf6521de2014-04-07 12:42:04 +02002875# Tests for version negotiation
2876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002877run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002878 "$P_SRV" \
2879 "$P_CLI" \
2880 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002881 -S "mbedtls_ssl_handshake returned" \
2882 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002883 -s "Protocol is TLSv1.2" \
2884 -c "Protocol is TLSv1.2"
2885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002886run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002887 "$P_SRV" \
2888 "$P_CLI max_version=tls1_1" \
2889 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002890 -S "mbedtls_ssl_handshake returned" \
2891 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002892 -s "Protocol is TLSv1.1" \
2893 -c "Protocol is TLSv1.1"
2894
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002895run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002896 "$P_SRV max_version=tls1_1" \
2897 "$P_CLI" \
2898 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002899 -S "mbedtls_ssl_handshake returned" \
2900 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002901 -s "Protocol is TLSv1.1" \
2902 -c "Protocol is TLSv1.1"
2903
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002904run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002905 "$P_SRV max_version=tls1_1" \
2906 "$P_CLI max_version=tls1_1" \
2907 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002908 -S "mbedtls_ssl_handshake returned" \
2909 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002910 -s "Protocol is TLSv1.1" \
2911 -c "Protocol is TLSv1.1"
2912
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002913run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002914 "$P_SRV min_version=tls1_1" \
2915 "$P_CLI max_version=tls1_1" \
2916 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002917 -S "mbedtls_ssl_handshake returned" \
2918 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002919 -s "Protocol is TLSv1.1" \
2920 -c "Protocol is TLSv1.1"
2921
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002922run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002923 "$P_SRV max_version=tls1_1" \
2924 "$P_CLI min_version=tls1_1" \
2925 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002926 -S "mbedtls_ssl_handshake returned" \
2927 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002928 -s "Protocol is TLSv1.1" \
2929 -c "Protocol is TLSv1.1"
2930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002931run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002932 "$P_SRV max_version=tls1_1" \
2933 "$P_CLI min_version=tls1_2" \
2934 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002935 -s "mbedtls_ssl_handshake returned" \
2936 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002937 -c "SSL - Handshake protocol not within min/max boundaries"
2938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002939run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002940 "$P_SRV min_version=tls1_2" \
2941 "$P_CLI max_version=tls1_1" \
2942 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002943 -s "mbedtls_ssl_handshake returned" \
2944 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002945 -s "SSL - Handshake protocol not within min/max boundaries"
2946
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002947# Tests for ALPN extension
2948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002949run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002950 "$P_SRV debug_level=3" \
2951 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002952 0 \
2953 -C "client hello, adding alpn extension" \
2954 -S "found alpn extension" \
2955 -C "got an alert message, type: \\[2:120]" \
2956 -S "server hello, adding alpn extension" \
2957 -C "found alpn extension " \
2958 -C "Application Layer Protocol is" \
2959 -S "Application Layer Protocol is"
2960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002961run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002962 "$P_SRV debug_level=3" \
2963 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002964 0 \
2965 -c "client hello, adding alpn extension" \
2966 -s "found alpn extension" \
2967 -C "got an alert message, type: \\[2:120]" \
2968 -S "server hello, adding alpn extension" \
2969 -C "found alpn extension " \
2970 -c "Application Layer Protocol is (none)" \
2971 -S "Application Layer Protocol is"
2972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002973run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002974 "$P_SRV debug_level=3 alpn=abc,1234" \
2975 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002976 0 \
2977 -C "client hello, adding alpn extension" \
2978 -S "found alpn extension" \
2979 -C "got an alert message, type: \\[2:120]" \
2980 -S "server hello, adding alpn extension" \
2981 -C "found alpn extension " \
2982 -C "Application Layer Protocol is" \
2983 -s "Application Layer Protocol is (none)"
2984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002985run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002986 "$P_SRV debug_level=3 alpn=abc,1234" \
2987 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002988 0 \
2989 -c "client hello, adding alpn extension" \
2990 -s "found alpn extension" \
2991 -C "got an alert message, type: \\[2:120]" \
2992 -s "server hello, adding alpn extension" \
2993 -c "found alpn extension" \
2994 -c "Application Layer Protocol is abc" \
2995 -s "Application Layer Protocol is abc"
2996
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002997run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002998 "$P_SRV debug_level=3 alpn=abc,1234" \
2999 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003000 0 \
3001 -c "client hello, adding alpn extension" \
3002 -s "found alpn extension" \
3003 -C "got an alert message, type: \\[2:120]" \
3004 -s "server hello, adding alpn extension" \
3005 -c "found alpn extension" \
3006 -c "Application Layer Protocol is abc" \
3007 -s "Application Layer Protocol is abc"
3008
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003009run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003010 "$P_SRV debug_level=3 alpn=abc,1234" \
3011 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003012 0 \
3013 -c "client hello, adding alpn extension" \
3014 -s "found alpn extension" \
3015 -C "got an alert message, type: \\[2:120]" \
3016 -s "server hello, adding alpn extension" \
3017 -c "found alpn extension" \
3018 -c "Application Layer Protocol is 1234" \
3019 -s "Application Layer Protocol is 1234"
3020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003021run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003022 "$P_SRV debug_level=3 alpn=abc,123" \
3023 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003024 1 \
3025 -c "client hello, adding alpn extension" \
3026 -s "found alpn extension" \
3027 -c "got an alert message, type: \\[2:120]" \
3028 -S "server hello, adding alpn extension" \
3029 -C "found alpn extension" \
3030 -C "Application Layer Protocol is 1234" \
3031 -S "Application Layer Protocol is 1234"
3032
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003033
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003034# Tests for keyUsage in leaf certificates, part 1:
3035# server-side certificate/suite selection
3036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003037run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003038 "$P_SRV key_file=data_files/server2.key \
3039 crt_file=data_files/server2.ku-ds.crt" \
3040 "$P_CLI" \
3041 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003042 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003043
3044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003045run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003046 "$P_SRV key_file=data_files/server2.key \
3047 crt_file=data_files/server2.ku-ke.crt" \
3048 "$P_CLI" \
3049 0 \
3050 -c "Ciphersuite is TLS-RSA-WITH-"
3051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003052run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003053 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003054 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003055 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003056 1 \
3057 -C "Ciphersuite is "
3058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003059run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003060 "$P_SRV key_file=data_files/server5.key \
3061 crt_file=data_files/server5.ku-ds.crt" \
3062 "$P_CLI" \
3063 0 \
3064 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3065
3066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003067run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003068 "$P_SRV key_file=data_files/server5.key \
3069 crt_file=data_files/server5.ku-ka.crt" \
3070 "$P_CLI" \
3071 0 \
3072 -c "Ciphersuite is TLS-ECDH-"
3073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003074run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003075 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003076 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003077 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003078 1 \
3079 -C "Ciphersuite is "
3080
3081# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003082# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003084run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003085 "$O_SRV -key data_files/server2.key \
3086 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003087 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003088 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3089 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003090 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003091 -C "Processing of the Certificate handshake message failed" \
3092 -c "Ciphersuite is TLS-"
3093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003094run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003095 "$O_SRV -key data_files/server2.key \
3096 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003097 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003098 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3099 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003100 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003101 -C "Processing of the Certificate handshake message failed" \
3102 -c "Ciphersuite is TLS-"
3103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003104run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003105 "$O_SRV -key data_files/server2.key \
3106 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003107 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003108 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3109 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003110 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003111 -C "Processing of the Certificate handshake message failed" \
3112 -c "Ciphersuite is TLS-"
3113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003114run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003115 "$O_SRV -key data_files/server2.key \
3116 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003117 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003118 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3119 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003120 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003121 -c "Processing of the Certificate handshake message failed" \
3122 -C "Ciphersuite is TLS-"
3123
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003124run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3125 "$O_SRV -key data_files/server2.key \
3126 -cert data_files/server2.ku-ke.crt" \
3127 "$P_CLI debug_level=1 auth_mode=optional \
3128 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3129 0 \
3130 -c "bad certificate (usage extensions)" \
3131 -C "Processing of the Certificate handshake message failed" \
3132 -c "Ciphersuite is TLS-" \
3133 -c "! Usage does not match the keyUsage extension"
3134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003135run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003136 "$O_SRV -key data_files/server2.key \
3137 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003138 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003139 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3140 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003141 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003142 -C "Processing of the Certificate handshake message failed" \
3143 -c "Ciphersuite is TLS-"
3144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003145run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003146 "$O_SRV -key data_files/server2.key \
3147 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003148 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003149 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3150 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003151 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003152 -c "Processing of the Certificate handshake message failed" \
3153 -C "Ciphersuite is TLS-"
3154
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003155run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3156 "$O_SRV -key data_files/server2.key \
3157 -cert data_files/server2.ku-ds.crt" \
3158 "$P_CLI debug_level=1 auth_mode=optional \
3159 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3160 0 \
3161 -c "bad certificate (usage extensions)" \
3162 -C "Processing of the Certificate handshake message failed" \
3163 -c "Ciphersuite is TLS-" \
3164 -c "! Usage does not match the keyUsage extension"
3165
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003166# Tests for keyUsage in leaf certificates, part 3:
3167# server-side checking of client cert
3168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003169run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003170 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003171 "$O_CLI -key data_files/server2.key \
3172 -cert data_files/server2.ku-ds.crt" \
3173 0 \
3174 -S "bad certificate (usage extensions)" \
3175 -S "Processing of the Certificate handshake message failed"
3176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003177run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003178 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003179 "$O_CLI -key data_files/server2.key \
3180 -cert data_files/server2.ku-ke.crt" \
3181 0 \
3182 -s "bad certificate (usage extensions)" \
3183 -S "Processing of the Certificate handshake message failed"
3184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003185run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003186 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003187 "$O_CLI -key data_files/server2.key \
3188 -cert data_files/server2.ku-ke.crt" \
3189 1 \
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: ECDSA, DigitalSignature: OK" \
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/server5.key \
3196 -cert data_files/server5.ku-ds.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: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003202 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003203 "$O_CLI -key data_files/server5.key \
3204 -cert data_files/server5.ku-ka.crt" \
3205 0 \
3206 -s "bad certificate (usage extensions)" \
3207 -S "Processing of the Certificate handshake message failed"
3208
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003209# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003211run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003212 "$P_SRV key_file=data_files/server5.key \
3213 crt_file=data_files/server5.eku-srv.crt" \
3214 "$P_CLI" \
3215 0
3216
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003217run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003218 "$P_SRV key_file=data_files/server5.key \
3219 crt_file=data_files/server5.eku-srv.crt" \
3220 "$P_CLI" \
3221 0
3222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003223run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003224 "$P_SRV key_file=data_files/server5.key \
3225 crt_file=data_files/server5.eku-cs_any.crt" \
3226 "$P_CLI" \
3227 0
3228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003229run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003230 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003231 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003232 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003233 1
3234
3235# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3236
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003237run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003238 "$O_SRV -key data_files/server5.key \
3239 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003240 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003241 0 \
3242 -C "bad certificate (usage extensions)" \
3243 -C "Processing of the Certificate handshake message failed" \
3244 -c "Ciphersuite is TLS-"
3245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003246run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003247 "$O_SRV -key data_files/server5.key \
3248 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003249 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003250 0 \
3251 -C "bad certificate (usage extensions)" \
3252 -C "Processing of the Certificate handshake message failed" \
3253 -c "Ciphersuite is TLS-"
3254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003255run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003256 "$O_SRV -key data_files/server5.key \
3257 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003258 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003259 0 \
3260 -C "bad certificate (usage extensions)" \
3261 -C "Processing of the Certificate handshake message failed" \
3262 -c "Ciphersuite is TLS-"
3263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003264run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003265 "$O_SRV -key data_files/server5.key \
3266 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003267 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003268 1 \
3269 -c "bad certificate (usage extensions)" \
3270 -c "Processing of the Certificate handshake message failed" \
3271 -C "Ciphersuite is TLS-"
3272
3273# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003275run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003276 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003277 "$O_CLI -key data_files/server5.key \
3278 -cert data_files/server5.eku-cli.crt" \
3279 0 \
3280 -S "bad certificate (usage extensions)" \
3281 -S "Processing of the Certificate handshake message failed"
3282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003283run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003284 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003285 "$O_CLI -key data_files/server5.key \
3286 -cert data_files/server5.eku-srv_cli.crt" \
3287 0 \
3288 -S "bad certificate (usage extensions)" \
3289 -S "Processing of the Certificate handshake message failed"
3290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003291run_test "extKeyUsage cli-auth: codeSign,anyEKU -> 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-cs_any.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: codeSign -> fail (soft)" \
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-cs.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 -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003308 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003309 "$O_CLI -key data_files/server5.key \
3310 -cert data_files/server5.eku-cs.crt" \
3311 1 \
3312 -s "bad certificate (usage extensions)" \
3313 -s "Processing of the Certificate handshake message failed"
3314
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003315# Tests for DHM parameters loading
3316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003317run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003318 "$P_SRV" \
3319 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3320 debug_level=3" \
3321 0 \
3322 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003323 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003325run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003326 "$P_SRV dhm_file=data_files/dhparams.pem" \
3327 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3328 debug_level=3" \
3329 0 \
3330 -c "value of 'DHM: P ' (1024 bits)" \
3331 -c "value of 'DHM: G ' (2 bits)"
3332
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003333# Tests for DHM client-side size checking
3334
3335run_test "DHM size: server default, client default, OK" \
3336 "$P_SRV" \
3337 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3338 debug_level=1" \
3339 0 \
3340 -C "DHM prime too short:"
3341
3342run_test "DHM size: server default, client 2048, OK" \
3343 "$P_SRV" \
3344 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3345 debug_level=1 dhmlen=2048" \
3346 0 \
3347 -C "DHM prime too short:"
3348
3349run_test "DHM size: server 1024, client default, OK" \
3350 "$P_SRV dhm_file=data_files/dhparams.pem" \
3351 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3352 debug_level=1" \
3353 0 \
3354 -C "DHM prime too short:"
3355
3356run_test "DHM size: server 1000, client default, rejected" \
3357 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3358 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3359 debug_level=1" \
3360 1 \
3361 -c "DHM prime too short:"
3362
3363run_test "DHM size: server default, client 2049, rejected" \
3364 "$P_SRV" \
3365 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3366 debug_level=1 dhmlen=2049" \
3367 1 \
3368 -c "DHM prime too short:"
3369
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003370# Tests for PSK callback
3371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003372run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003373 "$P_SRV psk=abc123 psk_identity=foo" \
3374 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3375 psk_identity=foo psk=abc123" \
3376 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003377 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003378 -S "SSL - Unknown identity received" \
3379 -S "SSL - Verification of the message MAC failed"
3380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003381run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003382 "$P_SRV" \
3383 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3384 psk_identity=foo psk=abc123" \
3385 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003386 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003387 -S "SSL - Unknown identity received" \
3388 -S "SSL - Verification of the message MAC failed"
3389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003390run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003391 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3392 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3393 psk_identity=foo psk=abc123" \
3394 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003395 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003396 -s "SSL - Unknown identity received" \
3397 -S "SSL - Verification of the message MAC failed"
3398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003399run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003400 "$P_SRV psk_list=abc,dead,def,beef" \
3401 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3402 psk_identity=abc psk=dead" \
3403 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003404 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003405 -S "SSL - Unknown identity received" \
3406 -S "SSL - Verification of the message MAC failed"
3407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003408run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003409 "$P_SRV psk_list=abc,dead,def,beef" \
3410 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3411 psk_identity=def psk=beef" \
3412 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003413 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003414 -S "SSL - Unknown identity received" \
3415 -S "SSL - Verification of the message MAC failed"
3416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003417run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003418 "$P_SRV psk_list=abc,dead,def,beef" \
3419 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3420 psk_identity=ghi psk=beef" \
3421 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003422 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003423 -s "SSL - Unknown identity received" \
3424 -S "SSL - Verification of the message MAC failed"
3425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003426run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003427 "$P_SRV psk_list=abc,dead,def,beef" \
3428 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3429 psk_identity=abc psk=beef" \
3430 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003431 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003432 -S "SSL - Unknown identity received" \
3433 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003434
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003435# Tests for EC J-PAKE
3436
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003437requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003438run_test "ECJPAKE: client not configured" \
3439 "$P_SRV debug_level=3" \
3440 "$P_CLI debug_level=3" \
3441 0 \
3442 -C "add ciphersuite: c0ff" \
3443 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003444 -S "found ecjpake kkpp extension" \
3445 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003446 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003447 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003448 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003449 -S "None of the common ciphersuites is usable"
3450
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003451requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003452run_test "ECJPAKE: server not configured" \
3453 "$P_SRV debug_level=3" \
3454 "$P_CLI debug_level=3 ecjpake_pw=bla \
3455 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3456 1 \
3457 -c "add ciphersuite: c0ff" \
3458 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003459 -s "found ecjpake kkpp extension" \
3460 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003461 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003462 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003463 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003464 -s "None of the common ciphersuites is usable"
3465
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003466requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003467run_test "ECJPAKE: working, TLS" \
3468 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3469 "$P_CLI debug_level=3 ecjpake_pw=bla \
3470 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003471 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003472 -c "add ciphersuite: c0ff" \
3473 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003474 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003475 -s "found ecjpake kkpp extension" \
3476 -S "skip ecjpake kkpp extension" \
3477 -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é-Gonnard921f2d02015-09-16 22:52:18 +02003480 -S "None of the common ciphersuites is usable" \
3481 -S "SSL - Verification of the message MAC failed"
3482
Janos Follath74537a62016-09-02 13:45:28 +01003483server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003484requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003485run_test "ECJPAKE: password mismatch, TLS" \
3486 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3487 "$P_CLI debug_level=3 ecjpake_pw=bad \
3488 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3489 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003490 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003491 -s "SSL - Verification of the message MAC failed"
3492
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003493requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003494run_test "ECJPAKE: working, DTLS" \
3495 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3496 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3497 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3498 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003499 -c "re-using cached ecjpake parameters" \
3500 -S "SSL - Verification of the message MAC failed"
3501
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003502requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003503run_test "ECJPAKE: working, DTLS, no cookie" \
3504 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3505 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3506 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3507 0 \
3508 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003509 -S "SSL - Verification of the message MAC failed"
3510
Janos Follath74537a62016-09-02 13:45:28 +01003511server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003512requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003513run_test "ECJPAKE: password mismatch, DTLS" \
3514 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3515 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3516 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3517 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003518 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003519 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003520
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003521# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003522requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003523run_test "ECJPAKE: working, DTLS, nolog" \
3524 "$P_SRV dtls=1 ecjpake_pw=bla" \
3525 "$P_CLI dtls=1 ecjpake_pw=bla \
3526 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3527 0
3528
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003529# Tests for ciphersuites per version
3530
Janos Follathe2681a42016-03-07 15:57:05 +00003531requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003532run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003533 "$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 +02003534 "$P_CLI force_version=ssl3" \
3535 0 \
3536 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003538run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003539 "$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 +01003540 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003541 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003542 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003544run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003545 "$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 +02003546 "$P_CLI force_version=tls1_1" \
3547 0 \
3548 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003550run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003551 "$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 +02003552 "$P_CLI force_version=tls1_2" \
3553 0 \
3554 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3555
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003556# Test for ClientHello without extensions
3557
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003558requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003559run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003560 "$P_SRV debug_level=3" \
3561 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3562 0 \
3563 -s "dumping 'client hello extensions' (0 bytes)"
3564
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003565requires_gnutls
3566run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3567 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3568 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3569 0 \
3570 -s "dumping 'client hello extensions' (0 bytes)"
3571
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003572# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003573
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003574run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003575 "$P_SRV" \
3576 "$P_CLI request_size=100" \
3577 0 \
3578 -s "Read from client: 100 bytes read$"
3579
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003580run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003581 "$P_SRV" \
3582 "$P_CLI request_size=500" \
3583 0 \
3584 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003585
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003586# Tests for small packets
3587
Janos Follathe2681a42016-03-07 15:57:05 +00003588requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003589run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003590 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003591 "$P_CLI request_size=1 force_version=ssl3 \
3592 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3593 0 \
3594 -s "Read from client: 1 bytes read"
3595
Janos Follathe2681a42016-03-07 15:57:05 +00003596requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003597run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003598 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003599 "$P_CLI request_size=1 force_version=ssl3 \
3600 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3601 0 \
3602 -s "Read from client: 1 bytes read"
3603
3604run_test "Small packet TLS 1.0 BlockCipher" \
3605 "$P_SRV" \
3606 "$P_CLI request_size=1 force_version=tls1 \
3607 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3608 0 \
3609 -s "Read from client: 1 bytes read"
3610
Hanno Becker8501f982017-11-10 08:59:04 +00003611run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003612 "$P_SRV" \
3613 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3614 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3615 0 \
3616 -s "Read from client: 1 bytes read"
3617
Hanno Becker32c55012017-11-10 08:42:54 +00003618requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003619run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003620 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003621 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003622 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003623 0 \
3624 -s "Read from client: 1 bytes read"
3625
Hanno Becker32c55012017-11-10 08:42:54 +00003626requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003627run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003628 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003629 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003630 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003631 0 \
3632 -s "Read from client: 1 bytes read"
3633
3634run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003635 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003636 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003637 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3638 0 \
3639 -s "Read from client: 1 bytes read"
3640
3641run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3642 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3643 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003644 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003645 0 \
3646 -s "Read from client: 1 bytes read"
3647
3648requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3649run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003650 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003651 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003652 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003653 0 \
3654 -s "Read from client: 1 bytes read"
3655
Hanno Becker8501f982017-11-10 08:59:04 +00003656requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3657run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003658 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3659 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3660 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003661 0 \
3662 -s "Read from client: 1 bytes read"
3663
3664run_test "Small packet TLS 1.1 BlockCipher" \
3665 "$P_SRV" \
3666 "$P_CLI request_size=1 force_version=tls1_1 \
3667 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3668 0 \
3669 -s "Read from client: 1 bytes read"
3670
Hanno Becker8501f982017-11-10 08:59:04 +00003671run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003672 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003673 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003674 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003675 0 \
3676 -s "Read from client: 1 bytes read"
3677
3678requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3679run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003680 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003681 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003682 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003683 0 \
3684 -s "Read from client: 1 bytes read"
3685
3686requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3687run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003688 "$P_SRV trunc_hmac=1" \
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 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003691 0 \
3692 -s "Read from client: 1 bytes read"
3693
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003694run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003695 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003696 "$P_CLI request_size=1 force_version=tls1_1 \
3697 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3698 0 \
3699 -s "Read from client: 1 bytes read"
3700
Hanno Becker8501f982017-11-10 08:59:04 +00003701run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3702 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003703 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003704 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003705 0 \
3706 -s "Read from client: 1 bytes read"
3707
Hanno Becker8501f982017-11-10 08:59:04 +00003708requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3709run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003710 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003711 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003712 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003713 0 \
3714 -s "Read from client: 1 bytes read"
3715
Hanno Becker32c55012017-11-10 08:42:54 +00003716requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003717run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003718 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
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 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003721 0 \
3722 -s "Read from client: 1 bytes read"
3723
3724run_test "Small packet TLS 1.2 BlockCipher" \
3725 "$P_SRV" \
3726 "$P_CLI request_size=1 force_version=tls1_2 \
3727 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3728 0 \
3729 -s "Read from client: 1 bytes read"
3730
Hanno Becker8501f982017-11-10 08:59:04 +00003731run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003732 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003733 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003734 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003735 0 \
3736 -s "Read from client: 1 bytes read"
3737
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003738run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3739 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003740 "$P_CLI request_size=1 force_version=tls1_2 \
3741 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003742 0 \
3743 -s "Read from client: 1 bytes read"
3744
Hanno Becker32c55012017-11-10 08:42:54 +00003745requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003746run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003747 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003748 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003749 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003750 0 \
3751 -s "Read from client: 1 bytes read"
3752
Hanno Becker8501f982017-11-10 08:59:04 +00003753requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3754run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003755 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003756 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003757 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003758 0 \
3759 -s "Read from client: 1 bytes read"
3760
3761run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003762 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003763 "$P_CLI request_size=1 force_version=tls1_2 \
3764 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3765 0 \
3766 -s "Read from client: 1 bytes read"
3767
Hanno Becker8501f982017-11-10 08:59:04 +00003768run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003769 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003770 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003771 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003772 0 \
3773 -s "Read from client: 1 bytes read"
3774
Hanno Becker32c55012017-11-10 08:42:54 +00003775requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003776run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003777 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003778 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003779 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003780 0 \
3781 -s "Read from client: 1 bytes read"
3782
Hanno Becker8501f982017-11-10 08:59:04 +00003783requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3784run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003785 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003786 "$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 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003788 0 \
3789 -s "Read from client: 1 bytes read"
3790
3791run_test "Small packet TLS 1.2 AEAD" \
3792 "$P_SRV" \
3793 "$P_CLI request_size=1 force_version=tls1_2 \
3794 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3795 0 \
3796 -s "Read from client: 1 bytes read"
3797
3798run_test "Small packet TLS 1.2 AEAD shorter tag" \
3799 "$P_SRV" \
3800 "$P_CLI request_size=1 force_version=tls1_2 \
3801 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3802 0 \
3803 -s "Read from client: 1 bytes read"
3804
Hanno Beckere2148042017-11-10 08:59:18 +00003805# Tests for small packets in DTLS
3806
3807requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3808run_test "Small packet DTLS 1.0" \
3809 "$P_SRV dtls=1 force_version=dtls1" \
3810 "$P_CLI dtls=1 request_size=1 \
3811 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3812 0 \
3813 -s "Read from client: 1 bytes read"
3814
3815requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3816run_test "Small packet DTLS 1.0, without EtM" \
3817 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3818 "$P_CLI dtls=1 request_size=1 \
3819 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3820 0 \
3821 -s "Read from client: 1 bytes read"
3822
3823requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3824requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3825run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003826 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3827 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003828 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3829 0 \
3830 -s "Read from client: 1 bytes read"
3831
3832requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3833requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3834run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003835 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003836 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003838 0 \
3839 -s "Read from client: 1 bytes read"
3840
3841requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3842run_test "Small packet DTLS 1.2" \
3843 "$P_SRV dtls=1 force_version=dtls1_2" \
3844 "$P_CLI dtls=1 request_size=1 \
3845 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3846 0 \
3847 -s "Read from client: 1 bytes read"
3848
3849requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3850run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003851 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003852 "$P_CLI dtls=1 request_size=1 \
3853 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3854 0 \
3855 -s "Read from client: 1 bytes read"
3856
3857requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3858requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3859run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003860 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003861 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003862 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003863 0 \
3864 -s "Read from client: 1 bytes read"
3865
3866requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3867requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3868run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003869 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003870 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003871 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003872 0 \
3873 -s "Read from client: 1 bytes read"
3874
Janos Follath00efff72016-05-06 13:48:23 +01003875# A test for extensions in SSLv3
3876
3877requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3878run_test "SSLv3 with extensions, server side" \
3879 "$P_SRV min_version=ssl3 debug_level=3" \
3880 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3881 0 \
3882 -S "dumping 'client hello extensions'" \
3883 -S "server hello, total extension length:"
3884
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003885# Test for large packets
3886
Janos Follathe2681a42016-03-07 15:57:05 +00003887requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003888run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003889 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003890 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003891 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3892 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003893 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003894 -s "Read from client: 16384 bytes read"
3895
Janos Follathe2681a42016-03-07 15:57:05 +00003896requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003897run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003898 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003899 "$P_CLI request_size=16384 force_version=ssl3 \
3900 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3901 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003902 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003903 -s "Read from client: 16384 bytes read"
3904
3905run_test "Large packet TLS 1.0 BlockCipher" \
3906 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003907 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003908 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3909 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003910 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003911 -s "Read from client: 16384 bytes read"
3912
Hanno Becker278fc7a2017-11-10 09:16:28 +00003913run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003914 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003915 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3916 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3917 0 \
3918 -s "Read from client: 16384 bytes read"
3919
Hanno Becker32c55012017-11-10 08:42:54 +00003920requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003921run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003922 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003923 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003924 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003925 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 Becker32c55012017-11-10 08:42:54 +00003929requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003930run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003931 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003932 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003933 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003934 0 \
3935 -s "Read from client: 16384 bytes read"
3936
3937run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003938 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003939 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003940 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3941 0 \
3942 -s "Read from client: 16384 bytes read"
3943
3944run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3945 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3946 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003947 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003948 0 \
3949 -s "Read from client: 16384 bytes read"
3950
3951requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3952run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003953 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003954 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003955 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003956 0 \
3957 -s "Read from client: 16384 bytes read"
3958
Hanno Becker278fc7a2017-11-10 09:16:28 +00003959requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3960run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003961 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003962 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003963 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003964 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003965 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003966 -s "Read from client: 16384 bytes read"
3967
3968run_test "Large packet TLS 1.1 BlockCipher" \
3969 "$P_SRV" \
3970 "$P_CLI request_size=16384 force_version=tls1_1 \
3971 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3972 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003973 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003974 -s "Read from client: 16384 bytes read"
3975
Hanno Becker278fc7a2017-11-10 09:16:28 +00003976run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3977 "$P_SRV" \
3978 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3979 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003980 0 \
3981 -s "Read from client: 16384 bytes read"
3982
Hanno Becker32c55012017-11-10 08:42:54 +00003983requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003984run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003985 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003986 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003987 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003988 0 \
3989 -s "Read from client: 16384 bytes read"
3990
Hanno Becker32c55012017-11-10 08:42:54 +00003991requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003992run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003993 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003994 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003995 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003996 0 \
3997 -s "Read from client: 16384 bytes read"
3998
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003999run_test "Large packet TLS 1.1 StreamCipher" \
4000 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4001 "$P_CLI request_size=16384 force_version=tls1_1 \
4002 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4003 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004004 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004005 -s "Read from client: 16384 bytes read"
4006
Hanno Becker278fc7a2017-11-10 09:16:28 +00004007run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
4008 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004009 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004010 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004011 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004012 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004013 -s "Read from client: 16384 bytes read"
4014
Hanno Becker278fc7a2017-11-10 09:16:28 +00004015requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4016run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004017 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004018 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004019 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004020 0 \
4021 -s "Read from client: 16384 bytes read"
4022
Hanno Becker278fc7a2017-11-10 09:16:28 +00004023requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4024run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004025 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004026 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004027 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004028 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004029 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004030 -s "Read from client: 16384 bytes read"
4031
4032run_test "Large packet TLS 1.2 BlockCipher" \
4033 "$P_SRV" \
4034 "$P_CLI request_size=16384 force_version=tls1_2 \
4035 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4036 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004037 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004038 -s "Read from client: 16384 bytes read"
4039
Hanno Becker278fc7a2017-11-10 09:16:28 +00004040run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
4041 "$P_SRV" \
4042 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4043 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4044 0 \
4045 -s "Read from client: 16384 bytes read"
4046
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004047run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
4048 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004049 "$P_CLI request_size=16384 force_version=tls1_2 \
4050 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004051 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004052 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004053 -s "Read from client: 16384 bytes read"
4054
Hanno Becker32c55012017-11-10 08:42:54 +00004055requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004056run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004057 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004058 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004059 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004060 0 \
4061 -s "Read from client: 16384 bytes read"
4062
Hanno Becker278fc7a2017-11-10 09:16:28 +00004063requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4064run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004065 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004066 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004067 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004068 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004069 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004070 -s "Read from client: 16384 bytes read"
4071
4072run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004073 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004074 "$P_CLI request_size=16384 force_version=tls1_2 \
4075 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4076 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004077 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004078 -s "Read from client: 16384 bytes read"
4079
Hanno Becker278fc7a2017-11-10 09:16:28 +00004080run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004081 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004082 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004083 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4084 0 \
4085 -s "Read from client: 16384 bytes read"
4086
Hanno Becker32c55012017-11-10 08:42:54 +00004087requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004088run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004089 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004090 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004091 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004092 0 \
4093 -s "Read from client: 16384 bytes read"
4094
Hanno Becker278fc7a2017-11-10 09:16:28 +00004095requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4096run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004097 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004098 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004099 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004100 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004101 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004102 -s "Read from client: 16384 bytes read"
4103
4104run_test "Large packet TLS 1.2 AEAD" \
4105 "$P_SRV" \
4106 "$P_CLI request_size=16384 force_version=tls1_2 \
4107 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4108 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004109 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004110 -s "Read from client: 16384 bytes read"
4111
4112run_test "Large packet TLS 1.2 AEAD shorter tag" \
4113 "$P_SRV" \
4114 "$P_CLI request_size=16384 force_version=tls1_2 \
4115 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4116 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
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004120# Tests for DTLS HelloVerifyRequest
4121
4122run_test "DTLS cookie: enabled" \
4123 "$P_SRV dtls=1 debug_level=2" \
4124 "$P_CLI dtls=1 debug_level=2" \
4125 0 \
4126 -s "cookie verification failed" \
4127 -s "cookie verification passed" \
4128 -S "cookie verification skipped" \
4129 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004130 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004131 -S "SSL - The requested feature is not available"
4132
4133run_test "DTLS cookie: disabled" \
4134 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4135 "$P_CLI dtls=1 debug_level=2" \
4136 0 \
4137 -S "cookie verification failed" \
4138 -S "cookie verification passed" \
4139 -s "cookie verification skipped" \
4140 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004141 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004142 -S "SSL - The requested feature is not available"
4143
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004144run_test "DTLS cookie: default (failing)" \
4145 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4146 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4147 1 \
4148 -s "cookie verification failed" \
4149 -S "cookie verification passed" \
4150 -S "cookie verification skipped" \
4151 -C "received hello verify request" \
4152 -S "hello verification requested" \
4153 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004154
4155requires_ipv6
4156run_test "DTLS cookie: enabled, IPv6" \
4157 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4158 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4159 0 \
4160 -s "cookie verification failed" \
4161 -s "cookie verification passed" \
4162 -S "cookie verification skipped" \
4163 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004164 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004165 -S "SSL - The requested feature is not available"
4166
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004167run_test "DTLS cookie: enabled, nbio" \
4168 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4169 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4170 0 \
4171 -s "cookie verification failed" \
4172 -s "cookie verification passed" \
4173 -S "cookie verification skipped" \
4174 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004175 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004176 -S "SSL - The requested feature is not available"
4177
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004178# Tests for client reconnecting from the same port with DTLS
4179
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004180not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004181run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004182 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4183 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004184 0 \
4185 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004186 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004187 -S "Client initiated reconnection from same port"
4188
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004189not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004190run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004191 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4192 "$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 +02004193 0 \
4194 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004195 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004196 -s "Client initiated reconnection from same port"
4197
Paul Bakker362689d2016-05-13 10:33:25 +01004198not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4199run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004200 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4201 "$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 +02004202 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004203 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004204 -s "Client initiated reconnection from same port"
4205
Paul Bakker362689d2016-05-13 10:33:25 +01004206only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4207run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4208 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4209 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4210 0 \
4211 -S "The operation timed out" \
4212 -s "Client initiated reconnection from same port"
4213
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004214run_test "DTLS client reconnect from same port: no cookies" \
4215 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004216 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4217 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004218 -s "The operation timed out" \
4219 -S "Client initiated reconnection from same port"
4220
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004221# Tests for various cases of client authentication with DTLS
4222# (focused on handshake flows and message parsing)
4223
4224run_test "DTLS client auth: required" \
4225 "$P_SRV dtls=1 auth_mode=required" \
4226 "$P_CLI dtls=1" \
4227 0 \
4228 -s "Verifying peer X.509 certificate... ok"
4229
4230run_test "DTLS client auth: optional, client has no cert" \
4231 "$P_SRV dtls=1 auth_mode=optional" \
4232 "$P_CLI dtls=1 crt_file=none key_file=none" \
4233 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004234 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004235
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004236run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004237 "$P_SRV dtls=1 auth_mode=none" \
4238 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
4239 0 \
4240 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004241 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004242
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02004243run_test "DTLS wrong PSK: badmac alert" \
4244 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
4245 "$P_CLI dtls=1 psk=abc124" \
4246 1 \
4247 -s "SSL - Verification of the message MAC failed" \
4248 -c "SSL - A fatal alert message was received from our peer"
4249
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02004250# Tests for receiving fragmented handshake messages with DTLS
4251
4252requires_gnutls
4253run_test "DTLS reassembly: no fragmentation (gnutls server)" \
4254 "$G_SRV -u --mtu 2048 -a" \
4255 "$P_CLI dtls=1 debug_level=2" \
4256 0 \
4257 -C "found fragmented DTLS handshake message" \
4258 -C "error"
4259
4260requires_gnutls
4261run_test "DTLS reassembly: some fragmentation (gnutls server)" \
4262 "$G_SRV -u --mtu 512" \
4263 "$P_CLI dtls=1 debug_level=2" \
4264 0 \
4265 -c "found fragmented DTLS handshake message" \
4266 -C "error"
4267
4268requires_gnutls
4269run_test "DTLS reassembly: more fragmentation (gnutls server)" \
4270 "$G_SRV -u --mtu 128" \
4271 "$P_CLI dtls=1 debug_level=2" \
4272 0 \
4273 -c "found fragmented DTLS handshake message" \
4274 -C "error"
4275
4276requires_gnutls
4277run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
4278 "$G_SRV -u --mtu 128" \
4279 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4280 0 \
4281 -c "found fragmented DTLS handshake message" \
4282 -C "error"
4283
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004284requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004285requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004286run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4287 "$G_SRV -u --mtu 256" \
4288 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4289 0 \
4290 -c "found fragmented DTLS handshake message" \
4291 -c "client hello, adding renegotiation extension" \
4292 -c "found renegotiation extension" \
4293 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004294 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004295 -C "error" \
4296 -s "Extra-header:"
4297
4298requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004299requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004300run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4301 "$G_SRV -u --mtu 256" \
4302 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4303 0 \
4304 -c "found fragmented DTLS handshake message" \
4305 -c "client hello, adding renegotiation extension" \
4306 -c "found renegotiation extension" \
4307 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004308 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004309 -C "error" \
4310 -s "Extra-header:"
4311
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004312run_test "DTLS reassembly: no fragmentation (openssl server)" \
4313 "$O_SRV -dtls1 -mtu 2048" \
4314 "$P_CLI dtls=1 debug_level=2" \
4315 0 \
4316 -C "found fragmented DTLS handshake message" \
4317 -C "error"
4318
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004319run_test "DTLS reassembly: some fragmentation (openssl server)" \
4320 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004321 "$P_CLI dtls=1 debug_level=2" \
4322 0 \
4323 -c "found fragmented DTLS handshake message" \
4324 -C "error"
4325
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004326run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004327 "$O_SRV -dtls1 -mtu 256" \
4328 "$P_CLI dtls=1 debug_level=2" \
4329 0 \
4330 -c "found fragmented DTLS handshake message" \
4331 -C "error"
4332
4333run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4334 "$O_SRV -dtls1 -mtu 256" \
4335 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4336 0 \
4337 -c "found fragmented DTLS handshake message" \
4338 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004339
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004340# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004341
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004342not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004343run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004344 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004345 "$P_SRV dtls=1 debug_level=2" \
4346 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004347 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004348 -C "replayed record" \
4349 -S "replayed record" \
4350 -C "record from another epoch" \
4351 -S "record from another epoch" \
4352 -C "discarding invalid record" \
4353 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004354 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004355 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004356 -c "HTTP/1.0 200 OK"
4357
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004358not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004359run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004360 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004361 "$P_SRV dtls=1 debug_level=2" \
4362 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004363 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004364 -c "replayed record" \
4365 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004366 -c "discarding invalid record" \
4367 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004368 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004369 -s "Extra-header:" \
4370 -c "HTTP/1.0 200 OK"
4371
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004372run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4373 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004374 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4375 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004376 0 \
4377 -c "replayed record" \
4378 -S "replayed record" \
4379 -c "discarding invalid record" \
4380 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004381 -c "resend" \
4382 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004383 -s "Extra-header:" \
4384 -c "HTTP/1.0 200 OK"
4385
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004386run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004387 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004388 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004389 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004390 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004391 -c "discarding invalid record (mac)" \
4392 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004393 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004394 -c "HTTP/1.0 200 OK" \
4395 -S "too many records with bad MAC" \
4396 -S "Verification of the message MAC failed"
4397
4398run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4399 -p "$P_PXY bad_ad=1" \
4400 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4401 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4402 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004403 -C "discarding invalid record (mac)" \
4404 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004405 -S "Extra-header:" \
4406 -C "HTTP/1.0 200 OK" \
4407 -s "too many records with bad MAC" \
4408 -s "Verification of the message MAC failed"
4409
4410run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4411 -p "$P_PXY bad_ad=1" \
4412 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4413 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4414 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004415 -c "discarding invalid record (mac)" \
4416 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004417 -s "Extra-header:" \
4418 -c "HTTP/1.0 200 OK" \
4419 -S "too many records with bad MAC" \
4420 -S "Verification of the message MAC failed"
4421
4422run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4423 -p "$P_PXY bad_ad=1" \
4424 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4425 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4426 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004427 -c "discarding invalid record (mac)" \
4428 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004429 -s "Extra-header:" \
4430 -c "HTTP/1.0 200 OK" \
4431 -s "too many records with bad MAC" \
4432 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004433
4434run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004435 -p "$P_PXY delay_ccs=1" \
4436 "$P_SRV dtls=1 debug_level=1" \
4437 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004438 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004439 -c "record from another epoch" \
4440 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004441 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004442 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004443 -s "Extra-header:" \
4444 -c "HTTP/1.0 200 OK"
4445
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004446# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004447
Janos Follath74537a62016-09-02 13:45:28 +01004448client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004449run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004450 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004451 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4452 psk=abc123" \
4453 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004454 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4455 0 \
4456 -s "Extra-header:" \
4457 -c "HTTP/1.0 200 OK"
4458
Janos Follath74537a62016-09-02 13:45:28 +01004459client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004460run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4461 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004462 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4463 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004464 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4465 0 \
4466 -s "Extra-header:" \
4467 -c "HTTP/1.0 200 OK"
4468
Janos Follath74537a62016-09-02 13:45:28 +01004469client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004470run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4471 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004472 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4473 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004474 0 \
4475 -s "Extra-header:" \
4476 -c "HTTP/1.0 200 OK"
4477
Janos Follath74537a62016-09-02 13:45:28 +01004478client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004479run_test "DTLS proxy: 3d, FS, client auth" \
4480 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004481 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4482 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004483 0 \
4484 -s "Extra-header:" \
4485 -c "HTTP/1.0 200 OK"
4486
Janos Follath74537a62016-09-02 13:45:28 +01004487client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004488run_test "DTLS proxy: 3d, FS, ticket" \
4489 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004490 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4491 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004492 0 \
4493 -s "Extra-header:" \
4494 -c "HTTP/1.0 200 OK"
4495
Janos Follath74537a62016-09-02 13:45:28 +01004496client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004497run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4498 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004499 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4500 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004501 0 \
4502 -s "Extra-header:" \
4503 -c "HTTP/1.0 200 OK"
4504
Janos Follath74537a62016-09-02 13:45:28 +01004505client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004506run_test "DTLS proxy: 3d, max handshake, nbio" \
4507 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004508 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4509 auth_mode=required" \
4510 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004511 0 \
4512 -s "Extra-header:" \
4513 -c "HTTP/1.0 200 OK"
4514
Janos Follath74537a62016-09-02 13:45:28 +01004515client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004516run_test "DTLS proxy: 3d, min handshake, resumption" \
4517 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4518 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4519 psk=abc123 debug_level=3" \
4520 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4521 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4522 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4523 0 \
4524 -s "a session has been resumed" \
4525 -c "a session has been resumed" \
4526 -s "Extra-header:" \
4527 -c "HTTP/1.0 200 OK"
4528
Janos Follath74537a62016-09-02 13:45:28 +01004529client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004530run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4531 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4532 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4533 psk=abc123 debug_level=3 nbio=2" \
4534 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4535 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4536 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4537 0 \
4538 -s "a session has been resumed" \
4539 -c "a session has been resumed" \
4540 -s "Extra-header:" \
4541 -c "HTTP/1.0 200 OK"
4542
Janos Follath74537a62016-09-02 13:45:28 +01004543client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004544requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004545run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004546 -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=none \
4548 psk=abc123 renegotiation=1 debug_level=2" \
4549 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4550 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004551 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4552 0 \
4553 -c "=> renegotiate" \
4554 -s "=> renegotiate" \
4555 -s "Extra-header:" \
4556 -c "HTTP/1.0 200 OK"
4557
Janos Follath74537a62016-09-02 13:45:28 +01004558client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004559requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004560run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4561 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004562 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4563 psk=abc123 renegotiation=1 debug_level=2" \
4564 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4565 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004566 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4567 0 \
4568 -c "=> renegotiate" \
4569 -s "=> renegotiate" \
4570 -s "Extra-header:" \
4571 -c "HTTP/1.0 200 OK"
4572
Janos Follath74537a62016-09-02 13:45:28 +01004573client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004574requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004575run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004576 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004577 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004578 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004579 debug_level=2" \
4580 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004581 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004582 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4583 0 \
4584 -c "=> renegotiate" \
4585 -s "=> renegotiate" \
4586 -s "Extra-header:" \
4587 -c "HTTP/1.0 200 OK"
4588
Janos Follath74537a62016-09-02 13:45:28 +01004589client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004590requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004591run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004592 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004593 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004594 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004595 debug_level=2 nbio=2" \
4596 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004597 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004598 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4599 0 \
4600 -c "=> renegotiate" \
4601 -s "=> renegotiate" \
4602 -s "Extra-header:" \
4603 -c "HTTP/1.0 200 OK"
4604
Janos Follath74537a62016-09-02 13:45:28 +01004605client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004606not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004607run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004608 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4609 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004610 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004611 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004612 -c "HTTP/1.0 200 OK"
4613
Janos Follath74537a62016-09-02 13:45:28 +01004614client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004615not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004616run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4617 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4618 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004619 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004620 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004621 -c "HTTP/1.0 200 OK"
4622
Janos Follath74537a62016-09-02 13:45:28 +01004623client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004624not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004625run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4626 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4627 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004628 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004629 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004630 -c "HTTP/1.0 200 OK"
4631
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004632requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004633client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004634not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004635run_test "DTLS proxy: 3d, gnutls server" \
4636 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4637 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004638 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004639 0 \
4640 -s "Extra-header:" \
4641 -c "Extra-header:"
4642
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004643requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004644client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004645not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004646run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4647 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4648 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004649 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004650 0 \
4651 -s "Extra-header:" \
4652 -c "Extra-header:"
4653
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004654requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004655client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004656not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004657run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4658 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4659 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004660 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004661 0 \
4662 -s "Extra-header:" \
4663 -c "Extra-header:"
4664
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004665# Final report
4666
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004667echo "------------------------------------------------------------------------"
4668
4669if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004670 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004671else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004672 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004673fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004674PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004675echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004676
4677exit $FAILS