blob: d3d1589a90401d6531cd5f6062428c82e8355e20 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200125# skip next test if the flag is enabled in config.h
126requires_config_disabled() {
127 if grep "^#define $1" $CONFIG_H > /dev/null; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200132# skip next test if OpenSSL doesn't support FALLBACK_SCSV
133requires_openssl_with_fallback_scsv() {
134 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
135 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
136 then
137 OPENSSL_HAS_FBSCSV="YES"
138 else
139 OPENSSL_HAS_FBSCSV="NO"
140 fi
141 fi
142 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
143 SKIP_NEXT="YES"
144 fi
145}
146
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200147# skip next test if GnuTLS isn't available
148requires_gnutls() {
149 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200150 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151 GNUTLS_AVAILABLE="YES"
152 else
153 GNUTLS_AVAILABLE="NO"
154 fi
155 fi
156 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200161# skip next test if IPv6 isn't available on this host
162requires_ipv6() {
163 if [ -z "${HAS_IPV6:-}" ]; then
164 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
165 SRV_PID=$!
166 sleep 1
167 kill $SRV_PID >/dev/null 2>&1
168 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
169 HAS_IPV6="NO"
170 else
171 HAS_IPV6="YES"
172 fi
173 rm -r $SRV_OUT
174 fi
175
176 if [ "$HAS_IPV6" = "NO" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200181# skip the next test if valgrind is in use
182not_with_valgrind() {
183 if [ "$MEMCHECK" -gt 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Paul Bakker362689d2016-05-13 10:33:25 +0100188# skip the next test if valgrind is NOT in use
189only_with_valgrind() {
190 if [ "$MEMCHECK" -eq 0 ]; then
191 SKIP_NEXT="YES"
192 fi
193}
194
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200195# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100196client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200197 CLI_DELAY_FACTOR=$1
198}
199
Janos Follath74537a62016-09-02 13:45:28 +0100200# wait for the given seconds after the client finished in the next test
201server_needs_more_time() {
202 SRV_DELAY_SECONDS=$1
203}
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205# print_name <name>
206print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100207 TESTS=$(( $TESTS + 1 ))
208 LINE=""
209
210 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
211 LINE="$TESTS "
212 fi
213
214 LINE="$LINE$1"
215 printf "$LINE "
216 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100217 for i in `seq 1 $LEN`; do printf '.'; done
218 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100220}
221
222# fail <message>
223fail() {
224 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100225 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200227 mv $SRV_OUT o-srv-${TESTS}.log
228 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if [ -n "$PXY_CMD" ]; then
230 mv $PXY_OUT o-pxy-${TESTS}.log
231 fi
232 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100233
Azim Khan03da1212018-03-29 11:04:20 +0100234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot -o "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200235 echo " ! server output:"
236 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200237 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200238 echo " ! client output:"
239 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200240 if [ -n "$PXY_CMD" ]; then
241 echo " ! ========================================================"
242 echo " ! proxy output:"
243 cat o-pxy-${TESTS}.log
244 fi
245 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200246 fi
247
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200248 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249}
250
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251# is_polar <cmd_line>
252is_polar() {
253 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
254}
255
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200256# openssl s_server doesn't have -www with DTLS
257check_osrv_dtls() {
258 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
259 NEEDS_INPUT=1
260 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
261 else
262 NEEDS_INPUT=0
263 fi
264}
265
266# provide input to commands that need it
267provide_input() {
268 if [ $NEEDS_INPUT -eq 0 ]; then
269 return
270 fi
271
272 while true; do
273 echo "HTTP/1.0 200 OK"
274 sleep 1
275 done
276}
277
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100278# has_mem_err <log_file_name>
279has_mem_err() {
280 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
281 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
282 then
283 return 1 # false: does not have errors
284 else
285 return 0 # true: has errors
286 fi
287}
288
Gilles Peskine418b5362017-12-14 18:58:42 +0100289# Wait for process $2 to be listening on port $1
290if type lsof >/dev/null 2>/dev/null; then
291 wait_server_start() {
292 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200293 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100294 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200295 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100296 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200297 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100298 # Make a tight loop, server normally takes less than 1s to start.
299 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
300 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
301 echo "SERVERSTART TIMEOUT"
302 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
303 break
304 fi
305 # Linux and *BSD support decimal arguments to sleep. On other
306 # OSes this may be a tight loop.
307 sleep 0.1 2>/dev/null || true
308 done
309 }
310else
Gilles Peskine7163a6a2018-06-29 15:48:13 +0200311 echo "Warning: lsof not available, wait_server_start = sleep"
Gilles Peskine418b5362017-12-14 18:58:42 +0100312 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200313 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100314 }
315fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200316
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100317# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100318# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100319# acceptable bounds
320check_server_hello_time() {
321 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100322 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100323 # Get the Unix timestamp for now
324 CUR_TIME=$(date +'%s')
325 THRESHOLD_IN_SECS=300
326
327 # Check if the ServerHello time was printed
328 if [ -z "$SERVER_HELLO_TIME" ]; then
329 return 1
330 fi
331
332 # Check the time in ServerHello is within acceptable bounds
333 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
334 # The time in ServerHello is at least 5 minutes before now
335 return 1
336 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100337 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100338 return 1
339 else
340 return 0
341 fi
342}
343
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200344# wait for client to terminate and set CLI_EXIT
345# must be called right after starting the client
346wait_client_done() {
347 CLI_PID=$!
348
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200349 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
350 CLI_DELAY_FACTOR=1
351
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200352 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200353 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200354
355 wait $CLI_PID
356 CLI_EXIT=$?
357
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200358 kill $DOG_PID >/dev/null 2>&1
359 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200360
361 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100362
363 sleep $SRV_DELAY_SECONDS
364 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200365}
366
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200367# check if the given command uses dtls and sets global variable DTLS
368detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200369 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200370 DTLS=1
371 else
372 DTLS=0
373 fi
374}
375
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200376# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100377# Options: -s pattern pattern that must be present in server output
378# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100379# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100380# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100381# -S pattern pattern that must be absent in server output
382# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100383# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100384# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100385run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100386 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200387 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100388
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100389 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
390 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200391 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100392 return
393 fi
394
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100396
Paul Bakkerb7584a52016-05-10 10:50:43 +0100397 # Do we only run numbered tests?
398 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
399 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
400 else
401 SKIP_NEXT="YES"
402 fi
403
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200404 # should we skip?
405 if [ "X$SKIP_NEXT" = "XYES" ]; then
406 SKIP_NEXT="NO"
407 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200408 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200409 return
410 fi
411
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200412 # does this test use a proxy?
413 if [ "X$1" = "X-p" ]; then
414 PXY_CMD="$2"
415 shift 2
416 else
417 PXY_CMD=""
418 fi
419
420 # get commands and client output
421 SRV_CMD="$1"
422 CLI_CMD="$2"
423 CLI_EXPECT="$3"
424 shift 3
425
426 # fix client port
427 if [ -n "$PXY_CMD" ]; then
428 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
429 else
430 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
431 fi
432
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200433 # update DTLS variable
434 detect_dtls "$SRV_CMD"
435
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100436 # prepend valgrind to our commands if active
437 if [ "$MEMCHECK" -gt 0 ]; then
438 if is_polar "$SRV_CMD"; then
439 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
440 fi
441 if is_polar "$CLI_CMD"; then
442 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
443 fi
444 fi
445
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200446 TIMES_LEFT=2
447 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200448 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200449
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200450 # run the commands
451 if [ -n "$PXY_CMD" ]; then
452 echo "$PXY_CMD" > $PXY_OUT
453 $PXY_CMD >> $PXY_OUT 2>&1 &
454 PXY_PID=$!
455 # assume proxy starts faster than server
456 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200457
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200458 check_osrv_dtls
459 echo "$SRV_CMD" > $SRV_OUT
460 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
461 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100462 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200463
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200464 echo "$CLI_CMD" > $CLI_OUT
465 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
466 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100467
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200468 # terminate the server (and the proxy)
469 kill $SRV_PID
470 wait $SRV_PID
471 if [ -n "$PXY_CMD" ]; then
472 kill $PXY_PID >/dev/null 2>&1
473 wait $PXY_PID
474 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100475
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200476 # retry only on timeouts
477 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
478 printf "RETRY "
479 else
480 TIMES_LEFT=0
481 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200482 done
483
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100484 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200485 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100486 # expected client exit to incorrectly succeed in case of catastrophic
487 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100488 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200489 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100490 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100491 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100492 return
493 fi
494 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100495 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200496 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100497 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100498 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100499 return
500 fi
501 fi
502
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100503 # check server exit code
504 if [ $? != 0 ]; then
505 fail "server fail"
506 return
507 fi
508
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100509 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100510 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
511 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100512 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200513 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100514 return
515 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100516
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100517 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200518 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100519 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100520 while [ $# -gt 0 ]
521 do
522 case $1 in
523 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100524 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100525 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100526 return
527 fi
528 ;;
529
530 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100531 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100532 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100533 return
534 fi
535 ;;
536
537 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100538 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100539 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100540 return
541 fi
542 ;;
543
544 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100545 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100546 fail "pattern '$2' MUST NOT be present in the Client output"
547 return
548 fi
549 ;;
550
551 # The filtering in the following two options (-u and -U) do the following
552 # - ignore valgrind output
553 # - filter out everything but lines right after the pattern occurances
554 # - keep one of each non-unique line
555 # - count how many lines remain
556 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
557 # if there were no duplicates.
558 "-U")
559 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
560 fail "lines following pattern '$2' must be unique in Server output"
561 return
562 fi
563 ;;
564
565 "-u")
566 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
567 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100568 return
569 fi
570 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100571 "-F")
572 if ! $2 "$SRV_OUT"; then
573 fail "function call to '$2' failed on Server output"
574 return
575 fi
576 ;;
577 "-f")
578 if ! $2 "$CLI_OUT"; then
579 fail "function call to '$2' failed on Client output"
580 return
581 fi
582 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100583
584 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200585 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100586 exit 1
587 esac
588 shift 2
589 done
590
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100591 # check valgrind's results
592 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200593 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100594 fail "Server has memory errors"
595 return
596 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200597 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100598 fail "Client has memory errors"
599 return
600 fi
601 fi
602
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100603 # if we're here, everything is ok
604 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100605 if [ "$PRESERVE_LOGS" -gt 0 ]; then
606 mv $SRV_OUT o-srv-${TESTS}.log
607 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Beckerdc6c0e42018-08-20 12:21:35 +0100608 if [ -n "$PXY_CMD" ]; then
609 mv $PXY_OUT o-pxy-${TESTS}.log
610 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100611 fi
612
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200613 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100614}
615
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100616cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200618 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
619 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
620 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
621 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100622 exit 1
623}
624
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100625#
626# MAIN
627#
628
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000629if cd $( dirname $0 ); then :; else
630 echo "cd $( dirname $0 ) failed" >&2
631 exit 1
632fi
633
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100634get_options "$@"
635
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100636# sanity checks, avoid an avalanche of errors
637if [ ! -x "$P_SRV" ]; then
638 echo "Command '$P_SRV' is not an executable file"
639 exit 1
640fi
641if [ ! -x "$P_CLI" ]; then
642 echo "Command '$P_CLI' is not an executable file"
643 exit 1
644fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200645if [ ! -x "$P_PXY" ]; then
646 echo "Command '$P_PXY' is not an executable file"
647 exit 1
648fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100649if [ "$MEMCHECK" -gt 0 ]; then
650 if which valgrind >/dev/null 2>&1; then :; else
651 echo "Memcheck not possible. Valgrind not found"
652 exit 1
653 fi
654fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100655if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
656 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100657 exit 1
658fi
659
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200660# used by watchdog
661MAIN_PID="$$"
662
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100663# We use somewhat arbitrary delays for tests:
664# - how long do we wait for the server to start (when lsof not available)?
665# - how long do we allow for the client to finish?
666# (not to check performance, just to avoid waiting indefinitely)
667# Things are slower with valgrind, so give extra time here.
668#
669# Note: without lsof, there is a trade-off between the running time of this
670# script and the risk of spurious errors because we didn't wait long enough.
671# The watchdog delay on the other hand doesn't affect normal running time of
672# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200673if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100674 START_DELAY=6
675 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200676else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100677 START_DELAY=2
678 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200679fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100680
681# some particular tests need more time:
682# - for the client, we multiply the usual watchdog limit by a factor
683# - for the server, we sleep for a number of seconds after the client exits
684# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200685CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100686SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200687
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200688# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000689# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200690P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
691P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100692P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200693O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200694O_CLI="$O_CLI -connect localhost:+SRV_PORT"
695G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000696G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200697
Gilles Peskine62469d92017-05-10 10:13:59 +0200698# Allow SHA-1, because many of our test certificates use it
699P_SRV="$P_SRV allow_sha1=1"
700P_CLI="$P_CLI allow_sha1=1"
701
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200702# Also pick a unique name for intermediate files
703SRV_OUT="srv_out.$$"
704CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200705PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200706SESSION="session.$$"
707
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200708SKIP_NEXT="NO"
709
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100710trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100711
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200712# Basic test
713
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200714# Checks that:
715# - things work with all ciphersuites active (used with config-full in all.sh)
716# - the expected (highest security) parameters are selected
717# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200718run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200719 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200720 "$P_CLI" \
721 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200722 -s "Protocol is TLSv1.2" \
723 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
724 -s "client hello v3, signature_algorithm ext: 6" \
725 -s "ECDHE curve: secp521r1" \
726 -S "error" \
727 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200728
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000729run_test "Default, DTLS" \
730 "$P_SRV dtls=1" \
731 "$P_CLI dtls=1" \
732 0 \
733 -s "Protocol is DTLSv1.2" \
734 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
735
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100736# Test current time in ServerHello
737requires_config_enabled MBEDTLS_HAVE_TIME
738run_test "Default, ServerHello contains gmt_unix_time" \
739 "$P_SRV debug_level=3" \
740 "$P_CLI debug_level=3" \
741 0 \
742 -s "Protocol is TLSv1.2" \
743 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
744 -s "client hello v3, signature_algorithm ext: 6" \
745 -s "ECDHE curve: secp521r1" \
746 -S "error" \
747 -C "error" \
748 -f "check_server_hello_time" \
749 -F "check_server_hello_time"
750
Simon Butcher8e004102016-10-14 00:48:33 +0100751# Test for uniqueness of IVs in AEAD ciphersuites
752run_test "Unique IV in GCM" \
753 "$P_SRV exchanges=20 debug_level=4" \
754 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
755 0 \
756 -u "IV used" \
757 -U "IV used"
758
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100759# Tests for rc4 option
760
Simon Butchera410af52016-05-19 22:12:18 +0100761requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100762run_test "RC4: server disabled, client enabled" \
763 "$P_SRV" \
764 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
765 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100766 -s "SSL - The server has no ciphersuites in common"
767
Simon Butchera410af52016-05-19 22:12:18 +0100768requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100769run_test "RC4: server half, client enabled" \
770 "$P_SRV arc4=1" \
771 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
772 1 \
773 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100774
775run_test "RC4: server enabled, client disabled" \
776 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
777 "$P_CLI" \
778 1 \
779 -s "SSL - The server has no ciphersuites in common"
780
781run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100782 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100783 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
784 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100785 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100786 -S "SSL - The server has no ciphersuites in common"
787
Hanno Becker3a333a52018-08-17 09:54:10 +0100788# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
789
790requires_gnutls
791requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
792run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
793 "$G_SRV"\
794 "$P_CLI force_version=tls1_1" \
795 0
796
797requires_gnutls
798requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
799run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
800 "$G_SRV"\
801 "$P_CLI force_version=tls1" \
802 0
803
Gilles Peskinebc70a182017-05-09 15:59:24 +0200804# Tests for SHA-1 support
805
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200806requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200807run_test "SHA-1 forbidden by default in server certificate" \
808 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
809 "$P_CLI debug_level=2 allow_sha1=0" \
810 1 \
811 -c "The certificate is signed with an unacceptable hash"
812
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200813requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
814run_test "SHA-1 forbidden by default in server certificate" \
815 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
816 "$P_CLI debug_level=2 allow_sha1=0" \
817 0
818
Gilles Peskinebc70a182017-05-09 15:59:24 +0200819run_test "SHA-1 explicitly allowed in server certificate" \
820 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
821 "$P_CLI allow_sha1=1" \
822 0
823
824run_test "SHA-256 allowed by default in server certificate" \
825 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
826 "$P_CLI allow_sha1=0" \
827 0
828
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200829requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200830run_test "SHA-1 forbidden by default in client certificate" \
831 "$P_SRV auth_mode=required allow_sha1=0" \
832 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
833 1 \
834 -s "The certificate is signed with an unacceptable hash"
835
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200836requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
837run_test "SHA-1 forbidden by default in client certificate" \
838 "$P_SRV auth_mode=required allow_sha1=0" \
839 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
840 0
841
Gilles Peskinebc70a182017-05-09 15:59:24 +0200842run_test "SHA-1 explicitly allowed in client certificate" \
843 "$P_SRV auth_mode=required allow_sha1=1" \
844 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
845 0
846
847run_test "SHA-256 allowed by default in client certificate" \
848 "$P_SRV auth_mode=required allow_sha1=0" \
849 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
850 0
851
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100852# Tests for Truncated HMAC extension
853
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100854run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200855 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100856 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100857 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000858 -s "dumping 'expected mac' (20 bytes)" \
859 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100860
Hanno Becker32c55012017-11-10 08:42:54 +0000861requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100862run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200863 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000864 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100865 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000866 -s "dumping 'expected mac' (20 bytes)" \
867 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100868
Hanno Becker32c55012017-11-10 08:42:54 +0000869requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100870run_test "Truncated HMAC: client enabled, server default" \
871 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000872 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100873 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000874 -s "dumping 'expected mac' (20 bytes)" \
875 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100876
Hanno Becker32c55012017-11-10 08:42:54 +0000877requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100878run_test "Truncated HMAC: client enabled, server disabled" \
879 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000880 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100881 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000882 -s "dumping 'expected mac' (20 bytes)" \
883 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100884
Hanno Becker32c55012017-11-10 08:42:54 +0000885requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000886run_test "Truncated HMAC: client disabled, server enabled" \
887 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000888 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000889 0 \
890 -s "dumping 'expected mac' (20 bytes)" \
891 -S "dumping 'expected mac' (10 bytes)"
892
893requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100894run_test "Truncated HMAC: client enabled, server enabled" \
895 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000896 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100897 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000898 -S "dumping 'expected mac' (20 bytes)" \
899 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100900
Hanno Becker4c4f4102017-11-10 09:16:05 +0000901run_test "Truncated HMAC, DTLS: client default, server default" \
902 "$P_SRV dtls=1 debug_level=4" \
903 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
904 0 \
905 -s "dumping 'expected mac' (20 bytes)" \
906 -S "dumping 'expected mac' (10 bytes)"
907
908requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
909run_test "Truncated HMAC, DTLS: client disabled, server default" \
910 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000911 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000912 0 \
913 -s "dumping 'expected mac' (20 bytes)" \
914 -S "dumping 'expected mac' (10 bytes)"
915
916requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
917run_test "Truncated HMAC, DTLS: client enabled, server default" \
918 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000919 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000920 0 \
921 -s "dumping 'expected mac' (20 bytes)" \
922 -S "dumping 'expected mac' (10 bytes)"
923
924requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
925run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
926 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000927 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000928 0 \
929 -s "dumping 'expected mac' (20 bytes)" \
930 -S "dumping 'expected mac' (10 bytes)"
931
932requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
933run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
934 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000935 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000936 0 \
937 -s "dumping 'expected mac' (20 bytes)" \
938 -S "dumping 'expected mac' (10 bytes)"
939
940requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
941run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
942 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000943 "$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 +0100944 0 \
945 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100946 -s "dumping 'expected mac' (10 bytes)"
947
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100948# Tests for Encrypt-then-MAC extension
949
950run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100951 "$P_SRV debug_level=3 \
952 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100953 "$P_CLI debug_level=3" \
954 0 \
955 -c "client hello, adding encrypt_then_mac extension" \
956 -s "found encrypt then mac extension" \
957 -s "server hello, adding encrypt then mac extension" \
958 -c "found encrypt_then_mac extension" \
959 -c "using encrypt then mac" \
960 -s "using encrypt then mac"
961
962run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100963 "$P_SRV debug_level=3 etm=0 \
964 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100965 "$P_CLI debug_level=3 etm=1" \
966 0 \
967 -c "client hello, adding encrypt_then_mac extension" \
968 -s "found encrypt then mac extension" \
969 -S "server hello, adding encrypt then mac extension" \
970 -C "found encrypt_then_mac extension" \
971 -C "using encrypt then mac" \
972 -S "using encrypt then mac"
973
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100974run_test "Encrypt then MAC: client enabled, aead cipher" \
975 "$P_SRV debug_level=3 etm=1 \
976 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
977 "$P_CLI debug_level=3 etm=1" \
978 0 \
979 -c "client hello, adding encrypt_then_mac extension" \
980 -s "found encrypt then mac extension" \
981 -S "server hello, adding encrypt then mac extension" \
982 -C "found encrypt_then_mac extension" \
983 -C "using encrypt then mac" \
984 -S "using encrypt then mac"
985
986run_test "Encrypt then MAC: client enabled, stream cipher" \
987 "$P_SRV debug_level=3 etm=1 \
988 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100989 "$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 +0100990 0 \
991 -c "client hello, adding encrypt_then_mac extension" \
992 -s "found encrypt then mac extension" \
993 -S "server hello, adding encrypt then mac extension" \
994 -C "found encrypt_then_mac extension" \
995 -C "using encrypt then mac" \
996 -S "using encrypt then mac"
997
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100998run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100999 "$P_SRV debug_level=3 etm=1 \
1000 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001001 "$P_CLI debug_level=3 etm=0" \
1002 0 \
1003 -C "client hello, adding encrypt_then_mac extension" \
1004 -S "found encrypt then mac extension" \
1005 -S "server hello, adding encrypt then mac extension" \
1006 -C "found encrypt_then_mac extension" \
1007 -C "using encrypt then mac" \
1008 -S "using encrypt then mac"
1009
Janos Follathe2681a42016-03-07 15:57:05 +00001010requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001011run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001012 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001013 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001014 "$P_CLI debug_level=3 force_version=ssl3" \
1015 0 \
1016 -C "client hello, adding encrypt_then_mac extension" \
1017 -S "found encrypt then mac extension" \
1018 -S "server hello, adding encrypt then mac extension" \
1019 -C "found encrypt_then_mac extension" \
1020 -C "using encrypt then mac" \
1021 -S "using encrypt then mac"
1022
Janos Follathe2681a42016-03-07 15:57:05 +00001023requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001024run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001025 "$P_SRV debug_level=3 force_version=ssl3 \
1026 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001027 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001028 0 \
1029 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001030 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001031 -S "server hello, adding encrypt then mac extension" \
1032 -C "found encrypt_then_mac extension" \
1033 -C "using encrypt then mac" \
1034 -S "using encrypt then mac"
1035
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001036# Tests for Extended Master Secret extension
1037
1038run_test "Extended Master Secret: default" \
1039 "$P_SRV debug_level=3" \
1040 "$P_CLI debug_level=3" \
1041 0 \
1042 -c "client hello, adding extended_master_secret extension" \
1043 -s "found extended master secret extension" \
1044 -s "server hello, adding extended master secret extension" \
1045 -c "found extended_master_secret extension" \
1046 -c "using extended master secret" \
1047 -s "using extended master secret"
1048
1049run_test "Extended Master Secret: client enabled, server disabled" \
1050 "$P_SRV debug_level=3 extended_ms=0" \
1051 "$P_CLI debug_level=3 extended_ms=1" \
1052 0 \
1053 -c "client hello, adding extended_master_secret extension" \
1054 -s "found extended master secret extension" \
1055 -S "server hello, adding extended master secret extension" \
1056 -C "found extended_master_secret extension" \
1057 -C "using extended master secret" \
1058 -S "using extended master secret"
1059
1060run_test "Extended Master Secret: client disabled, server enabled" \
1061 "$P_SRV debug_level=3 extended_ms=1" \
1062 "$P_CLI debug_level=3 extended_ms=0" \
1063 0 \
1064 -C "client hello, adding extended_master_secret extension" \
1065 -S "found extended master secret extension" \
1066 -S "server hello, adding extended master secret extension" \
1067 -C "found extended_master_secret extension" \
1068 -C "using extended master secret" \
1069 -S "using extended master secret"
1070
Janos Follathe2681a42016-03-07 15:57:05 +00001071requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001072run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001073 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001074 "$P_CLI debug_level=3 force_version=ssl3" \
1075 0 \
1076 -C "client hello, adding extended_master_secret extension" \
1077 -S "found extended master secret extension" \
1078 -S "server hello, adding extended master secret extension" \
1079 -C "found extended_master_secret extension" \
1080 -C "using extended master secret" \
1081 -S "using extended master secret"
1082
Janos Follathe2681a42016-03-07 15:57:05 +00001083requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001084run_test "Extended Master Secret: client enabled, server SSLv3" \
1085 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001086 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001087 0 \
1088 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001089 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001090 -S "server hello, adding extended master secret extension" \
1091 -C "found extended_master_secret extension" \
1092 -C "using extended master secret" \
1093 -S "using extended master secret"
1094
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001095# Tests for FALLBACK_SCSV
1096
1097run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001098 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001099 "$P_CLI debug_level=3 force_version=tls1_1" \
1100 0 \
1101 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001102 -S "received FALLBACK_SCSV" \
1103 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001104 -C "is a fatal alert message (msg 86)"
1105
1106run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001107 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001108 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1109 0 \
1110 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001111 -S "received FALLBACK_SCSV" \
1112 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001113 -C "is a fatal alert message (msg 86)"
1114
1115run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001116 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001117 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001118 1 \
1119 -c "adding FALLBACK_SCSV" \
1120 -s "received FALLBACK_SCSV" \
1121 -s "inapropriate fallback" \
1122 -c "is a fatal alert message (msg 86)"
1123
1124run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001125 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001126 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001127 0 \
1128 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001129 -s "received FALLBACK_SCSV" \
1130 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001131 -C "is a fatal alert message (msg 86)"
1132
1133requires_openssl_with_fallback_scsv
1134run_test "Fallback SCSV: default, openssl server" \
1135 "$O_SRV" \
1136 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1137 0 \
1138 -C "adding FALLBACK_SCSV" \
1139 -C "is a fatal alert message (msg 86)"
1140
1141requires_openssl_with_fallback_scsv
1142run_test "Fallback SCSV: enabled, openssl server" \
1143 "$O_SRV" \
1144 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1145 1 \
1146 -c "adding FALLBACK_SCSV" \
1147 -c "is a fatal alert message (msg 86)"
1148
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001149requires_openssl_with_fallback_scsv
1150run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001151 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001152 "$O_CLI -tls1_1" \
1153 0 \
1154 -S "received FALLBACK_SCSV" \
1155 -S "inapropriate fallback"
1156
1157requires_openssl_with_fallback_scsv
1158run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001159 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001160 "$O_CLI -tls1_1 -fallback_scsv" \
1161 1 \
1162 -s "received FALLBACK_SCSV" \
1163 -s "inapropriate fallback"
1164
1165requires_openssl_with_fallback_scsv
1166run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001167 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001168 "$O_CLI -fallback_scsv" \
1169 0 \
1170 -s "received FALLBACK_SCSV" \
1171 -S "inapropriate fallback"
1172
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001173# Test sending and receiving empty application data records
1174
1175run_test "Encrypt then MAC: empty application data record" \
1176 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1177 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1178 0 \
1179 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1180 -s "dumping 'input payload after decrypt' (0 bytes)" \
1181 -c "0 bytes written in 1 fragments"
1182
1183run_test "Default, no Encrypt then MAC: empty application data record" \
1184 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1185 "$P_CLI auth_mode=none etm=0 request_size=0" \
1186 0 \
1187 -s "dumping 'input payload after decrypt' (0 bytes)" \
1188 -c "0 bytes written in 1 fragments"
1189
1190run_test "Encrypt then MAC, DTLS: empty application data record" \
1191 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1192 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1193 0 \
1194 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1195 -s "dumping 'input payload after decrypt' (0 bytes)" \
1196 -c "0 bytes written in 1 fragments"
1197
1198run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
1199 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1200 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1201 0 \
1202 -s "dumping 'input payload after decrypt' (0 bytes)" \
1203 -c "0 bytes written in 1 fragments"
1204
Gilles Peskined50177f2017-05-16 17:53:03 +02001205## ClientHello generated with
1206## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1207## then manually twiddling the ciphersuite list.
1208## The ClientHello content is spelled out below as a hex string as
1209## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1210## The expected response is an inappropriate_fallback alert.
1211requires_openssl_with_fallback_scsv
1212run_test "Fallback SCSV: beginning of list" \
1213 "$P_SRV debug_level=2" \
1214 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1215 0 \
1216 -s "received FALLBACK_SCSV" \
1217 -s "inapropriate fallback"
1218
1219requires_openssl_with_fallback_scsv
1220run_test "Fallback SCSV: end of list" \
1221 "$P_SRV debug_level=2" \
1222 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1223 0 \
1224 -s "received FALLBACK_SCSV" \
1225 -s "inapropriate fallback"
1226
1227## Here the expected response is a valid ServerHello prefix, up to the random.
1228requires_openssl_with_fallback_scsv
1229run_test "Fallback SCSV: not in list" \
1230 "$P_SRV debug_level=2" \
1231 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1232 0 \
1233 -S "received FALLBACK_SCSV" \
1234 -S "inapropriate fallback"
1235
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001236# Tests for CBC 1/n-1 record splitting
1237
1238run_test "CBC Record splitting: TLS 1.2, no splitting" \
1239 "$P_SRV" \
1240 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1241 request_size=123 force_version=tls1_2" \
1242 0 \
1243 -s "Read from client: 123 bytes read" \
1244 -S "Read from client: 1 bytes read" \
1245 -S "122 bytes read"
1246
1247run_test "CBC Record splitting: TLS 1.1, no splitting" \
1248 "$P_SRV" \
1249 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1250 request_size=123 force_version=tls1_1" \
1251 0 \
1252 -s "Read from client: 123 bytes read" \
1253 -S "Read from client: 1 bytes read" \
1254 -S "122 bytes read"
1255
1256run_test "CBC Record splitting: TLS 1.0, splitting" \
1257 "$P_SRV" \
1258 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1259 request_size=123 force_version=tls1" \
1260 0 \
1261 -S "Read from client: 123 bytes read" \
1262 -s "Read from client: 1 bytes read" \
1263 -s "122 bytes read"
1264
Janos Follathe2681a42016-03-07 15:57:05 +00001265requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001266run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001267 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001268 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1269 request_size=123 force_version=ssl3" \
1270 0 \
1271 -S "Read from client: 123 bytes read" \
1272 -s "Read from client: 1 bytes read" \
1273 -s "122 bytes read"
1274
1275run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001276 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001277 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1278 request_size=123 force_version=tls1" \
1279 0 \
1280 -s "Read from client: 123 bytes read" \
1281 -S "Read from client: 1 bytes read" \
1282 -S "122 bytes read"
1283
1284run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1285 "$P_SRV" \
1286 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1287 request_size=123 force_version=tls1 recsplit=0" \
1288 0 \
1289 -s "Read from client: 123 bytes read" \
1290 -S "Read from client: 1 bytes read" \
1291 -S "122 bytes read"
1292
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001293run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1294 "$P_SRV nbio=2" \
1295 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1296 request_size=123 force_version=tls1" \
1297 0 \
1298 -S "Read from client: 123 bytes read" \
1299 -s "Read from client: 1 bytes read" \
1300 -s "122 bytes read"
1301
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001302# Tests for Session Tickets
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001305 "$P_SRV debug_level=3 tickets=1" \
1306 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001307 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001308 -c "client hello, adding session ticket extension" \
1309 -s "found session ticket extension" \
1310 -s "server hello, adding session ticket extension" \
1311 -c "found session_ticket extension" \
1312 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001313 -S "session successfully restored from cache" \
1314 -s "session successfully restored from ticket" \
1315 -s "a session has been resumed" \
1316 -c "a session has been resumed"
1317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001318run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001319 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1320 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001321 0 \
1322 -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" \
1327 -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 tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1334 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001335 0 \
1336 -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" \
1341 -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"
1345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001347 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001348 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001349 0 \
1350 -c "client hello, adding session ticket extension" \
1351 -c "found session_ticket extension" \
1352 -c "parse new session ticket" \
1353 -c "a session has been resumed"
1354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001355run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001356 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001357 "( $O_CLI -sess_out $SESSION; \
1358 $O_CLI -sess_in $SESSION; \
1359 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001360 0 \
1361 -s "found session ticket extension" \
1362 -s "server hello, adding session ticket extension" \
1363 -S "session successfully restored from cache" \
1364 -s "session successfully restored from ticket" \
1365 -s "a session has been resumed"
1366
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001367# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001369run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001370 "$P_SRV debug_level=3 tickets=0" \
1371 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001372 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001373 -c "client hello, adding session ticket extension" \
1374 -s "found session ticket extension" \
1375 -S "server hello, adding session ticket extension" \
1376 -C "found session_ticket extension" \
1377 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001378 -s "session successfully restored from cache" \
1379 -S "session successfully restored from ticket" \
1380 -s "a session has been resumed" \
1381 -c "a session has been resumed"
1382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001383run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001384 "$P_SRV debug_level=3 tickets=1" \
1385 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001386 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001387 -C "client hello, adding session ticket extension" \
1388 -S "found session ticket extension" \
1389 -S "server hello, adding session ticket extension" \
1390 -C "found session_ticket extension" \
1391 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001392 -s "session successfully restored from cache" \
1393 -S "session successfully restored from ticket" \
1394 -s "a session has been resumed" \
1395 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001397run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001398 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1399 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001400 0 \
1401 -S "session successfully restored from cache" \
1402 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001403 -S "a session has been resumed" \
1404 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001406run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001407 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1408 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001409 0 \
1410 -s "session successfully restored from cache" \
1411 -S "session successfully restored from ticket" \
1412 -s "a session has been resumed" \
1413 -c "a session has been resumed"
1414
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001415run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001416 "$P_SRV debug_level=3 tickets=0" \
1417 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001418 0 \
1419 -s "session successfully restored from cache" \
1420 -S "session successfully restored from ticket" \
1421 -s "a session has been resumed" \
1422 -c "a session has been resumed"
1423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001424run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001425 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1426 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001427 0 \
1428 -S "session successfully restored from cache" \
1429 -S "session successfully restored from ticket" \
1430 -S "a session has been resumed" \
1431 -C "a session has been resumed"
1432
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001433run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001434 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1435 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001436 0 \
1437 -s "session successfully restored from cache" \
1438 -S "session successfully restored from ticket" \
1439 -s "a session has been resumed" \
1440 -c "a session has been resumed"
1441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001442run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001443 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001444 "( $O_CLI -sess_out $SESSION; \
1445 $O_CLI -sess_in $SESSION; \
1446 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001447 0 \
1448 -s "found session ticket extension" \
1449 -S "server hello, adding session ticket extension" \
1450 -s "session successfully restored from cache" \
1451 -S "session successfully restored from ticket" \
1452 -s "a session has been resumed"
1453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001454run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001455 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001456 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001457 0 \
1458 -C "found session_ticket extension" \
1459 -C "parse new session ticket" \
1460 -c "a session has been resumed"
1461
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001462# Tests for Max Fragment Length extension
1463
Hanno Becker6428f8d2017-09-22 16:58:50 +01001464MAX_CONTENT_LEN_EXPECT='16384'
1465MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1466
1467if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1468 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1469 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1470 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1471 printf "\n"
1472 printf "The tests assume this value and if it changes, the tests in this\n"
1473 printf "script should also be adjusted.\n"
1474 printf "\n"
1475
1476 exit 1
1477fi
1478
Hanno Becker4aed27e2017-09-18 15:00:34 +01001479requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001480run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001481 "$P_SRV debug_level=3" \
1482 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001483 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001484 -c "Maximum fragment length is 16384" \
1485 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001486 -C "client hello, adding max_fragment_length extension" \
1487 -S "found max fragment length extension" \
1488 -S "server hello, max_fragment_length extension" \
1489 -C "found max_fragment_length extension"
1490
Hanno Becker4aed27e2017-09-18 15:00:34 +01001491requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001492run_test "Max fragment length: enabled, default, larger message" \
1493 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001494 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001495 0 \
1496 -c "Maximum fragment length is 16384" \
1497 -s "Maximum fragment length is 16384" \
1498 -C "client hello, adding max_fragment_length extension" \
1499 -S "found max fragment length extension" \
1500 -S "server hello, max_fragment_length extension" \
1501 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001502 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001503 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001504 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001505
1506requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1507run_test "Max fragment length, DTLS: enabled, default, larger message" \
1508 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001509 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001510 1 \
1511 -c "Maximum fragment length is 16384" \
1512 -s "Maximum fragment length is 16384" \
1513 -C "client hello, adding max_fragment_length extension" \
1514 -S "found max fragment length extension" \
1515 -S "server hello, max_fragment_length extension" \
1516 -C "found max_fragment_length extension" \
1517 -c "fragment larger than.*maximum "
1518
1519requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1520run_test "Max fragment length: disabled, larger message" \
1521 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001522 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001523 0 \
1524 -C "Maximum fragment length is 16384" \
1525 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001526 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001527 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001528 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001529
1530requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1531run_test "Max fragment length DTLS: disabled, larger message" \
1532 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001533 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001534 1 \
1535 -C "Maximum fragment length is 16384" \
1536 -S "Maximum fragment length is 16384" \
1537 -c "fragment larger than.*maximum "
1538
1539requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001540run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001541 "$P_SRV debug_level=3" \
1542 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001543 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001544 -c "Maximum fragment length is 4096" \
1545 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001546 -c "client hello, adding max_fragment_length extension" \
1547 -s "found max fragment length extension" \
1548 -s "server hello, max_fragment_length extension" \
1549 -c "found max_fragment_length extension"
1550
Hanno Becker4aed27e2017-09-18 15:00:34 +01001551requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001552run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001553 "$P_SRV debug_level=3 max_frag_len=4096" \
1554 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001555 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001556 -c "Maximum fragment length is 16384" \
1557 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001558 -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"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001562
Hanno Becker4aed27e2017-09-18 15:00:34 +01001563requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001564requires_gnutls
1565run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001566 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001567 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001568 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001569 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001570 -c "client hello, adding max_fragment_length extension" \
1571 -c "found max_fragment_length extension"
1572
Hanno Becker4aed27e2017-09-18 15:00:34 +01001573requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001574run_test "Max fragment length: client, message just fits" \
1575 "$P_SRV debug_level=3" \
1576 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1577 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001578 -c "Maximum fragment length is 2048" \
1579 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001580 -c "client hello, adding max_fragment_length extension" \
1581 -s "found max fragment length extension" \
1582 -s "server hello, max_fragment_length extension" \
1583 -c "found max_fragment_length extension" \
1584 -c "2048 bytes written in 1 fragments" \
1585 -s "2048 bytes read"
1586
Hanno Becker4aed27e2017-09-18 15:00:34 +01001587requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001588run_test "Max fragment length: client, larger message" \
1589 "$P_SRV debug_level=3" \
1590 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1591 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001592 -c "Maximum fragment length is 2048" \
1593 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001594 -c "client hello, adding max_fragment_length extension" \
1595 -s "found max fragment length extension" \
1596 -s "server hello, max_fragment_length extension" \
1597 -c "found max_fragment_length extension" \
1598 -c "2345 bytes written in 2 fragments" \
1599 -s "2048 bytes read" \
1600 -s "297 bytes read"
1601
Hanno Becker4aed27e2017-09-18 15:00:34 +01001602requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001603run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001604 "$P_SRV debug_level=3 dtls=1" \
1605 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1606 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001607 -c "Maximum fragment length is 2048" \
1608 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001609 -c "client hello, adding max_fragment_length extension" \
1610 -s "found max fragment length extension" \
1611 -s "server hello, max_fragment_length extension" \
1612 -c "found max_fragment_length extension" \
1613 -c "fragment larger than.*maximum"
1614
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001615# Tests for renegotiation
1616
Hanno Becker6a243642017-10-12 15:18:45 +01001617# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001618run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001619 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001620 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001621 0 \
1622 -C "client hello, adding renegotiation extension" \
1623 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1624 -S "found renegotiation extension" \
1625 -s "server hello, secure renegotiation extension" \
1626 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001627 -C "=> renegotiate" \
1628 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001629 -S "write hello request"
1630
Hanno Becker6a243642017-10-12 15:18:45 +01001631requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001632run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001633 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001634 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001635 0 \
1636 -c "client hello, adding renegotiation extension" \
1637 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1638 -s "found renegotiation extension" \
1639 -s "server hello, secure renegotiation extension" \
1640 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001641 -c "=> renegotiate" \
1642 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001643 -S "write hello request"
1644
Hanno Becker6a243642017-10-12 15:18:45 +01001645requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001646run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001647 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001648 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001649 0 \
1650 -c "client hello, adding renegotiation extension" \
1651 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1652 -s "found renegotiation extension" \
1653 -s "server hello, secure renegotiation extension" \
1654 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001655 -c "=> renegotiate" \
1656 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001657 -s "write hello request"
1658
Janos Follathb0f148c2017-10-05 12:29:42 +01001659# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1660# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1661# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001662requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001663run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1664 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1665 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1666 0 \
1667 -c "client hello, adding renegotiation extension" \
1668 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1669 -s "found renegotiation extension" \
1670 -s "server hello, secure renegotiation extension" \
1671 -c "found renegotiation extension" \
1672 -c "=> renegotiate" \
1673 -s "=> renegotiate" \
1674 -S "write hello request" \
1675 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1676
1677# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1678# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1679# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001680requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001681run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1682 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1683 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1684 0 \
1685 -c "client hello, adding renegotiation extension" \
1686 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1687 -s "found renegotiation extension" \
1688 -s "server hello, secure renegotiation extension" \
1689 -c "found renegotiation extension" \
1690 -c "=> renegotiate" \
1691 -s "=> renegotiate" \
1692 -s "write hello request" \
1693 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1694
Hanno Becker6a243642017-10-12 15:18:45 +01001695requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001696run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001697 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001698 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001699 0 \
1700 -c "client hello, adding renegotiation extension" \
1701 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1702 -s "found renegotiation extension" \
1703 -s "server hello, secure renegotiation extension" \
1704 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001705 -c "=> renegotiate" \
1706 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001707 -s "write hello request"
1708
Hanno Becker6a243642017-10-12 15:18:45 +01001709requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001710run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001711 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001712 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001713 1 \
1714 -c "client hello, adding renegotiation extension" \
1715 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1716 -S "found renegotiation extension" \
1717 -s "server hello, secure renegotiation extension" \
1718 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001719 -c "=> renegotiate" \
1720 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001721 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001722 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001723 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001724
Hanno Becker6a243642017-10-12 15:18:45 +01001725requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001727 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001728 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001729 0 \
1730 -C "client hello, adding renegotiation extension" \
1731 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1732 -S "found renegotiation extension" \
1733 -s "server hello, secure renegotiation extension" \
1734 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001735 -C "=> renegotiate" \
1736 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001737 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001738 -S "SSL - An unexpected message was received from our peer" \
1739 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001740
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-rejected, not enforced" \
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=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001745 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
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
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001758# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001759requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001760run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001761 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001762 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001763 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001764 0 \
1765 -C "client hello, adding renegotiation extension" \
1766 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1767 -S "found renegotiation extension" \
1768 -s "server hello, secure renegotiation extension" \
1769 -c "found renegotiation extension" \
1770 -C "=> renegotiate" \
1771 -S "=> renegotiate" \
1772 -s "write hello request" \
1773 -S "SSL - An unexpected message was received from our peer" \
1774 -S "failed"
1775
Hanno Becker6a243642017-10-12 15:18:45 +01001776requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001778 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001779 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001780 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001781 0 \
1782 -C "client hello, adding renegotiation extension" \
1783 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1784 -S "found renegotiation extension" \
1785 -s "server hello, secure renegotiation extension" \
1786 -c "found renegotiation extension" \
1787 -C "=> renegotiate" \
1788 -S "=> renegotiate" \
1789 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001790 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001791
Hanno Becker6a243642017-10-12 15:18:45 +01001792requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001793run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001794 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001795 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001796 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001797 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 -c "=> renegotiate" \
1804 -s "=> renegotiate" \
1805 -s "write hello request" \
1806 -S "SSL - An unexpected message was received from our peer" \
1807 -S "failed"
1808
Hanno Becker6a243642017-10-12 15:18:45 +01001809requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001810run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001811 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001812 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1813 0 \
1814 -C "client hello, adding renegotiation extension" \
1815 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1816 -S "found renegotiation extension" \
1817 -s "server hello, secure renegotiation extension" \
1818 -c "found renegotiation extension" \
1819 -S "record counter limit reached: renegotiate" \
1820 -C "=> renegotiate" \
1821 -S "=> renegotiate" \
1822 -S "write hello request" \
1823 -S "SSL - An unexpected message was received from our peer" \
1824 -S "failed"
1825
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001826# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001827requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001828run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001829 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001830 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001831 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 -s "record counter limit reached: renegotiate" \
1838 -c "=> renegotiate" \
1839 -s "=> renegotiate" \
1840 -s "write hello request" \
1841 -S "SSL - An unexpected message was received from our peer" \
1842 -S "failed"
1843
Hanno Becker6a243642017-10-12 15:18:45 +01001844requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001845run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001846 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001847 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001848 0 \
1849 -c "client hello, adding renegotiation extension" \
1850 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1851 -s "found renegotiation extension" \
1852 -s "server hello, secure renegotiation extension" \
1853 -c "found renegotiation extension" \
1854 -s "record counter limit reached: renegotiate" \
1855 -c "=> renegotiate" \
1856 -s "=> renegotiate" \
1857 -s "write hello request" \
1858 -S "SSL - An unexpected message was received from our peer" \
1859 -S "failed"
1860
Hanno Becker6a243642017-10-12 15:18:45 +01001861requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001862run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001863 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001864 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1865 0 \
1866 -C "client hello, adding renegotiation extension" \
1867 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1868 -S "found renegotiation extension" \
1869 -s "server hello, secure renegotiation extension" \
1870 -c "found renegotiation extension" \
1871 -S "record counter limit reached: renegotiate" \
1872 -C "=> renegotiate" \
1873 -S "=> renegotiate" \
1874 -S "write hello request" \
1875 -S "SSL - An unexpected message was received from our peer" \
1876 -S "failed"
1877
Hanno Becker6a243642017-10-12 15:18:45 +01001878requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001879run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001880 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001881 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001882 0 \
1883 -c "client hello, adding renegotiation extension" \
1884 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1885 -s "found renegotiation extension" \
1886 -s "server hello, secure renegotiation extension" \
1887 -c "found renegotiation extension" \
1888 -c "=> renegotiate" \
1889 -s "=> renegotiate" \
1890 -S "write hello request"
1891
Hanno Becker6a243642017-10-12 15:18:45 +01001892requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001893run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001894 "$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 +02001895 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001896 0 \
1897 -c "client hello, adding renegotiation extension" \
1898 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1899 -s "found renegotiation extension" \
1900 -s "server hello, secure renegotiation extension" \
1901 -c "found renegotiation extension" \
1902 -c "=> renegotiate" \
1903 -s "=> renegotiate" \
1904 -s "write hello request"
1905
Hanno Becker6a243642017-10-12 15:18:45 +01001906requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001907run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001908 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001909 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001910 0 \
1911 -c "client hello, adding renegotiation extension" \
1912 -c "found renegotiation extension" \
1913 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001914 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001915 -C "error" \
1916 -c "HTTP/1.0 200 [Oo][Kk]"
1917
Paul Bakker539d9722015-02-08 16:18:35 +01001918requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001919requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001920run_test "Renegotiation: gnutls server strict, client-initiated" \
1921 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001922 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001923 0 \
1924 -c "client hello, adding renegotiation extension" \
1925 -c "found renegotiation extension" \
1926 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001927 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001928 -C "error" \
1929 -c "HTTP/1.0 200 [Oo][Kk]"
1930
Paul Bakker539d9722015-02-08 16:18:35 +01001931requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001932requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001933run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1934 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1935 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1936 1 \
1937 -c "client hello, adding renegotiation extension" \
1938 -C "found renegotiation extension" \
1939 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001940 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001941 -c "error" \
1942 -C "HTTP/1.0 200 [Oo][Kk]"
1943
Paul Bakker539d9722015-02-08 16:18:35 +01001944requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001945requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001946run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1947 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1948 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1949 allow_legacy=0" \
1950 1 \
1951 -c "client hello, adding renegotiation extension" \
1952 -C "found renegotiation extension" \
1953 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001954 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001955 -c "error" \
1956 -C "HTTP/1.0 200 [Oo][Kk]"
1957
Paul Bakker539d9722015-02-08 16:18:35 +01001958requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001959requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001960run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1961 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1962 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1963 allow_legacy=1" \
1964 0 \
1965 -c "client hello, adding renegotiation extension" \
1966 -C "found renegotiation extension" \
1967 -c "=> renegotiate" \
1968 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001969 -C "error" \
1970 -c "HTTP/1.0 200 [Oo][Kk]"
1971
Hanno Becker6a243642017-10-12 15:18:45 +01001972requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001973run_test "Renegotiation: DTLS, client-initiated" \
1974 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1975 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1976 0 \
1977 -c "client hello, adding renegotiation extension" \
1978 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1979 -s "found renegotiation extension" \
1980 -s "server hello, secure renegotiation extension" \
1981 -c "found renegotiation extension" \
1982 -c "=> renegotiate" \
1983 -s "=> renegotiate" \
1984 -S "write hello request"
1985
Hanno Becker6a243642017-10-12 15:18:45 +01001986requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001987run_test "Renegotiation: DTLS, server-initiated" \
1988 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001989 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1990 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001991 0 \
1992 -c "client hello, adding renegotiation extension" \
1993 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1994 -s "found renegotiation extension" \
1995 -s "server hello, secure renegotiation extension" \
1996 -c "found renegotiation extension" \
1997 -c "=> renegotiate" \
1998 -s "=> renegotiate" \
1999 -s "write hello request"
2000
Hanno Becker6a243642017-10-12 15:18:45 +01002001requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002002run_test "Renegotiation: DTLS, renego_period overflow" \
2003 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2004 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2005 0 \
2006 -c "client hello, adding renegotiation extension" \
2007 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2008 -s "found renegotiation extension" \
2009 -s "server hello, secure renegotiation extension" \
2010 -s "record counter limit reached: renegotiate" \
2011 -c "=> renegotiate" \
2012 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002013 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002014
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002015requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002016requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002017run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2018 "$G_SRV -u --mtu 4096" \
2019 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2020 0 \
2021 -c "client hello, adding renegotiation extension" \
2022 -c "found renegotiation extension" \
2023 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002024 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002025 -C "error" \
2026 -s "Extra-header:"
2027
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002028# Test for the "secure renegotation" extension only (no actual renegotiation)
2029
Paul Bakker539d9722015-02-08 16:18:35 +01002030requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002031run_test "Renego ext: gnutls server strict, client default" \
2032 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2033 "$P_CLI debug_level=3" \
2034 0 \
2035 -c "found renegotiation extension" \
2036 -C "error" \
2037 -c "HTTP/1.0 200 [Oo][Kk]"
2038
Paul Bakker539d9722015-02-08 16:18:35 +01002039requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002040run_test "Renego ext: gnutls server unsafe, client default" \
2041 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2042 "$P_CLI debug_level=3" \
2043 0 \
2044 -C "found renegotiation extension" \
2045 -C "error" \
2046 -c "HTTP/1.0 200 [Oo][Kk]"
2047
Paul Bakker539d9722015-02-08 16:18:35 +01002048requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002049run_test "Renego ext: gnutls server unsafe, client break legacy" \
2050 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2051 "$P_CLI debug_level=3 allow_legacy=-1" \
2052 1 \
2053 -C "found renegotiation extension" \
2054 -c "error" \
2055 -C "HTTP/1.0 200 [Oo][Kk]"
2056
Paul Bakker539d9722015-02-08 16:18:35 +01002057requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002058run_test "Renego ext: gnutls client strict, server default" \
2059 "$P_SRV debug_level=3" \
2060 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2061 0 \
2062 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2063 -s "server hello, secure renegotiation extension"
2064
Paul Bakker539d9722015-02-08 16:18:35 +01002065requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002066run_test "Renego ext: gnutls client unsafe, server default" \
2067 "$P_SRV debug_level=3" \
2068 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2069 0 \
2070 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2071 -S "server hello, secure renegotiation extension"
2072
Paul Bakker539d9722015-02-08 16:18:35 +01002073requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002074run_test "Renego ext: gnutls client unsafe, server break legacy" \
2075 "$P_SRV debug_level=3 allow_legacy=-1" \
2076 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2077 1 \
2078 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2079 -S "server hello, secure renegotiation extension"
2080
Janos Follath0b242342016-02-17 10:11:21 +00002081# Tests for silently dropping trailing extra bytes in .der certificates
2082
2083requires_gnutls
2084run_test "DER format: no trailing bytes" \
2085 "$P_SRV crt_file=data_files/server5-der0.crt \
2086 key_file=data_files/server5.key" \
2087 "$G_CLI " \
2088 0 \
2089 -c "Handshake was completed" \
2090
2091requires_gnutls
2092run_test "DER format: with a trailing zero byte" \
2093 "$P_SRV crt_file=data_files/server5-der1a.crt \
2094 key_file=data_files/server5.key" \
2095 "$G_CLI " \
2096 0 \
2097 -c "Handshake was completed" \
2098
2099requires_gnutls
2100run_test "DER format: with a trailing random byte" \
2101 "$P_SRV crt_file=data_files/server5-der1b.crt \
2102 key_file=data_files/server5.key" \
2103 "$G_CLI " \
2104 0 \
2105 -c "Handshake was completed" \
2106
2107requires_gnutls
2108run_test "DER format: with 2 trailing random bytes" \
2109 "$P_SRV crt_file=data_files/server5-der2.crt \
2110 key_file=data_files/server5.key" \
2111 "$G_CLI " \
2112 0 \
2113 -c "Handshake was completed" \
2114
2115requires_gnutls
2116run_test "DER format: with 4 trailing random bytes" \
2117 "$P_SRV crt_file=data_files/server5-der4.crt \
2118 key_file=data_files/server5.key" \
2119 "$G_CLI " \
2120 0 \
2121 -c "Handshake was completed" \
2122
2123requires_gnutls
2124run_test "DER format: with 8 trailing random bytes" \
2125 "$P_SRV crt_file=data_files/server5-der8.crt \
2126 key_file=data_files/server5.key" \
2127 "$G_CLI " \
2128 0 \
2129 -c "Handshake was completed" \
2130
2131requires_gnutls
2132run_test "DER format: with 9 trailing random bytes" \
2133 "$P_SRV crt_file=data_files/server5-der9.crt \
2134 key_file=data_files/server5.key" \
2135 "$G_CLI " \
2136 0 \
2137 -c "Handshake was completed" \
2138
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002139# Tests for auth_mode
2140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002141run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002142 "$P_SRV crt_file=data_files/server5-badsign.crt \
2143 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002144 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002145 1 \
2146 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002147 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002148 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002149 -c "X509 - Certificate verification failed"
2150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002151run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002152 "$P_SRV crt_file=data_files/server5-badsign.crt \
2153 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002154 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002155 0 \
2156 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002157 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002158 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002159 -C "X509 - Certificate verification failed"
2160
Hanno Beckere6706e62017-05-15 16:05:15 +01002161run_test "Authentication: server goodcert, client optional, no trusted CA" \
2162 "$P_SRV" \
2163 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2164 0 \
2165 -c "x509_verify_cert() returned" \
2166 -c "! The certificate is not correctly signed by the trusted CA" \
2167 -c "! Certificate verification flags"\
2168 -C "! mbedtls_ssl_handshake returned" \
2169 -C "X509 - Certificate verification failed" \
2170 -C "SSL - No CA Chain is set, but required to operate"
2171
2172run_test "Authentication: server goodcert, client required, no trusted CA" \
2173 "$P_SRV" \
2174 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2175 1 \
2176 -c "x509_verify_cert() returned" \
2177 -c "! The certificate is not correctly signed by the trusted CA" \
2178 -c "! Certificate verification flags"\
2179 -c "! mbedtls_ssl_handshake returned" \
2180 -c "SSL - No CA Chain is set, but required to operate"
2181
2182# The purpose of the next two tests is to test the client's behaviour when receiving a server
2183# certificate with an unsupported elliptic curve. This should usually not happen because
2184# the client informs the server about the supported curves - it does, though, in the
2185# corner case of a static ECDH suite, because the server doesn't check the curve on that
2186# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2187# different means to have the server ignoring the client's supported curve list.
2188
2189requires_config_enabled MBEDTLS_ECP_C
2190run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2191 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2192 crt_file=data_files/server5.ku-ka.crt" \
2193 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2194 1 \
2195 -c "bad certificate (EC key curve)"\
2196 -c "! Certificate verification flags"\
2197 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2198
2199requires_config_enabled MBEDTLS_ECP_C
2200run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2201 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2202 crt_file=data_files/server5.ku-ka.crt" \
2203 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2204 1 \
2205 -c "bad certificate (EC key curve)"\
2206 -c "! Certificate verification flags"\
2207 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002209run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002210 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002211 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002212 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002213 0 \
2214 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002215 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002216 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002217 -C "X509 - Certificate verification failed"
2218
Simon Butcher99000142016-10-13 17:21:01 +01002219run_test "Authentication: client SHA256, server required" \
2220 "$P_SRV auth_mode=required" \
2221 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2222 key_file=data_files/server6.key \
2223 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2224 0 \
2225 -c "Supported Signature Algorithm found: 4," \
2226 -c "Supported Signature Algorithm found: 5,"
2227
2228run_test "Authentication: client SHA384, server required" \
2229 "$P_SRV auth_mode=required" \
2230 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2231 key_file=data_files/server6.key \
2232 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2233 0 \
2234 -c "Supported Signature Algorithm found: 4," \
2235 -c "Supported Signature Algorithm found: 5,"
2236
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002237requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2238run_test "Authentication: client has no cert, server required (SSLv3)" \
2239 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2240 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2241 key_file=data_files/server5.key" \
2242 1 \
2243 -S "skip write certificate request" \
2244 -C "skip parse certificate request" \
2245 -c "got a certificate request" \
2246 -c "got no certificate to send" \
2247 -S "x509_verify_cert() returned" \
2248 -s "client has no certificate" \
2249 -s "! mbedtls_ssl_handshake returned" \
2250 -c "! mbedtls_ssl_handshake returned" \
2251 -s "No client certification received from the client, but required by the authentication mode"
2252
2253run_test "Authentication: client has no cert, server required (TLS)" \
2254 "$P_SRV debug_level=3 auth_mode=required" \
2255 "$P_CLI debug_level=3 crt_file=none \
2256 key_file=data_files/server5.key" \
2257 1 \
2258 -S "skip write certificate request" \
2259 -C "skip parse certificate request" \
2260 -c "got a certificate request" \
2261 -c "= write certificate$" \
2262 -C "skip write certificate$" \
2263 -S "x509_verify_cert() returned" \
2264 -s "client has no certificate" \
2265 -s "! mbedtls_ssl_handshake returned" \
2266 -c "! mbedtls_ssl_handshake returned" \
2267 -s "No client certification received from the client, but required by the authentication mode"
2268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002269run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002270 "$P_SRV debug_level=3 auth_mode=required" \
2271 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002272 key_file=data_files/server5.key" \
2273 1 \
2274 -S "skip write certificate request" \
2275 -C "skip parse certificate request" \
2276 -c "got a certificate request" \
2277 -C "skip write certificate" \
2278 -C "skip write certificate verify" \
2279 -S "skip parse certificate verify" \
2280 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002281 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002282 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002283 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002284 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002285 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002286# We don't check that the client receives the alert because it might
2287# detect that its write end of the connection is closed and abort
2288# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002289
Janos Follath89baba22017-04-10 14:34:35 +01002290run_test "Authentication: client cert not trusted, server required" \
2291 "$P_SRV debug_level=3 auth_mode=required" \
2292 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2293 key_file=data_files/server5.key" \
2294 1 \
2295 -S "skip write certificate request" \
2296 -C "skip parse certificate request" \
2297 -c "got a certificate request" \
2298 -C "skip write certificate" \
2299 -C "skip write certificate verify" \
2300 -S "skip parse certificate verify" \
2301 -s "x509_verify_cert() returned" \
2302 -s "! The certificate is not correctly signed by the trusted CA" \
2303 -s "! mbedtls_ssl_handshake returned" \
2304 -c "! mbedtls_ssl_handshake returned" \
2305 -s "X509 - Certificate verification failed"
2306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002307run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002308 "$P_SRV debug_level=3 auth_mode=optional" \
2309 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002310 key_file=data_files/server5.key" \
2311 0 \
2312 -S "skip write certificate request" \
2313 -C "skip parse certificate request" \
2314 -c "got a certificate request" \
2315 -C "skip write certificate" \
2316 -C "skip write certificate verify" \
2317 -S "skip parse certificate verify" \
2318 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002319 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002320 -S "! mbedtls_ssl_handshake returned" \
2321 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002322 -S "X509 - Certificate verification failed"
2323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002324run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002325 "$P_SRV debug_level=3 auth_mode=none" \
2326 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002327 key_file=data_files/server5.key" \
2328 0 \
2329 -s "skip write certificate request" \
2330 -C "skip parse certificate request" \
2331 -c "got no certificate request" \
2332 -c "skip write certificate" \
2333 -c "skip write certificate verify" \
2334 -s "skip parse certificate verify" \
2335 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002336 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002337 -S "! mbedtls_ssl_handshake returned" \
2338 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002339 -S "X509 - Certificate verification failed"
2340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002341run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002342 "$P_SRV debug_level=3 auth_mode=optional" \
2343 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002344 0 \
2345 -S "skip write certificate request" \
2346 -C "skip parse certificate request" \
2347 -c "got a certificate request" \
2348 -C "skip write certificate$" \
2349 -C "got no certificate to send" \
2350 -S "SSLv3 client has no certificate" \
2351 -c "skip write certificate verify" \
2352 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002353 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002354 -S "! mbedtls_ssl_handshake returned" \
2355 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002356 -S "X509 - Certificate verification failed"
2357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002358run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002359 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002360 "$O_CLI" \
2361 0 \
2362 -S "skip write certificate request" \
2363 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002364 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002365 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002366 -S "X509 - Certificate verification failed"
2367
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002368run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002369 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002370 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002371 0 \
2372 -C "skip parse certificate request" \
2373 -c "got a certificate request" \
2374 -C "skip write certificate$" \
2375 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002376 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002377
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002378run_test "Authentication: client no cert, openssl server required" \
2379 "$O_SRV -Verify 10" \
2380 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2381 1 \
2382 -C "skip parse certificate request" \
2383 -c "got a certificate request" \
2384 -C "skip write certificate$" \
2385 -c "skip write certificate verify" \
2386 -c "! mbedtls_ssl_handshake returned"
2387
Janos Follathe2681a42016-03-07 15:57:05 +00002388requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002389run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002390 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002391 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002392 0 \
2393 -S "skip write certificate request" \
2394 -C "skip parse certificate request" \
2395 -c "got a certificate request" \
2396 -C "skip write certificate$" \
2397 -c "skip write certificate verify" \
2398 -c "got no certificate to send" \
2399 -s "SSLv3 client has no certificate" \
2400 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002401 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002402 -S "! mbedtls_ssl_handshake returned" \
2403 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002404 -S "X509 - Certificate verification failed"
2405
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002406# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2407# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002408
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002409MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002410MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002411
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002412if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002413 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002414 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002415 printf "test value of ${MAX_IM_CA}. \n"
2416 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002417 printf "The tests assume this value and if it changes, the tests in this\n"
2418 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002419 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002420
2421 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002422fi
2423
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002424run_test "Authentication: server max_int chain, client default" \
2425 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2426 key_file=data_files/dir-maxpath/09.key" \
2427 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2428 0 \
2429 -C "X509 - A fatal error occured"
2430
2431run_test "Authentication: server max_int+1 chain, client default" \
2432 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2433 key_file=data_files/dir-maxpath/10.key" \
2434 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2435 1 \
2436 -c "X509 - A fatal error occured"
2437
2438run_test "Authentication: server max_int+1 chain, client optional" \
2439 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2440 key_file=data_files/dir-maxpath/10.key" \
2441 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2442 auth_mode=optional" \
2443 1 \
2444 -c "X509 - A fatal error occured"
2445
2446run_test "Authentication: server max_int+1 chain, client none" \
2447 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2448 key_file=data_files/dir-maxpath/10.key" \
2449 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2450 auth_mode=none" \
2451 0 \
2452 -C "X509 - A fatal error occured"
2453
2454run_test "Authentication: client max_int+1 chain, server default" \
2455 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2456 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2457 key_file=data_files/dir-maxpath/10.key" \
2458 0 \
2459 -S "X509 - A fatal error occured"
2460
2461run_test "Authentication: client max_int+1 chain, server optional" \
2462 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2463 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2464 key_file=data_files/dir-maxpath/10.key" \
2465 1 \
2466 -s "X509 - A fatal error occured"
2467
2468run_test "Authentication: client max_int+1 chain, server required" \
2469 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2470 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2471 key_file=data_files/dir-maxpath/10.key" \
2472 1 \
2473 -s "X509 - A fatal error occured"
2474
2475run_test "Authentication: client max_int chain, server required" \
2476 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2477 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2478 key_file=data_files/dir-maxpath/09.key" \
2479 0 \
2480 -S "X509 - A fatal error occured"
2481
Janos Follath89baba22017-04-10 14:34:35 +01002482# Tests for CA list in CertificateRequest messages
2483
2484run_test "Authentication: send CA list in CertificateRequest (default)" \
2485 "$P_SRV debug_level=3 auth_mode=required" \
2486 "$P_CLI crt_file=data_files/server6.crt \
2487 key_file=data_files/server6.key" \
2488 0 \
2489 -s "requested DN"
2490
2491run_test "Authentication: do not send CA list in CertificateRequest" \
2492 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2493 "$P_CLI crt_file=data_files/server6.crt \
2494 key_file=data_files/server6.key" \
2495 0 \
2496 -S "requested DN"
2497
2498run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2499 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2500 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2501 key_file=data_files/server5.key" \
2502 1 \
2503 -S "requested DN" \
2504 -s "x509_verify_cert() returned" \
2505 -s "! The certificate is not correctly signed by the trusted CA" \
2506 -s "! mbedtls_ssl_handshake returned" \
2507 -c "! mbedtls_ssl_handshake returned" \
2508 -s "X509 - Certificate verification failed"
2509
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002510# Tests for certificate selection based on SHA verson
2511
2512run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2513 "$P_SRV crt_file=data_files/server5.crt \
2514 key_file=data_files/server5.key \
2515 crt_file2=data_files/server5-sha1.crt \
2516 key_file2=data_files/server5.key" \
2517 "$P_CLI force_version=tls1_2" \
2518 0 \
2519 -c "signed using.*ECDSA with SHA256" \
2520 -C "signed using.*ECDSA with SHA1"
2521
2522run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2523 "$P_SRV crt_file=data_files/server5.crt \
2524 key_file=data_files/server5.key \
2525 crt_file2=data_files/server5-sha1.crt \
2526 key_file2=data_files/server5.key" \
2527 "$P_CLI force_version=tls1_1" \
2528 0 \
2529 -C "signed using.*ECDSA with SHA256" \
2530 -c "signed using.*ECDSA with SHA1"
2531
2532run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2533 "$P_SRV crt_file=data_files/server5.crt \
2534 key_file=data_files/server5.key \
2535 crt_file2=data_files/server5-sha1.crt \
2536 key_file2=data_files/server5.key" \
2537 "$P_CLI force_version=tls1" \
2538 0 \
2539 -C "signed using.*ECDSA with SHA256" \
2540 -c "signed using.*ECDSA with SHA1"
2541
2542run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2543 "$P_SRV crt_file=data_files/server5.crt \
2544 key_file=data_files/server5.key \
2545 crt_file2=data_files/server6.crt \
2546 key_file2=data_files/server6.key" \
2547 "$P_CLI force_version=tls1_1" \
2548 0 \
2549 -c "serial number.*09" \
2550 -c "signed using.*ECDSA with SHA256" \
2551 -C "signed using.*ECDSA with SHA1"
2552
2553run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2554 "$P_SRV crt_file=data_files/server6.crt \
2555 key_file=data_files/server6.key \
2556 crt_file2=data_files/server5.crt \
2557 key_file2=data_files/server5.key" \
2558 "$P_CLI force_version=tls1_1" \
2559 0 \
2560 -c "serial number.*0A" \
2561 -c "signed using.*ECDSA with SHA256" \
2562 -C "signed using.*ECDSA with SHA1"
2563
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002564# tests for SNI
2565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002566run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002567 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002568 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002569 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002570 0 \
2571 -S "parse ServerName extension" \
2572 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2573 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002576 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002577 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002578 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 +02002579 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002580 0 \
2581 -s "parse ServerName extension" \
2582 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2583 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002585run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002586 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002587 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002588 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 +02002589 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002590 0 \
2591 -s "parse ServerName extension" \
2592 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2593 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002595run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002596 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002597 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002598 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 +02002599 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002600 1 \
2601 -s "parse ServerName extension" \
2602 -s "ssl_sni_wrapper() returned" \
2603 -s "mbedtls_ssl_handshake returned" \
2604 -c "mbedtls_ssl_handshake returned" \
2605 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002606
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002607run_test "SNI: client auth no override: optional" \
2608 "$P_SRV debug_level=3 auth_mode=optional \
2609 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2610 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2611 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002612 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002613 -S "skip write certificate request" \
2614 -C "skip parse certificate request" \
2615 -c "got a certificate request" \
2616 -C "skip write certificate" \
2617 -C "skip write certificate verify" \
2618 -S "skip parse certificate verify"
2619
2620run_test "SNI: client auth override: none -> optional" \
2621 "$P_SRV debug_level=3 auth_mode=none \
2622 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2623 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2624 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002625 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002626 -S "skip write certificate request" \
2627 -C "skip parse certificate request" \
2628 -c "got a certificate request" \
2629 -C "skip write certificate" \
2630 -C "skip write certificate verify" \
2631 -S "skip parse certificate verify"
2632
2633run_test "SNI: client auth override: optional -> none" \
2634 "$P_SRV debug_level=3 auth_mode=optional \
2635 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2636 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2637 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002638 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002639 -s "skip write certificate request" \
2640 -C "skip parse certificate request" \
2641 -c "got no certificate request" \
2642 -c "skip write certificate" \
2643 -c "skip write certificate verify" \
2644 -s "skip parse certificate verify"
2645
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002646run_test "SNI: CA no override" \
2647 "$P_SRV debug_level=3 auth_mode=optional \
2648 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2649 ca_file=data_files/test-ca.crt \
2650 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2651 "$P_CLI debug_level=3 server_name=localhost \
2652 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2653 1 \
2654 -S "skip write certificate request" \
2655 -C "skip parse certificate request" \
2656 -c "got a certificate request" \
2657 -C "skip write certificate" \
2658 -C "skip write certificate verify" \
2659 -S "skip parse certificate verify" \
2660 -s "x509_verify_cert() returned" \
2661 -s "! The certificate is not correctly signed by the trusted CA" \
2662 -S "The certificate has been revoked (is on a CRL)"
2663
2664run_test "SNI: CA override" \
2665 "$P_SRV debug_level=3 auth_mode=optional \
2666 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2667 ca_file=data_files/test-ca.crt \
2668 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2669 "$P_CLI debug_level=3 server_name=localhost \
2670 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2671 0 \
2672 -S "skip write certificate request" \
2673 -C "skip parse certificate request" \
2674 -c "got a certificate request" \
2675 -C "skip write certificate" \
2676 -C "skip write certificate verify" \
2677 -S "skip parse certificate verify" \
2678 -S "x509_verify_cert() returned" \
2679 -S "! The certificate is not correctly signed by the trusted CA" \
2680 -S "The certificate has been revoked (is on a CRL)"
2681
2682run_test "SNI: CA override with CRL" \
2683 "$P_SRV debug_level=3 auth_mode=optional \
2684 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2685 ca_file=data_files/test-ca.crt \
2686 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2687 "$P_CLI debug_level=3 server_name=localhost \
2688 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2689 1 \
2690 -S "skip write certificate request" \
2691 -C "skip parse certificate request" \
2692 -c "got a certificate request" \
2693 -C "skip write certificate" \
2694 -C "skip write certificate verify" \
2695 -S "skip parse certificate verify" \
2696 -s "x509_verify_cert() returned" \
2697 -S "! The certificate is not correctly signed by the trusted CA" \
2698 -s "The certificate has been revoked (is on a CRL)"
2699
Andres AGe8b07742016-12-07 10:01:30 +00002700# Tests for SNI and DTLS
2701
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002702run_test "SNI: DTLS, no SNI callback" \
2703 "$P_SRV debug_level=3 dtls=1 \
2704 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2705 "$P_CLI server_name=localhost dtls=1" \
2706 0 \
2707 -S "parse ServerName extension" \
2708 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2709 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2710
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002711run_test "SNI: DTLS, matching cert 1" \
Andres AGe8b07742016-12-07 10:01:30 +00002712 "$P_SRV debug_level=3 dtls=1 \
2713 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2714 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2715 "$P_CLI server_name=localhost dtls=1" \
2716 0 \
2717 -s "parse ServerName extension" \
2718 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2719 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2720
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002721run_test "SNI: DTLS, matching cert 2" \
2722 "$P_SRV debug_level=3 dtls=1 \
2723 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2724 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2725 "$P_CLI server_name=polarssl.example dtls=1" \
2726 0 \
2727 -s "parse ServerName extension" \
2728 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2729 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2730
2731run_test "SNI: DTLS, no matching cert" \
2732 "$P_SRV debug_level=3 dtls=1 \
2733 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2734 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2735 "$P_CLI server_name=nonesuch.example dtls=1" \
2736 1 \
2737 -s "parse ServerName extension" \
2738 -s "ssl_sni_wrapper() returned" \
2739 -s "mbedtls_ssl_handshake returned" \
2740 -c "mbedtls_ssl_handshake returned" \
2741 -c "SSL - A fatal alert message was received from our peer"
2742
2743run_test "SNI: DTLS, client auth no override: optional" \
2744 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2745 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2746 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2747 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2748 0 \
2749 -S "skip write certificate request" \
2750 -C "skip parse certificate request" \
2751 -c "got a certificate request" \
2752 -C "skip write certificate" \
2753 -C "skip write certificate verify" \
2754 -S "skip parse certificate verify"
2755
2756run_test "SNI: DTLS, client auth override: none -> optional" \
2757 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2758 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2759 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2760 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2761 0 \
2762 -S "skip write certificate request" \
2763 -C "skip parse certificate request" \
2764 -c "got a certificate request" \
2765 -C "skip write certificate" \
2766 -C "skip write certificate verify" \
2767 -S "skip parse certificate verify"
2768
2769run_test "SNI: DTLS, client auth override: optional -> none" \
2770 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2771 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2772 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2773 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2774 0 \
2775 -s "skip write certificate request" \
2776 -C "skip parse certificate request" \
2777 -c "got no certificate request" \
2778 -c "skip write certificate" \
2779 -c "skip write certificate verify" \
2780 -s "skip parse certificate verify"
2781
2782run_test "SNI: DTLS, CA no override" \
2783 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2784 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2785 ca_file=data_files/test-ca.crt \
2786 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2787 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2788 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2789 1 \
2790 -S "skip write certificate request" \
2791 -C "skip parse certificate request" \
2792 -c "got a certificate request" \
2793 -C "skip write certificate" \
2794 -C "skip write certificate verify" \
2795 -S "skip parse certificate verify" \
2796 -s "x509_verify_cert() returned" \
2797 -s "! The certificate is not correctly signed by the trusted CA" \
2798 -S "The certificate has been revoked (is on a CRL)"
2799
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002800run_test "SNI: DTLS, CA override" \
Andres AGe8b07742016-12-07 10:01:30 +00002801 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2802 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2803 ca_file=data_files/test-ca.crt \
2804 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2805 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2806 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2807 0 \
2808 -S "skip write certificate request" \
2809 -C "skip parse certificate request" \
2810 -c "got a certificate request" \
2811 -C "skip write certificate" \
2812 -C "skip write certificate verify" \
2813 -S "skip parse certificate verify" \
2814 -S "x509_verify_cert() returned" \
2815 -S "! The certificate is not correctly signed by the trusted CA" \
2816 -S "The certificate has been revoked (is on a CRL)"
2817
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002818run_test "SNI: DTLS, CA override with CRL" \
Andres AGe8b07742016-12-07 10:01:30 +00002819 "$P_SRV debug_level=3 auth_mode=optional \
2820 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2821 ca_file=data_files/test-ca.crt \
2822 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2823 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2824 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2825 1 \
2826 -S "skip write certificate request" \
2827 -C "skip parse certificate request" \
2828 -c "got a certificate request" \
2829 -C "skip write certificate" \
2830 -C "skip write certificate verify" \
2831 -S "skip parse certificate verify" \
2832 -s "x509_verify_cert() returned" \
2833 -S "! The certificate is not correctly signed by the trusted CA" \
2834 -s "The certificate has been revoked (is on a CRL)"
2835
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002836# Tests for non-blocking I/O: exercise a variety of handshake flows
2837
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002838run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002839 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2840 "$P_CLI nbio=2 tickets=0" \
2841 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002842 -S "mbedtls_ssl_handshake returned" \
2843 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002844 -c "Read from server: .* bytes read"
2845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002846run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002847 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2848 "$P_CLI nbio=2 tickets=0" \
2849 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002850 -S "mbedtls_ssl_handshake returned" \
2851 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002852 -c "Read from server: .* bytes read"
2853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002854run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002855 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2856 "$P_CLI nbio=2 tickets=1" \
2857 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002858 -S "mbedtls_ssl_handshake returned" \
2859 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002860 -c "Read from server: .* bytes read"
2861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002862run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002863 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2864 "$P_CLI nbio=2 tickets=1" \
2865 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002866 -S "mbedtls_ssl_handshake returned" \
2867 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002868 -c "Read from server: .* bytes read"
2869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002870run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002871 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2872 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2873 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002874 -S "mbedtls_ssl_handshake returned" \
2875 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002876 -c "Read from server: .* bytes read"
2877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002878run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002879 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2880 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2881 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002882 -S "mbedtls_ssl_handshake returned" \
2883 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002884 -c "Read from server: .* bytes read"
2885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002886run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002887 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2888 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2889 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002890 -S "mbedtls_ssl_handshake returned" \
2891 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002892 -c "Read from server: .* bytes read"
2893
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002894# Tests for version negotiation
2895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002896run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002897 "$P_SRV" \
2898 "$P_CLI" \
2899 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002900 -S "mbedtls_ssl_handshake returned" \
2901 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002902 -s "Protocol is TLSv1.2" \
2903 -c "Protocol is TLSv1.2"
2904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002905run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002906 "$P_SRV" \
2907 "$P_CLI max_version=tls1_1" \
2908 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002909 -S "mbedtls_ssl_handshake returned" \
2910 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002911 -s "Protocol is TLSv1.1" \
2912 -c "Protocol is TLSv1.1"
2913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002914run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002915 "$P_SRV max_version=tls1_1" \
2916 "$P_CLI" \
2917 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002918 -S "mbedtls_ssl_handshake returned" \
2919 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002920 -s "Protocol is TLSv1.1" \
2921 -c "Protocol is TLSv1.1"
2922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002923run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002924 "$P_SRV max_version=tls1_1" \
2925 "$P_CLI max_version=tls1_1" \
2926 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002927 -S "mbedtls_ssl_handshake returned" \
2928 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002929 -s "Protocol is TLSv1.1" \
2930 -c "Protocol is TLSv1.1"
2931
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002932run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002933 "$P_SRV min_version=tls1_1" \
2934 "$P_CLI max_version=tls1_1" \
2935 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002936 -S "mbedtls_ssl_handshake returned" \
2937 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002938 -s "Protocol is TLSv1.1" \
2939 -c "Protocol is TLSv1.1"
2940
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002941run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002942 "$P_SRV max_version=tls1_1" \
2943 "$P_CLI min_version=tls1_1" \
2944 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002945 -S "mbedtls_ssl_handshake returned" \
2946 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002947 -s "Protocol is TLSv1.1" \
2948 -c "Protocol is TLSv1.1"
2949
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002950run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002951 "$P_SRV max_version=tls1_1" \
2952 "$P_CLI min_version=tls1_2" \
2953 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002954 -s "mbedtls_ssl_handshake returned" \
2955 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002956 -c "SSL - Handshake protocol not within min/max boundaries"
2957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002958run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002959 "$P_SRV min_version=tls1_2" \
2960 "$P_CLI max_version=tls1_1" \
2961 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002962 -s "mbedtls_ssl_handshake returned" \
2963 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002964 -s "SSL - Handshake protocol not within min/max boundaries"
2965
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002966# Tests for ALPN extension
2967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002968run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002969 "$P_SRV debug_level=3" \
2970 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002971 0 \
2972 -C "client hello, adding alpn extension" \
2973 -S "found alpn extension" \
2974 -C "got an alert message, type: \\[2:120]" \
2975 -S "server hello, adding alpn extension" \
2976 -C "found alpn extension " \
2977 -C "Application Layer Protocol is" \
2978 -S "Application Layer Protocol is"
2979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002980run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002981 "$P_SRV debug_level=3" \
2982 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002983 0 \
2984 -c "client hello, adding alpn extension" \
2985 -s "found alpn extension" \
2986 -C "got an alert message, type: \\[2:120]" \
2987 -S "server hello, adding alpn extension" \
2988 -C "found alpn extension " \
2989 -c "Application Layer Protocol is (none)" \
2990 -S "Application Layer Protocol is"
2991
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002992run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002993 "$P_SRV debug_level=3 alpn=abc,1234" \
2994 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002995 0 \
2996 -C "client hello, adding alpn extension" \
2997 -S "found alpn extension" \
2998 -C "got an alert message, type: \\[2:120]" \
2999 -S "server hello, adding alpn extension" \
3000 -C "found alpn extension " \
3001 -C "Application Layer Protocol is" \
3002 -s "Application Layer Protocol is (none)"
3003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003004run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003005 "$P_SRV debug_level=3 alpn=abc,1234" \
3006 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003007 0 \
3008 -c "client hello, adding alpn extension" \
3009 -s "found alpn extension" \
3010 -C "got an alert message, type: \\[2:120]" \
3011 -s "server hello, adding alpn extension" \
3012 -c "found alpn extension" \
3013 -c "Application Layer Protocol is abc" \
3014 -s "Application Layer Protocol is abc"
3015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003016run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003017 "$P_SRV debug_level=3 alpn=abc,1234" \
3018 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003019 0 \
3020 -c "client hello, adding alpn extension" \
3021 -s "found alpn extension" \
3022 -C "got an alert message, type: \\[2:120]" \
3023 -s "server hello, adding alpn extension" \
3024 -c "found alpn extension" \
3025 -c "Application Layer Protocol is abc" \
3026 -s "Application Layer Protocol is abc"
3027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003028run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003029 "$P_SRV debug_level=3 alpn=abc,1234" \
3030 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003031 0 \
3032 -c "client hello, adding alpn extension" \
3033 -s "found alpn extension" \
3034 -C "got an alert message, type: \\[2:120]" \
3035 -s "server hello, adding alpn extension" \
3036 -c "found alpn extension" \
3037 -c "Application Layer Protocol is 1234" \
3038 -s "Application Layer Protocol is 1234"
3039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003040run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003041 "$P_SRV debug_level=3 alpn=abc,123" \
3042 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003043 1 \
3044 -c "client hello, adding alpn extension" \
3045 -s "found alpn extension" \
3046 -c "got an alert message, type: \\[2:120]" \
3047 -S "server hello, adding alpn extension" \
3048 -C "found alpn extension" \
3049 -C "Application Layer Protocol is 1234" \
3050 -S "Application Layer Protocol is 1234"
3051
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003052
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003053# Tests for keyUsage in leaf certificates, part 1:
3054# server-side certificate/suite selection
3055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003056run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003057 "$P_SRV key_file=data_files/server2.key \
3058 crt_file=data_files/server2.ku-ds.crt" \
3059 "$P_CLI" \
3060 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003061 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003062
3063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003064run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003065 "$P_SRV key_file=data_files/server2.key \
3066 crt_file=data_files/server2.ku-ke.crt" \
3067 "$P_CLI" \
3068 0 \
3069 -c "Ciphersuite is TLS-RSA-WITH-"
3070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003071run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003072 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003073 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003074 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003075 1 \
3076 -C "Ciphersuite is "
3077
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003078run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003079 "$P_SRV key_file=data_files/server5.key \
3080 crt_file=data_files/server5.ku-ds.crt" \
3081 "$P_CLI" \
3082 0 \
3083 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3084
3085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003086run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003087 "$P_SRV key_file=data_files/server5.key \
3088 crt_file=data_files/server5.ku-ka.crt" \
3089 "$P_CLI" \
3090 0 \
3091 -c "Ciphersuite is TLS-ECDH-"
3092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003093run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003094 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003095 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003096 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003097 1 \
3098 -C "Ciphersuite is "
3099
3100# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003101# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003103run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003104 "$O_SRV -key data_files/server2.key \
3105 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003106 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003107 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3108 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003109 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003110 -C "Processing of the Certificate handshake message failed" \
3111 -c "Ciphersuite is TLS-"
3112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003113run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003114 "$O_SRV -key data_files/server2.key \
3115 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003116 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003117 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3118 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003119 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003120 -C "Processing of the Certificate handshake message failed" \
3121 -c "Ciphersuite is TLS-"
3122
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003123run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003124 "$O_SRV -key data_files/server2.key \
3125 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003126 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003127 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3128 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003129 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003130 -C "Processing of the Certificate handshake message failed" \
3131 -c "Ciphersuite is TLS-"
3132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003133run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003134 "$O_SRV -key data_files/server2.key \
3135 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003136 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003137 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3138 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003139 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003140 -c "Processing of the Certificate handshake message failed" \
3141 -C "Ciphersuite is TLS-"
3142
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003143run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3144 "$O_SRV -key data_files/server2.key \
3145 -cert data_files/server2.ku-ke.crt" \
3146 "$P_CLI debug_level=1 auth_mode=optional \
3147 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3148 0 \
3149 -c "bad certificate (usage extensions)" \
3150 -C "Processing of the Certificate handshake message failed" \
3151 -c "Ciphersuite is TLS-" \
3152 -c "! Usage does not match the keyUsage extension"
3153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003154run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003155 "$O_SRV -key data_files/server2.key \
3156 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003157 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003158 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3159 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003160 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003161 -C "Processing of the Certificate handshake message failed" \
3162 -c "Ciphersuite is TLS-"
3163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003164run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003165 "$O_SRV -key data_files/server2.key \
3166 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003167 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003168 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3169 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003170 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003171 -c "Processing of the Certificate handshake message failed" \
3172 -C "Ciphersuite is TLS-"
3173
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003174run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3175 "$O_SRV -key data_files/server2.key \
3176 -cert data_files/server2.ku-ds.crt" \
3177 "$P_CLI debug_level=1 auth_mode=optional \
3178 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3179 0 \
3180 -c "bad certificate (usage extensions)" \
3181 -C "Processing of the Certificate handshake message failed" \
3182 -c "Ciphersuite is TLS-" \
3183 -c "! Usage does not match the keyUsage extension"
3184
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003185# Tests for keyUsage in leaf certificates, part 3:
3186# server-side checking of client cert
3187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003188run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003189 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003190 "$O_CLI -key data_files/server2.key \
3191 -cert data_files/server2.ku-ds.crt" \
3192 0 \
3193 -S "bad certificate (usage extensions)" \
3194 -S "Processing of the Certificate handshake message failed"
3195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003196run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003197 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003198 "$O_CLI -key data_files/server2.key \
3199 -cert data_files/server2.ku-ke.crt" \
3200 0 \
3201 -s "bad certificate (usage extensions)" \
3202 -S "Processing of the Certificate handshake message failed"
3203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003204run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003205 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003206 "$O_CLI -key data_files/server2.key \
3207 -cert data_files/server2.ku-ke.crt" \
3208 1 \
3209 -s "bad certificate (usage extensions)" \
3210 -s "Processing of the Certificate handshake message failed"
3211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003212run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003213 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003214 "$O_CLI -key data_files/server5.key \
3215 -cert data_files/server5.ku-ds.crt" \
3216 0 \
3217 -S "bad certificate (usage extensions)" \
3218 -S "Processing of the Certificate handshake message failed"
3219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003220run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003221 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003222 "$O_CLI -key data_files/server5.key \
3223 -cert data_files/server5.ku-ka.crt" \
3224 0 \
3225 -s "bad certificate (usage extensions)" \
3226 -S "Processing of the Certificate handshake message failed"
3227
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003228# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3229
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003230run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003231 "$P_SRV key_file=data_files/server5.key \
3232 crt_file=data_files/server5.eku-srv.crt" \
3233 "$P_CLI" \
3234 0
3235
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003236run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003237 "$P_SRV key_file=data_files/server5.key \
3238 crt_file=data_files/server5.eku-srv.crt" \
3239 "$P_CLI" \
3240 0
3241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003242run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003243 "$P_SRV key_file=data_files/server5.key \
3244 crt_file=data_files/server5.eku-cs_any.crt" \
3245 "$P_CLI" \
3246 0
3247
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003248run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003249 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003250 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003251 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003252 1
3253
3254# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003256run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003257 "$O_SRV -key data_files/server5.key \
3258 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003259 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003260 0 \
3261 -C "bad certificate (usage extensions)" \
3262 -C "Processing of the Certificate handshake message failed" \
3263 -c "Ciphersuite is TLS-"
3264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003265run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003266 "$O_SRV -key data_files/server5.key \
3267 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003268 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003269 0 \
3270 -C "bad certificate (usage extensions)" \
3271 -C "Processing of the Certificate handshake message failed" \
3272 -c "Ciphersuite is TLS-"
3273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003274run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003275 "$O_SRV -key data_files/server5.key \
3276 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003277 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003278 0 \
3279 -C "bad certificate (usage extensions)" \
3280 -C "Processing of the Certificate handshake message failed" \
3281 -c "Ciphersuite is TLS-"
3282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003283run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003284 "$O_SRV -key data_files/server5.key \
3285 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003286 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003287 1 \
3288 -c "bad certificate (usage extensions)" \
3289 -c "Processing of the Certificate handshake message failed" \
3290 -C "Ciphersuite is TLS-"
3291
3292# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3293
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003294run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003295 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003296 "$O_CLI -key data_files/server5.key \
3297 -cert data_files/server5.eku-cli.crt" \
3298 0 \
3299 -S "bad certificate (usage extensions)" \
3300 -S "Processing of the Certificate handshake message failed"
3301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003302run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003303 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003304 "$O_CLI -key data_files/server5.key \
3305 -cert data_files/server5.eku-srv_cli.crt" \
3306 0 \
3307 -S "bad certificate (usage extensions)" \
3308 -S "Processing of the Certificate handshake message failed"
3309
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003310run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003311 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003312 "$O_CLI -key data_files/server5.key \
3313 -cert data_files/server5.eku-cs_any.crt" \
3314 0 \
3315 -S "bad certificate (usage extensions)" \
3316 -S "Processing of the Certificate handshake message failed"
3317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003318run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003319 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003320 "$O_CLI -key data_files/server5.key \
3321 -cert data_files/server5.eku-cs.crt" \
3322 0 \
3323 -s "bad certificate (usage extensions)" \
3324 -S "Processing of the Certificate handshake message failed"
3325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003326run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003327 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003328 "$O_CLI -key data_files/server5.key \
3329 -cert data_files/server5.eku-cs.crt" \
3330 1 \
3331 -s "bad certificate (usage extensions)" \
3332 -s "Processing of the Certificate handshake message failed"
3333
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003334# Tests for DHM parameters loading
3335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003336run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003337 "$P_SRV" \
3338 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3339 debug_level=3" \
3340 0 \
3341 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003342 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003343
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003344run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003345 "$P_SRV dhm_file=data_files/dhparams.pem" \
3346 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3347 debug_level=3" \
3348 0 \
3349 -c "value of 'DHM: P ' (1024 bits)" \
3350 -c "value of 'DHM: G ' (2 bits)"
3351
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003352# Tests for DHM client-side size checking
3353
3354run_test "DHM size: server default, client default, OK" \
3355 "$P_SRV" \
3356 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3357 debug_level=1" \
3358 0 \
3359 -C "DHM prime too short:"
3360
3361run_test "DHM size: server default, client 2048, OK" \
3362 "$P_SRV" \
3363 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3364 debug_level=1 dhmlen=2048" \
3365 0 \
3366 -C "DHM prime too short:"
3367
3368run_test "DHM size: server 1024, client default, OK" \
3369 "$P_SRV dhm_file=data_files/dhparams.pem" \
3370 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3371 debug_level=1" \
3372 0 \
3373 -C "DHM prime too short:"
3374
3375run_test "DHM size: server 1000, client default, rejected" \
3376 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3377 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3378 debug_level=1" \
3379 1 \
3380 -c "DHM prime too short:"
3381
3382run_test "DHM size: server default, client 2049, rejected" \
3383 "$P_SRV" \
3384 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3385 debug_level=1 dhmlen=2049" \
3386 1 \
3387 -c "DHM prime too short:"
3388
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003389# Tests for PSK callback
3390
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003391run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003392 "$P_SRV psk=abc123 psk_identity=foo" \
3393 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3394 psk_identity=foo psk=abc123" \
3395 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003396 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003397 -S "SSL - Unknown identity received" \
3398 -S "SSL - Verification of the message MAC failed"
3399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003400run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003401 "$P_SRV" \
3402 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3403 psk_identity=foo psk=abc123" \
3404 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003405 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003406 -S "SSL - Unknown identity received" \
3407 -S "SSL - Verification of the message MAC failed"
3408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003409run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003410 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3411 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3412 psk_identity=foo psk=abc123" \
3413 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003414 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003415 -s "SSL - Unknown identity received" \
3416 -S "SSL - Verification of the message MAC failed"
3417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003418run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003419 "$P_SRV psk_list=abc,dead,def,beef" \
3420 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3421 psk_identity=abc psk=dead" \
3422 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003423 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003424 -S "SSL - Unknown identity received" \
3425 -S "SSL - Verification of the message MAC failed"
3426
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003427run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003428 "$P_SRV psk_list=abc,dead,def,beef" \
3429 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3430 psk_identity=def psk=beef" \
3431 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003432 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003433 -S "SSL - Unknown identity received" \
3434 -S "SSL - Verification of the message MAC failed"
3435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003436run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003437 "$P_SRV psk_list=abc,dead,def,beef" \
3438 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3439 psk_identity=ghi psk=beef" \
3440 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003441 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003442 -s "SSL - Unknown identity received" \
3443 -S "SSL - Verification of the message MAC failed"
3444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003445run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003446 "$P_SRV psk_list=abc,dead,def,beef" \
3447 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3448 psk_identity=abc psk=beef" \
3449 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003450 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003451 -S "SSL - Unknown identity received" \
3452 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003453
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003454# Tests for EC J-PAKE
3455
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003456requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003457run_test "ECJPAKE: client not configured" \
3458 "$P_SRV debug_level=3" \
3459 "$P_CLI debug_level=3" \
3460 0 \
3461 -C "add ciphersuite: c0ff" \
3462 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003463 -S "found ecjpake kkpp extension" \
3464 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003465 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003466 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003467 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003468 -S "None of the common ciphersuites is usable"
3469
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003470requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003471run_test "ECJPAKE: server not configured" \
3472 "$P_SRV debug_level=3" \
3473 "$P_CLI debug_level=3 ecjpake_pw=bla \
3474 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3475 1 \
3476 -c "add ciphersuite: c0ff" \
3477 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003478 -s "found ecjpake kkpp extension" \
3479 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003480 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003481 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003482 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003483 -s "None of the common ciphersuites is usable"
3484
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003485requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003486run_test "ECJPAKE: working, TLS" \
3487 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3488 "$P_CLI debug_level=3 ecjpake_pw=bla \
3489 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003490 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003491 -c "add ciphersuite: c0ff" \
3492 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003493 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003494 -s "found ecjpake kkpp extension" \
3495 -S "skip ecjpake kkpp extension" \
3496 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003497 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003498 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003499 -S "None of the common ciphersuites is usable" \
3500 -S "SSL - Verification of the message MAC failed"
3501
Janos Follath74537a62016-09-02 13:45:28 +01003502server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003503requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003504run_test "ECJPAKE: password mismatch, TLS" \
3505 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3506 "$P_CLI debug_level=3 ecjpake_pw=bad \
3507 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3508 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003509 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003510 -s "SSL - Verification of the message MAC failed"
3511
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003512requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003513run_test "ECJPAKE: working, DTLS" \
3514 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3515 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3516 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3517 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003518 -c "re-using cached ecjpake parameters" \
3519 -S "SSL - Verification of the message MAC failed"
3520
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003521requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003522run_test "ECJPAKE: working, DTLS, no cookie" \
3523 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3524 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3525 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3526 0 \
3527 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003528 -S "SSL - Verification of the message MAC failed"
3529
Janos Follath74537a62016-09-02 13:45:28 +01003530server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003531requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003532run_test "ECJPAKE: password mismatch, DTLS" \
3533 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3534 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3535 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3536 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003537 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003538 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003539
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003540# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003541requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003542run_test "ECJPAKE: working, DTLS, nolog" \
3543 "$P_SRV dtls=1 ecjpake_pw=bla" \
3544 "$P_CLI dtls=1 ecjpake_pw=bla \
3545 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3546 0
3547
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003548# Tests for ciphersuites per version
3549
Janos Follathe2681a42016-03-07 15:57:05 +00003550requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003551run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003552 "$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 +02003553 "$P_CLI force_version=ssl3" \
3554 0 \
3555 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003557run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003558 "$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 +01003559 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003560 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003561 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003563run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003564 "$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 +02003565 "$P_CLI force_version=tls1_1" \
3566 0 \
3567 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003569run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003570 "$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 +02003571 "$P_CLI force_version=tls1_2" \
3572 0 \
3573 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3574
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003575# Test for ClientHello without extensions
3576
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003577requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003578run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003579 "$P_SRV debug_level=3" \
3580 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3581 0 \
3582 -s "dumping 'client hello extensions' (0 bytes)"
3583
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003584requires_gnutls
3585run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3586 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3587 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3588 0 \
3589 -s "dumping 'client hello extensions' (0 bytes)"
3590
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003591# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003592
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003593run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003594 "$P_SRV" \
3595 "$P_CLI request_size=100" \
3596 0 \
3597 -s "Read from client: 100 bytes read$"
3598
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003599run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003600 "$P_SRV" \
3601 "$P_CLI request_size=500" \
3602 0 \
3603 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003604
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003605# Tests for small packets
3606
Janos Follathe2681a42016-03-07 15:57:05 +00003607requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003608run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003609 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003610 "$P_CLI request_size=1 force_version=ssl3 \
3611 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3612 0 \
3613 -s "Read from client: 1 bytes read"
3614
Janos Follathe2681a42016-03-07 15:57:05 +00003615requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003616run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003617 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003618 "$P_CLI request_size=1 force_version=ssl3 \
3619 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3620 0 \
3621 -s "Read from client: 1 bytes read"
3622
3623run_test "Small packet TLS 1.0 BlockCipher" \
3624 "$P_SRV" \
3625 "$P_CLI request_size=1 force_version=tls1 \
3626 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3627 0 \
3628 -s "Read from client: 1 bytes read"
3629
Hanno Becker8501f982017-11-10 08:59:04 +00003630run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003631 "$P_SRV" \
3632 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3633 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3634 0 \
3635 -s "Read from client: 1 bytes read"
3636
Hanno Becker32c55012017-11-10 08:42:54 +00003637requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003638run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003639 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003640 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003641 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003642 0 \
3643 -s "Read from client: 1 bytes read"
3644
Hanno Becker32c55012017-11-10 08:42:54 +00003645requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003646run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003647 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003648 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003649 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003650 0 \
3651 -s "Read from client: 1 bytes read"
3652
3653run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003654 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003655 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003656 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3657 0 \
3658 -s "Read from client: 1 bytes read"
3659
3660run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3661 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3662 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003663 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003664 0 \
3665 -s "Read from client: 1 bytes read"
3666
3667requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3668run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003669 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003670 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003671 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003672 0 \
3673 -s "Read from client: 1 bytes read"
3674
Hanno Becker8501f982017-11-10 08:59:04 +00003675requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3676run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003677 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3678 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3679 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003680 0 \
3681 -s "Read from client: 1 bytes read"
3682
3683run_test "Small packet TLS 1.1 BlockCipher" \
3684 "$P_SRV" \
3685 "$P_CLI request_size=1 force_version=tls1_1 \
3686 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3687 0 \
3688 -s "Read from client: 1 bytes read"
3689
Hanno Becker8501f982017-11-10 08:59:04 +00003690run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003691 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003692 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003693 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003694 0 \
3695 -s "Read from client: 1 bytes read"
3696
3697requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3698run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003699 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003700 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003701 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003702 0 \
3703 -s "Read from client: 1 bytes read"
3704
3705requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3706run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003707 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003708 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003709 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003710 0 \
3711 -s "Read from client: 1 bytes read"
3712
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003713run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003714 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003715 "$P_CLI request_size=1 force_version=tls1_1 \
3716 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3717 0 \
3718 -s "Read from client: 1 bytes read"
3719
Hanno Becker8501f982017-11-10 08:59:04 +00003720run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3721 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003722 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003723 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003724 0 \
3725 -s "Read from client: 1 bytes read"
3726
Hanno Becker8501f982017-11-10 08:59:04 +00003727requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3728run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003729 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003730 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003731 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003732 0 \
3733 -s "Read from client: 1 bytes read"
3734
Hanno Becker32c55012017-11-10 08:42:54 +00003735requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003736run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003737 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003738 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003739 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003740 0 \
3741 -s "Read from client: 1 bytes read"
3742
3743run_test "Small packet TLS 1.2 BlockCipher" \
3744 "$P_SRV" \
3745 "$P_CLI request_size=1 force_version=tls1_2 \
3746 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3747 0 \
3748 -s "Read from client: 1 bytes read"
3749
Hanno Becker8501f982017-11-10 08:59:04 +00003750run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003751 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003752 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003753 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003754 0 \
3755 -s "Read from client: 1 bytes read"
3756
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003757run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3758 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003759 "$P_CLI request_size=1 force_version=tls1_2 \
3760 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003761 0 \
3762 -s "Read from client: 1 bytes read"
3763
Hanno Becker32c55012017-11-10 08:42:54 +00003764requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003765run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003766 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003767 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003768 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003769 0 \
3770 -s "Read from client: 1 bytes read"
3771
Hanno Becker8501f982017-11-10 08:59:04 +00003772requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3773run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003774 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003775 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003776 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003777 0 \
3778 -s "Read from client: 1 bytes read"
3779
3780run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003781 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003782 "$P_CLI request_size=1 force_version=tls1_2 \
3783 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3784 0 \
3785 -s "Read from client: 1 bytes read"
3786
Hanno Becker8501f982017-11-10 08:59:04 +00003787run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003788 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003789 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003791 0 \
3792 -s "Read from client: 1 bytes read"
3793
Hanno Becker32c55012017-11-10 08:42:54 +00003794requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003795run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003796 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003797 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003798 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003799 0 \
3800 -s "Read from client: 1 bytes read"
3801
Hanno Becker8501f982017-11-10 08:59:04 +00003802requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3803run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003804 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003805 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003806 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003807 0 \
3808 -s "Read from client: 1 bytes read"
3809
3810run_test "Small packet TLS 1.2 AEAD" \
3811 "$P_SRV" \
3812 "$P_CLI request_size=1 force_version=tls1_2 \
3813 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3814 0 \
3815 -s "Read from client: 1 bytes read"
3816
3817run_test "Small packet TLS 1.2 AEAD shorter tag" \
3818 "$P_SRV" \
3819 "$P_CLI request_size=1 force_version=tls1_2 \
3820 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3821 0 \
3822 -s "Read from client: 1 bytes read"
3823
Hanno Beckere2148042017-11-10 08:59:18 +00003824# Tests for small packets in DTLS
3825
3826requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3827run_test "Small packet DTLS 1.0" \
3828 "$P_SRV dtls=1 force_version=dtls1" \
3829 "$P_CLI dtls=1 request_size=1 \
3830 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3831 0 \
3832 -s "Read from client: 1 bytes read"
3833
3834requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3835run_test "Small packet DTLS 1.0, without EtM" \
3836 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3837 "$P_CLI dtls=1 request_size=1 \
3838 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3839 0 \
3840 -s "Read from client: 1 bytes read"
3841
3842requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3843requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3844run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003845 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3846 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003847 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3848 0 \
3849 -s "Read from client: 1 bytes read"
3850
3851requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3852requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3853run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003854 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003855 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003856 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003857 0 \
3858 -s "Read from client: 1 bytes read"
3859
3860requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3861run_test "Small packet DTLS 1.2" \
3862 "$P_SRV dtls=1 force_version=dtls1_2" \
3863 "$P_CLI dtls=1 request_size=1 \
3864 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3865 0 \
3866 -s "Read from client: 1 bytes read"
3867
3868requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3869run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003870 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003871 "$P_CLI dtls=1 request_size=1 \
3872 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3873 0 \
3874 -s "Read from client: 1 bytes read"
3875
3876requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3877requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3878run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003879 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003880 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003881 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003882 0 \
3883 -s "Read from client: 1 bytes read"
3884
3885requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3886requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3887run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003888 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003889 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003890 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003891 0 \
3892 -s "Read from client: 1 bytes read"
3893
Janos Follath00efff72016-05-06 13:48:23 +01003894# A test for extensions in SSLv3
3895
3896requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3897run_test "SSLv3 with extensions, server side" \
3898 "$P_SRV min_version=ssl3 debug_level=3" \
3899 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3900 0 \
3901 -S "dumping 'client hello extensions'" \
3902 -S "server hello, total extension length:"
3903
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003904# Test for large packets
3905
Janos Follathe2681a42016-03-07 15:57:05 +00003906requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003907run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003908 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003909 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003910 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3911 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003912 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003913 -s "Read from client: 16384 bytes read"
3914
Janos Follathe2681a42016-03-07 15:57:05 +00003915requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003916run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003917 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003918 "$P_CLI request_size=16384 force_version=ssl3 \
3919 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3920 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003921 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003922 -s "Read from client: 16384 bytes read"
3923
3924run_test "Large packet TLS 1.0 BlockCipher" \
3925 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003926 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003927 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3928 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003929 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003930 -s "Read from client: 16384 bytes read"
3931
Hanno Becker278fc7a2017-11-10 09:16:28 +00003932run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003933 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003934 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3935 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3936 0 \
3937 -s "Read from client: 16384 bytes read"
3938
Hanno Becker32c55012017-11-10 08:42:54 +00003939requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003940run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003941 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003942 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003943 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003944 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003945 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003946 -s "Read from client: 16384 bytes read"
3947
Hanno Becker32c55012017-11-10 08:42:54 +00003948requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003949run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003950 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003951 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003952 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003953 0 \
3954 -s "Read from client: 16384 bytes read"
3955
3956run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003957 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003958 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003959 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3960 0 \
3961 -s "Read from client: 16384 bytes read"
3962
3963run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3964 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3965 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003966 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003967 0 \
3968 -s "Read from client: 16384 bytes read"
3969
3970requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3971run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003972 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003973 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003974 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003975 0 \
3976 -s "Read from client: 16384 bytes read"
3977
Hanno Becker278fc7a2017-11-10 09:16:28 +00003978requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3979run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003980 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003981 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003982 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003983 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003984 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003985 -s "Read from client: 16384 bytes read"
3986
3987run_test "Large packet TLS 1.1 BlockCipher" \
3988 "$P_SRV" \
3989 "$P_CLI request_size=16384 force_version=tls1_1 \
3990 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3991 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003992 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003993 -s "Read from client: 16384 bytes read"
3994
Hanno Becker278fc7a2017-11-10 09:16:28 +00003995run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3996 "$P_SRV" \
3997 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3998 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003999 0 \
4000 -s "Read from client: 16384 bytes read"
4001
Hanno Becker32c55012017-11-10 08:42:54 +00004002requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004003run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004004 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004005 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004006 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004007 0 \
4008 -s "Read from client: 16384 bytes read"
4009
Hanno Becker32c55012017-11-10 08:42:54 +00004010requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004011run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004012 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004013 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004014 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004015 0 \
4016 -s "Read from client: 16384 bytes read"
4017
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004018run_test "Large packet TLS 1.1 StreamCipher" \
4019 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4020 "$P_CLI request_size=16384 force_version=tls1_1 \
4021 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4022 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004023 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004024 -s "Read from client: 16384 bytes read"
4025
Hanno Becker278fc7a2017-11-10 09:16:28 +00004026run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
4027 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004028 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004029 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004030 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004031 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004032 -s "Read from client: 16384 bytes read"
4033
Hanno Becker278fc7a2017-11-10 09:16:28 +00004034requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4035run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004036 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004037 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004038 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004039 0 \
4040 -s "Read from client: 16384 bytes read"
4041
Hanno Becker278fc7a2017-11-10 09:16:28 +00004042requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4043run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004044 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004045 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004046 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004047 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004048 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004049 -s "Read from client: 16384 bytes read"
4050
4051run_test "Large packet TLS 1.2 BlockCipher" \
4052 "$P_SRV" \
4053 "$P_CLI request_size=16384 force_version=tls1_2 \
4054 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4055 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004056 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004057 -s "Read from client: 16384 bytes read"
4058
Hanno Becker278fc7a2017-11-10 09:16:28 +00004059run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
4060 "$P_SRV" \
4061 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4062 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4063 0 \
4064 -s "Read from client: 16384 bytes read"
4065
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004066run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
4067 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004068 "$P_CLI request_size=16384 force_version=tls1_2 \
4069 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004070 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004071 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004072 -s "Read from client: 16384 bytes read"
4073
Hanno Becker32c55012017-11-10 08:42:54 +00004074requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004075run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004076 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004077 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004078 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004079 0 \
4080 -s "Read from client: 16384 bytes read"
4081
Hanno Becker278fc7a2017-11-10 09:16:28 +00004082requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4083run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004084 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004085 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004086 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004087 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004088 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004089 -s "Read from client: 16384 bytes read"
4090
4091run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004092 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004093 "$P_CLI request_size=16384 force_version=tls1_2 \
4094 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4095 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004096 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004097 -s "Read from client: 16384 bytes read"
4098
Hanno Becker278fc7a2017-11-10 09:16:28 +00004099run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004100 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004101 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004102 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4103 0 \
4104 -s "Read from client: 16384 bytes read"
4105
Hanno Becker32c55012017-11-10 08:42:54 +00004106requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004107run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004108 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004109 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004110 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004111 0 \
4112 -s "Read from client: 16384 bytes read"
4113
Hanno Becker278fc7a2017-11-10 09:16:28 +00004114requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4115run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004116 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004117 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004118 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004119 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004120 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004121 -s "Read from client: 16384 bytes read"
4122
4123run_test "Large packet TLS 1.2 AEAD" \
4124 "$P_SRV" \
4125 "$P_CLI request_size=16384 force_version=tls1_2 \
4126 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4127 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004128 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004129 -s "Read from client: 16384 bytes read"
4130
4131run_test "Large packet TLS 1.2 AEAD shorter tag" \
4132 "$P_SRV" \
4133 "$P_CLI request_size=16384 force_version=tls1_2 \
4134 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4135 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004136 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004137 -s "Read from client: 16384 bytes read"
4138
Ron Eldorc7f15232018-06-28 13:22:05 +03004139# Tests for ECC extensions (rfc 4492)
4140
Ron Eldor94226d82018-06-28 16:17:00 +03004141requires_config_enabled MBEDTLS_AES_C
4142requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4143requires_config_enabled MBEDTLS_SHA256_C
4144requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004145run_test "Force a non ECC ciphersuite in the client side" \
4146 "$P_SRV debug_level=3" \
Ron Eldor94226d82018-06-28 16:17:00 +03004147 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004148 0 \
4149 -C "client hello, adding supported_elliptic_curves extension" \
4150 -C "client hello, adding supported_point_formats extension" \
4151 -S "found supported elliptic curves extension" \
4152 -S "found supported point formats extension"
4153
Ron Eldor94226d82018-06-28 16:17:00 +03004154requires_config_enabled MBEDTLS_AES_C
4155requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4156requires_config_enabled MBEDTLS_SHA256_C
4157requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004158run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor94226d82018-06-28 16:17:00 +03004159 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004160 "$P_CLI debug_level=3" \
4161 0 \
4162 -C "found supported_point_formats extension" \
4163 -S "server hello, supported_point_formats extension"
4164
Ron Eldor94226d82018-06-28 16:17:00 +03004165requires_config_enabled MBEDTLS_AES_C
4166requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4167requires_config_enabled MBEDTLS_SHA256_C
4168requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004169run_test "Force an ECC ciphersuite in the client side" \
4170 "$P_SRV debug_level=3" \
4171 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4172 0 \
4173 -c "client hello, adding supported_elliptic_curves extension" \
4174 -c "client hello, adding supported_point_formats extension" \
4175 -s "found supported elliptic curves extension" \
4176 -s "found supported point formats extension"
4177
Ron Eldor94226d82018-06-28 16:17:00 +03004178requires_config_enabled MBEDTLS_AES_C
4179requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4180requires_config_enabled MBEDTLS_SHA256_C
4181requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004182run_test "Force an ECC ciphersuite in the server side" \
4183 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4184 "$P_CLI debug_level=3" \
4185 0 \
4186 -c "found supported_point_formats extension" \
4187 -s "server hello, supported_point_formats extension"
4188
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004189# Tests for DTLS HelloVerifyRequest
4190
4191run_test "DTLS cookie: enabled" \
4192 "$P_SRV dtls=1 debug_level=2" \
4193 "$P_CLI dtls=1 debug_level=2" \
4194 0 \
4195 -s "cookie verification failed" \
4196 -s "cookie verification passed" \
4197 -S "cookie verification skipped" \
4198 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004199 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004200 -S "SSL - The requested feature is not available"
4201
4202run_test "DTLS cookie: disabled" \
4203 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4204 "$P_CLI dtls=1 debug_level=2" \
4205 0 \
4206 -S "cookie verification failed" \
4207 -S "cookie verification passed" \
4208 -s "cookie verification skipped" \
4209 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004210 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004211 -S "SSL - The requested feature is not available"
4212
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004213run_test "DTLS cookie: default (failing)" \
4214 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4215 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4216 1 \
4217 -s "cookie verification failed" \
4218 -S "cookie verification passed" \
4219 -S "cookie verification skipped" \
4220 -C "received hello verify request" \
4221 -S "hello verification requested" \
4222 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004223
4224requires_ipv6
4225run_test "DTLS cookie: enabled, IPv6" \
4226 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4227 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4228 0 \
4229 -s "cookie verification failed" \
4230 -s "cookie verification passed" \
4231 -S "cookie verification skipped" \
4232 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004233 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004234 -S "SSL - The requested feature is not available"
4235
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004236run_test "DTLS cookie: enabled, nbio" \
4237 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4238 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4239 0 \
4240 -s "cookie verification failed" \
4241 -s "cookie verification passed" \
4242 -S "cookie verification skipped" \
4243 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004244 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004245 -S "SSL - The requested feature is not available"
4246
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004247# Tests for client reconnecting from the same port with DTLS
4248
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004249not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004250run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004251 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4252 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004253 0 \
4254 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004255 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004256 -S "Client initiated reconnection from same port"
4257
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004258not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004259run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004260 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4261 "$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 +02004262 0 \
4263 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004264 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004265 -s "Client initiated reconnection from same port"
4266
Paul Bakker362689d2016-05-13 10:33:25 +01004267not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4268run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004269 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4270 "$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 +02004271 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004272 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004273 -s "Client initiated reconnection from same port"
4274
Paul Bakker362689d2016-05-13 10:33:25 +01004275only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4276run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4277 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4278 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4279 0 \
4280 -S "The operation timed out" \
4281 -s "Client initiated reconnection from same port"
4282
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004283run_test "DTLS client reconnect from same port: no cookies" \
4284 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004285 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4286 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004287 -s "The operation timed out" \
4288 -S "Client initiated reconnection from same port"
4289
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004290# Tests for various cases of client authentication with DTLS
4291# (focused on handshake flows and message parsing)
4292
4293run_test "DTLS client auth: required" \
4294 "$P_SRV dtls=1 auth_mode=required" \
4295 "$P_CLI dtls=1" \
4296 0 \
4297 -s "Verifying peer X.509 certificate... ok"
4298
4299run_test "DTLS client auth: optional, client has no cert" \
4300 "$P_SRV dtls=1 auth_mode=optional" \
4301 "$P_CLI dtls=1 crt_file=none key_file=none" \
4302 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004303 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004304
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004305run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004306 "$P_SRV dtls=1 auth_mode=none" \
4307 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
4308 0 \
4309 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004310 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004311
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02004312run_test "DTLS wrong PSK: badmac alert" \
4313 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
4314 "$P_CLI dtls=1 psk=abc124" \
4315 1 \
4316 -s "SSL - Verification of the message MAC failed" \
4317 -c "SSL - A fatal alert message was received from our peer"
4318
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02004319# Tests for receiving fragmented handshake messages with DTLS
4320
4321requires_gnutls
4322run_test "DTLS reassembly: no fragmentation (gnutls server)" \
4323 "$G_SRV -u --mtu 2048 -a" \
4324 "$P_CLI dtls=1 debug_level=2" \
4325 0 \
4326 -C "found fragmented DTLS handshake message" \
4327 -C "error"
4328
4329requires_gnutls
4330run_test "DTLS reassembly: some fragmentation (gnutls server)" \
4331 "$G_SRV -u --mtu 512" \
4332 "$P_CLI dtls=1 debug_level=2" \
4333 0 \
4334 -c "found fragmented DTLS handshake message" \
4335 -C "error"
4336
4337requires_gnutls
4338run_test "DTLS reassembly: more fragmentation (gnutls server)" \
4339 "$G_SRV -u --mtu 128" \
4340 "$P_CLI dtls=1 debug_level=2" \
4341 0 \
4342 -c "found fragmented DTLS handshake message" \
4343 -C "error"
4344
4345requires_gnutls
4346run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
4347 "$G_SRV -u --mtu 128" \
4348 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4349 0 \
4350 -c "found fragmented DTLS handshake message" \
4351 -C "error"
4352
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004353requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004354requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004355run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4356 "$G_SRV -u --mtu 256" \
4357 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4358 0 \
4359 -c "found fragmented DTLS handshake message" \
4360 -c "client hello, adding renegotiation extension" \
4361 -c "found renegotiation extension" \
4362 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004363 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004364 -C "error" \
4365 -s "Extra-header:"
4366
4367requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004368requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004369run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4370 "$G_SRV -u --mtu 256" \
4371 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4372 0 \
4373 -c "found fragmented DTLS handshake message" \
4374 -c "client hello, adding renegotiation extension" \
4375 -c "found renegotiation extension" \
4376 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004377 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004378 -C "error" \
4379 -s "Extra-header:"
4380
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004381run_test "DTLS reassembly: no fragmentation (openssl server)" \
4382 "$O_SRV -dtls1 -mtu 2048" \
4383 "$P_CLI dtls=1 debug_level=2" \
4384 0 \
4385 -C "found fragmented DTLS handshake message" \
4386 -C "error"
4387
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004388run_test "DTLS reassembly: some fragmentation (openssl server)" \
4389 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004390 "$P_CLI dtls=1 debug_level=2" \
4391 0 \
4392 -c "found fragmented DTLS handshake message" \
4393 -C "error"
4394
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004395run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004396 "$O_SRV -dtls1 -mtu 256" \
4397 "$P_CLI dtls=1 debug_level=2" \
4398 0 \
4399 -c "found fragmented DTLS handshake message" \
4400 -C "error"
4401
4402run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4403 "$O_SRV -dtls1 -mtu 256" \
4404 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4405 0 \
4406 -c "found fragmented DTLS handshake message" \
4407 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004408
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004409# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004410
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004411not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004412run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004413 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004414 "$P_SRV dtls=1 debug_level=2" \
4415 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004416 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004417 -C "replayed record" \
4418 -S "replayed record" \
4419 -C "record from another epoch" \
4420 -S "record from another epoch" \
4421 -C "discarding invalid record" \
4422 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004423 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004424 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004425 -c "HTTP/1.0 200 OK"
4426
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004427not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004428run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004429 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004430 "$P_SRV dtls=1 debug_level=2" \
4431 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004432 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004433 -c "replayed record" \
4434 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004435 -c "discarding invalid record" \
4436 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004437 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004438 -s "Extra-header:" \
4439 -c "HTTP/1.0 200 OK"
4440
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004441run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4442 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004443 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4444 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004445 0 \
4446 -c "replayed record" \
4447 -S "replayed record" \
4448 -c "discarding invalid record" \
4449 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004450 -c "resend" \
4451 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004452 -s "Extra-header:" \
4453 -c "HTTP/1.0 200 OK"
4454
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004455run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004456 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004457 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004458 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004459 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004460 -c "discarding invalid record (mac)" \
4461 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004462 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004463 -c "HTTP/1.0 200 OK" \
4464 -S "too many records with bad MAC" \
4465 -S "Verification of the message MAC failed"
4466
4467run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4468 -p "$P_PXY bad_ad=1" \
4469 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4470 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4471 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004472 -C "discarding invalid record (mac)" \
4473 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004474 -S "Extra-header:" \
4475 -C "HTTP/1.0 200 OK" \
4476 -s "too many records with bad MAC" \
4477 -s "Verification of the message MAC failed"
4478
4479run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4480 -p "$P_PXY bad_ad=1" \
4481 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4482 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4483 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004484 -c "discarding invalid record (mac)" \
4485 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004486 -s "Extra-header:" \
4487 -c "HTTP/1.0 200 OK" \
4488 -S "too many records with bad MAC" \
4489 -S "Verification of the message MAC failed"
4490
4491run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4492 -p "$P_PXY bad_ad=1" \
4493 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4494 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4495 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004496 -c "discarding invalid record (mac)" \
4497 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004498 -s "Extra-header:" \
4499 -c "HTTP/1.0 200 OK" \
4500 -s "too many records with bad MAC" \
4501 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004502
4503run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004504 -p "$P_PXY delay_ccs=1" \
4505 "$P_SRV dtls=1 debug_level=1" \
4506 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004507 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004508 -c "record from another epoch" \
4509 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004510 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004511 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004512 -s "Extra-header:" \
4513 -c "HTTP/1.0 200 OK"
4514
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004515# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004516
Janos Follath74537a62016-09-02 13:45:28 +01004517client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004518run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004519 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004520 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4521 psk=abc123" \
4522 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004523 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4524 0 \
4525 -s "Extra-header:" \
4526 -c "HTTP/1.0 200 OK"
4527
Janos Follath74537a62016-09-02 13:45:28 +01004528client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004529run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4530 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004531 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4532 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004533 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4534 0 \
4535 -s "Extra-header:" \
4536 -c "HTTP/1.0 200 OK"
4537
Janos Follath74537a62016-09-02 13:45:28 +01004538client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004539run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4540 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004541 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4542 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004543 0 \
4544 -s "Extra-header:" \
4545 -c "HTTP/1.0 200 OK"
4546
Janos Follath74537a62016-09-02 13:45:28 +01004547client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004548run_test "DTLS proxy: 3d, FS, client auth" \
4549 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004550 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4551 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004552 0 \
4553 -s "Extra-header:" \
4554 -c "HTTP/1.0 200 OK"
4555
Janos Follath74537a62016-09-02 13:45:28 +01004556client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004557run_test "DTLS proxy: 3d, FS, ticket" \
4558 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004559 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4560 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004561 0 \
4562 -s "Extra-header:" \
4563 -c "HTTP/1.0 200 OK"
4564
Janos Follath74537a62016-09-02 13:45:28 +01004565client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004566run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4567 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004568 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4569 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004570 0 \
4571 -s "Extra-header:" \
4572 -c "HTTP/1.0 200 OK"
4573
Janos Follath74537a62016-09-02 13:45:28 +01004574client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004575run_test "DTLS proxy: 3d, max handshake, nbio" \
4576 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004577 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4578 auth_mode=required" \
4579 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004580 0 \
4581 -s "Extra-header:" \
4582 -c "HTTP/1.0 200 OK"
4583
Janos Follath74537a62016-09-02 13:45:28 +01004584client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004585run_test "DTLS proxy: 3d, min handshake, resumption" \
4586 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4587 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4588 psk=abc123 debug_level=3" \
4589 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4590 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4591 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4592 0 \
4593 -s "a session has been resumed" \
4594 -c "a session has been resumed" \
4595 -s "Extra-header:" \
4596 -c "HTTP/1.0 200 OK"
4597
Janos Follath74537a62016-09-02 13:45:28 +01004598client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004599run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4600 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4601 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4602 psk=abc123 debug_level=3 nbio=2" \
4603 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4604 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4605 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4606 0 \
4607 -s "a session has been resumed" \
4608 -c "a session has been resumed" \
4609 -s "Extra-header:" \
4610 -c "HTTP/1.0 200 OK"
4611
Janos Follath74537a62016-09-02 13:45:28 +01004612client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004613requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004614run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004615 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004616 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4617 psk=abc123 renegotiation=1 debug_level=2" \
4618 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4619 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004620 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4621 0 \
4622 -c "=> renegotiate" \
4623 -s "=> renegotiate" \
4624 -s "Extra-header:" \
4625 -c "HTTP/1.0 200 OK"
4626
Janos Follath74537a62016-09-02 13:45:28 +01004627client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004628requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004629run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4630 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004631 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4632 psk=abc123 renegotiation=1 debug_level=2" \
4633 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4634 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004635 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4636 0 \
4637 -c "=> renegotiate" \
4638 -s "=> renegotiate" \
4639 -s "Extra-header:" \
4640 -c "HTTP/1.0 200 OK"
4641
Janos Follath74537a62016-09-02 13:45:28 +01004642client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004643requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004644run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004645 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004646 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004647 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004648 debug_level=2" \
4649 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004650 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004651 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4652 0 \
4653 -c "=> renegotiate" \
4654 -s "=> renegotiate" \
4655 -s "Extra-header:" \
4656 -c "HTTP/1.0 200 OK"
4657
Janos Follath74537a62016-09-02 13:45:28 +01004658client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004659requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004660run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004661 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004662 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004663 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004664 debug_level=2 nbio=2" \
4665 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004666 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004667 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4668 0 \
4669 -c "=> renegotiate" \
4670 -s "=> renegotiate" \
4671 -s "Extra-header:" \
4672 -c "HTTP/1.0 200 OK"
4673
Janos Follath74537a62016-09-02 13:45:28 +01004674client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004675not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004676run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004677 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4678 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004679 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004680 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004681 -c "HTTP/1.0 200 OK"
4682
Janos Follath74537a62016-09-02 13:45:28 +01004683client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004684not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004685run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4686 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4687 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004688 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004689 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004690 -c "HTTP/1.0 200 OK"
4691
Janos Follath74537a62016-09-02 13:45:28 +01004692client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004693not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004694run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4695 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4696 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004697 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004698 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004699 -c "HTTP/1.0 200 OK"
4700
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004701requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004702client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004703not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004704run_test "DTLS proxy: 3d, gnutls server" \
4705 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4706 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004707 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004708 0 \
4709 -s "Extra-header:" \
4710 -c "Extra-header:"
4711
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004712requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004713client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004714not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004715run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4716 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4717 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004718 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004719 0 \
4720 -s "Extra-header:" \
4721 -c "Extra-header:"
4722
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004723requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004724client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004725not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004726run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4727 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4728 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004729 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004730 0 \
4731 -s "Extra-header:" \
4732 -c "Extra-header:"
4733
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004734# Final report
4735
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004736echo "------------------------------------------------------------------------"
4737
4738if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004739 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004740else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004741 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004742fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004743PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004744echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004745
4746exit $FAILS