blob: f1bcdee20d88adbdaec0c1cce9b192b4db9ac984 [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 Peskine3c9e2b52018-01-08 12:38:15 +0100311 echo "Warning: lsof not available, wait_server_start = sleep $START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100312 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200313 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100314 }
315fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200316
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100317# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100318# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100319# acceptable bounds
320check_server_hello_time() {
321 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100322 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100323 # Get the Unix timestamp for now
324 CUR_TIME=$(date +'%s')
325 THRESHOLD_IN_SECS=300
326
327 # Check if the ServerHello time was printed
328 if [ -z "$SERVER_HELLO_TIME" ]; then
329 return 1
330 fi
331
332 # Check the time in ServerHello is within acceptable bounds
333 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
334 # The time in ServerHello is at least 5 minutes before now
335 return 1
336 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100337 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100338 return 1
339 else
340 return 0
341 fi
342}
343
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200344# wait for client to terminate and set CLI_EXIT
345# must be called right after starting the client
346wait_client_done() {
347 CLI_PID=$!
348
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200349 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
350 CLI_DELAY_FACTOR=1
351
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200352 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200353 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200354
355 wait $CLI_PID
356 CLI_EXIT=$?
357
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200358 kill $DOG_PID >/dev/null 2>&1
359 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200360
361 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100362
363 sleep $SRV_DELAY_SECONDS
364 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200365}
366
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200367# check if the given command uses dtls and sets global variable DTLS
368detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200369 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200370 DTLS=1
371 else
372 DTLS=0
373 fi
374}
375
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200376# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100377# Options: -s pattern pattern that must be present in server output
378# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100379# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100380# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100381# -S pattern pattern that must be absent in server output
382# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100383# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100384# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100385run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100386 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200387 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100388
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100389 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
390 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200391 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100392 return
393 fi
394
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100396
Paul Bakkerb7584a52016-05-10 10:50:43 +0100397 # Do we only run numbered tests?
398 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
399 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
400 else
401 SKIP_NEXT="YES"
402 fi
403
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200404 # should we skip?
405 if [ "X$SKIP_NEXT" = "XYES" ]; then
406 SKIP_NEXT="NO"
407 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200408 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200409 return
410 fi
411
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200412 # does this test use a proxy?
413 if [ "X$1" = "X-p" ]; then
414 PXY_CMD="$2"
415 shift 2
416 else
417 PXY_CMD=""
418 fi
419
420 # get commands and client output
421 SRV_CMD="$1"
422 CLI_CMD="$2"
423 CLI_EXPECT="$3"
424 shift 3
425
426 # fix client port
427 if [ -n "$PXY_CMD" ]; then
428 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
429 else
430 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
431 fi
432
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200433 # update DTLS variable
434 detect_dtls "$SRV_CMD"
435
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100436 # prepend valgrind to our commands if active
437 if [ "$MEMCHECK" -gt 0 ]; then
438 if is_polar "$SRV_CMD"; then
439 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
440 fi
441 if is_polar "$CLI_CMD"; then
442 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
443 fi
444 fi
445
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200446 TIMES_LEFT=2
447 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200448 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200449
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200450 # run the commands
451 if [ -n "$PXY_CMD" ]; then
452 echo "$PXY_CMD" > $PXY_OUT
453 $PXY_CMD >> $PXY_OUT 2>&1 &
454 PXY_PID=$!
455 # assume proxy starts faster than server
456 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200457
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200458 check_osrv_dtls
459 echo "$SRV_CMD" > $SRV_OUT
460 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
461 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100462 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200463
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200464 echo "$CLI_CMD" > $CLI_OUT
465 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
466 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100467
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
Gilles Peskined50177f2017-05-16 17:53:03 +02001154## ClientHello generated with
1155## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1156## then manually twiddling the ciphersuite list.
1157## The ClientHello content is spelled out below as a hex string as
1158## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1159## The expected response is an inappropriate_fallback alert.
1160requires_openssl_with_fallback_scsv
1161run_test "Fallback SCSV: beginning of list" \
1162 "$P_SRV debug_level=2" \
1163 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1164 0 \
1165 -s "received FALLBACK_SCSV" \
1166 -s "inapropriate fallback"
1167
1168requires_openssl_with_fallback_scsv
1169run_test "Fallback SCSV: end of list" \
1170 "$P_SRV debug_level=2" \
1171 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1172 0 \
1173 -s "received FALLBACK_SCSV" \
1174 -s "inapropriate fallback"
1175
1176## Here the expected response is a valid ServerHello prefix, up to the random.
1177requires_openssl_with_fallback_scsv
1178run_test "Fallback SCSV: not in list" \
1179 "$P_SRV debug_level=2" \
1180 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1181 0 \
1182 -S "received FALLBACK_SCSV" \
1183 -S "inapropriate fallback"
1184
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001185# Tests for CBC 1/n-1 record splitting
1186
1187run_test "CBC Record splitting: TLS 1.2, no splitting" \
1188 "$P_SRV" \
1189 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1190 request_size=123 force_version=tls1_2" \
1191 0 \
1192 -s "Read from client: 123 bytes read" \
1193 -S "Read from client: 1 bytes read" \
1194 -S "122 bytes read"
1195
1196run_test "CBC Record splitting: TLS 1.1, no splitting" \
1197 "$P_SRV" \
1198 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1199 request_size=123 force_version=tls1_1" \
1200 0 \
1201 -s "Read from client: 123 bytes read" \
1202 -S "Read from client: 1 bytes read" \
1203 -S "122 bytes read"
1204
1205run_test "CBC Record splitting: TLS 1.0, splitting" \
1206 "$P_SRV" \
1207 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1208 request_size=123 force_version=tls1" \
1209 0 \
1210 -S "Read from client: 123 bytes read" \
1211 -s "Read from client: 1 bytes read" \
1212 -s "122 bytes read"
1213
Janos Follathe2681a42016-03-07 15:57:05 +00001214requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001215run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001216 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001217 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1218 request_size=123 force_version=ssl3" \
1219 0 \
1220 -S "Read from client: 123 bytes read" \
1221 -s "Read from client: 1 bytes read" \
1222 -s "122 bytes read"
1223
1224run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001225 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001226 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1227 request_size=123 force_version=tls1" \
1228 0 \
1229 -s "Read from client: 123 bytes read" \
1230 -S "Read from client: 1 bytes read" \
1231 -S "122 bytes read"
1232
1233run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1234 "$P_SRV" \
1235 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1236 request_size=123 force_version=tls1 recsplit=0" \
1237 0 \
1238 -s "Read from client: 123 bytes read" \
1239 -S "Read from client: 1 bytes read" \
1240 -S "122 bytes read"
1241
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001242run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1243 "$P_SRV nbio=2" \
1244 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1245 request_size=123 force_version=tls1" \
1246 0 \
1247 -S "Read from client: 123 bytes read" \
1248 -s "Read from client: 1 bytes read" \
1249 -s "122 bytes read"
1250
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001251# Tests for Session Tickets
1252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001253run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001254 "$P_SRV debug_level=3 tickets=1" \
1255 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001256 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001257 -c "client hello, adding session ticket extension" \
1258 -s "found session ticket extension" \
1259 -s "server hello, adding session ticket extension" \
1260 -c "found session_ticket extension" \
1261 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001262 -S "session successfully restored from cache" \
1263 -s "session successfully restored from ticket" \
1264 -s "a session has been resumed" \
1265 -c "a session has been resumed"
1266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001267run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001268 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1269 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001270 0 \
1271 -c "client hello, adding session ticket extension" \
1272 -s "found session ticket extension" \
1273 -s "server hello, adding session ticket extension" \
1274 -c "found session_ticket extension" \
1275 -c "parse new session ticket" \
1276 -S "session successfully restored from cache" \
1277 -s "session successfully restored from ticket" \
1278 -s "a session has been resumed" \
1279 -c "a session has been resumed"
1280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001281run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001282 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1283 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001284 0 \
1285 -c "client hello, adding session ticket extension" \
1286 -s "found session ticket extension" \
1287 -s "server hello, adding session ticket extension" \
1288 -c "found session_ticket extension" \
1289 -c "parse new session ticket" \
1290 -S "session successfully restored from cache" \
1291 -S "session successfully restored from ticket" \
1292 -S "a session has been resumed" \
1293 -C "a session has been resumed"
1294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001295run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001296 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001297 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001298 0 \
1299 -c "client hello, adding session ticket extension" \
1300 -c "found session_ticket extension" \
1301 -c "parse new session ticket" \
1302 -c "a session has been resumed"
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001305 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001306 "( $O_CLI -sess_out $SESSION; \
1307 $O_CLI -sess_in $SESSION; \
1308 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001309 0 \
1310 -s "found session ticket extension" \
1311 -s "server hello, adding session ticket extension" \
1312 -S "session successfully restored from cache" \
1313 -s "session successfully restored from ticket" \
1314 -s "a session has been resumed"
1315
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001316# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001318run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001319 "$P_SRV debug_level=3 tickets=0" \
1320 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001321 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001322 -c "client hello, adding session ticket extension" \
1323 -s "found session ticket extension" \
1324 -S "server hello, adding session ticket extension" \
1325 -C "found session_ticket extension" \
1326 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001327 -s "session successfully restored from cache" \
1328 -S "session successfully restored from ticket" \
1329 -s "a session has been resumed" \
1330 -c "a session has been resumed"
1331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001332run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_SRV debug_level=3 tickets=1" \
1334 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001335 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001336 -C "client hello, adding session ticket extension" \
1337 -S "found session ticket extension" \
1338 -S "server hello, adding session ticket extension" \
1339 -C "found session_ticket extension" \
1340 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001341 -s "session successfully restored from cache" \
1342 -S "session successfully restored from ticket" \
1343 -s "a session has been resumed" \
1344 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1348 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001349 0 \
1350 -S "session successfully restored from cache" \
1351 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001352 -S "a session has been resumed" \
1353 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001355run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001356 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1357 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001358 0 \
1359 -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é-Gonnard6df31962015-05-04 10:55:47 +02001364run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001365 "$P_SRV debug_level=3 tickets=0" \
1366 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001367 0 \
1368 -s "session successfully restored from cache" \
1369 -S "session successfully restored from ticket" \
1370 -s "a session has been resumed" \
1371 -c "a session has been resumed"
1372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001373run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001374 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1375 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001376 0 \
1377 -S "session successfully restored from cache" \
1378 -S "session successfully restored from ticket" \
1379 -S "a session has been resumed" \
1380 -C "a session has been resumed"
1381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001382run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001383 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1384 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001385 0 \
1386 -s "session successfully restored from cache" \
1387 -S "session successfully restored from ticket" \
1388 -s "a session has been resumed" \
1389 -c "a session has been resumed"
1390
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001391run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001392 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001393 "( $O_CLI -sess_out $SESSION; \
1394 $O_CLI -sess_in $SESSION; \
1395 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001396 0 \
1397 -s "found session ticket extension" \
1398 -S "server hello, adding session ticket extension" \
1399 -s "session successfully restored from cache" \
1400 -S "session successfully restored from ticket" \
1401 -s "a session has been resumed"
1402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001403run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001404 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001405 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001406 0 \
1407 -C "found session_ticket extension" \
1408 -C "parse new session ticket" \
1409 -c "a session has been resumed"
1410
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001411# Tests for Max Fragment Length extension
1412
Hanno Becker6428f8d2017-09-22 16:58:50 +01001413MAX_CONTENT_LEN_EXPECT='16384'
1414MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1415
1416if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1417 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1418 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1419 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1420 printf "\n"
1421 printf "The tests assume this value and if it changes, the tests in this\n"
1422 printf "script should also be adjusted.\n"
1423 printf "\n"
1424
1425 exit 1
1426fi
1427
Hanno Becker4aed27e2017-09-18 15:00:34 +01001428requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001429run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001430 "$P_SRV debug_level=3" \
1431 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001432 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001433 -c "Maximum fragment length is 16384" \
1434 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001435 -C "client hello, adding max_fragment_length extension" \
1436 -S "found max fragment length extension" \
1437 -S "server hello, max_fragment_length extension" \
1438 -C "found max_fragment_length extension"
1439
Hanno Becker4aed27e2017-09-18 15:00:34 +01001440requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001441run_test "Max fragment length: enabled, default, larger message" \
1442 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001443 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001444 0 \
1445 -c "Maximum fragment length is 16384" \
1446 -s "Maximum fragment length is 16384" \
1447 -C "client hello, adding max_fragment_length extension" \
1448 -S "found max fragment length extension" \
1449 -S "server hello, max_fragment_length extension" \
1450 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001451 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001452 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001453 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001454
1455requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1456run_test "Max fragment length, DTLS: enabled, default, larger message" \
1457 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001458 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001459 1 \
1460 -c "Maximum fragment length is 16384" \
1461 -s "Maximum fragment length is 16384" \
1462 -C "client hello, adding max_fragment_length extension" \
1463 -S "found max fragment length extension" \
1464 -S "server hello, max_fragment_length extension" \
1465 -C "found max_fragment_length extension" \
1466 -c "fragment larger than.*maximum "
1467
1468requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1469run_test "Max fragment length: disabled, larger message" \
1470 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001471 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001472 0 \
1473 -C "Maximum fragment length is 16384" \
1474 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001475 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001476 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001477 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001478
1479requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1480run_test "Max fragment length DTLS: disabled, larger message" \
1481 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001482 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001483 1 \
1484 -C "Maximum fragment length is 16384" \
1485 -S "Maximum fragment length is 16384" \
1486 -c "fragment larger than.*maximum "
1487
1488requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001489run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001490 "$P_SRV debug_level=3" \
1491 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001492 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001493 -c "Maximum fragment length is 4096" \
1494 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001495 -c "client hello, adding max_fragment_length extension" \
1496 -s "found max fragment length extension" \
1497 -s "server hello, max_fragment_length extension" \
1498 -c "found max_fragment_length extension"
1499
Hanno Becker4aed27e2017-09-18 15:00:34 +01001500requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001501run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001502 "$P_SRV debug_level=3 max_frag_len=4096" \
1503 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001504 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001505 -c "Maximum fragment length is 16384" \
1506 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001507 -C "client hello, adding max_fragment_length extension" \
1508 -S "found max fragment length extension" \
1509 -S "server hello, max_fragment_length extension" \
1510 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001511
Hanno Becker4aed27e2017-09-18 15:00:34 +01001512requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001513requires_gnutls
1514run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001515 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001516 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001517 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001518 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001519 -c "client hello, adding max_fragment_length extension" \
1520 -c "found max_fragment_length extension"
1521
Hanno Becker4aed27e2017-09-18 15:00:34 +01001522requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001523run_test "Max fragment length: client, message just fits" \
1524 "$P_SRV debug_level=3" \
1525 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1526 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001527 -c "Maximum fragment length is 2048" \
1528 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001529 -c "client hello, adding max_fragment_length extension" \
1530 -s "found max fragment length extension" \
1531 -s "server hello, max_fragment_length extension" \
1532 -c "found max_fragment_length extension" \
1533 -c "2048 bytes written in 1 fragments" \
1534 -s "2048 bytes read"
1535
Hanno Becker4aed27e2017-09-18 15:00:34 +01001536requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001537run_test "Max fragment length: client, larger message" \
1538 "$P_SRV debug_level=3" \
1539 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1540 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001541 -c "Maximum fragment length is 2048" \
1542 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001543 -c "client hello, adding max_fragment_length extension" \
1544 -s "found max fragment length extension" \
1545 -s "server hello, max_fragment_length extension" \
1546 -c "found max_fragment_length extension" \
1547 -c "2345 bytes written in 2 fragments" \
1548 -s "2048 bytes read" \
1549 -s "297 bytes read"
1550
Hanno Becker4aed27e2017-09-18 15:00:34 +01001551requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001552run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001553 "$P_SRV debug_level=3 dtls=1" \
1554 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1555 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001556 -c "Maximum fragment length is 2048" \
1557 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001558 -c "client hello, adding max_fragment_length extension" \
1559 -s "found max fragment length extension" \
1560 -s "server hello, max_fragment_length extension" \
1561 -c "found max_fragment_length extension" \
1562 -c "fragment larger than.*maximum"
1563
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001564# Tests for renegotiation
1565
Hanno Becker6a243642017-10-12 15:18:45 +01001566# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001567run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001568 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001569 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001570 0 \
1571 -C "client hello, adding renegotiation extension" \
1572 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1573 -S "found renegotiation extension" \
1574 -s "server hello, secure renegotiation extension" \
1575 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001576 -C "=> renegotiate" \
1577 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001578 -S "write hello request"
1579
Hanno Becker6a243642017-10-12 15:18:45 +01001580requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001581run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001582 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001583 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001584 0 \
1585 -c "client hello, adding renegotiation extension" \
1586 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1587 -s "found renegotiation extension" \
1588 -s "server hello, secure renegotiation extension" \
1589 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001590 -c "=> renegotiate" \
1591 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001592 -S "write hello request"
1593
Hanno Becker6a243642017-10-12 15:18:45 +01001594requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001595run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001596 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001597 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001598 0 \
1599 -c "client hello, adding renegotiation extension" \
1600 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1601 -s "found renegotiation extension" \
1602 -s "server hello, secure renegotiation extension" \
1603 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001604 -c "=> renegotiate" \
1605 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001606 -s "write hello request"
1607
Janos Follathb0f148c2017-10-05 12:29:42 +01001608# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1609# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1610# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001611requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001612run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1613 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1614 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1615 0 \
1616 -c "client hello, adding renegotiation extension" \
1617 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1618 -s "found renegotiation extension" \
1619 -s "server hello, secure renegotiation extension" \
1620 -c "found renegotiation extension" \
1621 -c "=> renegotiate" \
1622 -s "=> renegotiate" \
1623 -S "write hello request" \
1624 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1625
1626# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1627# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1628# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001629requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001630run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1631 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1632 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1633 0 \
1634 -c "client hello, adding renegotiation extension" \
1635 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1636 -s "found renegotiation extension" \
1637 -s "server hello, secure renegotiation extension" \
1638 -c "found renegotiation extension" \
1639 -c "=> renegotiate" \
1640 -s "=> renegotiate" \
1641 -s "write hello request" \
1642 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1643
Hanno Becker6a243642017-10-12 15:18:45 +01001644requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001645run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001646 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001647 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001648 0 \
1649 -c "client hello, adding renegotiation extension" \
1650 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1651 -s "found renegotiation extension" \
1652 -s "server hello, secure renegotiation extension" \
1653 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001654 -c "=> renegotiate" \
1655 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001656 -s "write hello request"
1657
Hanno Becker6a243642017-10-12 15:18:45 +01001658requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001659run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001660 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001661 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001662 1 \
1663 -c "client hello, adding renegotiation extension" \
1664 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1665 -S "found renegotiation extension" \
1666 -s "server hello, secure renegotiation extension" \
1667 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001668 -c "=> renegotiate" \
1669 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001670 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001671 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001672 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001673
Hanno Becker6a243642017-10-12 15:18:45 +01001674requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001675run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001676 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001677 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001678 0 \
1679 -C "client hello, adding renegotiation extension" \
1680 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1681 -S "found renegotiation extension" \
1682 -s "server hello, secure renegotiation extension" \
1683 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001684 -C "=> renegotiate" \
1685 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001686 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001687 -S "SSL - An unexpected message was received from our peer" \
1688 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001689
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: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001692 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001693 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001694 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001695 0 \
1696 -C "client hello, adding renegotiation extension" \
1697 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1698 -S "found renegotiation extension" \
1699 -s "server hello, secure renegotiation extension" \
1700 -c "found renegotiation extension" \
1701 -C "=> renegotiate" \
1702 -S "=> renegotiate" \
1703 -s "write hello request" \
1704 -S "SSL - An unexpected message was received from our peer" \
1705 -S "failed"
1706
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001707# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001708requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001709run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001710 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001711 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001712 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001713 0 \
1714 -C "client hello, adding renegotiation extension" \
1715 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1716 -S "found renegotiation extension" \
1717 -s "server hello, secure renegotiation extension" \
1718 -c "found renegotiation extension" \
1719 -C "=> renegotiate" \
1720 -S "=> renegotiate" \
1721 -s "write hello request" \
1722 -S "SSL - An unexpected message was received from our peer" \
1723 -S "failed"
1724
Hanno Becker6a243642017-10-12 15:18:45 +01001725requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001727 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001728 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001729 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001730 0 \
1731 -C "client hello, adding renegotiation extension" \
1732 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1733 -S "found renegotiation extension" \
1734 -s "server hello, secure renegotiation extension" \
1735 -c "found renegotiation extension" \
1736 -C "=> renegotiate" \
1737 -S "=> renegotiate" \
1738 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001739 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001740
Hanno Becker6a243642017-10-12 15:18:45 +01001741requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001742run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001743 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001744 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001745 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001746 0 \
1747 -c "client hello, adding renegotiation extension" \
1748 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1749 -s "found renegotiation extension" \
1750 -s "server hello, secure renegotiation extension" \
1751 -c "found renegotiation extension" \
1752 -c "=> renegotiate" \
1753 -s "=> renegotiate" \
1754 -s "write hello request" \
1755 -S "SSL - An unexpected message was received from our peer" \
1756 -S "failed"
1757
Hanno Becker6a243642017-10-12 15:18:45 +01001758requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001759run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001760 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001761 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1762 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 -S "record counter limit reached: renegotiate" \
1769 -C "=> renegotiate" \
1770 -S "=> renegotiate" \
1771 -S "write hello request" \
1772 -S "SSL - An unexpected message was received from our peer" \
1773 -S "failed"
1774
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001775# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001776requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001777run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001778 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001779 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001780 0 \
1781 -c "client hello, adding renegotiation extension" \
1782 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1783 -s "found renegotiation extension" \
1784 -s "server hello, secure renegotiation extension" \
1785 -c "found renegotiation extension" \
1786 -s "record counter limit reached: renegotiate" \
1787 -c "=> renegotiate" \
1788 -s "=> renegotiate" \
1789 -s "write hello request" \
1790 -S "SSL - An unexpected message was received from our peer" \
1791 -S "failed"
1792
Hanno Becker6a243642017-10-12 15:18:45 +01001793requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001794run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001795 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001796 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001797 0 \
1798 -c "client hello, adding renegotiation extension" \
1799 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1800 -s "found renegotiation extension" \
1801 -s "server hello, secure renegotiation extension" \
1802 -c "found renegotiation extension" \
1803 -s "record counter limit reached: renegotiate" \
1804 -c "=> renegotiate" \
1805 -s "=> renegotiate" \
1806 -s "write hello request" \
1807 -S "SSL - An unexpected message was received from our peer" \
1808 -S "failed"
1809
Hanno Becker6a243642017-10-12 15:18:45 +01001810requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001811run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001812 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001813 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1814 0 \
1815 -C "client hello, adding renegotiation extension" \
1816 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1817 -S "found renegotiation extension" \
1818 -s "server hello, secure renegotiation extension" \
1819 -c "found renegotiation extension" \
1820 -S "record counter limit reached: renegotiate" \
1821 -C "=> renegotiate" \
1822 -S "=> renegotiate" \
1823 -S "write hello request" \
1824 -S "SSL - An unexpected message was received from our peer" \
1825 -S "failed"
1826
Hanno Becker6a243642017-10-12 15:18:45 +01001827requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001828run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001829 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001830 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001831 0 \
1832 -c "client hello, adding renegotiation extension" \
1833 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1834 -s "found renegotiation extension" \
1835 -s "server hello, secure renegotiation extension" \
1836 -c "found renegotiation extension" \
1837 -c "=> renegotiate" \
1838 -s "=> renegotiate" \
1839 -S "write hello request"
1840
Hanno Becker6a243642017-10-12 15:18:45 +01001841requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001842run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001843 "$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 +02001844 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001845 0 \
1846 -c "client hello, adding renegotiation extension" \
1847 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1848 -s "found renegotiation extension" \
1849 -s "server hello, secure renegotiation extension" \
1850 -c "found renegotiation extension" \
1851 -c "=> renegotiate" \
1852 -s "=> renegotiate" \
1853 -s "write hello request"
1854
Hanno Becker6a243642017-10-12 15:18:45 +01001855requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001856run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001857 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001859 0 \
1860 -c "client hello, adding renegotiation extension" \
1861 -c "found renegotiation extension" \
1862 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001863 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001864 -C "error" \
1865 -c "HTTP/1.0 200 [Oo][Kk]"
1866
Paul Bakker539d9722015-02-08 16:18:35 +01001867requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001868requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001869run_test "Renegotiation: gnutls server strict, client-initiated" \
1870 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001871 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001872 0 \
1873 -c "client hello, adding renegotiation extension" \
1874 -c "found renegotiation extension" \
1875 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001876 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001877 -C "error" \
1878 -c "HTTP/1.0 200 [Oo][Kk]"
1879
Paul Bakker539d9722015-02-08 16:18:35 +01001880requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001881requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001882run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1883 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1884 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1885 1 \
1886 -c "client hello, adding renegotiation extension" \
1887 -C "found renegotiation extension" \
1888 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001889 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001890 -c "error" \
1891 -C "HTTP/1.0 200 [Oo][Kk]"
1892
Paul Bakker539d9722015-02-08 16:18:35 +01001893requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001894requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001895run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1896 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1897 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1898 allow_legacy=0" \
1899 1 \
1900 -c "client hello, adding renegotiation extension" \
1901 -C "found renegotiation extension" \
1902 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001903 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001904 -c "error" \
1905 -C "HTTP/1.0 200 [Oo][Kk]"
1906
Paul Bakker539d9722015-02-08 16:18:35 +01001907requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001908requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001909run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1910 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1911 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1912 allow_legacy=1" \
1913 0 \
1914 -c "client hello, adding renegotiation extension" \
1915 -C "found renegotiation extension" \
1916 -c "=> renegotiate" \
1917 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001918 -C "error" \
1919 -c "HTTP/1.0 200 [Oo][Kk]"
1920
Hanno Becker6a243642017-10-12 15:18:45 +01001921requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001922run_test "Renegotiation: DTLS, client-initiated" \
1923 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1924 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1925 0 \
1926 -c "client hello, adding renegotiation extension" \
1927 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1928 -s "found renegotiation extension" \
1929 -s "server hello, secure renegotiation extension" \
1930 -c "found renegotiation extension" \
1931 -c "=> renegotiate" \
1932 -s "=> renegotiate" \
1933 -S "write hello request"
1934
Hanno Becker6a243642017-10-12 15:18:45 +01001935requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001936run_test "Renegotiation: DTLS, server-initiated" \
1937 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001938 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1939 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001940 0 \
1941 -c "client hello, adding renegotiation extension" \
1942 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1943 -s "found renegotiation extension" \
1944 -s "server hello, secure renegotiation extension" \
1945 -c "found renegotiation extension" \
1946 -c "=> renegotiate" \
1947 -s "=> renegotiate" \
1948 -s "write hello request"
1949
Hanno Becker6a243642017-10-12 15:18:45 +01001950requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00001951run_test "Renegotiation: DTLS, renego_period overflow" \
1952 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1953 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1954 0 \
1955 -c "client hello, adding renegotiation extension" \
1956 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1957 -s "found renegotiation extension" \
1958 -s "server hello, secure renegotiation extension" \
1959 -s "record counter limit reached: renegotiate" \
1960 -c "=> renegotiate" \
1961 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01001962 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00001963
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001964requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001965requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001966run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1967 "$G_SRV -u --mtu 4096" \
1968 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1969 0 \
1970 -c "client hello, adding renegotiation extension" \
1971 -c "found renegotiation extension" \
1972 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001973 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001974 -C "error" \
1975 -s "Extra-header:"
1976
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001977# Test for the "secure renegotation" extension only (no actual renegotiation)
1978
Paul Bakker539d9722015-02-08 16:18:35 +01001979requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001980run_test "Renego ext: gnutls server strict, client default" \
1981 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1982 "$P_CLI debug_level=3" \
1983 0 \
1984 -c "found renegotiation extension" \
1985 -C "error" \
1986 -c "HTTP/1.0 200 [Oo][Kk]"
1987
Paul Bakker539d9722015-02-08 16:18:35 +01001988requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001989run_test "Renego ext: gnutls server unsafe, client default" \
1990 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1991 "$P_CLI debug_level=3" \
1992 0 \
1993 -C "found renegotiation extension" \
1994 -C "error" \
1995 -c "HTTP/1.0 200 [Oo][Kk]"
1996
Paul Bakker539d9722015-02-08 16:18:35 +01001997requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001998run_test "Renego ext: gnutls server unsafe, client break legacy" \
1999 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2000 "$P_CLI debug_level=3 allow_legacy=-1" \
2001 1 \
2002 -C "found renegotiation extension" \
2003 -c "error" \
2004 -C "HTTP/1.0 200 [Oo][Kk]"
2005
Paul Bakker539d9722015-02-08 16:18:35 +01002006requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002007run_test "Renego ext: gnutls client strict, server default" \
2008 "$P_SRV debug_level=3" \
2009 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2010 0 \
2011 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2012 -s "server hello, secure renegotiation extension"
2013
Paul Bakker539d9722015-02-08 16:18:35 +01002014requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002015run_test "Renego ext: gnutls client unsafe, server default" \
2016 "$P_SRV debug_level=3" \
2017 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2018 0 \
2019 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2020 -S "server hello, secure renegotiation extension"
2021
Paul Bakker539d9722015-02-08 16:18:35 +01002022requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002023run_test "Renego ext: gnutls client unsafe, server break legacy" \
2024 "$P_SRV debug_level=3 allow_legacy=-1" \
2025 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2026 1 \
2027 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2028 -S "server hello, secure renegotiation extension"
2029
Janos Follath0b242342016-02-17 10:11:21 +00002030# Tests for silently dropping trailing extra bytes in .der certificates
2031
2032requires_gnutls
2033run_test "DER format: no trailing bytes" \
2034 "$P_SRV crt_file=data_files/server5-der0.crt \
2035 key_file=data_files/server5.key" \
2036 "$G_CLI " \
2037 0 \
2038 -c "Handshake was completed" \
2039
2040requires_gnutls
2041run_test "DER format: with a trailing zero byte" \
2042 "$P_SRV crt_file=data_files/server5-der1a.crt \
2043 key_file=data_files/server5.key" \
2044 "$G_CLI " \
2045 0 \
2046 -c "Handshake was completed" \
2047
2048requires_gnutls
2049run_test "DER format: with a trailing random byte" \
2050 "$P_SRV crt_file=data_files/server5-der1b.crt \
2051 key_file=data_files/server5.key" \
2052 "$G_CLI " \
2053 0 \
2054 -c "Handshake was completed" \
2055
2056requires_gnutls
2057run_test "DER format: with 2 trailing random bytes" \
2058 "$P_SRV crt_file=data_files/server5-der2.crt \
2059 key_file=data_files/server5.key" \
2060 "$G_CLI " \
2061 0 \
2062 -c "Handshake was completed" \
2063
2064requires_gnutls
2065run_test "DER format: with 4 trailing random bytes" \
2066 "$P_SRV crt_file=data_files/server5-der4.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 8 trailing random bytes" \
2074 "$P_SRV crt_file=data_files/server5-der8.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 9 trailing random bytes" \
2082 "$P_SRV crt_file=data_files/server5-der9.crt \
2083 key_file=data_files/server5.key" \
2084 "$G_CLI " \
2085 0 \
2086 -c "Handshake was completed" \
2087
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002088# Tests for auth_mode
2089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002090run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002091 "$P_SRV crt_file=data_files/server5-badsign.crt \
2092 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002093 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002094 1 \
2095 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002096 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002097 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002098 -c "X509 - Certificate verification failed"
2099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002100run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002101 "$P_SRV crt_file=data_files/server5-badsign.crt \
2102 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002103 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002104 0 \
2105 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002106 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002107 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002108 -C "X509 - Certificate verification failed"
2109
Hanno Beckere6706e62017-05-15 16:05:15 +01002110run_test "Authentication: server goodcert, client optional, no trusted CA" \
2111 "$P_SRV" \
2112 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2113 0 \
2114 -c "x509_verify_cert() returned" \
2115 -c "! The certificate is not correctly signed by the trusted CA" \
2116 -c "! Certificate verification flags"\
2117 -C "! mbedtls_ssl_handshake returned" \
2118 -C "X509 - Certificate verification failed" \
2119 -C "SSL - No CA Chain is set, but required to operate"
2120
2121run_test "Authentication: server goodcert, client required, no trusted CA" \
2122 "$P_SRV" \
2123 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2124 1 \
2125 -c "x509_verify_cert() returned" \
2126 -c "! The certificate is not correctly signed by the trusted CA" \
2127 -c "! Certificate verification flags"\
2128 -c "! mbedtls_ssl_handshake returned" \
2129 -c "SSL - No CA Chain is set, but required to operate"
2130
2131# The purpose of the next two tests is to test the client's behaviour when receiving a server
2132# certificate with an unsupported elliptic curve. This should usually not happen because
2133# the client informs the server about the supported curves - it does, though, in the
2134# corner case of a static ECDH suite, because the server doesn't check the curve on that
2135# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2136# different means to have the server ignoring the client's supported curve list.
2137
2138requires_config_enabled MBEDTLS_ECP_C
2139run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2140 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2141 crt_file=data_files/server5.ku-ka.crt" \
2142 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2143 1 \
2144 -c "bad certificate (EC key curve)"\
2145 -c "! Certificate verification flags"\
2146 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2147
2148requires_config_enabled MBEDTLS_ECP_C
2149run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2150 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2151 crt_file=data_files/server5.ku-ka.crt" \
2152 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2153 1 \
2154 -c "bad certificate (EC key curve)"\
2155 -c "! Certificate verification flags"\
2156 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002158run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002159 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002160 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002161 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002162 0 \
2163 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002164 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002165 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002166 -C "X509 - Certificate verification failed"
2167
Simon Butcher99000142016-10-13 17:21:01 +01002168run_test "Authentication: client SHA256, server required" \
2169 "$P_SRV auth_mode=required" \
2170 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2171 key_file=data_files/server6.key \
2172 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2173 0 \
2174 -c "Supported Signature Algorithm found: 4," \
2175 -c "Supported Signature Algorithm found: 5,"
2176
2177run_test "Authentication: client SHA384, server required" \
2178 "$P_SRV auth_mode=required" \
2179 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2180 key_file=data_files/server6.key \
2181 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2182 0 \
2183 -c "Supported Signature Algorithm found: 4," \
2184 -c "Supported Signature Algorithm found: 5,"
2185
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002186requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2187run_test "Authentication: client has no cert, server required (SSLv3)" \
2188 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2189 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2190 key_file=data_files/server5.key" \
2191 1 \
2192 -S "skip write certificate request" \
2193 -C "skip parse certificate request" \
2194 -c "got a certificate request" \
2195 -c "got no certificate to send" \
2196 -S "x509_verify_cert() returned" \
2197 -s "client has no certificate" \
2198 -s "! mbedtls_ssl_handshake returned" \
2199 -c "! mbedtls_ssl_handshake returned" \
2200 -s "No client certification received from the client, but required by the authentication mode"
2201
2202run_test "Authentication: client has no cert, server required (TLS)" \
2203 "$P_SRV debug_level=3 auth_mode=required" \
2204 "$P_CLI debug_level=3 crt_file=none \
2205 key_file=data_files/server5.key" \
2206 1 \
2207 -S "skip write certificate request" \
2208 -C "skip parse certificate request" \
2209 -c "got a certificate request" \
2210 -c "= write certificate$" \
2211 -C "skip write certificate$" \
2212 -S "x509_verify_cert() returned" \
2213 -s "client has no certificate" \
2214 -s "! mbedtls_ssl_handshake returned" \
2215 -c "! mbedtls_ssl_handshake returned" \
2216 -s "No client certification received from the client, but required by the authentication mode"
2217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002218run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002219 "$P_SRV debug_level=3 auth_mode=required" \
2220 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002221 key_file=data_files/server5.key" \
2222 1 \
2223 -S "skip write certificate request" \
2224 -C "skip parse certificate request" \
2225 -c "got a certificate request" \
2226 -C "skip write certificate" \
2227 -C "skip write certificate verify" \
2228 -S "skip parse certificate verify" \
2229 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002230 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002231 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002232 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002233 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002234 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002235# We don't check that the client receives the alert because it might
2236# detect that its write end of the connection is closed and abort
2237# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002238
Janos Follath89baba22017-04-10 14:34:35 +01002239run_test "Authentication: client cert not trusted, server required" \
2240 "$P_SRV debug_level=3 auth_mode=required" \
2241 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2242 key_file=data_files/server5.key" \
2243 1 \
2244 -S "skip write certificate request" \
2245 -C "skip parse certificate request" \
2246 -c "got a certificate request" \
2247 -C "skip write certificate" \
2248 -C "skip write certificate verify" \
2249 -S "skip parse certificate verify" \
2250 -s "x509_verify_cert() returned" \
2251 -s "! The certificate is not correctly signed by the trusted CA" \
2252 -s "! mbedtls_ssl_handshake returned" \
2253 -c "! mbedtls_ssl_handshake returned" \
2254 -s "X509 - Certificate verification failed"
2255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002256run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002257 "$P_SRV debug_level=3 auth_mode=optional" \
2258 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002259 key_file=data_files/server5.key" \
2260 0 \
2261 -S "skip write certificate request" \
2262 -C "skip parse certificate request" \
2263 -c "got a certificate request" \
2264 -C "skip write certificate" \
2265 -C "skip write certificate verify" \
2266 -S "skip parse certificate verify" \
2267 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002268 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002269 -S "! mbedtls_ssl_handshake returned" \
2270 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002271 -S "X509 - Certificate verification failed"
2272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002273run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002274 "$P_SRV debug_level=3 auth_mode=none" \
2275 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002276 key_file=data_files/server5.key" \
2277 0 \
2278 -s "skip write certificate request" \
2279 -C "skip parse certificate request" \
2280 -c "got no certificate request" \
2281 -c "skip write certificate" \
2282 -c "skip write certificate verify" \
2283 -s "skip parse certificate verify" \
2284 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002285 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002286 -S "! mbedtls_ssl_handshake returned" \
2287 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002288 -S "X509 - Certificate verification failed"
2289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002290run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002291 "$P_SRV debug_level=3 auth_mode=optional" \
2292 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002293 0 \
2294 -S "skip write certificate request" \
2295 -C "skip parse certificate request" \
2296 -c "got a certificate request" \
2297 -C "skip write certificate$" \
2298 -C "got no certificate to send" \
2299 -S "SSLv3 client has no certificate" \
2300 -c "skip write certificate verify" \
2301 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002302 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002303 -S "! mbedtls_ssl_handshake returned" \
2304 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002305 -S "X509 - Certificate verification failed"
2306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002307run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002308 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002309 "$O_CLI" \
2310 0 \
2311 -S "skip write certificate request" \
2312 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002313 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002314 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002315 -S "X509 - Certificate verification failed"
2316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002317run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002318 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002319 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002320 0 \
2321 -C "skip parse certificate request" \
2322 -c "got a certificate request" \
2323 -C "skip write certificate$" \
2324 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002325 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002326
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002327run_test "Authentication: client no cert, openssl server required" \
2328 "$O_SRV -Verify 10" \
2329 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2330 1 \
2331 -C "skip parse certificate request" \
2332 -c "got a certificate request" \
2333 -C "skip write certificate$" \
2334 -c "skip write certificate verify" \
2335 -c "! mbedtls_ssl_handshake returned"
2336
Janos Follathe2681a42016-03-07 15:57:05 +00002337requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002338run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002339 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002340 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002341 0 \
2342 -S "skip write certificate request" \
2343 -C "skip parse certificate request" \
2344 -c "got a certificate request" \
2345 -C "skip write certificate$" \
2346 -c "skip write certificate verify" \
2347 -c "got no certificate to send" \
2348 -s "SSLv3 client has no certificate" \
2349 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002350 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002351 -S "! mbedtls_ssl_handshake returned" \
2352 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002353 -S "X509 - Certificate verification failed"
2354
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002355# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2356# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002357
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002358MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002359MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002360
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002361if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002362 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002363 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002364 printf "test value of ${MAX_IM_CA}. \n"
2365 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002366 printf "The tests assume this value and if it changes, the tests in this\n"
2367 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002368 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002369
2370 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002371fi
2372
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002373run_test "Authentication: server max_int chain, client default" \
2374 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2375 key_file=data_files/dir-maxpath/09.key" \
2376 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2377 0 \
2378 -C "X509 - A fatal error occured"
2379
2380run_test "Authentication: server max_int+1 chain, client default" \
2381 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2382 key_file=data_files/dir-maxpath/10.key" \
2383 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2384 1 \
2385 -c "X509 - A fatal error occured"
2386
2387run_test "Authentication: server max_int+1 chain, client optional" \
2388 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2389 key_file=data_files/dir-maxpath/10.key" \
2390 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2391 auth_mode=optional" \
2392 1 \
2393 -c "X509 - A fatal error occured"
2394
2395run_test "Authentication: server max_int+1 chain, client none" \
2396 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2397 key_file=data_files/dir-maxpath/10.key" \
2398 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2399 auth_mode=none" \
2400 0 \
2401 -C "X509 - A fatal error occured"
2402
2403run_test "Authentication: client max_int+1 chain, server default" \
2404 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2405 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2406 key_file=data_files/dir-maxpath/10.key" \
2407 0 \
2408 -S "X509 - A fatal error occured"
2409
2410run_test "Authentication: client max_int+1 chain, server optional" \
2411 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2412 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2413 key_file=data_files/dir-maxpath/10.key" \
2414 1 \
2415 -s "X509 - A fatal error occured"
2416
2417run_test "Authentication: client max_int+1 chain, server required" \
2418 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2419 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2420 key_file=data_files/dir-maxpath/10.key" \
2421 1 \
2422 -s "X509 - A fatal error occured"
2423
2424run_test "Authentication: client max_int chain, server required" \
2425 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2426 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2427 key_file=data_files/dir-maxpath/09.key" \
2428 0 \
2429 -S "X509 - A fatal error occured"
2430
Janos Follath89baba22017-04-10 14:34:35 +01002431# Tests for CA list in CertificateRequest messages
2432
2433run_test "Authentication: send CA list in CertificateRequest (default)" \
2434 "$P_SRV debug_level=3 auth_mode=required" \
2435 "$P_CLI crt_file=data_files/server6.crt \
2436 key_file=data_files/server6.key" \
2437 0 \
2438 -s "requested DN"
2439
2440run_test "Authentication: do not send CA list in CertificateRequest" \
2441 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2442 "$P_CLI crt_file=data_files/server6.crt \
2443 key_file=data_files/server6.key" \
2444 0 \
2445 -S "requested DN"
2446
2447run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2448 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2449 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2450 key_file=data_files/server5.key" \
2451 1 \
2452 -S "requested DN" \
2453 -s "x509_verify_cert() returned" \
2454 -s "! The certificate is not correctly signed by the trusted CA" \
2455 -s "! mbedtls_ssl_handshake returned" \
2456 -c "! mbedtls_ssl_handshake returned" \
2457 -s "X509 - Certificate verification failed"
2458
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002459# Tests for certificate selection based on SHA verson
2460
2461run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2462 "$P_SRV crt_file=data_files/server5.crt \
2463 key_file=data_files/server5.key \
2464 crt_file2=data_files/server5-sha1.crt \
2465 key_file2=data_files/server5.key" \
2466 "$P_CLI force_version=tls1_2" \
2467 0 \
2468 -c "signed using.*ECDSA with SHA256" \
2469 -C "signed using.*ECDSA with SHA1"
2470
2471run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2472 "$P_SRV crt_file=data_files/server5.crt \
2473 key_file=data_files/server5.key \
2474 crt_file2=data_files/server5-sha1.crt \
2475 key_file2=data_files/server5.key" \
2476 "$P_CLI force_version=tls1_1" \
2477 0 \
2478 -C "signed using.*ECDSA with SHA256" \
2479 -c "signed using.*ECDSA with SHA1"
2480
2481run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2482 "$P_SRV crt_file=data_files/server5.crt \
2483 key_file=data_files/server5.key \
2484 crt_file2=data_files/server5-sha1.crt \
2485 key_file2=data_files/server5.key" \
2486 "$P_CLI force_version=tls1" \
2487 0 \
2488 -C "signed using.*ECDSA with SHA256" \
2489 -c "signed using.*ECDSA with SHA1"
2490
2491run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2492 "$P_SRV crt_file=data_files/server5.crt \
2493 key_file=data_files/server5.key \
2494 crt_file2=data_files/server6.crt \
2495 key_file2=data_files/server6.key" \
2496 "$P_CLI force_version=tls1_1" \
2497 0 \
2498 -c "serial number.*09" \
2499 -c "signed using.*ECDSA with SHA256" \
2500 -C "signed using.*ECDSA with SHA1"
2501
2502run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2503 "$P_SRV crt_file=data_files/server6.crt \
2504 key_file=data_files/server6.key \
2505 crt_file2=data_files/server5.crt \
2506 key_file2=data_files/server5.key" \
2507 "$P_CLI force_version=tls1_1" \
2508 0 \
2509 -c "serial number.*0A" \
2510 -c "signed using.*ECDSA with SHA256" \
2511 -C "signed using.*ECDSA with SHA1"
2512
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002513# tests for SNI
2514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002515run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002516 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002517 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002518 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002519 0 \
2520 -S "parse ServerName extension" \
2521 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2522 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002524run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002525 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002526 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002527 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 +02002528 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002529 0 \
2530 -s "parse ServerName extension" \
2531 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2532 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002534run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002535 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002536 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002537 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 +02002538 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002539 0 \
2540 -s "parse ServerName extension" \
2541 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2542 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002544run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002545 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002546 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002547 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 +02002548 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002549 1 \
2550 -s "parse ServerName extension" \
2551 -s "ssl_sni_wrapper() returned" \
2552 -s "mbedtls_ssl_handshake returned" \
2553 -c "mbedtls_ssl_handshake returned" \
2554 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002555
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002556run_test "SNI: client auth no override: optional" \
2557 "$P_SRV debug_level=3 auth_mode=optional \
2558 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2559 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2560 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002561 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002562 -S "skip write certificate request" \
2563 -C "skip parse certificate request" \
2564 -c "got a certificate request" \
2565 -C "skip write certificate" \
2566 -C "skip write certificate verify" \
2567 -S "skip parse certificate verify"
2568
2569run_test "SNI: client auth override: none -> optional" \
2570 "$P_SRV debug_level=3 auth_mode=none \
2571 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2572 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2573 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002574 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002575 -S "skip write certificate request" \
2576 -C "skip parse certificate request" \
2577 -c "got a certificate request" \
2578 -C "skip write certificate" \
2579 -C "skip write certificate verify" \
2580 -S "skip parse certificate verify"
2581
2582run_test "SNI: client auth override: optional -> none" \
2583 "$P_SRV debug_level=3 auth_mode=optional \
2584 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2585 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2586 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002587 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002588 -s "skip write certificate request" \
2589 -C "skip parse certificate request" \
2590 -c "got no certificate request" \
2591 -c "skip write certificate" \
2592 -c "skip write certificate verify" \
2593 -s "skip parse certificate verify"
2594
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002595run_test "SNI: CA no override" \
2596 "$P_SRV debug_level=3 auth_mode=optional \
2597 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2598 ca_file=data_files/test-ca.crt \
2599 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2600 "$P_CLI debug_level=3 server_name=localhost \
2601 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2602 1 \
2603 -S "skip write certificate request" \
2604 -C "skip parse certificate request" \
2605 -c "got a certificate request" \
2606 -C "skip write certificate" \
2607 -C "skip write certificate verify" \
2608 -S "skip parse certificate verify" \
2609 -s "x509_verify_cert() returned" \
2610 -s "! The certificate is not correctly signed by the trusted CA" \
2611 -S "The certificate has been revoked (is on a CRL)"
2612
2613run_test "SNI: CA override" \
2614 "$P_SRV debug_level=3 auth_mode=optional \
2615 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2616 ca_file=data_files/test-ca.crt \
2617 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2618 "$P_CLI debug_level=3 server_name=localhost \
2619 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2620 0 \
2621 -S "skip write certificate request" \
2622 -C "skip parse certificate request" \
2623 -c "got a certificate request" \
2624 -C "skip write certificate" \
2625 -C "skip write certificate verify" \
2626 -S "skip parse certificate verify" \
2627 -S "x509_verify_cert() returned" \
2628 -S "! The certificate is not correctly signed by the trusted CA" \
2629 -S "The certificate has been revoked (is on a CRL)"
2630
2631run_test "SNI: CA override with CRL" \
2632 "$P_SRV debug_level=3 auth_mode=optional \
2633 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2634 ca_file=data_files/test-ca.crt \
2635 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2636 "$P_CLI debug_level=3 server_name=localhost \
2637 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2638 1 \
2639 -S "skip write certificate request" \
2640 -C "skip parse certificate request" \
2641 -c "got a certificate request" \
2642 -C "skip write certificate" \
2643 -C "skip write certificate verify" \
2644 -S "skip parse certificate verify" \
2645 -s "x509_verify_cert() returned" \
2646 -S "! The certificate is not correctly signed by the trusted CA" \
2647 -s "The certificate has been revoked (is on a CRL)"
2648
Andres AGe8b07742016-12-07 10:01:30 +00002649# Tests for SNI and DTLS
2650
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002651run_test "SNI: DTLS, matching cert 1" \
Andres AGe8b07742016-12-07 10:01:30 +00002652 "$P_SRV debug_level=3 dtls=1 \
2653 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2654 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2655 "$P_CLI server_name=localhost dtls=1" \
2656 0 \
2657 -s "parse ServerName extension" \
2658 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2659 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2660
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002661run_test "SNI: DTLS, CA override" \
Andres AGe8b07742016-12-07 10:01:30 +00002662 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2663 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2664 ca_file=data_files/test-ca.crt \
2665 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2666 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2667 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2668 0 \
2669 -S "skip write certificate request" \
2670 -C "skip parse certificate request" \
2671 -c "got a certificate request" \
2672 -C "skip write certificate" \
2673 -C "skip write certificate verify" \
2674 -S "skip parse certificate verify" \
2675 -S "x509_verify_cert() returned" \
2676 -S "! The certificate is not correctly signed by the trusted CA" \
2677 -S "The certificate has been revoked (is on a CRL)"
2678
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002679run_test "SNI: DTLS, CA override with CRL" \
Andres AGe8b07742016-12-07 10:01:30 +00002680 "$P_SRV debug_level=3 auth_mode=optional \
2681 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2682 ca_file=data_files/test-ca.crt \
2683 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2684 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2685 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2686 1 \
2687 -S "skip write certificate request" \
2688 -C "skip parse certificate request" \
2689 -c "got a certificate request" \
2690 -C "skip write certificate" \
2691 -C "skip write certificate verify" \
2692 -S "skip parse certificate verify" \
2693 -s "x509_verify_cert() returned" \
2694 -S "! The certificate is not correctly signed by the trusted CA" \
2695 -s "The certificate has been revoked (is on a CRL)"
2696
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002697# Tests for non-blocking I/O: exercise a variety of handshake flows
2698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002699run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002700 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2701 "$P_CLI nbio=2 tickets=0" \
2702 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002703 -S "mbedtls_ssl_handshake returned" \
2704 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002705 -c "Read from server: .* bytes read"
2706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002707run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002708 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2709 "$P_CLI nbio=2 tickets=0" \
2710 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002711 -S "mbedtls_ssl_handshake returned" \
2712 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002713 -c "Read from server: .* bytes read"
2714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002715run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002716 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2717 "$P_CLI nbio=2 tickets=1" \
2718 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002719 -S "mbedtls_ssl_handshake returned" \
2720 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002721 -c "Read from server: .* bytes read"
2722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002723run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002724 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2725 "$P_CLI nbio=2 tickets=1" \
2726 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002727 -S "mbedtls_ssl_handshake returned" \
2728 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002729 -c "Read from server: .* bytes read"
2730
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002731run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002732 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2733 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2734 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002735 -S "mbedtls_ssl_handshake returned" \
2736 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002737 -c "Read from server: .* bytes read"
2738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002739run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002740 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2741 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2742 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002743 -S "mbedtls_ssl_handshake returned" \
2744 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002745 -c "Read from server: .* bytes read"
2746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002747run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002748 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2749 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2750 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002751 -S "mbedtls_ssl_handshake returned" \
2752 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002753 -c "Read from server: .* bytes read"
2754
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002755# Tests for version negotiation
2756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002757run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002758 "$P_SRV" \
2759 "$P_CLI" \
2760 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002761 -S "mbedtls_ssl_handshake returned" \
2762 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002763 -s "Protocol is TLSv1.2" \
2764 -c "Protocol is TLSv1.2"
2765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002766run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002767 "$P_SRV" \
2768 "$P_CLI max_version=tls1_1" \
2769 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002770 -S "mbedtls_ssl_handshake returned" \
2771 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002772 -s "Protocol is TLSv1.1" \
2773 -c "Protocol is TLSv1.1"
2774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002775run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002776 "$P_SRV max_version=tls1_1" \
2777 "$P_CLI" \
2778 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002779 -S "mbedtls_ssl_handshake returned" \
2780 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002781 -s "Protocol is TLSv1.1" \
2782 -c "Protocol is TLSv1.1"
2783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002784run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002785 "$P_SRV max_version=tls1_1" \
2786 "$P_CLI max_version=tls1_1" \
2787 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002788 -S "mbedtls_ssl_handshake returned" \
2789 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002790 -s "Protocol is TLSv1.1" \
2791 -c "Protocol is TLSv1.1"
2792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002793run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002794 "$P_SRV min_version=tls1_1" \
2795 "$P_CLI max_version=tls1_1" \
2796 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002797 -S "mbedtls_ssl_handshake returned" \
2798 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002799 -s "Protocol is TLSv1.1" \
2800 -c "Protocol is TLSv1.1"
2801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002802run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002803 "$P_SRV max_version=tls1_1" \
2804 "$P_CLI min_version=tls1_1" \
2805 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002806 -S "mbedtls_ssl_handshake returned" \
2807 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002808 -s "Protocol is TLSv1.1" \
2809 -c "Protocol is TLSv1.1"
2810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002811run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002812 "$P_SRV max_version=tls1_1" \
2813 "$P_CLI min_version=tls1_2" \
2814 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002815 -s "mbedtls_ssl_handshake returned" \
2816 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002817 -c "SSL - Handshake protocol not within min/max boundaries"
2818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002819run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002820 "$P_SRV min_version=tls1_2" \
2821 "$P_CLI max_version=tls1_1" \
2822 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002823 -s "mbedtls_ssl_handshake returned" \
2824 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002825 -s "SSL - Handshake protocol not within min/max boundaries"
2826
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002827# Tests for ALPN extension
2828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002829run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002830 "$P_SRV debug_level=3" \
2831 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002832 0 \
2833 -C "client hello, adding alpn extension" \
2834 -S "found alpn extension" \
2835 -C "got an alert message, type: \\[2:120]" \
2836 -S "server hello, adding alpn extension" \
2837 -C "found alpn extension " \
2838 -C "Application Layer Protocol is" \
2839 -S "Application Layer Protocol is"
2840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002841run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002842 "$P_SRV debug_level=3" \
2843 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002844 0 \
2845 -c "client hello, adding alpn extension" \
2846 -s "found alpn extension" \
2847 -C "got an alert message, type: \\[2:120]" \
2848 -S "server hello, adding alpn extension" \
2849 -C "found alpn extension " \
2850 -c "Application Layer Protocol is (none)" \
2851 -S "Application Layer Protocol is"
2852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002853run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002854 "$P_SRV debug_level=3 alpn=abc,1234" \
2855 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002856 0 \
2857 -C "client hello, adding alpn extension" \
2858 -S "found alpn extension" \
2859 -C "got an alert message, type: \\[2:120]" \
2860 -S "server hello, adding alpn extension" \
2861 -C "found alpn extension " \
2862 -C "Application Layer Protocol is" \
2863 -s "Application Layer Protocol is (none)"
2864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002865run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002866 "$P_SRV debug_level=3 alpn=abc,1234" \
2867 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002868 0 \
2869 -c "client hello, adding alpn extension" \
2870 -s "found alpn extension" \
2871 -C "got an alert message, type: \\[2:120]" \
2872 -s "server hello, adding alpn extension" \
2873 -c "found alpn extension" \
2874 -c "Application Layer Protocol is abc" \
2875 -s "Application Layer Protocol is abc"
2876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002877run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002878 "$P_SRV debug_level=3 alpn=abc,1234" \
2879 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002880 0 \
2881 -c "client hello, adding alpn extension" \
2882 -s "found alpn extension" \
2883 -C "got an alert message, type: \\[2:120]" \
2884 -s "server hello, adding alpn extension" \
2885 -c "found alpn extension" \
2886 -c "Application Layer Protocol is abc" \
2887 -s "Application Layer Protocol is abc"
2888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002889run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002890 "$P_SRV debug_level=3 alpn=abc,1234" \
2891 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002892 0 \
2893 -c "client hello, adding alpn extension" \
2894 -s "found alpn extension" \
2895 -C "got an alert message, type: \\[2:120]" \
2896 -s "server hello, adding alpn extension" \
2897 -c "found alpn extension" \
2898 -c "Application Layer Protocol is 1234" \
2899 -s "Application Layer Protocol is 1234"
2900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002901run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002902 "$P_SRV debug_level=3 alpn=abc,123" \
2903 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002904 1 \
2905 -c "client hello, adding alpn extension" \
2906 -s "found alpn extension" \
2907 -c "got an alert message, type: \\[2:120]" \
2908 -S "server hello, adding alpn extension" \
2909 -C "found alpn extension" \
2910 -C "Application Layer Protocol is 1234" \
2911 -S "Application Layer Protocol is 1234"
2912
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002913
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002914# Tests for keyUsage in leaf certificates, part 1:
2915# server-side certificate/suite selection
2916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002917run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002918 "$P_SRV key_file=data_files/server2.key \
2919 crt_file=data_files/server2.ku-ds.crt" \
2920 "$P_CLI" \
2921 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002922 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002923
2924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002925run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002926 "$P_SRV key_file=data_files/server2.key \
2927 crt_file=data_files/server2.ku-ke.crt" \
2928 "$P_CLI" \
2929 0 \
2930 -c "Ciphersuite is TLS-RSA-WITH-"
2931
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002932run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002933 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002934 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002935 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002936 1 \
2937 -C "Ciphersuite is "
2938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002939run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002940 "$P_SRV key_file=data_files/server5.key \
2941 crt_file=data_files/server5.ku-ds.crt" \
2942 "$P_CLI" \
2943 0 \
2944 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2945
2946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002947run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002948 "$P_SRV key_file=data_files/server5.key \
2949 crt_file=data_files/server5.ku-ka.crt" \
2950 "$P_CLI" \
2951 0 \
2952 -c "Ciphersuite is TLS-ECDH-"
2953
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002954run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002955 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002956 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002957 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002958 1 \
2959 -C "Ciphersuite is "
2960
2961# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002962# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002964run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002965 "$O_SRV -key data_files/server2.key \
2966 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002967 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002968 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2969 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002970 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002971 -C "Processing of the Certificate handshake message failed" \
2972 -c "Ciphersuite is TLS-"
2973
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002974run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002975 "$O_SRV -key data_files/server2.key \
2976 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002977 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002978 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2979 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002980 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002981 -C "Processing of the Certificate handshake message failed" \
2982 -c "Ciphersuite is TLS-"
2983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002984run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002985 "$O_SRV -key data_files/server2.key \
2986 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002987 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002988 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2989 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002990 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002991 -C "Processing of the Certificate handshake message failed" \
2992 -c "Ciphersuite is TLS-"
2993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002994run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002995 "$O_SRV -key data_files/server2.key \
2996 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002997 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002998 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2999 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003000 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003001 -c "Processing of the Certificate handshake message failed" \
3002 -C "Ciphersuite is TLS-"
3003
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003004run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3005 "$O_SRV -key data_files/server2.key \
3006 -cert data_files/server2.ku-ke.crt" \
3007 "$P_CLI debug_level=1 auth_mode=optional \
3008 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3009 0 \
3010 -c "bad certificate (usage extensions)" \
3011 -C "Processing of the Certificate handshake message failed" \
3012 -c "Ciphersuite is TLS-" \
3013 -c "! Usage does not match the keyUsage extension"
3014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003015run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003016 "$O_SRV -key data_files/server2.key \
3017 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003018 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003019 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3020 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003021 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003022 -C "Processing of the Certificate handshake message failed" \
3023 -c "Ciphersuite is TLS-"
3024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003025run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003026 "$O_SRV -key data_files/server2.key \
3027 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003028 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003029 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3030 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003031 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003032 -c "Processing of the Certificate handshake message failed" \
3033 -C "Ciphersuite is TLS-"
3034
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003035run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3036 "$O_SRV -key data_files/server2.key \
3037 -cert data_files/server2.ku-ds.crt" \
3038 "$P_CLI debug_level=1 auth_mode=optional \
3039 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3040 0 \
3041 -c "bad certificate (usage extensions)" \
3042 -C "Processing of the Certificate handshake message failed" \
3043 -c "Ciphersuite is TLS-" \
3044 -c "! Usage does not match the keyUsage extension"
3045
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003046# Tests for keyUsage in leaf certificates, part 3:
3047# server-side checking of client cert
3048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003049run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003050 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003051 "$O_CLI -key data_files/server2.key \
3052 -cert data_files/server2.ku-ds.crt" \
3053 0 \
3054 -S "bad certificate (usage extensions)" \
3055 -S "Processing of the Certificate handshake message failed"
3056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003057run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003058 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003059 "$O_CLI -key data_files/server2.key \
3060 -cert data_files/server2.ku-ke.crt" \
3061 0 \
3062 -s "bad certificate (usage extensions)" \
3063 -S "Processing of the Certificate handshake message failed"
3064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003065run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003066 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003067 "$O_CLI -key data_files/server2.key \
3068 -cert data_files/server2.ku-ke.crt" \
3069 1 \
3070 -s "bad certificate (usage extensions)" \
3071 -s "Processing of the Certificate handshake message failed"
3072
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003073run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003074 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003075 "$O_CLI -key data_files/server5.key \
3076 -cert data_files/server5.ku-ds.crt" \
3077 0 \
3078 -S "bad certificate (usage extensions)" \
3079 -S "Processing of the Certificate handshake message failed"
3080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003081run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003082 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003083 "$O_CLI -key data_files/server5.key \
3084 -cert data_files/server5.ku-ka.crt" \
3085 0 \
3086 -s "bad certificate (usage extensions)" \
3087 -S "Processing of the Certificate handshake message failed"
3088
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003089# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3090
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003091run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003092 "$P_SRV key_file=data_files/server5.key \
3093 crt_file=data_files/server5.eku-srv.crt" \
3094 "$P_CLI" \
3095 0
3096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003097run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003098 "$P_SRV key_file=data_files/server5.key \
3099 crt_file=data_files/server5.eku-srv.crt" \
3100 "$P_CLI" \
3101 0
3102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003103run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003104 "$P_SRV key_file=data_files/server5.key \
3105 crt_file=data_files/server5.eku-cs_any.crt" \
3106 "$P_CLI" \
3107 0
3108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003109run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003110 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003111 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003112 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003113 1
3114
3115# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003117run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003118 "$O_SRV -key data_files/server5.key \
3119 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003120 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003121 0 \
3122 -C "bad certificate (usage extensions)" \
3123 -C "Processing of the Certificate handshake message failed" \
3124 -c "Ciphersuite is TLS-"
3125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003126run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003127 "$O_SRV -key data_files/server5.key \
3128 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003129 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003130 0 \
3131 -C "bad certificate (usage extensions)" \
3132 -C "Processing of the Certificate handshake message failed" \
3133 -c "Ciphersuite is TLS-"
3134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003135run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003136 "$O_SRV -key data_files/server5.key \
3137 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003138 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003139 0 \
3140 -C "bad certificate (usage extensions)" \
3141 -C "Processing of the Certificate handshake message failed" \
3142 -c "Ciphersuite is TLS-"
3143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003144run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003145 "$O_SRV -key data_files/server5.key \
3146 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003147 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003148 1 \
3149 -c "bad certificate (usage extensions)" \
3150 -c "Processing of the Certificate handshake message failed" \
3151 -C "Ciphersuite is TLS-"
3152
3153# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003155run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003156 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003157 "$O_CLI -key data_files/server5.key \
3158 -cert data_files/server5.eku-cli.crt" \
3159 0 \
3160 -S "bad certificate (usage extensions)" \
3161 -S "Processing of the Certificate handshake message failed"
3162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003163run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003164 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003165 "$O_CLI -key data_files/server5.key \
3166 -cert data_files/server5.eku-srv_cli.crt" \
3167 0 \
3168 -S "bad certificate (usage extensions)" \
3169 -S "Processing of the Certificate handshake message failed"
3170
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003171run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003172 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003173 "$O_CLI -key data_files/server5.key \
3174 -cert data_files/server5.eku-cs_any.crt" \
3175 0 \
3176 -S "bad certificate (usage extensions)" \
3177 -S "Processing of the Certificate handshake message failed"
3178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003179run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003180 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003181 "$O_CLI -key data_files/server5.key \
3182 -cert data_files/server5.eku-cs.crt" \
3183 0 \
3184 -s "bad certificate (usage extensions)" \
3185 -S "Processing of the Certificate handshake message failed"
3186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003187run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003188 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003189 "$O_CLI -key data_files/server5.key \
3190 -cert data_files/server5.eku-cs.crt" \
3191 1 \
3192 -s "bad certificate (usage extensions)" \
3193 -s "Processing of the Certificate handshake message failed"
3194
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003195# Tests for DHM parameters loading
3196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003197run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003198 "$P_SRV" \
3199 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3200 debug_level=3" \
3201 0 \
3202 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003203 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003205run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003206 "$P_SRV dhm_file=data_files/dhparams.pem" \
3207 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3208 debug_level=3" \
3209 0 \
3210 -c "value of 'DHM: P ' (1024 bits)" \
3211 -c "value of 'DHM: G ' (2 bits)"
3212
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003213# Tests for DHM client-side size checking
3214
3215run_test "DHM size: server default, client default, OK" \
3216 "$P_SRV" \
3217 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3218 debug_level=1" \
3219 0 \
3220 -C "DHM prime too short:"
3221
3222run_test "DHM size: server default, client 2048, OK" \
3223 "$P_SRV" \
3224 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3225 debug_level=1 dhmlen=2048" \
3226 0 \
3227 -C "DHM prime too short:"
3228
3229run_test "DHM size: server 1024, client default, OK" \
3230 "$P_SRV dhm_file=data_files/dhparams.pem" \
3231 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3232 debug_level=1" \
3233 0 \
3234 -C "DHM prime too short:"
3235
3236run_test "DHM size: server 1000, client default, rejected" \
3237 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3238 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3239 debug_level=1" \
3240 1 \
3241 -c "DHM prime too short:"
3242
3243run_test "DHM size: server default, client 2049, rejected" \
3244 "$P_SRV" \
3245 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3246 debug_level=1 dhmlen=2049" \
3247 1 \
3248 -c "DHM prime too short:"
3249
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003250# Tests for PSK callback
3251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003252run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003253 "$P_SRV psk=abc123 psk_identity=foo" \
3254 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3255 psk_identity=foo psk=abc123" \
3256 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003257 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003258 -S "SSL - Unknown identity received" \
3259 -S "SSL - Verification of the message MAC failed"
3260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003261run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003262 "$P_SRV" \
3263 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3264 psk_identity=foo psk=abc123" \
3265 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003266 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003267 -S "SSL - Unknown identity received" \
3268 -S "SSL - Verification of the message MAC failed"
3269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003270run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003271 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3272 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3273 psk_identity=foo psk=abc123" \
3274 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003275 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003276 -s "SSL - Unknown identity received" \
3277 -S "SSL - Verification of the message MAC failed"
3278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003279run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003280 "$P_SRV psk_list=abc,dead,def,beef" \
3281 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3282 psk_identity=abc psk=dead" \
3283 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003284 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003285 -S "SSL - Unknown identity received" \
3286 -S "SSL - Verification of the message MAC failed"
3287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003288run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003289 "$P_SRV psk_list=abc,dead,def,beef" \
3290 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3291 psk_identity=def psk=beef" \
3292 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003293 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003294 -S "SSL - Unknown identity received" \
3295 -S "SSL - Verification of the message MAC failed"
3296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003297run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003298 "$P_SRV psk_list=abc,dead,def,beef" \
3299 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3300 psk_identity=ghi psk=beef" \
3301 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003302 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003303 -s "SSL - Unknown identity received" \
3304 -S "SSL - Verification of the message MAC failed"
3305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003306run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003307 "$P_SRV psk_list=abc,dead,def,beef" \
3308 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3309 psk_identity=abc psk=beef" \
3310 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003311 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003312 -S "SSL - Unknown identity received" \
3313 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003314
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003315# Tests for EC J-PAKE
3316
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003317requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003318run_test "ECJPAKE: client not configured" \
3319 "$P_SRV debug_level=3" \
3320 "$P_CLI debug_level=3" \
3321 0 \
3322 -C "add ciphersuite: c0ff" \
3323 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003324 -S "found ecjpake kkpp extension" \
3325 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003326 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003327 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003328 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003329 -S "None of the common ciphersuites is usable"
3330
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003331requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003332run_test "ECJPAKE: server not configured" \
3333 "$P_SRV debug_level=3" \
3334 "$P_CLI debug_level=3 ecjpake_pw=bla \
3335 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3336 1 \
3337 -c "add ciphersuite: c0ff" \
3338 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003339 -s "found ecjpake kkpp extension" \
3340 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003341 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003342 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003343 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003344 -s "None of the common ciphersuites is usable"
3345
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003346requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003347run_test "ECJPAKE: working, TLS" \
3348 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3349 "$P_CLI debug_level=3 ecjpake_pw=bla \
3350 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003351 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003352 -c "add ciphersuite: c0ff" \
3353 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003354 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003355 -s "found ecjpake kkpp extension" \
3356 -S "skip ecjpake kkpp extension" \
3357 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003358 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003359 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003360 -S "None of the common ciphersuites is usable" \
3361 -S "SSL - Verification of the message MAC failed"
3362
Janos Follath74537a62016-09-02 13:45:28 +01003363server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003364requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003365run_test "ECJPAKE: password mismatch, TLS" \
3366 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3367 "$P_CLI debug_level=3 ecjpake_pw=bad \
3368 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3369 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003370 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003371 -s "SSL - Verification of the message MAC failed"
3372
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003373requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003374run_test "ECJPAKE: working, DTLS" \
3375 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3376 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3377 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3378 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003379 -c "re-using cached ecjpake parameters" \
3380 -S "SSL - Verification of the message MAC failed"
3381
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003382requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003383run_test "ECJPAKE: working, DTLS, no cookie" \
3384 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3385 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3386 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3387 0 \
3388 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003389 -S "SSL - Verification of the message MAC failed"
3390
Janos Follath74537a62016-09-02 13:45:28 +01003391server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003392requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003393run_test "ECJPAKE: password mismatch, DTLS" \
3394 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3395 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3396 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3397 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003398 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003399 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003400
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003401# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003402requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003403run_test "ECJPAKE: working, DTLS, nolog" \
3404 "$P_SRV dtls=1 ecjpake_pw=bla" \
3405 "$P_CLI dtls=1 ecjpake_pw=bla \
3406 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3407 0
3408
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003409# Tests for ciphersuites per version
3410
Janos Follathe2681a42016-03-07 15:57:05 +00003411requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003412run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003413 "$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 +02003414 "$P_CLI force_version=ssl3" \
3415 0 \
3416 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003418run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003419 "$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 +01003420 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003421 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003422 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003424run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003425 "$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 +02003426 "$P_CLI force_version=tls1_1" \
3427 0 \
3428 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003430run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003431 "$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 +02003432 "$P_CLI force_version=tls1_2" \
3433 0 \
3434 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3435
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003436# Test for ClientHello without extensions
3437
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003438requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003439run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003440 "$P_SRV debug_level=3" \
3441 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3442 0 \
3443 -s "dumping 'client hello extensions' (0 bytes)"
3444
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003445requires_gnutls
3446run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3447 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3448 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3449 0 \
3450 -s "dumping 'client hello extensions' (0 bytes)"
3451
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003452# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003453
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003454run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003455 "$P_SRV" \
3456 "$P_CLI request_size=100" \
3457 0 \
3458 -s "Read from client: 100 bytes read$"
3459
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003460run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003461 "$P_SRV" \
3462 "$P_CLI request_size=500" \
3463 0 \
3464 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003465
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003466# Tests for small packets
3467
Janos Follathe2681a42016-03-07 15:57:05 +00003468requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003469run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003470 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003471 "$P_CLI request_size=1 force_version=ssl3 \
3472 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3473 0 \
3474 -s "Read from client: 1 bytes read"
3475
Janos Follathe2681a42016-03-07 15:57:05 +00003476requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003477run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003478 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003479 "$P_CLI request_size=1 force_version=ssl3 \
3480 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3481 0 \
3482 -s "Read from client: 1 bytes read"
3483
3484run_test "Small packet TLS 1.0 BlockCipher" \
3485 "$P_SRV" \
3486 "$P_CLI request_size=1 force_version=tls1 \
3487 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3488 0 \
3489 -s "Read from client: 1 bytes read"
3490
Hanno Becker8501f982017-11-10 08:59:04 +00003491run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003492 "$P_SRV" \
3493 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3494 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3495 0 \
3496 -s "Read from client: 1 bytes read"
3497
Hanno Becker32c55012017-11-10 08:42:54 +00003498requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003499run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003500 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003501 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003502 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003503 0 \
3504 -s "Read from client: 1 bytes read"
3505
Hanno Becker32c55012017-11-10 08:42:54 +00003506requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003507run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003508 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003509 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003510 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003511 0 \
3512 -s "Read from client: 1 bytes read"
3513
3514run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003515 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003516 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003517 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3518 0 \
3519 -s "Read from client: 1 bytes read"
3520
3521run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3522 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3523 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003524 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003525 0 \
3526 -s "Read from client: 1 bytes read"
3527
3528requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3529run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003530 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003531 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003532 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003533 0 \
3534 -s "Read from client: 1 bytes read"
3535
Hanno Becker8501f982017-11-10 08:59:04 +00003536requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3537run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003538 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3539 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3540 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003541 0 \
3542 -s "Read from client: 1 bytes read"
3543
3544run_test "Small packet TLS 1.1 BlockCipher" \
3545 "$P_SRV" \
3546 "$P_CLI request_size=1 force_version=tls1_1 \
3547 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3548 0 \
3549 -s "Read from client: 1 bytes read"
3550
Hanno Becker8501f982017-11-10 08:59:04 +00003551run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003552 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003553 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003554 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003555 0 \
3556 -s "Read from client: 1 bytes read"
3557
3558requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3559run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003560 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003561 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003562 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003563 0 \
3564 -s "Read from client: 1 bytes read"
3565
3566requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3567run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003568 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003569 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003570 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003571 0 \
3572 -s "Read from client: 1 bytes read"
3573
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003574run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003575 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003576 "$P_CLI request_size=1 force_version=tls1_1 \
3577 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3578 0 \
3579 -s "Read from client: 1 bytes read"
3580
Hanno Becker8501f982017-11-10 08:59:04 +00003581run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3582 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003583 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003584 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003585 0 \
3586 -s "Read from client: 1 bytes read"
3587
Hanno Becker8501f982017-11-10 08:59:04 +00003588requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3589run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003590 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003591 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003592 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003593 0 \
3594 -s "Read from client: 1 bytes read"
3595
Hanno Becker32c55012017-11-10 08:42:54 +00003596requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003597run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003598 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003599 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003600 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003601 0 \
3602 -s "Read from client: 1 bytes read"
3603
3604run_test "Small packet TLS 1.2 BlockCipher" \
3605 "$P_SRV" \
3606 "$P_CLI request_size=1 force_version=tls1_2 \
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.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003612 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003613 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003614 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003615 0 \
3616 -s "Read from client: 1 bytes read"
3617
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003618run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3619 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003620 "$P_CLI request_size=1 force_version=tls1_2 \
3621 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003622 0 \
3623 -s "Read from client: 1 bytes read"
3624
Hanno Becker32c55012017-11-10 08:42:54 +00003625requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003626run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003627 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003628 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003629 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003630 0 \
3631 -s "Read from client: 1 bytes read"
3632
Hanno Becker8501f982017-11-10 08:59:04 +00003633requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3634run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003635 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003636 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003637 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003638 0 \
3639 -s "Read from client: 1 bytes read"
3640
3641run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003642 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003643 "$P_CLI request_size=1 force_version=tls1_2 \
3644 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3645 0 \
3646 -s "Read from client: 1 bytes read"
3647
Hanno Becker8501f982017-11-10 08:59:04 +00003648run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003649 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003650 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003651 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003652 0 \
3653 -s "Read from client: 1 bytes read"
3654
Hanno Becker32c55012017-11-10 08:42:54 +00003655requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003656run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003657 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003658 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003659 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003660 0 \
3661 -s "Read from client: 1 bytes read"
3662
Hanno Becker8501f982017-11-10 08:59:04 +00003663requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3664run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003665 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003666 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003667 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003668 0 \
3669 -s "Read from client: 1 bytes read"
3670
3671run_test "Small packet TLS 1.2 AEAD" \
3672 "$P_SRV" \
3673 "$P_CLI request_size=1 force_version=tls1_2 \
3674 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3675 0 \
3676 -s "Read from client: 1 bytes read"
3677
3678run_test "Small packet TLS 1.2 AEAD shorter tag" \
3679 "$P_SRV" \
3680 "$P_CLI request_size=1 force_version=tls1_2 \
3681 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3682 0 \
3683 -s "Read from client: 1 bytes read"
3684
Hanno Beckere2148042017-11-10 08:59:18 +00003685# Tests for small packets in DTLS
3686
3687requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3688run_test "Small packet DTLS 1.0" \
3689 "$P_SRV dtls=1 force_version=dtls1" \
3690 "$P_CLI dtls=1 request_size=1 \
3691 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3692 0 \
3693 -s "Read from client: 1 bytes read"
3694
3695requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3696run_test "Small packet DTLS 1.0, without EtM" \
3697 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3698 "$P_CLI dtls=1 request_size=1 \
3699 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3700 0 \
3701 -s "Read from client: 1 bytes read"
3702
3703requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3704requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3705run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003706 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3707 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003708 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3709 0 \
3710 -s "Read from client: 1 bytes read"
3711
3712requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3713requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3714run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003715 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003716 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003717 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003718 0 \
3719 -s "Read from client: 1 bytes read"
3720
3721requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3722run_test "Small packet DTLS 1.2" \
3723 "$P_SRV dtls=1 force_version=dtls1_2" \
3724 "$P_CLI dtls=1 request_size=1 \
3725 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3726 0 \
3727 -s "Read from client: 1 bytes read"
3728
3729requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3730run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003731 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003732 "$P_CLI dtls=1 request_size=1 \
3733 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3734 0 \
3735 -s "Read from client: 1 bytes read"
3736
3737requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3738requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3739run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003740 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003741 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003742 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003743 0 \
3744 -s "Read from client: 1 bytes read"
3745
3746requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3747requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3748run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003749 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003750 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003751 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003752 0 \
3753 -s "Read from client: 1 bytes read"
3754
Janos Follath00efff72016-05-06 13:48:23 +01003755# A test for extensions in SSLv3
3756
3757requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3758run_test "SSLv3 with extensions, server side" \
3759 "$P_SRV min_version=ssl3 debug_level=3" \
3760 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3761 0 \
3762 -S "dumping 'client hello extensions'" \
3763 -S "server hello, total extension length:"
3764
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003765# Test for large packets
3766
Janos Follathe2681a42016-03-07 15:57:05 +00003767requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003768run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003769 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003770 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003771 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3772 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003773 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003774 -s "Read from client: 16384 bytes read"
3775
Janos Follathe2681a42016-03-07 15:57:05 +00003776requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003777run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003778 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003779 "$P_CLI request_size=16384 force_version=ssl3 \
3780 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3781 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003782 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003783 -s "Read from client: 16384 bytes read"
3784
3785run_test "Large packet TLS 1.0 BlockCipher" \
3786 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003787 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003788 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3789 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003790 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003791 -s "Read from client: 16384 bytes read"
3792
Hanno Becker278fc7a2017-11-10 09:16:28 +00003793run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003794 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003795 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3796 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3797 0 \
3798 -s "Read from client: 16384 bytes read"
3799
Hanno Becker32c55012017-11-10 08:42:54 +00003800requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003801run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003802 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003803 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003804 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003805 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003806 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003807 -s "Read from client: 16384 bytes read"
3808
Hanno Becker32c55012017-11-10 08:42:54 +00003809requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003810run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003811 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003812 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003813 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003814 0 \
3815 -s "Read from client: 16384 bytes read"
3816
3817run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003818 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003819 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003820 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3821 0 \
3822 -s "Read from client: 16384 bytes read"
3823
3824run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3825 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3826 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003827 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003828 0 \
3829 -s "Read from client: 16384 bytes read"
3830
3831requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3832run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003833 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003834 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003835 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003836 0 \
3837 -s "Read from client: 16384 bytes read"
3838
Hanno Becker278fc7a2017-11-10 09:16:28 +00003839requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3840run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003841 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003842 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003843 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003844 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003845 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003846 -s "Read from client: 16384 bytes read"
3847
3848run_test "Large packet TLS 1.1 BlockCipher" \
3849 "$P_SRV" \
3850 "$P_CLI request_size=16384 force_version=tls1_1 \
3851 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3852 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003853 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003854 -s "Read from client: 16384 bytes read"
3855
Hanno Becker278fc7a2017-11-10 09:16:28 +00003856run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3857 "$P_SRV" \
3858 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3859 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003860 0 \
3861 -s "Read from client: 16384 bytes read"
3862
Hanno Becker32c55012017-11-10 08:42:54 +00003863requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003864run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003865 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003866 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003867 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003868 0 \
3869 -s "Read from client: 16384 bytes read"
3870
Hanno Becker32c55012017-11-10 08:42:54 +00003871requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003872run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003873 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003874 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003875 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003876 0 \
3877 -s "Read from client: 16384 bytes read"
3878
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003879run_test "Large packet TLS 1.1 StreamCipher" \
3880 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3881 "$P_CLI request_size=16384 force_version=tls1_1 \
3882 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3883 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003884 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003885 -s "Read from client: 16384 bytes read"
3886
Hanno Becker278fc7a2017-11-10 09:16:28 +00003887run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
3888 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003889 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003890 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003891 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003892 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003893 -s "Read from client: 16384 bytes read"
3894
Hanno Becker278fc7a2017-11-10 09:16:28 +00003895requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3896run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003897 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003898 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003899 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003900 0 \
3901 -s "Read from client: 16384 bytes read"
3902
Hanno Becker278fc7a2017-11-10 09:16:28 +00003903requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3904run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003905 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003906 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003907 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003908 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003909 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003910 -s "Read from client: 16384 bytes read"
3911
3912run_test "Large packet TLS 1.2 BlockCipher" \
3913 "$P_SRV" \
3914 "$P_CLI request_size=16384 force_version=tls1_2 \
3915 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3916 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003917 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003918 -s "Read from client: 16384 bytes read"
3919
Hanno Becker278fc7a2017-11-10 09:16:28 +00003920run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
3921 "$P_SRV" \
3922 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
3923 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3924 0 \
3925 -s "Read from client: 16384 bytes read"
3926
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003927run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3928 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003929 "$P_CLI request_size=16384 force_version=tls1_2 \
3930 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003931 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003932 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003933 -s "Read from client: 16384 bytes read"
3934
Hanno Becker32c55012017-11-10 08:42:54 +00003935requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003936run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003937 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003938 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003939 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003940 0 \
3941 -s "Read from client: 16384 bytes read"
3942
Hanno Becker278fc7a2017-11-10 09:16:28 +00003943requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3944run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003945 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003946 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003947 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003948 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003949 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003950 -s "Read from client: 16384 bytes read"
3951
3952run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003953 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003954 "$P_CLI request_size=16384 force_version=tls1_2 \
3955 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3956 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003957 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003958 -s "Read from client: 16384 bytes read"
3959
Hanno Becker278fc7a2017-11-10 09:16:28 +00003960run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003961 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003962 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003963 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
3964 0 \
3965 -s "Read from client: 16384 bytes read"
3966
Hanno Becker32c55012017-11-10 08:42:54 +00003967requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003968run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003969 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003970 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003971 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003972 0 \
3973 -s "Read from client: 16384 bytes read"
3974
Hanno Becker278fc7a2017-11-10 09:16:28 +00003975requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3976run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003977 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003978 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003979 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003980 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003981 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003982 -s "Read from client: 16384 bytes read"
3983
3984run_test "Large packet TLS 1.2 AEAD" \
3985 "$P_SRV" \
3986 "$P_CLI request_size=16384 force_version=tls1_2 \
3987 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3988 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003989 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003990 -s "Read from client: 16384 bytes read"
3991
3992run_test "Large packet TLS 1.2 AEAD shorter tag" \
3993 "$P_SRV" \
3994 "$P_CLI request_size=16384 force_version=tls1_2 \
3995 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3996 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003997 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003998 -s "Read from client: 16384 bytes read"
3999
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004000# Tests for DTLS HelloVerifyRequest
4001
4002run_test "DTLS cookie: enabled" \
4003 "$P_SRV dtls=1 debug_level=2" \
4004 "$P_CLI dtls=1 debug_level=2" \
4005 0 \
4006 -s "cookie verification failed" \
4007 -s "cookie verification passed" \
4008 -S "cookie verification skipped" \
4009 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004010 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004011 -S "SSL - The requested feature is not available"
4012
4013run_test "DTLS cookie: disabled" \
4014 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4015 "$P_CLI dtls=1 debug_level=2" \
4016 0 \
4017 -S "cookie verification failed" \
4018 -S "cookie verification passed" \
4019 -s "cookie verification skipped" \
4020 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004021 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004022 -S "SSL - The requested feature is not available"
4023
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004024run_test "DTLS cookie: default (failing)" \
4025 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4026 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4027 1 \
4028 -s "cookie verification failed" \
4029 -S "cookie verification passed" \
4030 -S "cookie verification skipped" \
4031 -C "received hello verify request" \
4032 -S "hello verification requested" \
4033 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004034
4035requires_ipv6
4036run_test "DTLS cookie: enabled, IPv6" \
4037 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4038 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4039 0 \
4040 -s "cookie verification failed" \
4041 -s "cookie verification passed" \
4042 -S "cookie verification skipped" \
4043 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004044 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004045 -S "SSL - The requested feature is not available"
4046
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004047run_test "DTLS cookie: enabled, nbio" \
4048 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4049 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4050 0 \
4051 -s "cookie verification failed" \
4052 -s "cookie verification passed" \
4053 -S "cookie verification skipped" \
4054 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004055 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004056 -S "SSL - The requested feature is not available"
4057
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004058# Tests for client reconnecting from the same port with DTLS
4059
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004060not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004061run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004062 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4063 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004064 0 \
4065 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004066 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004067 -S "Client initiated reconnection from same port"
4068
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004069not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004070run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004071 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4072 "$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 +02004073 0 \
4074 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004075 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004076 -s "Client initiated reconnection from same port"
4077
Paul Bakker362689d2016-05-13 10:33:25 +01004078not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4079run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004080 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4081 "$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 +02004082 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004083 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004084 -s "Client initiated reconnection from same port"
4085
Paul Bakker362689d2016-05-13 10:33:25 +01004086only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4087run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4088 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4089 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4090 0 \
4091 -S "The operation timed out" \
4092 -s "Client initiated reconnection from same port"
4093
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004094run_test "DTLS client reconnect from same port: no cookies" \
4095 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004096 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4097 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004098 -s "The operation timed out" \
4099 -S "Client initiated reconnection from same port"
4100
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004101# Tests for various cases of client authentication with DTLS
4102# (focused on handshake flows and message parsing)
4103
4104run_test "DTLS client auth: required" \
4105 "$P_SRV dtls=1 auth_mode=required" \
4106 "$P_CLI dtls=1" \
4107 0 \
4108 -s "Verifying peer X.509 certificate... ok"
4109
4110run_test "DTLS client auth: optional, client has no cert" \
4111 "$P_SRV dtls=1 auth_mode=optional" \
4112 "$P_CLI dtls=1 crt_file=none key_file=none" \
4113 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004114 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004115
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004116run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004117 "$P_SRV dtls=1 auth_mode=none" \
4118 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
4119 0 \
4120 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004121 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004122
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02004123run_test "DTLS wrong PSK: badmac alert" \
4124 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
4125 "$P_CLI dtls=1 psk=abc124" \
4126 1 \
4127 -s "SSL - Verification of the message MAC failed" \
4128 -c "SSL - A fatal alert message was received from our peer"
4129
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02004130# Tests for receiving fragmented handshake messages with DTLS
4131
4132requires_gnutls
4133run_test "DTLS reassembly: no fragmentation (gnutls server)" \
4134 "$G_SRV -u --mtu 2048 -a" \
4135 "$P_CLI dtls=1 debug_level=2" \
4136 0 \
4137 -C "found fragmented DTLS handshake message" \
4138 -C "error"
4139
4140requires_gnutls
4141run_test "DTLS reassembly: some fragmentation (gnutls server)" \
4142 "$G_SRV -u --mtu 512" \
4143 "$P_CLI dtls=1 debug_level=2" \
4144 0 \
4145 -c "found fragmented DTLS handshake message" \
4146 -C "error"
4147
4148requires_gnutls
4149run_test "DTLS reassembly: more fragmentation (gnutls server)" \
4150 "$G_SRV -u --mtu 128" \
4151 "$P_CLI dtls=1 debug_level=2" \
4152 0 \
4153 -c "found fragmented DTLS handshake message" \
4154 -C "error"
4155
4156requires_gnutls
4157run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
4158 "$G_SRV -u --mtu 128" \
4159 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4160 0 \
4161 -c "found fragmented DTLS handshake message" \
4162 -C "error"
4163
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004164requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004165requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004166run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4167 "$G_SRV -u --mtu 256" \
4168 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4169 0 \
4170 -c "found fragmented DTLS handshake message" \
4171 -c "client hello, adding renegotiation extension" \
4172 -c "found renegotiation extension" \
4173 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004174 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004175 -C "error" \
4176 -s "Extra-header:"
4177
4178requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004179requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004180run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4181 "$G_SRV -u --mtu 256" \
4182 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4183 0 \
4184 -c "found fragmented DTLS handshake message" \
4185 -c "client hello, adding renegotiation extension" \
4186 -c "found renegotiation extension" \
4187 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004188 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004189 -C "error" \
4190 -s "Extra-header:"
4191
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004192run_test "DTLS reassembly: no fragmentation (openssl server)" \
4193 "$O_SRV -dtls1 -mtu 2048" \
4194 "$P_CLI dtls=1 debug_level=2" \
4195 0 \
4196 -C "found fragmented DTLS handshake message" \
4197 -C "error"
4198
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004199run_test "DTLS reassembly: some fragmentation (openssl server)" \
4200 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004201 "$P_CLI dtls=1 debug_level=2" \
4202 0 \
4203 -c "found fragmented DTLS handshake message" \
4204 -C "error"
4205
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004206run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004207 "$O_SRV -dtls1 -mtu 256" \
4208 "$P_CLI dtls=1 debug_level=2" \
4209 0 \
4210 -c "found fragmented DTLS handshake message" \
4211 -C "error"
4212
4213run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4214 "$O_SRV -dtls1 -mtu 256" \
4215 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4216 0 \
4217 -c "found fragmented DTLS handshake message" \
4218 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004219
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004220# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004221
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004222not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004223run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004224 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004225 "$P_SRV dtls=1 debug_level=2" \
4226 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004227 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004228 -C "replayed record" \
4229 -S "replayed record" \
4230 -C "record from another epoch" \
4231 -S "record from another epoch" \
4232 -C "discarding invalid record" \
4233 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004234 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004235 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004236 -c "HTTP/1.0 200 OK"
4237
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004238not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004239run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004240 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004241 "$P_SRV dtls=1 debug_level=2" \
4242 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004243 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004244 -c "replayed record" \
4245 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004246 -c "discarding invalid record" \
4247 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004248 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004249 -s "Extra-header:" \
4250 -c "HTTP/1.0 200 OK"
4251
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004252run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4253 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004254 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4255 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004256 0 \
4257 -c "replayed record" \
4258 -S "replayed record" \
4259 -c "discarding invalid record" \
4260 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004261 -c "resend" \
4262 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004263 -s "Extra-header:" \
4264 -c "HTTP/1.0 200 OK"
4265
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004266run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004267 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004268 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004269 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004270 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004271 -c "discarding invalid record (mac)" \
4272 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004273 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004274 -c "HTTP/1.0 200 OK" \
4275 -S "too many records with bad MAC" \
4276 -S "Verification of the message MAC failed"
4277
4278run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4279 -p "$P_PXY bad_ad=1" \
4280 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4281 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4282 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004283 -C "discarding invalid record (mac)" \
4284 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004285 -S "Extra-header:" \
4286 -C "HTTP/1.0 200 OK" \
4287 -s "too many records with bad MAC" \
4288 -s "Verification of the message MAC failed"
4289
4290run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4291 -p "$P_PXY bad_ad=1" \
4292 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4293 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4294 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004295 -c "discarding invalid record (mac)" \
4296 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004297 -s "Extra-header:" \
4298 -c "HTTP/1.0 200 OK" \
4299 -S "too many records with bad MAC" \
4300 -S "Verification of the message MAC failed"
4301
4302run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4303 -p "$P_PXY bad_ad=1" \
4304 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4305 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4306 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004307 -c "discarding invalid record (mac)" \
4308 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004309 -s "Extra-header:" \
4310 -c "HTTP/1.0 200 OK" \
4311 -s "too many records with bad MAC" \
4312 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004313
4314run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004315 -p "$P_PXY delay_ccs=1" \
4316 "$P_SRV dtls=1 debug_level=1" \
4317 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004318 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004319 -c "record from another epoch" \
4320 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004321 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004322 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004323 -s "Extra-header:" \
4324 -c "HTTP/1.0 200 OK"
4325
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004326# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004327
Janos Follath74537a62016-09-02 13:45:28 +01004328client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004329run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004330 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004331 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4332 psk=abc123" \
4333 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004334 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4335 0 \
4336 -s "Extra-header:" \
4337 -c "HTTP/1.0 200 OK"
4338
Janos Follath74537a62016-09-02 13:45:28 +01004339client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004340run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4341 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004342 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4343 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004344 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4345 0 \
4346 -s "Extra-header:" \
4347 -c "HTTP/1.0 200 OK"
4348
Janos Follath74537a62016-09-02 13:45:28 +01004349client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004350run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4351 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004352 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4353 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004354 0 \
4355 -s "Extra-header:" \
4356 -c "HTTP/1.0 200 OK"
4357
Janos Follath74537a62016-09-02 13:45:28 +01004358client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004359run_test "DTLS proxy: 3d, FS, client auth" \
4360 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004361 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4362 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004363 0 \
4364 -s "Extra-header:" \
4365 -c "HTTP/1.0 200 OK"
4366
Janos Follath74537a62016-09-02 13:45:28 +01004367client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004368run_test "DTLS proxy: 3d, FS, ticket" \
4369 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004370 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4371 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004372 0 \
4373 -s "Extra-header:" \
4374 -c "HTTP/1.0 200 OK"
4375
Janos Follath74537a62016-09-02 13:45:28 +01004376client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004377run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4378 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004379 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4380 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004381 0 \
4382 -s "Extra-header:" \
4383 -c "HTTP/1.0 200 OK"
4384
Janos Follath74537a62016-09-02 13:45:28 +01004385client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004386run_test "DTLS proxy: 3d, max handshake, nbio" \
4387 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004388 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4389 auth_mode=required" \
4390 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004391 0 \
4392 -s "Extra-header:" \
4393 -c "HTTP/1.0 200 OK"
4394
Janos Follath74537a62016-09-02 13:45:28 +01004395client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004396run_test "DTLS proxy: 3d, min handshake, resumption" \
4397 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4398 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4399 psk=abc123 debug_level=3" \
4400 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4401 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4402 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4403 0 \
4404 -s "a session has been resumed" \
4405 -c "a session has been resumed" \
4406 -s "Extra-header:" \
4407 -c "HTTP/1.0 200 OK"
4408
Janos Follath74537a62016-09-02 13:45:28 +01004409client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004410run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4411 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4412 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4413 psk=abc123 debug_level=3 nbio=2" \
4414 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4415 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4416 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4417 0 \
4418 -s "a session has been resumed" \
4419 -c "a session has been resumed" \
4420 -s "Extra-header:" \
4421 -c "HTTP/1.0 200 OK"
4422
Janos Follath74537a62016-09-02 13:45:28 +01004423client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004424requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004425run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004426 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004427 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4428 psk=abc123 renegotiation=1 debug_level=2" \
4429 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4430 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004431 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4432 0 \
4433 -c "=> renegotiate" \
4434 -s "=> renegotiate" \
4435 -s "Extra-header:" \
4436 -c "HTTP/1.0 200 OK"
4437
Janos Follath74537a62016-09-02 13:45:28 +01004438client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004439requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004440run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4441 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004442 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4443 psk=abc123 renegotiation=1 debug_level=2" \
4444 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4445 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004446 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4447 0 \
4448 -c "=> renegotiate" \
4449 -s "=> renegotiate" \
4450 -s "Extra-header:" \
4451 -c "HTTP/1.0 200 OK"
4452
Janos Follath74537a62016-09-02 13:45:28 +01004453client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004454requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004455run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004456 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004457 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004458 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004459 debug_level=2" \
4460 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004461 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004462 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4463 0 \
4464 -c "=> renegotiate" \
4465 -s "=> renegotiate" \
4466 -s "Extra-header:" \
4467 -c "HTTP/1.0 200 OK"
4468
Janos Follath74537a62016-09-02 13:45:28 +01004469client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004470requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004471run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004472 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004473 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004474 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004475 debug_level=2 nbio=2" \
4476 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004477 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004478 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4479 0 \
4480 -c "=> renegotiate" \
4481 -s "=> renegotiate" \
4482 -s "Extra-header:" \
4483 -c "HTTP/1.0 200 OK"
4484
Janos Follath74537a62016-09-02 13:45:28 +01004485client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004486not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004487run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004488 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4489 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004490 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004491 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004492 -c "HTTP/1.0 200 OK"
4493
Janos Follath74537a62016-09-02 13:45:28 +01004494client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004495not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004496run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4497 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4498 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004499 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004500 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004501 -c "HTTP/1.0 200 OK"
4502
Janos Follath74537a62016-09-02 13:45:28 +01004503client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004504not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004505run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4506 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4507 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004508 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004509 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004510 -c "HTTP/1.0 200 OK"
4511
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004512requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004513client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004514not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004515run_test "DTLS proxy: 3d, gnutls server" \
4516 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4517 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004518 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004519 0 \
4520 -s "Extra-header:" \
4521 -c "Extra-header:"
4522
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004523requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004524client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004525not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004526run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4527 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4528 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004529 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004530 0 \
4531 -s "Extra-header:" \
4532 -c "Extra-header:"
4533
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004534requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004535client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004536not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004537run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4538 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4539 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004540 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004541 0 \
4542 -s "Extra-header:" \
4543 -c "Extra-header:"
4544
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004545# Final report
4546
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004547echo "------------------------------------------------------------------------"
4548
4549if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004550 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004551else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004552 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004553fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004554PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004555echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004556
4557exit $FAILS