blob: b19cf6084f59594589700eaa16d117531dacd39a [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
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
235 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
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200289# wait for server to start: two versions depending on lsof availability
290wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200291 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200292 START_TIME=$( date +%s )
293 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200294
295 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200296 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200297 while [ $DONE -eq 0 ]; do
298 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
299 then
300 DONE=1
301 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
302 echo "SERVERSTART TIMEOUT"
303 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
304 DONE=1
305 fi
306 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200307 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200308 while [ $DONE -eq 0 ]; do
309 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
310 then
311 DONE=1
312 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
313 echo "SERVERSTART TIMEOUT"
314 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
315 DONE=1
316 fi
317 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200318 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200319 else
320 sleep "$START_DELAY"
321 fi
322}
323
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100324# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100325# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100326# acceptable bounds
327check_server_hello_time() {
328 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100329 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100330 # Get the Unix timestamp for now
331 CUR_TIME=$(date +'%s')
332 THRESHOLD_IN_SECS=300
333
334 # Check if the ServerHello time was printed
335 if [ -z "$SERVER_HELLO_TIME" ]; then
336 return 1
337 fi
338
339 # Check the time in ServerHello is within acceptable bounds
340 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
341 # The time in ServerHello is at least 5 minutes before now
342 return 1
343 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100344 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100345 return 1
346 else
347 return 0
348 fi
349}
350
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200351# wait for client to terminate and set CLI_EXIT
352# must be called right after starting the client
353wait_client_done() {
354 CLI_PID=$!
355
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200356 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
357 CLI_DELAY_FACTOR=1
358
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200359 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200360 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200361
362 wait $CLI_PID
363 CLI_EXIT=$?
364
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200365 kill $DOG_PID >/dev/null 2>&1
366 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200367
368 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100369
370 sleep $SRV_DELAY_SECONDS
371 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200372}
373
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200374# check if the given command uses dtls and sets global variable DTLS
375detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200376 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200377 DTLS=1
378 else
379 DTLS=0
380 fi
381}
382
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200383# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100384# Options: -s pattern pattern that must be present in server output
385# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100386# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100387# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100388# -S pattern pattern that must be absent in server output
389# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100390# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100391# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100392run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100393 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200394 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100396 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
397 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200398 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100399 return
400 fi
401
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100403
Paul Bakkerb7584a52016-05-10 10:50:43 +0100404 # Do we only run numbered tests?
405 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
406 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
407 else
408 SKIP_NEXT="YES"
409 fi
410
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200411 # should we skip?
412 if [ "X$SKIP_NEXT" = "XYES" ]; then
413 SKIP_NEXT="NO"
414 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200415 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200416 return
417 fi
418
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200419 # does this test use a proxy?
420 if [ "X$1" = "X-p" ]; then
421 PXY_CMD="$2"
422 shift 2
423 else
424 PXY_CMD=""
425 fi
426
427 # get commands and client output
428 SRV_CMD="$1"
429 CLI_CMD="$2"
430 CLI_EXPECT="$3"
431 shift 3
432
433 # fix client port
434 if [ -n "$PXY_CMD" ]; then
435 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
436 else
437 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
438 fi
439
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200440 # update DTLS variable
441 detect_dtls "$SRV_CMD"
442
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100443 # prepend valgrind to our commands if active
444 if [ "$MEMCHECK" -gt 0 ]; then
445 if is_polar "$SRV_CMD"; then
446 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
447 fi
448 if is_polar "$CLI_CMD"; then
449 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
450 fi
451 fi
452
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200453 TIMES_LEFT=2
454 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200455 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200456
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200457 # run the commands
458 if [ -n "$PXY_CMD" ]; then
459 echo "$PXY_CMD" > $PXY_OUT
460 $PXY_CMD >> $PXY_OUT 2>&1 &
461 PXY_PID=$!
462 # assume proxy starts faster than server
463 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200464
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200465 check_osrv_dtls
466 echo "$SRV_CMD" > $SRV_OUT
467 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
468 SRV_PID=$!
469 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200470
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200471 echo "$CLI_CMD" > $CLI_OUT
472 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
473 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100474
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200475 # terminate the server (and the proxy)
476 kill $SRV_PID
477 wait $SRV_PID
478 if [ -n "$PXY_CMD" ]; then
479 kill $PXY_PID >/dev/null 2>&1
480 wait $PXY_PID
481 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100482
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200483 # retry only on timeouts
484 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
485 printf "RETRY "
486 else
487 TIMES_LEFT=0
488 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200489 done
490
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100491 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200492 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100493 # expected client exit to incorrectly succeed in case of catastrophic
494 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100495 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200496 if grep "Performing the SSL/TLS handshake" $SRV_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
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100502 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200503 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100504 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100505 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100506 return
507 fi
508 fi
509
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100510 # check server exit code
511 if [ $? != 0 ]; then
512 fail "server fail"
513 return
514 fi
515
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100516 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100517 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
518 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100519 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200520 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100521 return
522 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100523
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100524 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200525 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100526 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100527 while [ $# -gt 0 ]
528 do
529 case $1 in
530 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100531 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 +0100532 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100533 return
534 fi
535 ;;
536
537 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100538 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 +0100539 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100540 return
541 fi
542 ;;
543
544 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100545 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 +0100546 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100547 return
548 fi
549 ;;
550
551 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100552 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 +0100553 fail "pattern '$2' MUST NOT be present in the Client output"
554 return
555 fi
556 ;;
557
558 # The filtering in the following two options (-u and -U) do the following
559 # - ignore valgrind output
560 # - filter out everything but lines right after the pattern occurances
561 # - keep one of each non-unique line
562 # - count how many lines remain
563 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
564 # if there were no duplicates.
565 "-U")
566 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
567 fail "lines following pattern '$2' must be unique in Server output"
568 return
569 fi
570 ;;
571
572 "-u")
573 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
574 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100575 return
576 fi
577 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100578 "-F")
579 if ! $2 "$SRV_OUT"; then
580 fail "function call to '$2' failed on Server output"
581 return
582 fi
583 ;;
584 "-f")
585 if ! $2 "$CLI_OUT"; then
586 fail "function call to '$2' failed on Client output"
587 return
588 fi
589 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100590
591 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200592 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100593 exit 1
594 esac
595 shift 2
596 done
597
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100598 # check valgrind's results
599 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200600 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100601 fail "Server has memory errors"
602 return
603 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200604 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100605 fail "Client has memory errors"
606 return
607 fi
608 fi
609
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100610 # if we're here, everything is ok
611 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100612 if [ "$PRESERVE_LOGS" -gt 0 ]; then
613 mv $SRV_OUT o-srv-${TESTS}.log
614 mv $CLI_OUT o-cli-${TESTS}.log
615 fi
616
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100618}
619
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100620cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200621 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200622 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
623 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
624 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
625 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100626 exit 1
627}
628
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100629#
630# MAIN
631#
632
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000633if cd $( dirname $0 ); then :; else
634 echo "cd $( dirname $0 ) failed" >&2
635 exit 1
636fi
637
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100638get_options "$@"
639
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100640# sanity checks, avoid an avalanche of errors
641if [ ! -x "$P_SRV" ]; then
642 echo "Command '$P_SRV' is not an executable file"
643 exit 1
644fi
645if [ ! -x "$P_CLI" ]; then
646 echo "Command '$P_CLI' is not an executable file"
647 exit 1
648fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200649if [ ! -x "$P_PXY" ]; then
650 echo "Command '$P_PXY' is not an executable file"
651 exit 1
652fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100653if [ "$MEMCHECK" -gt 0 ]; then
654 if which valgrind >/dev/null 2>&1; then :; else
655 echo "Memcheck not possible. Valgrind not found"
656 exit 1
657 fi
658fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100659if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
660 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100661 exit 1
662fi
663
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200664# used by watchdog
665MAIN_PID="$$"
666
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200667# be more patient with valgrind
668if [ "$MEMCHECK" -gt 0 ]; then
669 START_DELAY=3
670 DOG_DELAY=30
671else
672 START_DELAY=1
673 DOG_DELAY=10
674fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200675CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100676SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200677
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200678# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000679# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200680P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
681P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100682P_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 +0200683O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200684O_CLI="$O_CLI -connect localhost:+SRV_PORT"
685G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000686G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200687
Gilles Peskine62469d92017-05-10 10:13:59 +0200688# Allow SHA-1, because many of our test certificates use it
689P_SRV="$P_SRV allow_sha1=1"
690P_CLI="$P_CLI allow_sha1=1"
691
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200692# Also pick a unique name for intermediate files
693SRV_OUT="srv_out.$$"
694CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200695PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200696SESSION="session.$$"
697
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200698SKIP_NEXT="NO"
699
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100700trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100701
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200702# Basic test
703
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200704# Checks that:
705# - things work with all ciphersuites active (used with config-full in all.sh)
706# - the expected (highest security) parameters are selected
707# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200708run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200709 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200710 "$P_CLI" \
711 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200712 -s "Protocol is TLSv1.2" \
713 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
714 -s "client hello v3, signature_algorithm ext: 6" \
715 -s "ECDHE curve: secp521r1" \
716 -S "error" \
717 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200718
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000719run_test "Default, DTLS" \
720 "$P_SRV dtls=1" \
721 "$P_CLI dtls=1" \
722 0 \
723 -s "Protocol is DTLSv1.2" \
724 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
725
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100726# Test current time in ServerHello
727requires_config_enabled MBEDTLS_HAVE_TIME
728run_test "Default, ServerHello contains gmt_unix_time" \
729 "$P_SRV debug_level=3" \
730 "$P_CLI debug_level=3" \
731 0 \
732 -s "Protocol is TLSv1.2" \
733 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
734 -s "client hello v3, signature_algorithm ext: 6" \
735 -s "ECDHE curve: secp521r1" \
736 -S "error" \
737 -C "error" \
738 -f "check_server_hello_time" \
739 -F "check_server_hello_time"
740
Simon Butcher8e004102016-10-14 00:48:33 +0100741# Test for uniqueness of IVs in AEAD ciphersuites
742run_test "Unique IV in GCM" \
743 "$P_SRV exchanges=20 debug_level=4" \
744 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
745 0 \
746 -u "IV used" \
747 -U "IV used"
748
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100749# Tests for rc4 option
750
Simon Butchera410af52016-05-19 22:12:18 +0100751requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100752run_test "RC4: server disabled, client enabled" \
753 "$P_SRV" \
754 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
755 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100756 -s "SSL - The server has no ciphersuites in common"
757
Simon Butchera410af52016-05-19 22:12:18 +0100758requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100759run_test "RC4: server half, client enabled" \
760 "$P_SRV arc4=1" \
761 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
762 1 \
763 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100764
765run_test "RC4: server enabled, client disabled" \
766 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
767 "$P_CLI" \
768 1 \
769 -s "SSL - The server has no ciphersuites in common"
770
771run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100772 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100773 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
774 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100775 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100776 -S "SSL - The server has no ciphersuites in common"
777
Gilles Peskinebc70a182017-05-09 15:59:24 +0200778# Tests for SHA-1 support
779
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200780requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200781run_test "SHA-1 forbidden by default in server certificate" \
782 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
783 "$P_CLI debug_level=2 allow_sha1=0" \
784 1 \
785 -c "The certificate is signed with an unacceptable hash"
786
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200787requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
788run_test "SHA-1 forbidden by default in server certificate" \
789 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
790 "$P_CLI debug_level=2 allow_sha1=0" \
791 0
792
Gilles Peskinebc70a182017-05-09 15:59:24 +0200793run_test "SHA-1 explicitly allowed in server certificate" \
794 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
795 "$P_CLI allow_sha1=1" \
796 0
797
798run_test "SHA-256 allowed by default in server certificate" \
799 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
800 "$P_CLI allow_sha1=0" \
801 0
802
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200803requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200804run_test "SHA-1 forbidden by default in client certificate" \
805 "$P_SRV auth_mode=required allow_sha1=0" \
806 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
807 1 \
808 -s "The certificate is signed with an unacceptable hash"
809
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200810requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
811run_test "SHA-1 forbidden by default in client certificate" \
812 "$P_SRV auth_mode=required allow_sha1=0" \
813 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
814 0
815
Gilles Peskinebc70a182017-05-09 15:59:24 +0200816run_test "SHA-1 explicitly allowed in client certificate" \
817 "$P_SRV auth_mode=required allow_sha1=1" \
818 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
819 0
820
821run_test "SHA-256 allowed by default in client certificate" \
822 "$P_SRV auth_mode=required allow_sha1=0" \
823 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
824 0
825
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100826# Tests for Truncated HMAC extension
827
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100828run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200829 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100830 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100831 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000832 -s "dumping 'expected mac' (20 bytes)" \
833 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100834
Hanno Becker32c55012017-11-10 08:42:54 +0000835requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100836run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200837 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000838 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100839 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000840 -s "dumping 'expected mac' (20 bytes)" \
841 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100842
Hanno Becker32c55012017-11-10 08:42:54 +0000843requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100844run_test "Truncated HMAC: client enabled, server default" \
845 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000846 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100847 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000848 -s "dumping 'expected mac' (20 bytes)" \
849 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100850
Hanno Becker32c55012017-11-10 08:42:54 +0000851requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100852run_test "Truncated HMAC: client enabled, server disabled" \
853 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000854 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100855 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000856 -s "dumping 'expected mac' (20 bytes)" \
857 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100858
Hanno Becker32c55012017-11-10 08:42:54 +0000859requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000860run_test "Truncated HMAC: client disabled, server enabled" \
861 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000862 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000863 0 \
864 -s "dumping 'expected mac' (20 bytes)" \
865 -S "dumping 'expected mac' (10 bytes)"
866
867requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100868run_test "Truncated HMAC: client enabled, server enabled" \
869 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000870 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100871 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000872 -S "dumping 'expected mac' (20 bytes)" \
873 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100874
Hanno Becker4c4f4102017-11-10 09:16:05 +0000875run_test "Truncated HMAC, DTLS: client default, server default" \
876 "$P_SRV dtls=1 debug_level=4" \
877 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
878 0 \
879 -s "dumping 'expected mac' (20 bytes)" \
880 -S "dumping 'expected mac' (10 bytes)"
881
882requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
883run_test "Truncated HMAC, DTLS: client disabled, server default" \
884 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000885 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000886 0 \
887 -s "dumping 'expected mac' (20 bytes)" \
888 -S "dumping 'expected mac' (10 bytes)"
889
890requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
891run_test "Truncated HMAC, DTLS: client enabled, server default" \
892 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000893 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000894 0 \
895 -s "dumping 'expected mac' (20 bytes)" \
896 -S "dumping 'expected mac' (10 bytes)"
897
898requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
899run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
900 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000901 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000902 0 \
903 -s "dumping 'expected mac' (20 bytes)" \
904 -S "dumping 'expected mac' (10 bytes)"
905
906requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
907run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
908 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000909 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000910 0 \
911 -s "dumping 'expected mac' (20 bytes)" \
912 -S "dumping 'expected mac' (10 bytes)"
913
914requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
915run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
916 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000917 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000918 0 \
919 -S "dumping 'expected mac' (20 bytes)" \
920 -s "dumping 'expected mac' (10 bytes)"
921
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100922# Tests for Encrypt-then-MAC extension
923
924run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100925 "$P_SRV debug_level=3 \
926 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100927 "$P_CLI debug_level=3" \
928 0 \
929 -c "client hello, adding encrypt_then_mac extension" \
930 -s "found encrypt then mac extension" \
931 -s "server hello, adding encrypt then mac extension" \
932 -c "found encrypt_then_mac extension" \
933 -c "using encrypt then mac" \
934 -s "using encrypt then mac"
935
936run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100937 "$P_SRV debug_level=3 etm=0 \
938 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100939 "$P_CLI debug_level=3 etm=1" \
940 0 \
941 -c "client hello, adding encrypt_then_mac extension" \
942 -s "found encrypt then mac extension" \
943 -S "server hello, adding encrypt then mac extension" \
944 -C "found encrypt_then_mac extension" \
945 -C "using encrypt then mac" \
946 -S "using encrypt then mac"
947
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100948run_test "Encrypt then MAC: client enabled, aead cipher" \
949 "$P_SRV debug_level=3 etm=1 \
950 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
951 "$P_CLI debug_level=3 etm=1" \
952 0 \
953 -c "client hello, adding encrypt_then_mac extension" \
954 -s "found encrypt then mac extension" \
955 -S "server hello, adding encrypt then mac extension" \
956 -C "found encrypt_then_mac extension" \
957 -C "using encrypt then mac" \
958 -S "using encrypt then mac"
959
960run_test "Encrypt then MAC: client enabled, stream cipher" \
961 "$P_SRV debug_level=3 etm=1 \
962 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100963 "$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 +0100964 0 \
965 -c "client hello, adding encrypt_then_mac extension" \
966 -s "found encrypt then mac extension" \
967 -S "server hello, adding encrypt then mac extension" \
968 -C "found encrypt_then_mac extension" \
969 -C "using encrypt then mac" \
970 -S "using encrypt then mac"
971
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100972run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100973 "$P_SRV debug_level=3 etm=1 \
974 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100975 "$P_CLI debug_level=3 etm=0" \
976 0 \
977 -C "client hello, adding encrypt_then_mac extension" \
978 -S "found encrypt then mac extension" \
979 -S "server hello, adding encrypt then mac extension" \
980 -C "found encrypt_then_mac extension" \
981 -C "using encrypt then mac" \
982 -S "using encrypt then mac"
983
Janos Follathe2681a42016-03-07 15:57:05 +0000984requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100985run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100986 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100987 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100988 "$P_CLI debug_level=3 force_version=ssl3" \
989 0 \
990 -C "client hello, adding encrypt_then_mac extension" \
991 -S "found encrypt then mac extension" \
992 -S "server hello, adding encrypt then mac extension" \
993 -C "found encrypt_then_mac extension" \
994 -C "using encrypt then mac" \
995 -S "using encrypt then mac"
996
Janos Follathe2681a42016-03-07 15:57:05 +0000997requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100998run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100999 "$P_SRV debug_level=3 force_version=ssl3 \
1000 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001001 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001002 0 \
1003 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001004 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001005 -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
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001010# Tests for Extended Master Secret extension
1011
1012run_test "Extended Master Secret: default" \
1013 "$P_SRV debug_level=3" \
1014 "$P_CLI debug_level=3" \
1015 0 \
1016 -c "client hello, adding extended_master_secret extension" \
1017 -s "found extended master secret extension" \
1018 -s "server hello, adding extended master secret extension" \
1019 -c "found extended_master_secret extension" \
1020 -c "using extended master secret" \
1021 -s "using extended master secret"
1022
1023run_test "Extended Master Secret: client enabled, server disabled" \
1024 "$P_SRV debug_level=3 extended_ms=0" \
1025 "$P_CLI debug_level=3 extended_ms=1" \
1026 0 \
1027 -c "client hello, adding extended_master_secret extension" \
1028 -s "found extended master secret extension" \
1029 -S "server hello, adding extended master secret extension" \
1030 -C "found extended_master_secret extension" \
1031 -C "using extended master secret" \
1032 -S "using extended master secret"
1033
1034run_test "Extended Master Secret: client disabled, server enabled" \
1035 "$P_SRV debug_level=3 extended_ms=1" \
1036 "$P_CLI debug_level=3 extended_ms=0" \
1037 0 \
1038 -C "client hello, adding extended_master_secret extension" \
1039 -S "found extended master secret extension" \
1040 -S "server hello, adding extended master secret extension" \
1041 -C "found extended_master_secret extension" \
1042 -C "using extended master secret" \
1043 -S "using extended master secret"
1044
Janos Follathe2681a42016-03-07 15:57:05 +00001045requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001046run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001047 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001048 "$P_CLI debug_level=3 force_version=ssl3" \
1049 0 \
1050 -C "client hello, adding extended_master_secret extension" \
1051 -S "found extended master secret extension" \
1052 -S "server hello, adding extended master secret extension" \
1053 -C "found extended_master_secret extension" \
1054 -C "using extended master secret" \
1055 -S "using extended master secret"
1056
Janos Follathe2681a42016-03-07 15:57:05 +00001057requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001058run_test "Extended Master Secret: client enabled, server SSLv3" \
1059 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001060 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001061 0 \
1062 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001063 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001064 -S "server hello, adding extended master secret extension" \
1065 -C "found extended_master_secret extension" \
1066 -C "using extended master secret" \
1067 -S "using extended master secret"
1068
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001069# Tests for FALLBACK_SCSV
1070
1071run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001072 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001073 "$P_CLI debug_level=3 force_version=tls1_1" \
1074 0 \
1075 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001076 -S "received FALLBACK_SCSV" \
1077 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001078 -C "is a fatal alert message (msg 86)"
1079
1080run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001081 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001082 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1083 0 \
1084 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001085 -S "received FALLBACK_SCSV" \
1086 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001087 -C "is a fatal alert message (msg 86)"
1088
1089run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001090 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001091 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001092 1 \
1093 -c "adding FALLBACK_SCSV" \
1094 -s "received FALLBACK_SCSV" \
1095 -s "inapropriate fallback" \
1096 -c "is a fatal alert message (msg 86)"
1097
1098run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001099 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001100 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001101 0 \
1102 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001103 -s "received FALLBACK_SCSV" \
1104 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001105 -C "is a fatal alert message (msg 86)"
1106
1107requires_openssl_with_fallback_scsv
1108run_test "Fallback SCSV: default, openssl server" \
1109 "$O_SRV" \
1110 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1111 0 \
1112 -C "adding FALLBACK_SCSV" \
1113 -C "is a fatal alert message (msg 86)"
1114
1115requires_openssl_with_fallback_scsv
1116run_test "Fallback SCSV: enabled, openssl server" \
1117 "$O_SRV" \
1118 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1119 1 \
1120 -c "adding FALLBACK_SCSV" \
1121 -c "is a fatal alert message (msg 86)"
1122
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001123requires_openssl_with_fallback_scsv
1124run_test "Fallback SCSV: disabled, openssl client" \
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 "$O_CLI -tls1_1" \
1127 0 \
1128 -S "received FALLBACK_SCSV" \
1129 -S "inapropriate fallback"
1130
1131requires_openssl_with_fallback_scsv
1132run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001133 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001134 "$O_CLI -tls1_1 -fallback_scsv" \
1135 1 \
1136 -s "received FALLBACK_SCSV" \
1137 -s "inapropriate fallback"
1138
1139requires_openssl_with_fallback_scsv
1140run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001141 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001142 "$O_CLI -fallback_scsv" \
1143 0 \
1144 -s "received FALLBACK_SCSV" \
1145 -S "inapropriate fallback"
1146
Gilles Peskined50177f2017-05-16 17:53:03 +02001147## ClientHello generated with
1148## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1149## then manually twiddling the ciphersuite list.
1150## The ClientHello content is spelled out below as a hex string as
1151## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1152## The expected response is an inappropriate_fallback alert.
1153requires_openssl_with_fallback_scsv
1154run_test "Fallback SCSV: beginning of list" \
1155 "$P_SRV debug_level=2" \
1156 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1157 0 \
1158 -s "received FALLBACK_SCSV" \
1159 -s "inapropriate fallback"
1160
1161requires_openssl_with_fallback_scsv
1162run_test "Fallback SCSV: end of list" \
1163 "$P_SRV debug_level=2" \
1164 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1165 0 \
1166 -s "received FALLBACK_SCSV" \
1167 -s "inapropriate fallback"
1168
1169## Here the expected response is a valid ServerHello prefix, up to the random.
1170requires_openssl_with_fallback_scsv
1171run_test "Fallback SCSV: not in list" \
1172 "$P_SRV debug_level=2" \
1173 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1174 0 \
1175 -S "received FALLBACK_SCSV" \
1176 -S "inapropriate fallback"
1177
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001178# Tests for CBC 1/n-1 record splitting
1179
1180run_test "CBC Record splitting: TLS 1.2, no splitting" \
1181 "$P_SRV" \
1182 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1183 request_size=123 force_version=tls1_2" \
1184 0 \
1185 -s "Read from client: 123 bytes read" \
1186 -S "Read from client: 1 bytes read" \
1187 -S "122 bytes read"
1188
1189run_test "CBC Record splitting: TLS 1.1, no splitting" \
1190 "$P_SRV" \
1191 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1192 request_size=123 force_version=tls1_1" \
1193 0 \
1194 -s "Read from client: 123 bytes read" \
1195 -S "Read from client: 1 bytes read" \
1196 -S "122 bytes read"
1197
1198run_test "CBC Record splitting: TLS 1.0, splitting" \
1199 "$P_SRV" \
1200 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1201 request_size=123 force_version=tls1" \
1202 0 \
1203 -S "Read from client: 123 bytes read" \
1204 -s "Read from client: 1 bytes read" \
1205 -s "122 bytes read"
1206
Janos Follathe2681a42016-03-07 15:57:05 +00001207requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001208run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001209 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001210 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1211 request_size=123 force_version=ssl3" \
1212 0 \
1213 -S "Read from client: 123 bytes read" \
1214 -s "Read from client: 1 bytes read" \
1215 -s "122 bytes read"
1216
1217run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001218 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001219 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1220 request_size=123 force_version=tls1" \
1221 0 \
1222 -s "Read from client: 123 bytes read" \
1223 -S "Read from client: 1 bytes read" \
1224 -S "122 bytes read"
1225
1226run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1227 "$P_SRV" \
1228 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1229 request_size=123 force_version=tls1 recsplit=0" \
1230 0 \
1231 -s "Read from client: 123 bytes read" \
1232 -S "Read from client: 1 bytes read" \
1233 -S "122 bytes read"
1234
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001235run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1236 "$P_SRV nbio=2" \
1237 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1238 request_size=123 force_version=tls1" \
1239 0 \
1240 -S "Read from client: 123 bytes read" \
1241 -s "Read from client: 1 bytes read" \
1242 -s "122 bytes read"
1243
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001244# Tests for Session Tickets
1245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001246run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001247 "$P_SRV debug_level=3 tickets=1" \
1248 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001249 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001250 -c "client hello, adding session ticket extension" \
1251 -s "found session ticket extension" \
1252 -s "server hello, adding session ticket extension" \
1253 -c "found session_ticket extension" \
1254 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001255 -S "session successfully restored from cache" \
1256 -s "session successfully restored from ticket" \
1257 -s "a session has been resumed" \
1258 -c "a session has been resumed"
1259
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001260run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001261 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1262 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001263 0 \
1264 -c "client hello, adding session ticket extension" \
1265 -s "found session ticket extension" \
1266 -s "server hello, adding session ticket extension" \
1267 -c "found session_ticket extension" \
1268 -c "parse new session ticket" \
1269 -S "session successfully restored from cache" \
1270 -s "session successfully restored from ticket" \
1271 -s "a session has been resumed" \
1272 -c "a session has been resumed"
1273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001274run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001275 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1276 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001277 0 \
1278 -c "client hello, adding session ticket extension" \
1279 -s "found session ticket extension" \
1280 -s "server hello, adding session ticket extension" \
1281 -c "found session_ticket extension" \
1282 -c "parse new session ticket" \
1283 -S "session successfully restored from cache" \
1284 -S "session successfully restored from ticket" \
1285 -S "a session has been resumed" \
1286 -C "a session has been resumed"
1287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001288run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001289 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001290 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001291 0 \
1292 -c "client hello, adding session ticket extension" \
1293 -c "found session_ticket extension" \
1294 -c "parse new session ticket" \
1295 -c "a session has been resumed"
1296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001297run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001298 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001299 "( $O_CLI -sess_out $SESSION; \
1300 $O_CLI -sess_in $SESSION; \
1301 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001302 0 \
1303 -s "found session ticket extension" \
1304 -s "server hello, adding session ticket extension" \
1305 -S "session successfully restored from cache" \
1306 -s "session successfully restored from ticket" \
1307 -s "a session has been resumed"
1308
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001309# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001311run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001312 "$P_SRV debug_level=3 tickets=0" \
1313 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001314 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001315 -c "client hello, adding session ticket extension" \
1316 -s "found session ticket extension" \
1317 -S "server hello, adding session ticket extension" \
1318 -C "found session_ticket extension" \
1319 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001320 -s "session successfully restored from cache" \
1321 -S "session successfully restored from ticket" \
1322 -s "a session has been resumed" \
1323 -c "a session has been resumed"
1324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001325run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001326 "$P_SRV debug_level=3 tickets=1" \
1327 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001328 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001329 -C "client hello, adding session ticket extension" \
1330 -S "found session ticket extension" \
1331 -S "server hello, adding session ticket extension" \
1332 -C "found session_ticket extension" \
1333 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001334 -s "session successfully restored from cache" \
1335 -S "session successfully restored from ticket" \
1336 -s "a session has been resumed" \
1337 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001339run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001340 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1341 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001342 0 \
1343 -S "session successfully restored from cache" \
1344 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001345 -S "a session has been resumed" \
1346 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001348run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001349 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1350 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001351 0 \
1352 -s "session successfully restored from cache" \
1353 -S "session successfully restored from ticket" \
1354 -s "a session has been resumed" \
1355 -c "a session has been resumed"
1356
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001357run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001358 "$P_SRV debug_level=3 tickets=0" \
1359 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001360 0 \
1361 -s "session successfully restored from cache" \
1362 -S "session successfully restored from ticket" \
1363 -s "a session has been resumed" \
1364 -c "a session has been resumed"
1365
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001366run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001367 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1368 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001369 0 \
1370 -S "session successfully restored from cache" \
1371 -S "session successfully restored from ticket" \
1372 -S "a session has been resumed" \
1373 -C "a session has been resumed"
1374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001376 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1377 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001378 0 \
1379 -s "session successfully restored from cache" \
1380 -S "session successfully restored from ticket" \
1381 -s "a session has been resumed" \
1382 -c "a session has been resumed"
1383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001384run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001385 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001386 "( $O_CLI -sess_out $SESSION; \
1387 $O_CLI -sess_in $SESSION; \
1388 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001389 0 \
1390 -s "found session ticket extension" \
1391 -S "server hello, adding session ticket extension" \
1392 -s "session successfully restored from cache" \
1393 -S "session successfully restored from ticket" \
1394 -s "a session has been resumed"
1395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001396run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001397 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001398 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001399 0 \
1400 -C "found session_ticket extension" \
1401 -C "parse new session ticket" \
1402 -c "a session has been resumed"
1403
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001404# Tests for Max Fragment Length extension
1405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001406run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001407 "$P_SRV debug_level=3" \
1408 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001409 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001410 -c "Maximum fragment length is 16384" \
1411 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001412 -C "client hello, adding max_fragment_length extension" \
1413 -S "found max fragment length extension" \
1414 -S "server hello, max_fragment_length extension" \
1415 -C "found max_fragment_length extension"
1416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001417run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001418 "$P_SRV debug_level=3" \
1419 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001420 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001421 -c "Maximum fragment length is 4096" \
1422 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001423 -c "client hello, adding max_fragment_length extension" \
1424 -s "found max fragment length extension" \
1425 -s "server hello, max_fragment_length extension" \
1426 -c "found max_fragment_length extension"
1427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001428run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001429 "$P_SRV debug_level=3 max_frag_len=4096" \
1430 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001431 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001432 -c "Maximum fragment length is 16384" \
1433 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001434 -C "client hello, adding max_fragment_length extension" \
1435 -S "found max fragment length extension" \
1436 -S "server hello, max_fragment_length extension" \
1437 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001439requires_gnutls
1440run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001441 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001442 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001443 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001444 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001445 -c "client hello, adding max_fragment_length extension" \
1446 -c "found max_fragment_length extension"
1447
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001448run_test "Max fragment length: client, message just fits" \
1449 "$P_SRV debug_level=3" \
1450 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1451 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001452 -c "Maximum fragment length is 2048" \
1453 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001454 -c "client hello, adding max_fragment_length extension" \
1455 -s "found max fragment length extension" \
1456 -s "server hello, max_fragment_length extension" \
1457 -c "found max_fragment_length extension" \
1458 -c "2048 bytes written in 1 fragments" \
1459 -s "2048 bytes read"
1460
1461run_test "Max fragment length: client, larger message" \
1462 "$P_SRV debug_level=3" \
1463 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1464 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001465 -c "Maximum fragment length is 2048" \
1466 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001467 -c "client hello, adding max_fragment_length extension" \
1468 -s "found max fragment length extension" \
1469 -s "server hello, max_fragment_length extension" \
1470 -c "found max_fragment_length extension" \
1471 -c "2345 bytes written in 2 fragments" \
1472 -s "2048 bytes read" \
1473 -s "297 bytes read"
1474
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001475run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001476 "$P_SRV debug_level=3 dtls=1" \
1477 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1478 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001479 -c "Maximum fragment length is 2048" \
1480 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001481 -c "client hello, adding max_fragment_length extension" \
1482 -s "found max fragment length extension" \
1483 -s "server hello, max_fragment_length extension" \
1484 -c "found max_fragment_length extension" \
1485 -c "fragment larger than.*maximum"
1486
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001487# Tests for renegotiation
1488
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001489run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001490 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001491 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001492 0 \
1493 -C "client hello, adding renegotiation extension" \
1494 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1495 -S "found renegotiation extension" \
1496 -s "server hello, secure renegotiation extension" \
1497 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001498 -C "=> renegotiate" \
1499 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001500 -S "write hello request"
1501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001502run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001503 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001504 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001505 0 \
1506 -c "client hello, adding renegotiation extension" \
1507 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1508 -s "found renegotiation extension" \
1509 -s "server hello, secure renegotiation extension" \
1510 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001511 -c "=> renegotiate" \
1512 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001513 -S "write hello request"
1514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001515run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001516 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001517 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001518 0 \
1519 -c "client hello, adding renegotiation extension" \
1520 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1521 -s "found renegotiation extension" \
1522 -s "server hello, secure renegotiation extension" \
1523 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001524 -c "=> renegotiate" \
1525 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001526 -s "write hello request"
1527
Janos Follathb0f148c2017-10-05 12:29:42 +01001528# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1529# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1530# algorithm stronger than SHA-1 is enabled in config.h
1531run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1532 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1533 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1534 0 \
1535 -c "client hello, adding renegotiation extension" \
1536 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1537 -s "found renegotiation extension" \
1538 -s "server hello, secure renegotiation extension" \
1539 -c "found renegotiation extension" \
1540 -c "=> renegotiate" \
1541 -s "=> renegotiate" \
1542 -S "write hello request" \
1543 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1544
1545# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1546# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1547# algorithm stronger than SHA-1 is enabled in config.h
1548run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1549 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1550 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1551 0 \
1552 -c "client hello, adding renegotiation extension" \
1553 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1554 -s "found renegotiation extension" \
1555 -s "server hello, secure renegotiation extension" \
1556 -c "found renegotiation extension" \
1557 -c "=> renegotiate" \
1558 -s "=> renegotiate" \
1559 -s "write hello request" \
1560 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001563 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001564 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001565 0 \
1566 -c "client hello, adding renegotiation extension" \
1567 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1568 -s "found renegotiation extension" \
1569 -s "server hello, secure renegotiation extension" \
1570 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001571 -c "=> renegotiate" \
1572 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001573 -s "write hello request"
1574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001575run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001576 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001577 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001578 1 \
1579 -c "client hello, adding renegotiation extension" \
1580 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1581 -S "found renegotiation extension" \
1582 -s "server hello, secure renegotiation extension" \
1583 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001584 -c "=> renegotiate" \
1585 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001586 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001587 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001588 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001590run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001591 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001592 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001593 0 \
1594 -C "client hello, adding renegotiation extension" \
1595 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1596 -S "found renegotiation extension" \
1597 -s "server hello, secure renegotiation extension" \
1598 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001599 -C "=> renegotiate" \
1600 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001601 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001602 -S "SSL - An unexpected message was received from our peer" \
1603 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001605run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001606 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001607 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001608 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001609 0 \
1610 -C "client hello, adding renegotiation extension" \
1611 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1612 -S "found renegotiation extension" \
1613 -s "server hello, secure renegotiation extension" \
1614 -c "found renegotiation extension" \
1615 -C "=> renegotiate" \
1616 -S "=> renegotiate" \
1617 -s "write hello request" \
1618 -S "SSL - An unexpected message was received from our peer" \
1619 -S "failed"
1620
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001621# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001622run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001623 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001624 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001625 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001626 0 \
1627 -C "client hello, adding renegotiation extension" \
1628 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1629 -S "found renegotiation extension" \
1630 -s "server hello, secure renegotiation extension" \
1631 -c "found renegotiation extension" \
1632 -C "=> renegotiate" \
1633 -S "=> renegotiate" \
1634 -s "write hello request" \
1635 -S "SSL - An unexpected message was received from our peer" \
1636 -S "failed"
1637
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001638run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001639 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001640 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001641 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001642 0 \
1643 -C "client hello, adding renegotiation extension" \
1644 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1645 -S "found renegotiation extension" \
1646 -s "server hello, secure renegotiation extension" \
1647 -c "found renegotiation extension" \
1648 -C "=> renegotiate" \
1649 -S "=> renegotiate" \
1650 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001651 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001653run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001654 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001655 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001656 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001657 0 \
1658 -c "client hello, adding renegotiation extension" \
1659 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1660 -s "found renegotiation extension" \
1661 -s "server hello, secure renegotiation extension" \
1662 -c "found renegotiation extension" \
1663 -c "=> renegotiate" \
1664 -s "=> renegotiate" \
1665 -s "write hello request" \
1666 -S "SSL - An unexpected message was received from our peer" \
1667 -S "failed"
1668
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001669run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001670 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001671 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1672 0 \
1673 -C "client hello, adding renegotiation extension" \
1674 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1675 -S "found renegotiation extension" \
1676 -s "server hello, secure renegotiation extension" \
1677 -c "found renegotiation extension" \
1678 -S "record counter limit reached: renegotiate" \
1679 -C "=> renegotiate" \
1680 -S "=> renegotiate" \
1681 -S "write hello request" \
1682 -S "SSL - An unexpected message was received from our peer" \
1683 -S "failed"
1684
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001685# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001686run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001687 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001688 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001689 0 \
1690 -c "client hello, adding renegotiation extension" \
1691 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1692 -s "found renegotiation extension" \
1693 -s "server hello, secure renegotiation extension" \
1694 -c "found renegotiation extension" \
1695 -s "record counter limit reached: renegotiate" \
1696 -c "=> renegotiate" \
1697 -s "=> renegotiate" \
1698 -s "write hello request" \
1699 -S "SSL - An unexpected message was received from our peer" \
1700 -S "failed"
1701
1702run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001703 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001704 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001705 0 \
1706 -c "client hello, adding renegotiation extension" \
1707 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1708 -s "found renegotiation extension" \
1709 -s "server hello, secure renegotiation extension" \
1710 -c "found renegotiation extension" \
1711 -s "record counter limit reached: renegotiate" \
1712 -c "=> renegotiate" \
1713 -s "=> renegotiate" \
1714 -s "write hello request" \
1715 -S "SSL - An unexpected message was received from our peer" \
1716 -S "failed"
1717
1718run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001719 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001720 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1721 0 \
1722 -C "client hello, adding renegotiation extension" \
1723 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1724 -S "found renegotiation extension" \
1725 -s "server hello, secure renegotiation extension" \
1726 -c "found renegotiation extension" \
1727 -S "record counter limit reached: renegotiate" \
1728 -C "=> renegotiate" \
1729 -S "=> renegotiate" \
1730 -S "write hello request" \
1731 -S "SSL - An unexpected message was received from our peer" \
1732 -S "failed"
1733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001734run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001735 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001736 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001737 0 \
1738 -c "client hello, adding renegotiation extension" \
1739 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1740 -s "found renegotiation extension" \
1741 -s "server hello, secure renegotiation extension" \
1742 -c "found renegotiation extension" \
1743 -c "=> renegotiate" \
1744 -s "=> renegotiate" \
1745 -S "write hello request"
1746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001747run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001748 "$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 +02001749 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001750 0 \
1751 -c "client hello, adding renegotiation extension" \
1752 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1753 -s "found renegotiation extension" \
1754 -s "server hello, secure renegotiation extension" \
1755 -c "found renegotiation extension" \
1756 -c "=> renegotiate" \
1757 -s "=> renegotiate" \
1758 -s "write hello request"
1759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001760run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001761 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001762 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001763 0 \
1764 -c "client hello, adding renegotiation extension" \
1765 -c "found renegotiation extension" \
1766 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001767 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001768 -C "error" \
1769 -c "HTTP/1.0 200 [Oo][Kk]"
1770
Paul Bakker539d9722015-02-08 16:18:35 +01001771requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001772run_test "Renegotiation: gnutls server strict, client-initiated" \
1773 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001774 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001775 0 \
1776 -c "client hello, adding renegotiation extension" \
1777 -c "found renegotiation extension" \
1778 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001779 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001780 -C "error" \
1781 -c "HTTP/1.0 200 [Oo][Kk]"
1782
Paul Bakker539d9722015-02-08 16:18:35 +01001783requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001784run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1785 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1786 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1787 1 \
1788 -c "client hello, adding renegotiation extension" \
1789 -C "found renegotiation extension" \
1790 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001791 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001792 -c "error" \
1793 -C "HTTP/1.0 200 [Oo][Kk]"
1794
Paul Bakker539d9722015-02-08 16:18:35 +01001795requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001796run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1797 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1798 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1799 allow_legacy=0" \
1800 1 \
1801 -c "client hello, adding renegotiation extension" \
1802 -C "found renegotiation extension" \
1803 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001804 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001805 -c "error" \
1806 -C "HTTP/1.0 200 [Oo][Kk]"
1807
Paul Bakker539d9722015-02-08 16:18:35 +01001808requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001809run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1810 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1811 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1812 allow_legacy=1" \
1813 0 \
1814 -c "client hello, adding renegotiation extension" \
1815 -C "found renegotiation extension" \
1816 -c "=> renegotiate" \
1817 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001818 -C "error" \
1819 -c "HTTP/1.0 200 [Oo][Kk]"
1820
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001821run_test "Renegotiation: DTLS, client-initiated" \
1822 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1823 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1824 0 \
1825 -c "client hello, adding renegotiation extension" \
1826 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1827 -s "found renegotiation extension" \
1828 -s "server hello, secure renegotiation extension" \
1829 -c "found renegotiation extension" \
1830 -c "=> renegotiate" \
1831 -s "=> renegotiate" \
1832 -S "write hello request"
1833
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001834run_test "Renegotiation: DTLS, server-initiated" \
1835 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001836 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1837 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001838 0 \
1839 -c "client hello, adding renegotiation extension" \
1840 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1841 -s "found renegotiation extension" \
1842 -s "server hello, secure renegotiation extension" \
1843 -c "found renegotiation extension" \
1844 -c "=> renegotiate" \
1845 -s "=> renegotiate" \
1846 -s "write hello request"
1847
Andres AG692ad842017-01-19 16:30:57 +00001848run_test "Renegotiation: DTLS, renego_period overflow" \
1849 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1850 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1851 0 \
1852 -c "client hello, adding renegotiation extension" \
1853 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1854 -s "found renegotiation extension" \
1855 -s "server hello, secure renegotiation extension" \
1856 -s "record counter limit reached: renegotiate" \
1857 -c "=> renegotiate" \
1858 -s "=> renegotiate" \
1859 -s "write hello request" \
1860
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001861requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001862run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1863 "$G_SRV -u --mtu 4096" \
1864 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1865 0 \
1866 -c "client hello, adding renegotiation extension" \
1867 -c "found renegotiation extension" \
1868 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001869 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001870 -C "error" \
1871 -s "Extra-header:"
1872
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001873# Test for the "secure renegotation" extension only (no actual renegotiation)
1874
Paul Bakker539d9722015-02-08 16:18:35 +01001875requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001876run_test "Renego ext: gnutls server strict, client default" \
1877 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1878 "$P_CLI debug_level=3" \
1879 0 \
1880 -c "found renegotiation extension" \
1881 -C "error" \
1882 -c "HTTP/1.0 200 [Oo][Kk]"
1883
Paul Bakker539d9722015-02-08 16:18:35 +01001884requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001885run_test "Renego ext: gnutls server unsafe, client default" \
1886 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1887 "$P_CLI debug_level=3" \
1888 0 \
1889 -C "found renegotiation extension" \
1890 -C "error" \
1891 -c "HTTP/1.0 200 [Oo][Kk]"
1892
Paul Bakker539d9722015-02-08 16:18:35 +01001893requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001894run_test "Renego ext: gnutls server unsafe, client break legacy" \
1895 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1896 "$P_CLI debug_level=3 allow_legacy=-1" \
1897 1 \
1898 -C "found renegotiation extension" \
1899 -c "error" \
1900 -C "HTTP/1.0 200 [Oo][Kk]"
1901
Paul Bakker539d9722015-02-08 16:18:35 +01001902requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001903run_test "Renego ext: gnutls client strict, server default" \
1904 "$P_SRV debug_level=3" \
1905 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1906 0 \
1907 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1908 -s "server hello, secure renegotiation extension"
1909
Paul Bakker539d9722015-02-08 16:18:35 +01001910requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001911run_test "Renego ext: gnutls client unsafe, server default" \
1912 "$P_SRV debug_level=3" \
1913 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1914 0 \
1915 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1916 -S "server hello, secure renegotiation extension"
1917
Paul Bakker539d9722015-02-08 16:18:35 +01001918requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001919run_test "Renego ext: gnutls client unsafe, server break legacy" \
1920 "$P_SRV debug_level=3 allow_legacy=-1" \
1921 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1922 1 \
1923 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1924 -S "server hello, secure renegotiation extension"
1925
Janos Follath0b242342016-02-17 10:11:21 +00001926# Tests for silently dropping trailing extra bytes in .der certificates
1927
1928requires_gnutls
1929run_test "DER format: no trailing bytes" \
1930 "$P_SRV crt_file=data_files/server5-der0.crt \
1931 key_file=data_files/server5.key" \
1932 "$G_CLI " \
1933 0 \
1934 -c "Handshake was completed" \
1935
1936requires_gnutls
1937run_test "DER format: with a trailing zero byte" \
1938 "$P_SRV crt_file=data_files/server5-der1a.crt \
1939 key_file=data_files/server5.key" \
1940 "$G_CLI " \
1941 0 \
1942 -c "Handshake was completed" \
1943
1944requires_gnutls
1945run_test "DER format: with a trailing random byte" \
1946 "$P_SRV crt_file=data_files/server5-der1b.crt \
1947 key_file=data_files/server5.key" \
1948 "$G_CLI " \
1949 0 \
1950 -c "Handshake was completed" \
1951
1952requires_gnutls
1953run_test "DER format: with 2 trailing random bytes" \
1954 "$P_SRV crt_file=data_files/server5-der2.crt \
1955 key_file=data_files/server5.key" \
1956 "$G_CLI " \
1957 0 \
1958 -c "Handshake was completed" \
1959
1960requires_gnutls
1961run_test "DER format: with 4 trailing random bytes" \
1962 "$P_SRV crt_file=data_files/server5-der4.crt \
1963 key_file=data_files/server5.key" \
1964 "$G_CLI " \
1965 0 \
1966 -c "Handshake was completed" \
1967
1968requires_gnutls
1969run_test "DER format: with 8 trailing random bytes" \
1970 "$P_SRV crt_file=data_files/server5-der8.crt \
1971 key_file=data_files/server5.key" \
1972 "$G_CLI " \
1973 0 \
1974 -c "Handshake was completed" \
1975
1976requires_gnutls
1977run_test "DER format: with 9 trailing random bytes" \
1978 "$P_SRV crt_file=data_files/server5-der9.crt \
1979 key_file=data_files/server5.key" \
1980 "$G_CLI " \
1981 0 \
1982 -c "Handshake was completed" \
1983
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001984# Tests for auth_mode
1985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001986run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001987 "$P_SRV crt_file=data_files/server5-badsign.crt \
1988 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001989 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001990 1 \
1991 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001992 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001993 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001994 -c "X509 - Certificate verification failed"
1995
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001996run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001997 "$P_SRV crt_file=data_files/server5-badsign.crt \
1998 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001999 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002000 0 \
2001 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002002 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002003 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002004 -C "X509 - Certificate verification failed"
2005
Hanno Beckere6706e62017-05-15 16:05:15 +01002006run_test "Authentication: server goodcert, client optional, no trusted CA" \
2007 "$P_SRV" \
2008 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2009 0 \
2010 -c "x509_verify_cert() returned" \
2011 -c "! The certificate is not correctly signed by the trusted CA" \
2012 -c "! Certificate verification flags"\
2013 -C "! mbedtls_ssl_handshake returned" \
2014 -C "X509 - Certificate verification failed" \
2015 -C "SSL - No CA Chain is set, but required to operate"
2016
2017run_test "Authentication: server goodcert, client required, no trusted CA" \
2018 "$P_SRV" \
2019 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2020 1 \
2021 -c "x509_verify_cert() returned" \
2022 -c "! The certificate is not correctly signed by the trusted CA" \
2023 -c "! Certificate verification flags"\
2024 -c "! mbedtls_ssl_handshake returned" \
2025 -c "SSL - No CA Chain is set, but required to operate"
2026
2027# The purpose of the next two tests is to test the client's behaviour when receiving a server
2028# certificate with an unsupported elliptic curve. This should usually not happen because
2029# the client informs the server about the supported curves - it does, though, in the
2030# corner case of a static ECDH suite, because the server doesn't check the curve on that
2031# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2032# different means to have the server ignoring the client's supported curve list.
2033
2034requires_config_enabled MBEDTLS_ECP_C
2035run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2036 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2037 crt_file=data_files/server5.ku-ka.crt" \
2038 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2039 1 \
2040 -c "bad certificate (EC key curve)"\
2041 -c "! Certificate verification flags"\
2042 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2043
2044requires_config_enabled MBEDTLS_ECP_C
2045run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2046 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2047 crt_file=data_files/server5.ku-ka.crt" \
2048 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2049 1 \
2050 -c "bad certificate (EC key curve)"\
2051 -c "! Certificate verification flags"\
2052 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002054run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002055 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002056 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002057 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002058 0 \
2059 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002060 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002061 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002062 -C "X509 - Certificate verification failed"
2063
Simon Butcher99000142016-10-13 17:21:01 +01002064run_test "Authentication: client SHA256, server required" \
2065 "$P_SRV auth_mode=required" \
2066 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2067 key_file=data_files/server6.key \
2068 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2069 0 \
2070 -c "Supported Signature Algorithm found: 4," \
2071 -c "Supported Signature Algorithm found: 5,"
2072
2073run_test "Authentication: client SHA384, server required" \
2074 "$P_SRV auth_mode=required" \
2075 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2076 key_file=data_files/server6.key \
2077 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2078 0 \
2079 -c "Supported Signature Algorithm found: 4," \
2080 -c "Supported Signature Algorithm found: 5,"
2081
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002082requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2083run_test "Authentication: client has no cert, server required (SSLv3)" \
2084 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2085 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2086 key_file=data_files/server5.key" \
2087 1 \
2088 -S "skip write certificate request" \
2089 -C "skip parse certificate request" \
2090 -c "got a certificate request" \
2091 -c "got no certificate to send" \
2092 -S "x509_verify_cert() returned" \
2093 -s "client has no certificate" \
2094 -s "! mbedtls_ssl_handshake returned" \
2095 -c "! mbedtls_ssl_handshake returned" \
2096 -s "No client certification received from the client, but required by the authentication mode"
2097
2098run_test "Authentication: client has no cert, server required (TLS)" \
2099 "$P_SRV debug_level=3 auth_mode=required" \
2100 "$P_CLI debug_level=3 crt_file=none \
2101 key_file=data_files/server5.key" \
2102 1 \
2103 -S "skip write certificate request" \
2104 -C "skip parse certificate request" \
2105 -c "got a certificate request" \
2106 -c "= write certificate$" \
2107 -C "skip write certificate$" \
2108 -S "x509_verify_cert() returned" \
2109 -s "client has no certificate" \
2110 -s "! mbedtls_ssl_handshake returned" \
2111 -c "! mbedtls_ssl_handshake returned" \
2112 -s "No client certification received from the client, but required by the authentication mode"
2113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002114run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002115 "$P_SRV debug_level=3 auth_mode=required" \
2116 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002117 key_file=data_files/server5.key" \
2118 1 \
2119 -S "skip write certificate request" \
2120 -C "skip parse certificate request" \
2121 -c "got a certificate request" \
2122 -C "skip write certificate" \
2123 -C "skip write certificate verify" \
2124 -S "skip parse certificate verify" \
2125 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002126 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002127 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002128 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002129 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002130 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002131# We don't check that the client receives the alert because it might
2132# detect that its write end of the connection is closed and abort
2133# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002134
Janos Follath89baba22017-04-10 14:34:35 +01002135run_test "Authentication: client cert not trusted, server required" \
2136 "$P_SRV debug_level=3 auth_mode=required" \
2137 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2138 key_file=data_files/server5.key" \
2139 1 \
2140 -S "skip write certificate request" \
2141 -C "skip parse certificate request" \
2142 -c "got a certificate request" \
2143 -C "skip write certificate" \
2144 -C "skip write certificate verify" \
2145 -S "skip parse certificate verify" \
2146 -s "x509_verify_cert() returned" \
2147 -s "! The certificate is not correctly signed by the trusted CA" \
2148 -s "! mbedtls_ssl_handshake returned" \
2149 -c "! mbedtls_ssl_handshake returned" \
2150 -s "X509 - Certificate verification failed"
2151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002152run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002153 "$P_SRV debug_level=3 auth_mode=optional" \
2154 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002155 key_file=data_files/server5.key" \
2156 0 \
2157 -S "skip write certificate request" \
2158 -C "skip parse certificate request" \
2159 -c "got a certificate request" \
2160 -C "skip write certificate" \
2161 -C "skip write certificate verify" \
2162 -S "skip parse certificate verify" \
2163 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002164 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002165 -S "! mbedtls_ssl_handshake returned" \
2166 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002167 -S "X509 - Certificate verification failed"
2168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002169run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002170 "$P_SRV debug_level=3 auth_mode=none" \
2171 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002172 key_file=data_files/server5.key" \
2173 0 \
2174 -s "skip write certificate request" \
2175 -C "skip parse certificate request" \
2176 -c "got no certificate request" \
2177 -c "skip write certificate" \
2178 -c "skip write certificate verify" \
2179 -s "skip parse certificate verify" \
2180 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002181 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002182 -S "! mbedtls_ssl_handshake returned" \
2183 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002184 -S "X509 - Certificate verification failed"
2185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002186run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002187 "$P_SRV debug_level=3 auth_mode=optional" \
2188 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002189 0 \
2190 -S "skip write certificate request" \
2191 -C "skip parse certificate request" \
2192 -c "got a certificate request" \
2193 -C "skip write certificate$" \
2194 -C "got no certificate to send" \
2195 -S "SSLv3 client has no certificate" \
2196 -c "skip write certificate verify" \
2197 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002198 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002199 -S "! mbedtls_ssl_handshake returned" \
2200 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002201 -S "X509 - Certificate verification failed"
2202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002203run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002204 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002205 "$O_CLI" \
2206 0 \
2207 -S "skip write certificate request" \
2208 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002209 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002210 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002211 -S "X509 - Certificate verification failed"
2212
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002213run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002214 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002215 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002216 0 \
2217 -C "skip parse certificate request" \
2218 -c "got a certificate request" \
2219 -C "skip write certificate$" \
2220 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002221 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002222
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002223run_test "Authentication: client no cert, openssl server required" \
2224 "$O_SRV -Verify 10" \
2225 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2226 1 \
2227 -C "skip parse certificate request" \
2228 -c "got a certificate request" \
2229 -C "skip write certificate$" \
2230 -c "skip write certificate verify" \
2231 -c "! mbedtls_ssl_handshake returned"
2232
Janos Follathe2681a42016-03-07 15:57:05 +00002233requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002234run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002235 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002236 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002237 0 \
2238 -S "skip write certificate request" \
2239 -C "skip parse certificate request" \
2240 -c "got a certificate request" \
2241 -C "skip write certificate$" \
2242 -c "skip write certificate verify" \
2243 -c "got no certificate to send" \
2244 -s "SSLv3 client has no certificate" \
2245 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002246 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002247 -S "! mbedtls_ssl_handshake returned" \
2248 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002249 -S "X509 - Certificate verification failed"
2250
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002251# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2252# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002253
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002254MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002255MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002256
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002257if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002258 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002259 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002260 printf "test value of ${MAX_IM_CA}. \n"
2261 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002262 printf "The tests assume this value and if it changes, the tests in this\n"
2263 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002264 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002265
2266 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002267fi
2268
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002269run_test "Authentication: server max_int chain, client default" \
2270 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2271 key_file=data_files/dir-maxpath/09.key" \
2272 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2273 0 \
2274 -C "X509 - A fatal error occured"
2275
2276run_test "Authentication: server max_int+1 chain, client default" \
2277 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2278 key_file=data_files/dir-maxpath/10.key" \
2279 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2280 1 \
2281 -c "X509 - A fatal error occured"
2282
2283run_test "Authentication: server max_int+1 chain, client optional" \
2284 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2285 key_file=data_files/dir-maxpath/10.key" \
2286 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2287 auth_mode=optional" \
2288 1 \
2289 -c "X509 - A fatal error occured"
2290
2291run_test "Authentication: server max_int+1 chain, client none" \
2292 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2293 key_file=data_files/dir-maxpath/10.key" \
2294 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2295 auth_mode=none" \
2296 0 \
2297 -C "X509 - A fatal error occured"
2298
2299run_test "Authentication: client max_int+1 chain, server default" \
2300 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2301 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2302 key_file=data_files/dir-maxpath/10.key" \
2303 0 \
2304 -S "X509 - A fatal error occured"
2305
2306run_test "Authentication: client max_int+1 chain, server optional" \
2307 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2308 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2309 key_file=data_files/dir-maxpath/10.key" \
2310 1 \
2311 -s "X509 - A fatal error occured"
2312
2313run_test "Authentication: client max_int+1 chain, server required" \
2314 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2315 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2316 key_file=data_files/dir-maxpath/10.key" \
2317 1 \
2318 -s "X509 - A fatal error occured"
2319
2320run_test "Authentication: client max_int chain, server required" \
2321 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2322 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2323 key_file=data_files/dir-maxpath/09.key" \
2324 0 \
2325 -S "X509 - A fatal error occured"
2326
Janos Follath89baba22017-04-10 14:34:35 +01002327# Tests for CA list in CertificateRequest messages
2328
2329run_test "Authentication: send CA list in CertificateRequest (default)" \
2330 "$P_SRV debug_level=3 auth_mode=required" \
2331 "$P_CLI crt_file=data_files/server6.crt \
2332 key_file=data_files/server6.key" \
2333 0 \
2334 -s "requested DN"
2335
2336run_test "Authentication: do not send CA list in CertificateRequest" \
2337 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2338 "$P_CLI crt_file=data_files/server6.crt \
2339 key_file=data_files/server6.key" \
2340 0 \
2341 -S "requested DN"
2342
2343run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2344 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2345 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2346 key_file=data_files/server5.key" \
2347 1 \
2348 -S "requested DN" \
2349 -s "x509_verify_cert() returned" \
2350 -s "! The certificate is not correctly signed by the trusted CA" \
2351 -s "! mbedtls_ssl_handshake returned" \
2352 -c "! mbedtls_ssl_handshake returned" \
2353 -s "X509 - Certificate verification failed"
2354
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002355# Tests for certificate selection based on SHA verson
2356
2357run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2358 "$P_SRV crt_file=data_files/server5.crt \
2359 key_file=data_files/server5.key \
2360 crt_file2=data_files/server5-sha1.crt \
2361 key_file2=data_files/server5.key" \
2362 "$P_CLI force_version=tls1_2" \
2363 0 \
2364 -c "signed using.*ECDSA with SHA256" \
2365 -C "signed using.*ECDSA with SHA1"
2366
2367run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2368 "$P_SRV crt_file=data_files/server5.crt \
2369 key_file=data_files/server5.key \
2370 crt_file2=data_files/server5-sha1.crt \
2371 key_file2=data_files/server5.key" \
2372 "$P_CLI force_version=tls1_1" \
2373 0 \
2374 -C "signed using.*ECDSA with SHA256" \
2375 -c "signed using.*ECDSA with SHA1"
2376
2377run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2378 "$P_SRV crt_file=data_files/server5.crt \
2379 key_file=data_files/server5.key \
2380 crt_file2=data_files/server5-sha1.crt \
2381 key_file2=data_files/server5.key" \
2382 "$P_CLI force_version=tls1" \
2383 0 \
2384 -C "signed using.*ECDSA with SHA256" \
2385 -c "signed using.*ECDSA with SHA1"
2386
2387run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2388 "$P_SRV crt_file=data_files/server5.crt \
2389 key_file=data_files/server5.key \
2390 crt_file2=data_files/server6.crt \
2391 key_file2=data_files/server6.key" \
2392 "$P_CLI force_version=tls1_1" \
2393 0 \
2394 -c "serial number.*09" \
2395 -c "signed using.*ECDSA with SHA256" \
2396 -C "signed using.*ECDSA with SHA1"
2397
2398run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2399 "$P_SRV crt_file=data_files/server6.crt \
2400 key_file=data_files/server6.key \
2401 crt_file2=data_files/server5.crt \
2402 key_file2=data_files/server5.key" \
2403 "$P_CLI force_version=tls1_1" \
2404 0 \
2405 -c "serial number.*0A" \
2406 -c "signed using.*ECDSA with SHA256" \
2407 -C "signed using.*ECDSA with SHA1"
2408
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002409# tests for SNI
2410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002411run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002412 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002413 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002414 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002415 0 \
2416 -S "parse ServerName extension" \
2417 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2418 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002420run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002421 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002422 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002423 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 +02002424 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002425 0 \
2426 -s "parse ServerName extension" \
2427 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2428 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002430run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002431 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002432 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002433 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 +02002434 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002435 0 \
2436 -s "parse ServerName extension" \
2437 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2438 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002440run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002441 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002442 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002443 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 +02002444 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002445 1 \
2446 -s "parse ServerName extension" \
2447 -s "ssl_sni_wrapper() returned" \
2448 -s "mbedtls_ssl_handshake returned" \
2449 -c "mbedtls_ssl_handshake returned" \
2450 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002451
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002452run_test "SNI: client auth no override: optional" \
2453 "$P_SRV debug_level=3 auth_mode=optional \
2454 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2455 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2456 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002457 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002458 -S "skip write certificate request" \
2459 -C "skip parse certificate request" \
2460 -c "got a certificate request" \
2461 -C "skip write certificate" \
2462 -C "skip write certificate verify" \
2463 -S "skip parse certificate verify"
2464
2465run_test "SNI: client auth override: none -> optional" \
2466 "$P_SRV debug_level=3 auth_mode=none \
2467 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2468 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2469 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002470 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002471 -S "skip write certificate request" \
2472 -C "skip parse certificate request" \
2473 -c "got a certificate request" \
2474 -C "skip write certificate" \
2475 -C "skip write certificate verify" \
2476 -S "skip parse certificate verify"
2477
2478run_test "SNI: client auth override: optional -> none" \
2479 "$P_SRV debug_level=3 auth_mode=optional \
2480 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2481 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2482 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002483 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002484 -s "skip write certificate request" \
2485 -C "skip parse certificate request" \
2486 -c "got no certificate request" \
2487 -c "skip write certificate" \
2488 -c "skip write certificate verify" \
2489 -s "skip parse certificate verify"
2490
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002491run_test "SNI: CA no override" \
2492 "$P_SRV debug_level=3 auth_mode=optional \
2493 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2494 ca_file=data_files/test-ca.crt \
2495 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2496 "$P_CLI debug_level=3 server_name=localhost \
2497 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2498 1 \
2499 -S "skip write certificate request" \
2500 -C "skip parse certificate request" \
2501 -c "got a certificate request" \
2502 -C "skip write certificate" \
2503 -C "skip write certificate verify" \
2504 -S "skip parse certificate verify" \
2505 -s "x509_verify_cert() returned" \
2506 -s "! The certificate is not correctly signed by the trusted CA" \
2507 -S "The certificate has been revoked (is on a CRL)"
2508
2509run_test "SNI: CA override" \
2510 "$P_SRV debug_level=3 auth_mode=optional \
2511 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2512 ca_file=data_files/test-ca.crt \
2513 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2514 "$P_CLI debug_level=3 server_name=localhost \
2515 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2516 0 \
2517 -S "skip write certificate request" \
2518 -C "skip parse certificate request" \
2519 -c "got a certificate request" \
2520 -C "skip write certificate" \
2521 -C "skip write certificate verify" \
2522 -S "skip parse certificate verify" \
2523 -S "x509_verify_cert() returned" \
2524 -S "! The certificate is not correctly signed by the trusted CA" \
2525 -S "The certificate has been revoked (is on a CRL)"
2526
2527run_test "SNI: CA override with CRL" \
2528 "$P_SRV debug_level=3 auth_mode=optional \
2529 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2530 ca_file=data_files/test-ca.crt \
2531 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2532 "$P_CLI debug_level=3 server_name=localhost \
2533 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2534 1 \
2535 -S "skip write certificate request" \
2536 -C "skip parse certificate request" \
2537 -c "got a certificate request" \
2538 -C "skip write certificate" \
2539 -C "skip write certificate verify" \
2540 -S "skip parse certificate verify" \
2541 -s "x509_verify_cert() returned" \
2542 -S "! The certificate is not correctly signed by the trusted CA" \
2543 -s "The certificate has been revoked (is on a CRL)"
2544
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002545# Tests for non-blocking I/O: exercise a variety of handshake flows
2546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002547run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002548 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2549 "$P_CLI nbio=2 tickets=0" \
2550 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002551 -S "mbedtls_ssl_handshake returned" \
2552 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002553 -c "Read from server: .* bytes read"
2554
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002555run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002556 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2557 "$P_CLI nbio=2 tickets=0" \
2558 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002559 -S "mbedtls_ssl_handshake returned" \
2560 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002561 -c "Read from server: .* bytes read"
2562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002563run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002564 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2565 "$P_CLI nbio=2 tickets=1" \
2566 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002567 -S "mbedtls_ssl_handshake returned" \
2568 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002569 -c "Read from server: .* bytes read"
2570
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002571run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002572 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2573 "$P_CLI nbio=2 tickets=1" \
2574 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002575 -S "mbedtls_ssl_handshake returned" \
2576 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002577 -c "Read from server: .* bytes read"
2578
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002579run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002580 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2581 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2582 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002583 -S "mbedtls_ssl_handshake returned" \
2584 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002585 -c "Read from server: .* bytes read"
2586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002587run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002588 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2589 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2590 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002591 -S "mbedtls_ssl_handshake returned" \
2592 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002593 -c "Read from server: .* bytes read"
2594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002595run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002596 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2597 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2598 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002599 -S "mbedtls_ssl_handshake returned" \
2600 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002601 -c "Read from server: .* bytes read"
2602
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002603# Tests for version negotiation
2604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002605run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002606 "$P_SRV" \
2607 "$P_CLI" \
2608 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002609 -S "mbedtls_ssl_handshake returned" \
2610 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002611 -s "Protocol is TLSv1.2" \
2612 -c "Protocol is TLSv1.2"
2613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002614run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002615 "$P_SRV" \
2616 "$P_CLI max_version=tls1_1" \
2617 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002618 -S "mbedtls_ssl_handshake returned" \
2619 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002620 -s "Protocol is TLSv1.1" \
2621 -c "Protocol is TLSv1.1"
2622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002623run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002624 "$P_SRV max_version=tls1_1" \
2625 "$P_CLI" \
2626 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002627 -S "mbedtls_ssl_handshake returned" \
2628 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002629 -s "Protocol is TLSv1.1" \
2630 -c "Protocol is TLSv1.1"
2631
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002632run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002633 "$P_SRV max_version=tls1_1" \
2634 "$P_CLI max_version=tls1_1" \
2635 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002636 -S "mbedtls_ssl_handshake returned" \
2637 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002638 -s "Protocol is TLSv1.1" \
2639 -c "Protocol is TLSv1.1"
2640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002641run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002642 "$P_SRV min_version=tls1_1" \
2643 "$P_CLI max_version=tls1_1" \
2644 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002645 -S "mbedtls_ssl_handshake returned" \
2646 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002647 -s "Protocol is TLSv1.1" \
2648 -c "Protocol is TLSv1.1"
2649
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002650run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002651 "$P_SRV max_version=tls1_1" \
2652 "$P_CLI min_version=tls1_1" \
2653 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002654 -S "mbedtls_ssl_handshake returned" \
2655 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002656 -s "Protocol is TLSv1.1" \
2657 -c "Protocol is TLSv1.1"
2658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002659run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002660 "$P_SRV max_version=tls1_1" \
2661 "$P_CLI min_version=tls1_2" \
2662 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002663 -s "mbedtls_ssl_handshake returned" \
2664 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002665 -c "SSL - Handshake protocol not within min/max boundaries"
2666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002667run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002668 "$P_SRV min_version=tls1_2" \
2669 "$P_CLI max_version=tls1_1" \
2670 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002671 -s "mbedtls_ssl_handshake returned" \
2672 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002673 -s "SSL - Handshake protocol not within min/max boundaries"
2674
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002675# Tests for ALPN extension
2676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002677run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002678 "$P_SRV debug_level=3" \
2679 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002680 0 \
2681 -C "client hello, adding alpn extension" \
2682 -S "found alpn extension" \
2683 -C "got an alert message, type: \\[2:120]" \
2684 -S "server hello, adding alpn extension" \
2685 -C "found alpn extension " \
2686 -C "Application Layer Protocol is" \
2687 -S "Application Layer Protocol is"
2688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002689run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002690 "$P_SRV debug_level=3" \
2691 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002692 0 \
2693 -c "client hello, adding alpn extension" \
2694 -s "found alpn extension" \
2695 -C "got an alert message, type: \\[2:120]" \
2696 -S "server hello, adding alpn extension" \
2697 -C "found alpn extension " \
2698 -c "Application Layer Protocol is (none)" \
2699 -S "Application Layer Protocol is"
2700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002701run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002702 "$P_SRV debug_level=3 alpn=abc,1234" \
2703 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002704 0 \
2705 -C "client hello, adding alpn extension" \
2706 -S "found alpn extension" \
2707 -C "got an alert message, type: \\[2:120]" \
2708 -S "server hello, adding alpn extension" \
2709 -C "found alpn extension " \
2710 -C "Application Layer Protocol is" \
2711 -s "Application Layer Protocol is (none)"
2712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002713run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002714 "$P_SRV debug_level=3 alpn=abc,1234" \
2715 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002716 0 \
2717 -c "client hello, adding alpn extension" \
2718 -s "found alpn extension" \
2719 -C "got an alert message, type: \\[2:120]" \
2720 -s "server hello, adding alpn extension" \
2721 -c "found alpn extension" \
2722 -c "Application Layer Protocol is abc" \
2723 -s "Application Layer Protocol is abc"
2724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002725run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002726 "$P_SRV debug_level=3 alpn=abc,1234" \
2727 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002728 0 \
2729 -c "client hello, adding alpn extension" \
2730 -s "found alpn extension" \
2731 -C "got an alert message, type: \\[2:120]" \
2732 -s "server hello, adding alpn extension" \
2733 -c "found alpn extension" \
2734 -c "Application Layer Protocol is abc" \
2735 -s "Application Layer Protocol is abc"
2736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002737run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002738 "$P_SRV debug_level=3 alpn=abc,1234" \
2739 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002740 0 \
2741 -c "client hello, adding alpn extension" \
2742 -s "found alpn extension" \
2743 -C "got an alert message, type: \\[2:120]" \
2744 -s "server hello, adding alpn extension" \
2745 -c "found alpn extension" \
2746 -c "Application Layer Protocol is 1234" \
2747 -s "Application Layer Protocol is 1234"
2748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002749run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002750 "$P_SRV debug_level=3 alpn=abc,123" \
2751 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002752 1 \
2753 -c "client hello, adding alpn extension" \
2754 -s "found alpn extension" \
2755 -c "got an alert message, type: \\[2:120]" \
2756 -S "server hello, adding alpn extension" \
2757 -C "found alpn extension" \
2758 -C "Application Layer Protocol is 1234" \
2759 -S "Application Layer Protocol is 1234"
2760
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002761
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002762# Tests for keyUsage in leaf certificates, part 1:
2763# server-side certificate/suite selection
2764
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002765run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002766 "$P_SRV key_file=data_files/server2.key \
2767 crt_file=data_files/server2.ku-ds.crt" \
2768 "$P_CLI" \
2769 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002770 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002771
2772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002773run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002774 "$P_SRV key_file=data_files/server2.key \
2775 crt_file=data_files/server2.ku-ke.crt" \
2776 "$P_CLI" \
2777 0 \
2778 -c "Ciphersuite is TLS-RSA-WITH-"
2779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002780run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002781 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002782 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002783 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002784 1 \
2785 -C "Ciphersuite is "
2786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002787run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002788 "$P_SRV key_file=data_files/server5.key \
2789 crt_file=data_files/server5.ku-ds.crt" \
2790 "$P_CLI" \
2791 0 \
2792 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2793
2794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002795run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002796 "$P_SRV key_file=data_files/server5.key \
2797 crt_file=data_files/server5.ku-ka.crt" \
2798 "$P_CLI" \
2799 0 \
2800 -c "Ciphersuite is TLS-ECDH-"
2801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002802run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002803 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002804 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002805 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002806 1 \
2807 -C "Ciphersuite is "
2808
2809# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002810# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002812run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002813 "$O_SRV -key data_files/server2.key \
2814 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002815 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002816 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2817 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002818 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002819 -C "Processing of the Certificate handshake message failed" \
2820 -c "Ciphersuite is TLS-"
2821
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002822run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002823 "$O_SRV -key data_files/server2.key \
2824 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002825 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002826 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2827 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002828 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002829 -C "Processing of the Certificate handshake message failed" \
2830 -c "Ciphersuite is TLS-"
2831
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002832run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002833 "$O_SRV -key data_files/server2.key \
2834 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002835 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002836 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2837 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002838 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002839 -C "Processing of the Certificate handshake message failed" \
2840 -c "Ciphersuite is TLS-"
2841
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002842run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002843 "$O_SRV -key data_files/server2.key \
2844 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002845 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002846 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2847 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002848 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002849 -c "Processing of the Certificate handshake message failed" \
2850 -C "Ciphersuite is TLS-"
2851
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002852run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2853 "$O_SRV -key data_files/server2.key \
2854 -cert data_files/server2.ku-ke.crt" \
2855 "$P_CLI debug_level=1 auth_mode=optional \
2856 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2857 0 \
2858 -c "bad certificate (usage extensions)" \
2859 -C "Processing of the Certificate handshake message failed" \
2860 -c "Ciphersuite is TLS-" \
2861 -c "! Usage does not match the keyUsage extension"
2862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002863run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002864 "$O_SRV -key data_files/server2.key \
2865 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002866 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002867 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2868 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002869 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002870 -C "Processing of the Certificate handshake message failed" \
2871 -c "Ciphersuite is TLS-"
2872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002873run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002874 "$O_SRV -key data_files/server2.key \
2875 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002876 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002877 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2878 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002879 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002880 -c "Processing of the Certificate handshake message failed" \
2881 -C "Ciphersuite is TLS-"
2882
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002883run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2884 "$O_SRV -key data_files/server2.key \
2885 -cert data_files/server2.ku-ds.crt" \
2886 "$P_CLI debug_level=1 auth_mode=optional \
2887 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2888 0 \
2889 -c "bad certificate (usage extensions)" \
2890 -C "Processing of the Certificate handshake message failed" \
2891 -c "Ciphersuite is TLS-" \
2892 -c "! Usage does not match the keyUsage extension"
2893
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002894# Tests for keyUsage in leaf certificates, part 3:
2895# server-side checking of client cert
2896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002897run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002898 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002899 "$O_CLI -key data_files/server2.key \
2900 -cert data_files/server2.ku-ds.crt" \
2901 0 \
2902 -S "bad certificate (usage extensions)" \
2903 -S "Processing of the Certificate handshake message failed"
2904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002905run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002906 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002907 "$O_CLI -key data_files/server2.key \
2908 -cert data_files/server2.ku-ke.crt" \
2909 0 \
2910 -s "bad certificate (usage extensions)" \
2911 -S "Processing of the Certificate handshake message failed"
2912
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002913run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002914 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002915 "$O_CLI -key data_files/server2.key \
2916 -cert data_files/server2.ku-ke.crt" \
2917 1 \
2918 -s "bad certificate (usage extensions)" \
2919 -s "Processing of the Certificate handshake message failed"
2920
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002921run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002922 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002923 "$O_CLI -key data_files/server5.key \
2924 -cert data_files/server5.ku-ds.crt" \
2925 0 \
2926 -S "bad certificate (usage extensions)" \
2927 -S "Processing of the Certificate handshake message failed"
2928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002929run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002930 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002931 "$O_CLI -key data_files/server5.key \
2932 -cert data_files/server5.ku-ka.crt" \
2933 0 \
2934 -s "bad certificate (usage extensions)" \
2935 -S "Processing of the Certificate handshake message failed"
2936
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002937# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002939run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002940 "$P_SRV key_file=data_files/server5.key \
2941 crt_file=data_files/server5.eku-srv.crt" \
2942 "$P_CLI" \
2943 0
2944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002945run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002946 "$P_SRV key_file=data_files/server5.key \
2947 crt_file=data_files/server5.eku-srv.crt" \
2948 "$P_CLI" \
2949 0
2950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002951run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002952 "$P_SRV key_file=data_files/server5.key \
2953 crt_file=data_files/server5.eku-cs_any.crt" \
2954 "$P_CLI" \
2955 0
2956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002957run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002958 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002959 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002960 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002961 1
2962
2963# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2964
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002965run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002966 "$O_SRV -key data_files/server5.key \
2967 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002968 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002969 0 \
2970 -C "bad certificate (usage extensions)" \
2971 -C "Processing of the Certificate handshake message failed" \
2972 -c "Ciphersuite is TLS-"
2973
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002974run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002975 "$O_SRV -key data_files/server5.key \
2976 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002977 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002978 0 \
2979 -C "bad certificate (usage extensions)" \
2980 -C "Processing of the Certificate handshake message failed" \
2981 -c "Ciphersuite is TLS-"
2982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002983run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002984 "$O_SRV -key data_files/server5.key \
2985 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002986 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002987 0 \
2988 -C "bad certificate (usage extensions)" \
2989 -C "Processing of the Certificate handshake message failed" \
2990 -c "Ciphersuite is TLS-"
2991
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002992run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002993 "$O_SRV -key data_files/server5.key \
2994 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002995 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002996 1 \
2997 -c "bad certificate (usage extensions)" \
2998 -c "Processing of the Certificate handshake message failed" \
2999 -C "Ciphersuite is TLS-"
3000
3001# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003003run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003004 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003005 "$O_CLI -key data_files/server5.key \
3006 -cert data_files/server5.eku-cli.crt" \
3007 0 \
3008 -S "bad certificate (usage extensions)" \
3009 -S "Processing of the Certificate handshake message failed"
3010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003011run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003012 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003013 "$O_CLI -key data_files/server5.key \
3014 -cert data_files/server5.eku-srv_cli.crt" \
3015 0 \
3016 -S "bad certificate (usage extensions)" \
3017 -S "Processing of the Certificate handshake message failed"
3018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003019run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003020 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003021 "$O_CLI -key data_files/server5.key \
3022 -cert data_files/server5.eku-cs_any.crt" \
3023 0 \
3024 -S "bad certificate (usage extensions)" \
3025 -S "Processing of the Certificate handshake message failed"
3026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003027run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003028 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003029 "$O_CLI -key data_files/server5.key \
3030 -cert data_files/server5.eku-cs.crt" \
3031 0 \
3032 -s "bad certificate (usage extensions)" \
3033 -S "Processing of the Certificate handshake message failed"
3034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003035run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003036 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003037 "$O_CLI -key data_files/server5.key \
3038 -cert data_files/server5.eku-cs.crt" \
3039 1 \
3040 -s "bad certificate (usage extensions)" \
3041 -s "Processing of the Certificate handshake message failed"
3042
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003043# Tests for DHM parameters loading
3044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003045run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003046 "$P_SRV" \
3047 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3048 debug_level=3" \
3049 0 \
3050 -c "value of 'DHM: P ' (2048 bits)" \
3051 -c "value of 'DHM: G ' (2048 bits)"
3052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003053run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003054 "$P_SRV dhm_file=data_files/dhparams.pem" \
3055 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3056 debug_level=3" \
3057 0 \
3058 -c "value of 'DHM: P ' (1024 bits)" \
3059 -c "value of 'DHM: G ' (2 bits)"
3060
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003061# Tests for DHM client-side size checking
3062
3063run_test "DHM size: server default, client default, OK" \
3064 "$P_SRV" \
3065 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3066 debug_level=1" \
3067 0 \
3068 -C "DHM prime too short:"
3069
3070run_test "DHM size: server default, client 2048, OK" \
3071 "$P_SRV" \
3072 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3073 debug_level=1 dhmlen=2048" \
3074 0 \
3075 -C "DHM prime too short:"
3076
3077run_test "DHM size: server 1024, client default, OK" \
3078 "$P_SRV dhm_file=data_files/dhparams.pem" \
3079 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3080 debug_level=1" \
3081 0 \
3082 -C "DHM prime too short:"
3083
3084run_test "DHM size: server 1000, client default, rejected" \
3085 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3086 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3087 debug_level=1" \
3088 1 \
3089 -c "DHM prime too short:"
3090
3091run_test "DHM size: server default, client 2049, rejected" \
3092 "$P_SRV" \
3093 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3094 debug_level=1 dhmlen=2049" \
3095 1 \
3096 -c "DHM prime too short:"
3097
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003098# Tests for PSK callback
3099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003100run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003101 "$P_SRV psk=abc123 psk_identity=foo" \
3102 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3103 psk_identity=foo psk=abc123" \
3104 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003105 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003106 -S "SSL - Unknown identity received" \
3107 -S "SSL - Verification of the message MAC failed"
3108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003109run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003110 "$P_SRV" \
3111 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3112 psk_identity=foo psk=abc123" \
3113 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003114 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003115 -S "SSL - Unknown identity received" \
3116 -S "SSL - Verification of the message MAC failed"
3117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003118run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003119 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3120 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3121 psk_identity=foo psk=abc123" \
3122 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003123 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003124 -s "SSL - Unknown identity received" \
3125 -S "SSL - Verification of the message MAC failed"
3126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003127run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003128 "$P_SRV psk_list=abc,dead,def,beef" \
3129 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3130 psk_identity=abc psk=dead" \
3131 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003132 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003133 -S "SSL - Unknown identity received" \
3134 -S "SSL - Verification of the message MAC failed"
3135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003136run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003137 "$P_SRV psk_list=abc,dead,def,beef" \
3138 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3139 psk_identity=def psk=beef" \
3140 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003141 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003142 -S "SSL - Unknown identity received" \
3143 -S "SSL - Verification of the message MAC failed"
3144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003145run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003146 "$P_SRV psk_list=abc,dead,def,beef" \
3147 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3148 psk_identity=ghi psk=beef" \
3149 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003150 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003151 -s "SSL - Unknown identity received" \
3152 -S "SSL - Verification of the message MAC failed"
3153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003154run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003155 "$P_SRV psk_list=abc,dead,def,beef" \
3156 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3157 psk_identity=abc psk=beef" \
3158 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003159 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003160 -S "SSL - Unknown identity received" \
3161 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003162
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003163# Tests for EC J-PAKE
3164
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003165requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003166run_test "ECJPAKE: client not configured" \
3167 "$P_SRV debug_level=3" \
3168 "$P_CLI debug_level=3" \
3169 0 \
3170 -C "add ciphersuite: c0ff" \
3171 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003172 -S "found ecjpake kkpp extension" \
3173 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003174 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003175 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003176 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003177 -S "None of the common ciphersuites is usable"
3178
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003179requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003180run_test "ECJPAKE: server not configured" \
3181 "$P_SRV debug_level=3" \
3182 "$P_CLI debug_level=3 ecjpake_pw=bla \
3183 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3184 1 \
3185 -c "add ciphersuite: c0ff" \
3186 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003187 -s "found ecjpake kkpp extension" \
3188 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003189 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003190 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003191 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003192 -s "None of the common ciphersuites is usable"
3193
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003194requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003195run_test "ECJPAKE: working, TLS" \
3196 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3197 "$P_CLI debug_level=3 ecjpake_pw=bla \
3198 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003199 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003200 -c "add ciphersuite: c0ff" \
3201 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003202 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003203 -s "found ecjpake kkpp extension" \
3204 -S "skip ecjpake kkpp extension" \
3205 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003206 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003207 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003208 -S "None of the common ciphersuites is usable" \
3209 -S "SSL - Verification of the message MAC failed"
3210
Janos Follath74537a62016-09-02 13:45:28 +01003211server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003212requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003213run_test "ECJPAKE: password mismatch, TLS" \
3214 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3215 "$P_CLI debug_level=3 ecjpake_pw=bad \
3216 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3217 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003218 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003219 -s "SSL - Verification of the message MAC failed"
3220
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003221requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003222run_test "ECJPAKE: working, DTLS" \
3223 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3224 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3225 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3226 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003227 -c "re-using cached ecjpake parameters" \
3228 -S "SSL - Verification of the message MAC failed"
3229
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003230requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003231run_test "ECJPAKE: working, DTLS, no cookie" \
3232 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3233 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3234 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3235 0 \
3236 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003237 -S "SSL - Verification of the message MAC failed"
3238
Janos Follath74537a62016-09-02 13:45:28 +01003239server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003240requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003241run_test "ECJPAKE: password mismatch, DTLS" \
3242 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3243 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3244 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3245 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003246 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003247 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003248
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003249# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003250requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003251run_test "ECJPAKE: working, DTLS, nolog" \
3252 "$P_SRV dtls=1 ecjpake_pw=bla" \
3253 "$P_CLI dtls=1 ecjpake_pw=bla \
3254 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3255 0
3256
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003257# Tests for ciphersuites per version
3258
Janos Follathe2681a42016-03-07 15:57:05 +00003259requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003260run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003261 "$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 +02003262 "$P_CLI force_version=ssl3" \
3263 0 \
3264 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003266run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003267 "$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 +01003268 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003269 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003270 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003272run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003273 "$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 +02003274 "$P_CLI force_version=tls1_1" \
3275 0 \
3276 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003278run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003279 "$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 +02003280 "$P_CLI force_version=tls1_2" \
3281 0 \
3282 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3283
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003284# Test for ClientHello without extensions
3285
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003286requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003287run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003288 "$P_SRV debug_level=3" \
3289 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3290 0 \
3291 -s "dumping 'client hello extensions' (0 bytes)"
3292
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003293requires_gnutls
3294run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3295 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3296 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3297 0 \
3298 -s "dumping 'client hello extensions' (0 bytes)"
3299
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003300# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003301
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003302run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003303 "$P_SRV" \
3304 "$P_CLI request_size=100" \
3305 0 \
3306 -s "Read from client: 100 bytes read$"
3307
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003308run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003309 "$P_SRV" \
3310 "$P_CLI request_size=500" \
3311 0 \
3312 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003313
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003314# Tests for small packets
3315
Janos Follathe2681a42016-03-07 15:57:05 +00003316requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003317run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003318 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003319 "$P_CLI request_size=1 force_version=ssl3 \
3320 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3321 0 \
3322 -s "Read from client: 1 bytes read"
3323
Janos Follathe2681a42016-03-07 15:57:05 +00003324requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003325run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003326 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003327 "$P_CLI request_size=1 force_version=ssl3 \
3328 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3329 0 \
3330 -s "Read from client: 1 bytes read"
3331
3332run_test "Small packet TLS 1.0 BlockCipher" \
3333 "$P_SRV" \
3334 "$P_CLI request_size=1 force_version=tls1 \
3335 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3336 0 \
3337 -s "Read from client: 1 bytes read"
3338
Hanno Becker8501f982017-11-10 08:59:04 +00003339run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003340 "$P_SRV" \
3341 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3342 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3343 0 \
3344 -s "Read from client: 1 bytes read"
3345
Hanno Becker32c55012017-11-10 08:42:54 +00003346requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003347run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003348 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003349 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003350 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003351 0 \
3352 -s "Read from client: 1 bytes read"
3353
Hanno Becker32c55012017-11-10 08:42:54 +00003354requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003355run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003356 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003357 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003358 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003359 0 \
3360 -s "Read from client: 1 bytes read"
3361
3362run_test "Small packet TLS 1.0 StreamCipher" \
3363 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3364 "$P_CLI request_size=1 force_version=tls1 \
3365 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3366 0 \
3367 -s "Read from client: 1 bytes read"
3368
3369run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3370 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3371 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003372 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003373 0 \
3374 -s "Read from client: 1 bytes read"
3375
3376requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3377run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003378 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003379 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003380 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003381 0 \
3382 -s "Read from client: 1 bytes read"
3383
Hanno Becker8501f982017-11-10 08:59:04 +00003384requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3385run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003386 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3387 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3388 trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003389 0 \
3390 -s "Read from client: 1 bytes read"
3391
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003392run_test "Small packet TLS 1.1 BlockCipher" \
3393 "$P_SRV" \
3394 "$P_CLI request_size=1 force_version=tls1_1 \
3395 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3396 0 \
3397 -s "Read from client: 1 bytes read"
3398
Hanno Becker8501f982017-11-10 08:59:04 +00003399run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003400 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003401 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003402 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003403 0 \
3404 -s "Read from client: 1 bytes read"
3405
3406requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3407run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003408 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003409 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003410 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003411 0 \
3412 -s "Read from client: 1 bytes read"
3413
3414requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3415run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003416 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003417 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003418 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003419 0 \
3420 -s "Read from client: 1 bytes read"
3421
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003422run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003423 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003424 "$P_CLI request_size=1 force_version=tls1_1 \
3425 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3426 0 \
3427 -s "Read from client: 1 bytes read"
3428
Hanno Becker8501f982017-11-10 08:59:04 +00003429run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3430 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003431 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003432 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003433 0 \
3434 -s "Read from client: 1 bytes read"
3435
3436requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3437run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003438 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003439 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003440 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003441 0 \
3442 -s "Read from client: 1 bytes read"
3443
Hanno Becker32c55012017-11-10 08:42:54 +00003444requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003445run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003446 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003447 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003448 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003449 0 \
3450 -s "Read from client: 1 bytes read"
3451
3452run_test "Small packet TLS 1.2 BlockCipher" \
3453 "$P_SRV" \
3454 "$P_CLI request_size=1 force_version=tls1_2 \
3455 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3456 0 \
3457 -s "Read from client: 1 bytes read"
3458
Hanno Becker8501f982017-11-10 08:59:04 +00003459run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003460 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003461 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003462 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003463 0 \
3464 -s "Read from client: 1 bytes read"
3465
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003466run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3467 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003468 "$P_CLI request_size=1 force_version=tls1_2 \
3469 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003470 0 \
3471 -s "Read from client: 1 bytes read"
3472
Hanno Becker32c55012017-11-10 08:42:54 +00003473requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003474run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003475 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003476 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003477 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003478 0 \
3479 -s "Read from client: 1 bytes read"
3480
Hanno Becker8501f982017-11-10 08:59:04 +00003481requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3482run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003483 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003484 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003485 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003486 0 \
3487 -s "Read from client: 1 bytes read"
3488
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003489run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003490 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003491 "$P_CLI request_size=1 force_version=tls1_2 \
3492 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3493 0 \
3494 -s "Read from client: 1 bytes read"
3495
Hanno Becker8501f982017-11-10 08:59:04 +00003496run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
3497 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3498 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003499 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003500 0 \
3501 -s "Read from client: 1 bytes read"
3502
Hanno Becker32c55012017-11-10 08:42:54 +00003503requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003504run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003505 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003506 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003507 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003508 0 \
3509 -s "Read from client: 1 bytes read"
3510
Hanno Becker8501f982017-11-10 08:59:04 +00003511requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3512run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003513 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003514 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003515 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003516 0 \
3517 -s "Read from client: 1 bytes read"
3518
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003519run_test "Small packet TLS 1.2 AEAD" \
3520 "$P_SRV" \
3521 "$P_CLI request_size=1 force_version=tls1_2 \
3522 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3523 0 \
3524 -s "Read from client: 1 bytes read"
3525
3526run_test "Small packet TLS 1.2 AEAD shorter tag" \
3527 "$P_SRV" \
3528 "$P_CLI request_size=1 force_version=tls1_2 \
3529 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3530 0 \
3531 -s "Read from client: 1 bytes read"
3532
Hanno Beckere2148042017-11-10 08:59:18 +00003533# Tests for small packets in DTLS
3534
3535requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3536run_test "Small packet DTLS 1.0" \
3537 "$P_SRV dtls=1 force_version=dtls1" \
3538 "$P_CLI dtls=1 request_size=1 \
3539 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3540 0 \
3541 -s "Read from client: 1 bytes read"
3542
3543requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3544run_test "Small packet DTLS 1.0, without EtM" \
3545 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3546 "$P_CLI dtls=1 request_size=1 \
3547 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3548 0 \
3549 -s "Read from client: 1 bytes read"
3550
3551requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3552requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3553run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003554 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3555 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003556 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3557 0 \
3558 -s "Read from client: 1 bytes read"
3559
3560requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3561requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3562run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003563 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003564 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003565 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003566 0 \
3567 -s "Read from client: 1 bytes read"
3568
3569requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3570run_test "Small packet DTLS 1.2" \
3571 "$P_SRV dtls=1 force_version=dtls1_2" \
3572 "$P_CLI dtls=1 request_size=1 \
3573 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3574 0 \
3575 -s "Read from client: 1 bytes read"
3576
3577requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3578run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003579 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003580 "$P_CLI dtls=1 request_size=1 \
3581 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3582 0 \
3583 -s "Read from client: 1 bytes read"
3584
3585requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3586requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3587run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003588 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003589 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003590 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003591 0 \
3592 -s "Read from client: 1 bytes read"
3593
3594requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3595requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3596run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003597 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003598 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003599 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003600 0 \
3601 -s "Read from client: 1 bytes read"
3602
Janos Follath00efff72016-05-06 13:48:23 +01003603# A test for extensions in SSLv3
3604
3605requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3606run_test "SSLv3 with extensions, server side" \
3607 "$P_SRV min_version=ssl3 debug_level=3" \
3608 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3609 0 \
3610 -S "dumping 'client hello extensions'" \
3611 -S "server hello, total extension length:"
3612
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003613# Test for large packets
3614
Janos Follathe2681a42016-03-07 15:57:05 +00003615requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003616run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003617 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003618 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003619 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3620 0 \
3621 -s "Read from client: 16384 bytes read"
3622
Janos Follathe2681a42016-03-07 15:57:05 +00003623requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003624run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003625 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003626 "$P_CLI request_size=16384 force_version=ssl3 \
3627 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3628 0 \
3629 -s "Read from client: 16384 bytes read"
3630
3631run_test "Large packet TLS 1.0 BlockCipher" \
3632 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003633 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003634 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3635 0 \
3636 -s "Read from client: 16384 bytes read"
3637
Hanno Becker278fc7a2017-11-10 09:16:28 +00003638run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
3639 "$P_SRV" \
3640 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3641 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3642 0 \
3643 -s "Read from client: 16384 bytes read"
3644
Hanno Becker32c55012017-11-10 08:42:54 +00003645requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003646run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003647 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003648 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003649 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003650 0 \
3651 -s "Read from client: 16384 bytes read"
3652
Hanno Becker32c55012017-11-10 08:42:54 +00003653requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003654run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003655 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003656 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003657 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003658 0 \
3659 -s "Read from client: 16384 bytes read"
3660
3661run_test "Large packet TLS 1.0 StreamCipher" \
3662 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3663 "$P_CLI request_size=16384 force_version=tls1 \
3664 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3665 0 \
3666 -s "Read from client: 16384 bytes read"
3667
3668run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3669 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3670 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003671 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003672 0 \
3673 -s "Read from client: 16384 bytes read"
3674
3675requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3676run_test "Large packet TLS 1.0 StreamCipher, 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" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003678 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003679 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003680 0 \
3681 -s "Read from client: 16384 bytes read"
3682
Hanno Becker278fc7a2017-11-10 09:16:28 +00003683requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3684run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003685 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003686 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003687 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003688 0 \
3689 -s "Read from client: 16384 bytes read"
3690
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003691run_test "Large packet TLS 1.1 BlockCipher" \
3692 "$P_SRV" \
3693 "$P_CLI request_size=16384 force_version=tls1_1 \
3694 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3695 0 \
3696 -s "Read from client: 16384 bytes read"
3697
Hanno Becker278fc7a2017-11-10 09:16:28 +00003698run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3699 "$P_SRV" \
3700 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3701 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003702 0 \
3703 -s "Read from client: 16384 bytes read"
3704
Hanno Becker32c55012017-11-10 08:42:54 +00003705requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003706run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003707 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003708 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003709 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003710 0 \
3711 -s "Read from client: 16384 bytes read"
3712
Hanno Becker32c55012017-11-10 08:42:54 +00003713requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003714run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003715 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003716 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003717 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003718 0 \
3719 -s "Read from client: 16384 bytes read"
3720
3721run_test "Large packet TLS 1.1 StreamCipher" \
3722 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3723 "$P_CLI request_size=16384 force_version=tls1_1 \
3724 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3725 0 \
3726 -s "Read from client: 16384 bytes read"
3727
3728run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
3729 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3730 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003731 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003732 0 \
3733 -s "Read from client: 16384 bytes read"
3734
3735requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3736run_test "Large packet TLS 1.1 StreamCipher, 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é-Gonnard8920f692014-06-18 22:05:08 +02003738 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003739 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003740 0 \
3741 -s "Read from client: 16384 bytes read"
3742
Hanno Becker278fc7a2017-11-10 09:16:28 +00003743requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3744run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003745 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003746 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003747 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003748 0 \
3749 -s "Read from client: 16384 bytes read"
3750
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003751run_test "Large packet TLS 1.2 BlockCipher" \
3752 "$P_SRV" \
3753 "$P_CLI request_size=16384 force_version=tls1_2 \
3754 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3755 0 \
3756 -s "Read from client: 16384 bytes read"
3757
Hanno Becker278fc7a2017-11-10 09:16:28 +00003758run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
3759 "$P_SRV" \
3760 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
3761 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3762 0 \
3763 -s "Read from client: 16384 bytes read"
3764
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003765run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3766 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003767 "$P_CLI request_size=16384 force_version=tls1_2 \
3768 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003769 0 \
3770 -s "Read from client: 16384 bytes read"
3771
Hanno Becker32c55012017-11-10 08:42:54 +00003772requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003773run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003774 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003775 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003776 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003777 0 \
3778 -s "Read from client: 16384 bytes read"
3779
Hanno Becker278fc7a2017-11-10 09:16:28 +00003780requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3781run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003782 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003783 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003784 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003785 0 \
3786 -s "Read from client: 16384 bytes read"
3787
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003788run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003789 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003790 "$P_CLI request_size=16384 force_version=tls1_2 \
3791 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3792 0 \
3793 -s "Read from client: 16384 bytes read"
3794
Hanno Becker278fc7a2017-11-10 09:16:28 +00003795run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
3796 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3797 "$P_CLI request_size=16384 force_version=tls1_2 \
3798 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
3799 0 \
3800 -s "Read from client: 16384 bytes read"
3801
Hanno Becker32c55012017-11-10 08:42:54 +00003802requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003803run_test "Large packet TLS 1.2 StreamCipher, 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" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003805 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003806 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003807 0 \
3808 -s "Read from client: 16384 bytes read"
3809
Hanno Becker278fc7a2017-11-10 09:16:28 +00003810requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3811run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003812 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003813 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003814 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003815 0 \
3816 -s "Read from client: 16384 bytes read"
3817
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003818run_test "Large packet TLS 1.2 AEAD" \
3819 "$P_SRV" \
3820 "$P_CLI request_size=16384 force_version=tls1_2 \
3821 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3822 0 \
3823 -s "Read from client: 16384 bytes read"
3824
3825run_test "Large packet TLS 1.2 AEAD shorter tag" \
3826 "$P_SRV" \
3827 "$P_CLI request_size=16384 force_version=tls1_2 \
3828 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3829 0 \
3830 -s "Read from client: 16384 bytes read"
3831
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003832# Tests for DTLS HelloVerifyRequest
3833
3834run_test "DTLS cookie: enabled" \
3835 "$P_SRV dtls=1 debug_level=2" \
3836 "$P_CLI dtls=1 debug_level=2" \
3837 0 \
3838 -s "cookie verification failed" \
3839 -s "cookie verification passed" \
3840 -S "cookie verification skipped" \
3841 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003842 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003843 -S "SSL - The requested feature is not available"
3844
3845run_test "DTLS cookie: disabled" \
3846 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3847 "$P_CLI dtls=1 debug_level=2" \
3848 0 \
3849 -S "cookie verification failed" \
3850 -S "cookie verification passed" \
3851 -s "cookie verification skipped" \
3852 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003853 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003854 -S "SSL - The requested feature is not available"
3855
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003856run_test "DTLS cookie: default (failing)" \
3857 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3858 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3859 1 \
3860 -s "cookie verification failed" \
3861 -S "cookie verification passed" \
3862 -S "cookie verification skipped" \
3863 -C "received hello verify request" \
3864 -S "hello verification requested" \
3865 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003866
3867requires_ipv6
3868run_test "DTLS cookie: enabled, IPv6" \
3869 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3870 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3871 0 \
3872 -s "cookie verification failed" \
3873 -s "cookie verification passed" \
3874 -S "cookie verification skipped" \
3875 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003876 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003877 -S "SSL - The requested feature is not available"
3878
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003879run_test "DTLS cookie: enabled, nbio" \
3880 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3881 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3882 0 \
3883 -s "cookie verification failed" \
3884 -s "cookie verification passed" \
3885 -S "cookie verification skipped" \
3886 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003887 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003888 -S "SSL - The requested feature is not available"
3889
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003890# Tests for client reconnecting from the same port with DTLS
3891
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003892not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003893run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003894 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3895 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003896 0 \
3897 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003898 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003899 -S "Client initiated reconnection from same port"
3900
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003901not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003902run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003903 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3904 "$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 +02003905 0 \
3906 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003907 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003908 -s "Client initiated reconnection from same port"
3909
Paul Bakker362689d2016-05-13 10:33:25 +01003910not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3911run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003912 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3913 "$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 +02003914 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003915 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003916 -s "Client initiated reconnection from same port"
3917
Paul Bakker362689d2016-05-13 10:33:25 +01003918only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3919run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3920 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3921 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3922 0 \
3923 -S "The operation timed out" \
3924 -s "Client initiated reconnection from same port"
3925
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003926run_test "DTLS client reconnect from same port: no cookies" \
3927 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003928 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3929 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003930 -s "The operation timed out" \
3931 -S "Client initiated reconnection from same port"
3932
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003933# Tests for various cases of client authentication with DTLS
3934# (focused on handshake flows and message parsing)
3935
3936run_test "DTLS client auth: required" \
3937 "$P_SRV dtls=1 auth_mode=required" \
3938 "$P_CLI dtls=1" \
3939 0 \
3940 -s "Verifying peer X.509 certificate... ok"
3941
3942run_test "DTLS client auth: optional, client has no cert" \
3943 "$P_SRV dtls=1 auth_mode=optional" \
3944 "$P_CLI dtls=1 crt_file=none key_file=none" \
3945 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003946 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003947
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003948run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003949 "$P_SRV dtls=1 auth_mode=none" \
3950 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3951 0 \
3952 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003953 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003954
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003955run_test "DTLS wrong PSK: badmac alert" \
3956 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3957 "$P_CLI dtls=1 psk=abc124" \
3958 1 \
3959 -s "SSL - Verification of the message MAC failed" \
3960 -c "SSL - A fatal alert message was received from our peer"
3961
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003962# Tests for receiving fragmented handshake messages with DTLS
3963
3964requires_gnutls
3965run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3966 "$G_SRV -u --mtu 2048 -a" \
3967 "$P_CLI dtls=1 debug_level=2" \
3968 0 \
3969 -C "found fragmented DTLS handshake message" \
3970 -C "error"
3971
3972requires_gnutls
3973run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3974 "$G_SRV -u --mtu 512" \
3975 "$P_CLI dtls=1 debug_level=2" \
3976 0 \
3977 -c "found fragmented DTLS handshake message" \
3978 -C "error"
3979
3980requires_gnutls
3981run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3982 "$G_SRV -u --mtu 128" \
3983 "$P_CLI dtls=1 debug_level=2" \
3984 0 \
3985 -c "found fragmented DTLS handshake message" \
3986 -C "error"
3987
3988requires_gnutls
3989run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3990 "$G_SRV -u --mtu 128" \
3991 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3992 0 \
3993 -c "found fragmented DTLS handshake message" \
3994 -C "error"
3995
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003996requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003997run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3998 "$G_SRV -u --mtu 256" \
3999 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4000 0 \
4001 -c "found fragmented DTLS handshake message" \
4002 -c "client hello, adding renegotiation extension" \
4003 -c "found renegotiation extension" \
4004 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004005 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004006 -C "error" \
4007 -s "Extra-header:"
4008
4009requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004010run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4011 "$G_SRV -u --mtu 256" \
4012 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4013 0 \
4014 -c "found fragmented DTLS handshake message" \
4015 -c "client hello, adding renegotiation extension" \
4016 -c "found renegotiation extension" \
4017 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004018 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004019 -C "error" \
4020 -s "Extra-header:"
4021
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004022run_test "DTLS reassembly: no fragmentation (openssl server)" \
4023 "$O_SRV -dtls1 -mtu 2048" \
4024 "$P_CLI dtls=1 debug_level=2" \
4025 0 \
4026 -C "found fragmented DTLS handshake message" \
4027 -C "error"
4028
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004029run_test "DTLS reassembly: some fragmentation (openssl server)" \
4030 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004031 "$P_CLI dtls=1 debug_level=2" \
4032 0 \
4033 -c "found fragmented DTLS handshake message" \
4034 -C "error"
4035
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004036run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004037 "$O_SRV -dtls1 -mtu 256" \
4038 "$P_CLI dtls=1 debug_level=2" \
4039 0 \
4040 -c "found fragmented DTLS handshake message" \
4041 -C "error"
4042
4043run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4044 "$O_SRV -dtls1 -mtu 256" \
4045 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4046 0 \
4047 -c "found fragmented DTLS handshake message" \
4048 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004049
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004050# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004051
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004052not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004053run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004054 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004055 "$P_SRV dtls=1 debug_level=2" \
4056 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004057 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004058 -C "replayed record" \
4059 -S "replayed record" \
4060 -C "record from another epoch" \
4061 -S "record from another epoch" \
4062 -C "discarding invalid record" \
4063 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004064 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004065 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004066 -c "HTTP/1.0 200 OK"
4067
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004068not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004069run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004070 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004071 "$P_SRV dtls=1 debug_level=2" \
4072 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004073 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004074 -c "replayed record" \
4075 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004076 -c "discarding invalid record" \
4077 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004078 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004079 -s "Extra-header:" \
4080 -c "HTTP/1.0 200 OK"
4081
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004082run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4083 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004084 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4085 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004086 0 \
4087 -c "replayed record" \
4088 -S "replayed record" \
4089 -c "discarding invalid record" \
4090 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004091 -c "resend" \
4092 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004093 -s "Extra-header:" \
4094 -c "HTTP/1.0 200 OK"
4095
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004096run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004097 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004098 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004099 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004100 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004101 -c "discarding invalid record (mac)" \
4102 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004103 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004104 -c "HTTP/1.0 200 OK" \
4105 -S "too many records with bad MAC" \
4106 -S "Verification of the message MAC failed"
4107
4108run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4109 -p "$P_PXY bad_ad=1" \
4110 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4111 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4112 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004113 -C "discarding invalid record (mac)" \
4114 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004115 -S "Extra-header:" \
4116 -C "HTTP/1.0 200 OK" \
4117 -s "too many records with bad MAC" \
4118 -s "Verification of the message MAC failed"
4119
4120run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4121 -p "$P_PXY bad_ad=1" \
4122 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4123 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4124 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004125 -c "discarding invalid record (mac)" \
4126 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004127 -s "Extra-header:" \
4128 -c "HTTP/1.0 200 OK" \
4129 -S "too many records with bad MAC" \
4130 -S "Verification of the message MAC failed"
4131
4132run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4133 -p "$P_PXY bad_ad=1" \
4134 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4135 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4136 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004137 -c "discarding invalid record (mac)" \
4138 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004139 -s "Extra-header:" \
4140 -c "HTTP/1.0 200 OK" \
4141 -s "too many records with bad MAC" \
4142 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004143
4144run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004145 -p "$P_PXY delay_ccs=1" \
4146 "$P_SRV dtls=1 debug_level=1" \
4147 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004148 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004149 -c "record from another epoch" \
4150 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004151 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004152 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004153 -s "Extra-header:" \
4154 -c "HTTP/1.0 200 OK"
4155
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004156# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004157
Janos Follath74537a62016-09-02 13:45:28 +01004158client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004159run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004160 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004161 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4162 psk=abc123" \
4163 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004164 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4165 0 \
4166 -s "Extra-header:" \
4167 -c "HTTP/1.0 200 OK"
4168
Janos Follath74537a62016-09-02 13:45:28 +01004169client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004170run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4171 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004172 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4173 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004174 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4175 0 \
4176 -s "Extra-header:" \
4177 -c "HTTP/1.0 200 OK"
4178
Janos Follath74537a62016-09-02 13:45:28 +01004179client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004180run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4181 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004182 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4183 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004184 0 \
4185 -s "Extra-header:" \
4186 -c "HTTP/1.0 200 OK"
4187
Janos Follath74537a62016-09-02 13:45:28 +01004188client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004189run_test "DTLS proxy: 3d, FS, client auth" \
4190 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004191 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4192 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004193 0 \
4194 -s "Extra-header:" \
4195 -c "HTTP/1.0 200 OK"
4196
Janos Follath74537a62016-09-02 13:45:28 +01004197client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004198run_test "DTLS proxy: 3d, FS, ticket" \
4199 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004200 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4201 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004202 0 \
4203 -s "Extra-header:" \
4204 -c "HTTP/1.0 200 OK"
4205
Janos Follath74537a62016-09-02 13:45:28 +01004206client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004207run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4208 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004209 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4210 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004211 0 \
4212 -s "Extra-header:" \
4213 -c "HTTP/1.0 200 OK"
4214
Janos Follath74537a62016-09-02 13:45:28 +01004215client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004216run_test "DTLS proxy: 3d, max handshake, nbio" \
4217 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004218 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4219 auth_mode=required" \
4220 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004221 0 \
4222 -s "Extra-header:" \
4223 -c "HTTP/1.0 200 OK"
4224
Janos Follath74537a62016-09-02 13:45:28 +01004225client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004226run_test "DTLS proxy: 3d, min handshake, resumption" \
4227 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4228 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4229 psk=abc123 debug_level=3" \
4230 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4231 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4232 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4233 0 \
4234 -s "a session has been resumed" \
4235 -c "a session has been resumed" \
4236 -s "Extra-header:" \
4237 -c "HTTP/1.0 200 OK"
4238
Janos Follath74537a62016-09-02 13:45:28 +01004239client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004240run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4241 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4242 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4243 psk=abc123 debug_level=3 nbio=2" \
4244 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4245 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4246 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4247 0 \
4248 -s "a session has been resumed" \
4249 -c "a session has been resumed" \
4250 -s "Extra-header:" \
4251 -c "HTTP/1.0 200 OK"
4252
Janos Follath74537a62016-09-02 13:45:28 +01004253client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004254run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004255 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004256 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4257 psk=abc123 renegotiation=1 debug_level=2" \
4258 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4259 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004260 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4261 0 \
4262 -c "=> renegotiate" \
4263 -s "=> renegotiate" \
4264 -s "Extra-header:" \
4265 -c "HTTP/1.0 200 OK"
4266
Janos Follath74537a62016-09-02 13:45:28 +01004267client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004268run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4269 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004270 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4271 psk=abc123 renegotiation=1 debug_level=2" \
4272 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4273 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004274 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4275 0 \
4276 -c "=> renegotiate" \
4277 -s "=> renegotiate" \
4278 -s "Extra-header:" \
4279 -c "HTTP/1.0 200 OK"
4280
Janos Follath74537a62016-09-02 13:45:28 +01004281client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004282run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004283 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004284 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004285 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004286 debug_level=2" \
4287 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004288 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004289 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4290 0 \
4291 -c "=> renegotiate" \
4292 -s "=> renegotiate" \
4293 -s "Extra-header:" \
4294 -c "HTTP/1.0 200 OK"
4295
Janos Follath74537a62016-09-02 13:45:28 +01004296client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004297run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004298 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004299 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004300 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004301 debug_level=2 nbio=2" \
4302 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004303 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004304 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4305 0 \
4306 -c "=> renegotiate" \
4307 -s "=> renegotiate" \
4308 -s "Extra-header:" \
4309 -c "HTTP/1.0 200 OK"
4310
Janos Follath74537a62016-09-02 13:45:28 +01004311client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004312not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004313run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004314 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4315 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004316 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004317 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004318 -c "HTTP/1.0 200 OK"
4319
Janos Follath74537a62016-09-02 13:45:28 +01004320client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004321not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004322run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4323 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4324 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004325 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004326 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004327 -c "HTTP/1.0 200 OK"
4328
Janos Follath74537a62016-09-02 13:45:28 +01004329client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004330not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004331run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4332 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4333 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004334 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004335 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004336 -c "HTTP/1.0 200 OK"
4337
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004338requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004339client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004340not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004341run_test "DTLS proxy: 3d, gnutls server" \
4342 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4343 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004344 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004345 0 \
4346 -s "Extra-header:" \
4347 -c "Extra-header:"
4348
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004349requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004350client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004351not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004352run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4353 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4354 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004355 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004356 0 \
4357 -s "Extra-header:" \
4358 -c "Extra-header:"
4359
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004360requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004361client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004362not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004363run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4364 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4365 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004366 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004367 0 \
4368 -s "Extra-header:" \
4369 -c "Extra-header:"
4370
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004371# Final report
4372
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004373echo "------------------------------------------------------------------------"
4374
4375if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004376 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004377else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004378 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004379fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004380PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004381echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004382
4383exit $FAILS