blob: 326dcad64a0a2077cf7fac73230acbee76280660 [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 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100832 -s "dumping 'computed mac' (20 bytes)" \
833 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100834
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100835run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200836 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100837 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
838 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100839 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100840 -s "dumping 'computed mac' (20 bytes)" \
841 -S "dumping 'computed mac' (10 bytes)"
842
843run_test "Truncated HMAC: client enabled, server default" \
844 "$P_SRV debug_level=4" \
845 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
846 trunc_hmac=1" \
847 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100848 -s "dumping 'computed mac' (20 bytes)" \
849 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100850
851run_test "Truncated HMAC: client enabled, server disabled" \
852 "$P_SRV debug_level=4 trunc_hmac=0" \
853 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
854 trunc_hmac=1" \
855 0 \
856 -s "dumping 'computed mac' (20 bytes)" \
857 -S "dumping 'computed mac' (10 bytes)"
858
859run_test "Truncated HMAC: client enabled, server enabled" \
860 "$P_SRV debug_level=4 trunc_hmac=1" \
861 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
862 trunc_hmac=1" \
863 0 \
864 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100865 -s "dumping 'computed mac' (10 bytes)"
866
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100867# Tests for Encrypt-then-MAC extension
868
869run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100870 "$P_SRV debug_level=3 \
871 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100872 "$P_CLI debug_level=3" \
873 0 \
874 -c "client hello, adding encrypt_then_mac extension" \
875 -s "found encrypt then mac extension" \
876 -s "server hello, adding encrypt then mac extension" \
877 -c "found encrypt_then_mac extension" \
878 -c "using encrypt then mac" \
879 -s "using encrypt then mac"
880
881run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100882 "$P_SRV debug_level=3 etm=0 \
883 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100884 "$P_CLI debug_level=3 etm=1" \
885 0 \
886 -c "client hello, adding encrypt_then_mac extension" \
887 -s "found encrypt then mac extension" \
888 -S "server hello, adding encrypt then mac extension" \
889 -C "found encrypt_then_mac extension" \
890 -C "using encrypt then mac" \
891 -S "using encrypt then mac"
892
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100893run_test "Encrypt then MAC: client enabled, aead cipher" \
894 "$P_SRV debug_level=3 etm=1 \
895 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
896 "$P_CLI debug_level=3 etm=1" \
897 0 \
898 -c "client hello, adding encrypt_then_mac extension" \
899 -s "found encrypt then mac extension" \
900 -S "server hello, adding encrypt then mac extension" \
901 -C "found encrypt_then_mac extension" \
902 -C "using encrypt then mac" \
903 -S "using encrypt then mac"
904
905run_test "Encrypt then MAC: client enabled, stream cipher" \
906 "$P_SRV debug_level=3 etm=1 \
907 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100908 "$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 +0100909 0 \
910 -c "client hello, adding encrypt_then_mac extension" \
911 -s "found encrypt then mac extension" \
912 -S "server hello, adding encrypt then mac extension" \
913 -C "found encrypt_then_mac extension" \
914 -C "using encrypt then mac" \
915 -S "using encrypt then mac"
916
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100917run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100918 "$P_SRV debug_level=3 etm=1 \
919 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100920 "$P_CLI debug_level=3 etm=0" \
921 0 \
922 -C "client hello, adding encrypt_then_mac extension" \
923 -S "found encrypt then mac extension" \
924 -S "server hello, adding encrypt then mac extension" \
925 -C "found encrypt_then_mac extension" \
926 -C "using encrypt then mac" \
927 -S "using encrypt then mac"
928
Janos Follathe2681a42016-03-07 15:57:05 +0000929requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100930run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100931 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100932 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100933 "$P_CLI debug_level=3 force_version=ssl3" \
934 0 \
935 -C "client hello, adding encrypt_then_mac extension" \
936 -S "found encrypt then mac extension" \
937 -S "server hello, adding encrypt then mac extension" \
938 -C "found encrypt_then_mac extension" \
939 -C "using encrypt then mac" \
940 -S "using encrypt then mac"
941
Janos Follathe2681a42016-03-07 15:57:05 +0000942requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100943run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100944 "$P_SRV debug_level=3 force_version=ssl3 \
945 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100946 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100947 0 \
948 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100949 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100950 -S "server hello, adding encrypt then mac extension" \
951 -C "found encrypt_then_mac extension" \
952 -C "using encrypt then mac" \
953 -S "using encrypt then mac"
954
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200955# Tests for Extended Master Secret extension
956
957run_test "Extended Master Secret: default" \
958 "$P_SRV debug_level=3" \
959 "$P_CLI debug_level=3" \
960 0 \
961 -c "client hello, adding extended_master_secret extension" \
962 -s "found extended master secret extension" \
963 -s "server hello, adding extended master secret extension" \
964 -c "found extended_master_secret extension" \
965 -c "using extended master secret" \
966 -s "using extended master secret"
967
968run_test "Extended Master Secret: client enabled, server disabled" \
969 "$P_SRV debug_level=3 extended_ms=0" \
970 "$P_CLI debug_level=3 extended_ms=1" \
971 0 \
972 -c "client hello, adding extended_master_secret extension" \
973 -s "found extended master secret extension" \
974 -S "server hello, adding extended master secret extension" \
975 -C "found extended_master_secret extension" \
976 -C "using extended master secret" \
977 -S "using extended master secret"
978
979run_test "Extended Master Secret: client disabled, server enabled" \
980 "$P_SRV debug_level=3 extended_ms=1" \
981 "$P_CLI debug_level=3 extended_ms=0" \
982 0 \
983 -C "client hello, adding extended_master_secret extension" \
984 -S "found extended master secret extension" \
985 -S "server hello, adding extended master secret extension" \
986 -C "found extended_master_secret extension" \
987 -C "using extended master secret" \
988 -S "using extended master secret"
989
Janos Follathe2681a42016-03-07 15:57:05 +0000990requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200991run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100992 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200993 "$P_CLI debug_level=3 force_version=ssl3" \
994 0 \
995 -C "client hello, adding extended_master_secret extension" \
996 -S "found extended master secret extension" \
997 -S "server hello, adding extended master secret extension" \
998 -C "found extended_master_secret extension" \
999 -C "using extended master secret" \
1000 -S "using extended master secret"
1001
Janos Follathe2681a42016-03-07 15:57:05 +00001002requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001003run_test "Extended Master Secret: client enabled, server SSLv3" \
1004 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001005 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001006 0 \
1007 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001008 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001009 -S "server hello, adding extended master secret extension" \
1010 -C "found extended_master_secret extension" \
1011 -C "using extended master secret" \
1012 -S "using extended master secret"
1013
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001014# Tests for FALLBACK_SCSV
1015
1016run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001017 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001018 "$P_CLI debug_level=3 force_version=tls1_1" \
1019 0 \
1020 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001021 -S "received FALLBACK_SCSV" \
1022 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001023 -C "is a fatal alert message (msg 86)"
1024
1025run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001026 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001027 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1028 0 \
1029 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001030 -S "received FALLBACK_SCSV" \
1031 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001032 -C "is a fatal alert message (msg 86)"
1033
1034run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001035 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001036 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001037 1 \
1038 -c "adding FALLBACK_SCSV" \
1039 -s "received FALLBACK_SCSV" \
1040 -s "inapropriate fallback" \
1041 -c "is a fatal alert message (msg 86)"
1042
1043run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001044 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001045 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001046 0 \
1047 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001048 -s "received FALLBACK_SCSV" \
1049 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001050 -C "is a fatal alert message (msg 86)"
1051
1052requires_openssl_with_fallback_scsv
1053run_test "Fallback SCSV: default, openssl server" \
1054 "$O_SRV" \
1055 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1056 0 \
1057 -C "adding FALLBACK_SCSV" \
1058 -C "is a fatal alert message (msg 86)"
1059
1060requires_openssl_with_fallback_scsv
1061run_test "Fallback SCSV: enabled, openssl server" \
1062 "$O_SRV" \
1063 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1064 1 \
1065 -c "adding FALLBACK_SCSV" \
1066 -c "is a fatal alert message (msg 86)"
1067
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001068requires_openssl_with_fallback_scsv
1069run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001070 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001071 "$O_CLI -tls1_1" \
1072 0 \
1073 -S "received FALLBACK_SCSV" \
1074 -S "inapropriate fallback"
1075
1076requires_openssl_with_fallback_scsv
1077run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001078 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001079 "$O_CLI -tls1_1 -fallback_scsv" \
1080 1 \
1081 -s "received FALLBACK_SCSV" \
1082 -s "inapropriate fallback"
1083
1084requires_openssl_with_fallback_scsv
1085run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001086 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001087 "$O_CLI -fallback_scsv" \
1088 0 \
1089 -s "received FALLBACK_SCSV" \
1090 -S "inapropriate fallback"
1091
Gilles Peskined50177f2017-05-16 17:53:03 +02001092## ClientHello generated with
1093## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1094## then manually twiddling the ciphersuite list.
1095## The ClientHello content is spelled out below as a hex string as
1096## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1097## The expected response is an inappropriate_fallback alert.
1098requires_openssl_with_fallback_scsv
1099run_test "Fallback SCSV: beginning of list" \
1100 "$P_SRV debug_level=2" \
1101 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1102 0 \
1103 -s "received FALLBACK_SCSV" \
1104 -s "inapropriate fallback"
1105
1106requires_openssl_with_fallback_scsv
1107run_test "Fallback SCSV: end of list" \
1108 "$P_SRV debug_level=2" \
1109 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1110 0 \
1111 -s "received FALLBACK_SCSV" \
1112 -s "inapropriate fallback"
1113
1114## Here the expected response is a valid ServerHello prefix, up to the random.
1115requires_openssl_with_fallback_scsv
1116run_test "Fallback SCSV: not in list" \
1117 "$P_SRV debug_level=2" \
1118 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1119 0 \
1120 -S "received FALLBACK_SCSV" \
1121 -S "inapropriate fallback"
1122
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001123# Tests for CBC 1/n-1 record splitting
1124
1125run_test "CBC Record splitting: TLS 1.2, no splitting" \
1126 "$P_SRV" \
1127 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1128 request_size=123 force_version=tls1_2" \
1129 0 \
1130 -s "Read from client: 123 bytes read" \
1131 -S "Read from client: 1 bytes read" \
1132 -S "122 bytes read"
1133
1134run_test "CBC Record splitting: TLS 1.1, no splitting" \
1135 "$P_SRV" \
1136 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1137 request_size=123 force_version=tls1_1" \
1138 0 \
1139 -s "Read from client: 123 bytes read" \
1140 -S "Read from client: 1 bytes read" \
1141 -S "122 bytes read"
1142
1143run_test "CBC Record splitting: TLS 1.0, splitting" \
1144 "$P_SRV" \
1145 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1146 request_size=123 force_version=tls1" \
1147 0 \
1148 -S "Read from client: 123 bytes read" \
1149 -s "Read from client: 1 bytes read" \
1150 -s "122 bytes read"
1151
Janos Follathe2681a42016-03-07 15:57:05 +00001152requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001153run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001154 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001155 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1156 request_size=123 force_version=ssl3" \
1157 0 \
1158 -S "Read from client: 123 bytes read" \
1159 -s "Read from client: 1 bytes read" \
1160 -s "122 bytes read"
1161
1162run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001163 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001164 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1165 request_size=123 force_version=tls1" \
1166 0 \
1167 -s "Read from client: 123 bytes read" \
1168 -S "Read from client: 1 bytes read" \
1169 -S "122 bytes read"
1170
1171run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1172 "$P_SRV" \
1173 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1174 request_size=123 force_version=tls1 recsplit=0" \
1175 0 \
1176 -s "Read from client: 123 bytes read" \
1177 -S "Read from client: 1 bytes read" \
1178 -S "122 bytes read"
1179
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001180run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1181 "$P_SRV nbio=2" \
1182 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1183 request_size=123 force_version=tls1" \
1184 0 \
1185 -S "Read from client: 123 bytes read" \
1186 -s "Read from client: 1 bytes read" \
1187 -s "122 bytes read"
1188
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001189# Tests for Session Tickets
1190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001191run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001192 "$P_SRV debug_level=3 tickets=1" \
1193 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001194 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001195 -c "client hello, adding session ticket extension" \
1196 -s "found session ticket extension" \
1197 -s "server hello, adding session ticket extension" \
1198 -c "found session_ticket extension" \
1199 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001200 -S "session successfully restored from cache" \
1201 -s "session successfully restored from ticket" \
1202 -s "a session has been resumed" \
1203 -c "a session has been resumed"
1204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001205run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001206 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1207 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001208 0 \
1209 -c "client hello, adding session ticket extension" \
1210 -s "found session ticket extension" \
1211 -s "server hello, adding session ticket extension" \
1212 -c "found session_ticket extension" \
1213 -c "parse new session ticket" \
1214 -S "session successfully restored from cache" \
1215 -s "session successfully restored from ticket" \
1216 -s "a session has been resumed" \
1217 -c "a session has been resumed"
1218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001219run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001220 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1221 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001222 0 \
1223 -c "client hello, adding session ticket extension" \
1224 -s "found session ticket extension" \
1225 -s "server hello, adding session ticket extension" \
1226 -c "found session_ticket extension" \
1227 -c "parse new session ticket" \
1228 -S "session successfully restored from cache" \
1229 -S "session successfully restored from ticket" \
1230 -S "a session has been resumed" \
1231 -C "a session has been resumed"
1232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001233run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001234 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001235 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001236 0 \
1237 -c "client hello, adding session ticket extension" \
1238 -c "found session_ticket extension" \
1239 -c "parse new session ticket" \
1240 -c "a session has been resumed"
1241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001242run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001243 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001244 "( $O_CLI -sess_out $SESSION; \
1245 $O_CLI -sess_in $SESSION; \
1246 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001247 0 \
1248 -s "found session ticket extension" \
1249 -s "server hello, adding session ticket extension" \
1250 -S "session successfully restored from cache" \
1251 -s "session successfully restored from ticket" \
1252 -s "a session has been resumed"
1253
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001254# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_SRV debug_level=3 tickets=0" \
1258 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001259 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001260 -c "client hello, adding session ticket extension" \
1261 -s "found session ticket extension" \
1262 -S "server hello, adding session ticket extension" \
1263 -C "found session_ticket extension" \
1264 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001265 -s "session successfully restored from cache" \
1266 -S "session successfully restored from ticket" \
1267 -s "a session has been resumed" \
1268 -c "a session has been resumed"
1269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001270run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001271 "$P_SRV debug_level=3 tickets=1" \
1272 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001273 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001274 -C "client hello, adding session ticket extension" \
1275 -S "found session ticket extension" \
1276 -S "server hello, adding session ticket extension" \
1277 -C "found session_ticket extension" \
1278 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001279 -s "session successfully restored from cache" \
1280 -S "session successfully restored from ticket" \
1281 -s "a session has been resumed" \
1282 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001283
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001284run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001285 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1286 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001287 0 \
1288 -S "session successfully restored from cache" \
1289 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001290 -S "a session has been resumed" \
1291 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001293run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001294 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1295 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001296 0 \
1297 -s "session successfully restored from cache" \
1298 -S "session successfully restored from ticket" \
1299 -s "a session has been resumed" \
1300 -c "a session has been resumed"
1301
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001302run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001303 "$P_SRV debug_level=3 tickets=0" \
1304 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001305 0 \
1306 -s "session successfully restored from cache" \
1307 -S "session successfully restored from ticket" \
1308 -s "a session has been resumed" \
1309 -c "a session has been resumed"
1310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001311run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001312 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1313 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001314 0 \
1315 -S "session successfully restored from cache" \
1316 -S "session successfully restored from ticket" \
1317 -S "a session has been resumed" \
1318 -C "a session has been resumed"
1319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001320run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001321 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1322 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001323 0 \
1324 -s "session successfully restored from cache" \
1325 -S "session successfully restored from ticket" \
1326 -s "a session has been resumed" \
1327 -c "a session has been resumed"
1328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001329run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001330 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001331 "( $O_CLI -sess_out $SESSION; \
1332 $O_CLI -sess_in $SESSION; \
1333 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001334 0 \
1335 -s "found session ticket extension" \
1336 -S "server hello, adding session ticket extension" \
1337 -s "session successfully restored from cache" \
1338 -S "session successfully restored from ticket" \
1339 -s "a session has been resumed"
1340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001341run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001342 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001343 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001344 0 \
1345 -C "found session_ticket extension" \
1346 -C "parse new session ticket" \
1347 -c "a session has been resumed"
1348
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001349# Tests for Max Fragment Length extension
1350
Hanno Becker6428f8d2017-09-22 16:58:50 +01001351MAX_CONTENT_LEN_EXPECT='16384'
1352MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1353
1354if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1355 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1356 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1357 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1358 printf "\n"
1359 printf "The tests assume this value and if it changes, the tests in this\n"
1360 printf "script should also be adjusted.\n"
1361 printf "\n"
1362
1363 exit 1
1364fi
1365
Hanno Becker4aed27e2017-09-18 15:00:34 +01001366requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001367run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001368 "$P_SRV debug_level=3" \
1369 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001370 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001371 -c "Maximum fragment length is 16384" \
1372 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001373 -C "client hello, adding max_fragment_length extension" \
1374 -S "found max fragment length extension" \
1375 -S "server hello, max_fragment_length extension" \
1376 -C "found max_fragment_length extension"
1377
Hanno Becker4aed27e2017-09-18 15:00:34 +01001378requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001379run_test "Max fragment length: enabled, default, larger message" \
1380 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001381 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001382 0 \
1383 -c "Maximum fragment length is 16384" \
1384 -s "Maximum fragment length is 16384" \
1385 -C "client hello, adding max_fragment_length extension" \
1386 -S "found max fragment length extension" \
1387 -S "server hello, max_fragment_length extension" \
1388 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001389 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001390 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001391 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001392
1393requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1394run_test "Max fragment length, DTLS: enabled, default, larger message" \
1395 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001396 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001397 1 \
1398 -c "Maximum fragment length is 16384" \
1399 -s "Maximum fragment length is 16384" \
1400 -C "client hello, adding max_fragment_length extension" \
1401 -S "found max fragment length extension" \
1402 -S "server hello, max_fragment_length extension" \
1403 -C "found max_fragment_length extension" \
1404 -c "fragment larger than.*maximum "
1405
1406requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1407run_test "Max fragment length: disabled, larger message" \
1408 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001409 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001410 0 \
1411 -C "Maximum fragment length is 16384" \
1412 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001413 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001414 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001415 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001416
1417requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1418run_test "Max fragment length DTLS: disabled, larger message" \
1419 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001420 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001421 1 \
1422 -C "Maximum fragment length is 16384" \
1423 -S "Maximum fragment length is 16384" \
1424 -c "fragment larger than.*maximum "
1425
1426requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001427run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001428 "$P_SRV debug_level=3" \
1429 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001430 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001431 -c "Maximum fragment length is 4096" \
1432 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001433 -c "client hello, adding max_fragment_length extension" \
1434 -s "found max fragment length extension" \
1435 -s "server hello, max_fragment_length extension" \
1436 -c "found max_fragment_length extension"
1437
Hanno Becker4aed27e2017-09-18 15:00:34 +01001438requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001439run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001440 "$P_SRV debug_level=3 max_frag_len=4096" \
1441 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001442 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001443 -c "Maximum fragment length is 16384" \
1444 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001445 -C "client hello, adding max_fragment_length extension" \
1446 -S "found max fragment length extension" \
1447 -S "server hello, max_fragment_length extension" \
1448 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001449
Hanno Becker4aed27e2017-09-18 15:00:34 +01001450requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001451requires_gnutls
1452run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001453 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001454 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001455 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001456 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001457 -c "client hello, adding max_fragment_length extension" \
1458 -c "found max_fragment_length extension"
1459
Hanno Becker4aed27e2017-09-18 15:00:34 +01001460requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001461run_test "Max fragment length: client, message just fits" \
1462 "$P_SRV debug_level=3" \
1463 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
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 "2048 bytes written in 1 fragments" \
1472 -s "2048 bytes read"
1473
Hanno Becker4aed27e2017-09-18 15:00:34 +01001474requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001475run_test "Max fragment length: client, larger message" \
1476 "$P_SRV debug_level=3" \
1477 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1478 0 \
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 "2345 bytes written in 2 fragments" \
1486 -s "2048 bytes read" \
1487 -s "297 bytes read"
1488
Hanno Becker4aed27e2017-09-18 15:00:34 +01001489requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001490run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001491 "$P_SRV debug_level=3 dtls=1" \
1492 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1493 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001494 -c "Maximum fragment length is 2048" \
1495 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001496 -c "client hello, adding max_fragment_length extension" \
1497 -s "found max fragment length extension" \
1498 -s "server hello, max_fragment_length extension" \
1499 -c "found max_fragment_length extension" \
1500 -c "fragment larger than.*maximum"
1501
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001502# Tests for renegotiation
1503
Hanno Becker6a243642017-10-12 15:18:45 +01001504# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001505run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001506 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001507 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001508 0 \
1509 -C "client hello, adding renegotiation extension" \
1510 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1511 -S "found renegotiation extension" \
1512 -s "server hello, secure renegotiation extension" \
1513 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001514 -C "=> renegotiate" \
1515 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001516 -S "write hello request"
1517
Hanno Becker6a243642017-10-12 15:18:45 +01001518requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001519run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001520 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001521 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001522 0 \
1523 -c "client hello, adding renegotiation extension" \
1524 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1525 -s "found renegotiation extension" \
1526 -s "server hello, secure renegotiation extension" \
1527 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001528 -c "=> renegotiate" \
1529 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001530 -S "write hello request"
1531
Hanno Becker6a243642017-10-12 15:18:45 +01001532requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001533run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001534 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001535 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001536 0 \
1537 -c "client hello, adding renegotiation extension" \
1538 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1539 -s "found renegotiation extension" \
1540 -s "server hello, secure renegotiation extension" \
1541 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001542 -c "=> renegotiate" \
1543 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001544 -s "write hello request"
1545
Janos Follathb0f148c2017-10-05 12:29:42 +01001546# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1547# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1548# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001549requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001550run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1551 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1552 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1553 0 \
1554 -c "client hello, adding renegotiation extension" \
1555 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1556 -s "found renegotiation extension" \
1557 -s "server hello, secure renegotiation extension" \
1558 -c "found renegotiation extension" \
1559 -c "=> renegotiate" \
1560 -s "=> renegotiate" \
1561 -S "write hello request" \
1562 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1563
1564# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1565# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1566# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001567requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001568run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1569 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1570 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1571 0 \
1572 -c "client hello, adding renegotiation extension" \
1573 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1574 -s "found renegotiation extension" \
1575 -s "server hello, secure renegotiation extension" \
1576 -c "found renegotiation extension" \
1577 -c "=> renegotiate" \
1578 -s "=> renegotiate" \
1579 -s "write hello request" \
1580 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1581
Hanno Becker6a243642017-10-12 15:18:45 +01001582requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001583run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001584 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001585 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001586 0 \
1587 -c "client hello, adding renegotiation extension" \
1588 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1589 -s "found renegotiation extension" \
1590 -s "server hello, secure renegotiation extension" \
1591 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001592 -c "=> renegotiate" \
1593 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001594 -s "write hello request"
1595
Hanno Becker6a243642017-10-12 15:18:45 +01001596requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001597run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001598 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001599 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001600 1 \
1601 -c "client hello, adding renegotiation extension" \
1602 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1603 -S "found renegotiation extension" \
1604 -s "server hello, secure renegotiation extension" \
1605 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001606 -c "=> renegotiate" \
1607 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001608 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001609 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001610 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001611
Hanno Becker6a243642017-10-12 15:18:45 +01001612requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001613run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001614 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001615 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001616 0 \
1617 -C "client hello, adding renegotiation extension" \
1618 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1619 -S "found renegotiation extension" \
1620 -s "server hello, secure renegotiation extension" \
1621 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001622 -C "=> renegotiate" \
1623 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001624 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001625 -S "SSL - An unexpected message was received from our peer" \
1626 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001627
Hanno Becker6a243642017-10-12 15:18:45 +01001628requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001629run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001630 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001631 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001632 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001633 0 \
1634 -C "client hello, adding renegotiation extension" \
1635 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1636 -S "found renegotiation extension" \
1637 -s "server hello, secure renegotiation extension" \
1638 -c "found renegotiation extension" \
1639 -C "=> renegotiate" \
1640 -S "=> renegotiate" \
1641 -s "write hello request" \
1642 -S "SSL - An unexpected message was received from our peer" \
1643 -S "failed"
1644
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001645# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001646requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001647run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001648 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001649 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001650 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001651 0 \
1652 -C "client hello, adding renegotiation extension" \
1653 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1654 -S "found renegotiation extension" \
1655 -s "server hello, secure renegotiation extension" \
1656 -c "found renegotiation extension" \
1657 -C "=> renegotiate" \
1658 -S "=> renegotiate" \
1659 -s "write hello request" \
1660 -S "SSL - An unexpected message was received from our peer" \
1661 -S "failed"
1662
Hanno Becker6a243642017-10-12 15:18:45 +01001663requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001664run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001665 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001666 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001667 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001668 0 \
1669 -C "client hello, adding renegotiation extension" \
1670 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1671 -S "found renegotiation extension" \
1672 -s "server hello, secure renegotiation extension" \
1673 -c "found renegotiation extension" \
1674 -C "=> renegotiate" \
1675 -S "=> renegotiate" \
1676 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001677 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001678
Hanno Becker6a243642017-10-12 15:18:45 +01001679requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001680run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001681 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001682 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001683 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001684 0 \
1685 -c "client hello, adding renegotiation extension" \
1686 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1687 -s "found renegotiation extension" \
1688 -s "server hello, secure renegotiation extension" \
1689 -c "found renegotiation extension" \
1690 -c "=> renegotiate" \
1691 -s "=> renegotiate" \
1692 -s "write hello request" \
1693 -S "SSL - An unexpected message was received from our peer" \
1694 -S "failed"
1695
Hanno Becker6a243642017-10-12 15:18:45 +01001696requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001697run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001698 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001699 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1700 0 \
1701 -C "client hello, adding renegotiation extension" \
1702 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1703 -S "found renegotiation extension" \
1704 -s "server hello, secure renegotiation extension" \
1705 -c "found renegotiation extension" \
1706 -S "record counter limit reached: renegotiate" \
1707 -C "=> renegotiate" \
1708 -S "=> renegotiate" \
1709 -S "write hello request" \
1710 -S "SSL - An unexpected message was received from our peer" \
1711 -S "failed"
1712
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001713# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001714requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001715run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001716 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001717 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001718 0 \
1719 -c "client hello, adding renegotiation extension" \
1720 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1721 -s "found renegotiation extension" \
1722 -s "server hello, secure renegotiation extension" \
1723 -c "found renegotiation extension" \
1724 -s "record counter limit reached: renegotiate" \
1725 -c "=> renegotiate" \
1726 -s "=> renegotiate" \
1727 -s "write hello request" \
1728 -S "SSL - An unexpected message was received from our peer" \
1729 -S "failed"
1730
Hanno Becker6a243642017-10-12 15:18:45 +01001731requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001732run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001733 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001734 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001735 0 \
1736 -c "client hello, adding renegotiation extension" \
1737 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1738 -s "found renegotiation extension" \
1739 -s "server hello, secure renegotiation extension" \
1740 -c "found renegotiation extension" \
1741 -s "record counter limit reached: renegotiate" \
1742 -c "=> renegotiate" \
1743 -s "=> renegotiate" \
1744 -s "write hello request" \
1745 -S "SSL - An unexpected message was received from our peer" \
1746 -S "failed"
1747
Hanno Becker6a243642017-10-12 15:18:45 +01001748requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001749run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001750 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001751 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1752 0 \
1753 -C "client hello, adding renegotiation extension" \
1754 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1755 -S "found renegotiation extension" \
1756 -s "server hello, secure renegotiation extension" \
1757 -c "found renegotiation extension" \
1758 -S "record counter limit reached: renegotiate" \
1759 -C "=> renegotiate" \
1760 -S "=> renegotiate" \
1761 -S "write hello request" \
1762 -S "SSL - An unexpected message was received from our peer" \
1763 -S "failed"
1764
Hanno Becker6a243642017-10-12 15:18:45 +01001765requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001766run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001767 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001768 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001769 0 \
1770 -c "client hello, adding renegotiation extension" \
1771 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1772 -s "found renegotiation extension" \
1773 -s "server hello, secure renegotiation extension" \
1774 -c "found renegotiation extension" \
1775 -c "=> renegotiate" \
1776 -s "=> renegotiate" \
1777 -S "write hello request"
1778
Hanno Becker6a243642017-10-12 15:18:45 +01001779requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001780run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001781 "$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 +02001782 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001783 0 \
1784 -c "client hello, adding renegotiation extension" \
1785 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1786 -s "found renegotiation extension" \
1787 -s "server hello, secure renegotiation extension" \
1788 -c "found renegotiation extension" \
1789 -c "=> renegotiate" \
1790 -s "=> renegotiate" \
1791 -s "write hello request"
1792
Hanno Becker6a243642017-10-12 15:18:45 +01001793requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001794run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001795 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001796 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001797 0 \
1798 -c "client hello, adding renegotiation extension" \
1799 -c "found renegotiation extension" \
1800 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001801 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001802 -C "error" \
1803 -c "HTTP/1.0 200 [Oo][Kk]"
1804
Paul Bakker539d9722015-02-08 16:18:35 +01001805requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001806requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001807run_test "Renegotiation: gnutls server strict, client-initiated" \
1808 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001809 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001810 0 \
1811 -c "client hello, adding renegotiation extension" \
1812 -c "found renegotiation extension" \
1813 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001814 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001815 -C "error" \
1816 -c "HTTP/1.0 200 [Oo][Kk]"
1817
Paul Bakker539d9722015-02-08 16:18:35 +01001818requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001819requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001820run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1821 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1822 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1823 1 \
1824 -c "client hello, adding renegotiation extension" \
1825 -C "found renegotiation extension" \
1826 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001827 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001828 -c "error" \
1829 -C "HTTP/1.0 200 [Oo][Kk]"
1830
Paul Bakker539d9722015-02-08 16:18:35 +01001831requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001832requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001833run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1834 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1835 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1836 allow_legacy=0" \
1837 1 \
1838 -c "client hello, adding renegotiation extension" \
1839 -C "found renegotiation extension" \
1840 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001841 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001842 -c "error" \
1843 -C "HTTP/1.0 200 [Oo][Kk]"
1844
Paul Bakker539d9722015-02-08 16:18:35 +01001845requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001846requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001847run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1848 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1849 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1850 allow_legacy=1" \
1851 0 \
1852 -c "client hello, adding renegotiation extension" \
1853 -C "found renegotiation extension" \
1854 -c "=> renegotiate" \
1855 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001856 -C "error" \
1857 -c "HTTP/1.0 200 [Oo][Kk]"
1858
Hanno Becker6a243642017-10-12 15:18:45 +01001859requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001860run_test "Renegotiation: DTLS, client-initiated" \
1861 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1862 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1863 0 \
1864 -c "client hello, adding renegotiation extension" \
1865 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1866 -s "found renegotiation extension" \
1867 -s "server hello, secure renegotiation extension" \
1868 -c "found renegotiation extension" \
1869 -c "=> renegotiate" \
1870 -s "=> renegotiate" \
1871 -S "write hello request"
1872
Hanno Becker6a243642017-10-12 15:18:45 +01001873requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001874run_test "Renegotiation: DTLS, server-initiated" \
1875 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001876 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1877 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001878 0 \
1879 -c "client hello, adding renegotiation extension" \
1880 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1881 -s "found renegotiation extension" \
1882 -s "server hello, secure renegotiation extension" \
1883 -c "found renegotiation extension" \
1884 -c "=> renegotiate" \
1885 -s "=> renegotiate" \
1886 -s "write hello request"
1887
Hanno Becker6a243642017-10-12 15:18:45 +01001888requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00001889run_test "Renegotiation: DTLS, renego_period overflow" \
1890 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1891 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1892 0 \
1893 -c "client hello, adding renegotiation extension" \
1894 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1895 -s "found renegotiation extension" \
1896 -s "server hello, secure renegotiation extension" \
1897 -s "record counter limit reached: renegotiate" \
1898 -c "=> renegotiate" \
1899 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01001900 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00001901
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001902requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001903requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001904run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1905 "$G_SRV -u --mtu 4096" \
1906 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1907 0 \
1908 -c "client hello, adding renegotiation extension" \
1909 -c "found renegotiation extension" \
1910 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001911 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001912 -C "error" \
1913 -s "Extra-header:"
1914
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001915# Test for the "secure renegotation" extension only (no actual renegotiation)
1916
Paul Bakker539d9722015-02-08 16:18:35 +01001917requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001918run_test "Renego ext: gnutls server strict, client default" \
1919 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1920 "$P_CLI debug_level=3" \
1921 0 \
1922 -c "found renegotiation extension" \
1923 -C "error" \
1924 -c "HTTP/1.0 200 [Oo][Kk]"
1925
Paul Bakker539d9722015-02-08 16:18:35 +01001926requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001927run_test "Renego ext: gnutls server unsafe, client default" \
1928 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1929 "$P_CLI debug_level=3" \
1930 0 \
1931 -C "found renegotiation extension" \
1932 -C "error" \
1933 -c "HTTP/1.0 200 [Oo][Kk]"
1934
Paul Bakker539d9722015-02-08 16:18:35 +01001935requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001936run_test "Renego ext: gnutls server unsafe, client break legacy" \
1937 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1938 "$P_CLI debug_level=3 allow_legacy=-1" \
1939 1 \
1940 -C "found renegotiation extension" \
1941 -c "error" \
1942 -C "HTTP/1.0 200 [Oo][Kk]"
1943
Paul Bakker539d9722015-02-08 16:18:35 +01001944requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001945run_test "Renego ext: gnutls client strict, server default" \
1946 "$P_SRV debug_level=3" \
1947 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1948 0 \
1949 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1950 -s "server hello, secure renegotiation extension"
1951
Paul Bakker539d9722015-02-08 16:18:35 +01001952requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001953run_test "Renego ext: gnutls client unsafe, server default" \
1954 "$P_SRV debug_level=3" \
1955 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1956 0 \
1957 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1958 -S "server hello, secure renegotiation extension"
1959
Paul Bakker539d9722015-02-08 16:18:35 +01001960requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001961run_test "Renego ext: gnutls client unsafe, server break legacy" \
1962 "$P_SRV debug_level=3 allow_legacy=-1" \
1963 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1964 1 \
1965 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1966 -S "server hello, secure renegotiation extension"
1967
Janos Follath0b242342016-02-17 10:11:21 +00001968# Tests for silently dropping trailing extra bytes in .der certificates
1969
1970requires_gnutls
1971run_test "DER format: no trailing bytes" \
1972 "$P_SRV crt_file=data_files/server5-der0.crt \
1973 key_file=data_files/server5.key" \
1974 "$G_CLI " \
1975 0 \
1976 -c "Handshake was completed" \
1977
1978requires_gnutls
1979run_test "DER format: with a trailing zero byte" \
1980 "$P_SRV crt_file=data_files/server5-der1a.crt \
1981 key_file=data_files/server5.key" \
1982 "$G_CLI " \
1983 0 \
1984 -c "Handshake was completed" \
1985
1986requires_gnutls
1987run_test "DER format: with a trailing random byte" \
1988 "$P_SRV crt_file=data_files/server5-der1b.crt \
1989 key_file=data_files/server5.key" \
1990 "$G_CLI " \
1991 0 \
1992 -c "Handshake was completed" \
1993
1994requires_gnutls
1995run_test "DER format: with 2 trailing random bytes" \
1996 "$P_SRV crt_file=data_files/server5-der2.crt \
1997 key_file=data_files/server5.key" \
1998 "$G_CLI " \
1999 0 \
2000 -c "Handshake was completed" \
2001
2002requires_gnutls
2003run_test "DER format: with 4 trailing random bytes" \
2004 "$P_SRV crt_file=data_files/server5-der4.crt \
2005 key_file=data_files/server5.key" \
2006 "$G_CLI " \
2007 0 \
2008 -c "Handshake was completed" \
2009
2010requires_gnutls
2011run_test "DER format: with 8 trailing random bytes" \
2012 "$P_SRV crt_file=data_files/server5-der8.crt \
2013 key_file=data_files/server5.key" \
2014 "$G_CLI " \
2015 0 \
2016 -c "Handshake was completed" \
2017
2018requires_gnutls
2019run_test "DER format: with 9 trailing random bytes" \
2020 "$P_SRV crt_file=data_files/server5-der9.crt \
2021 key_file=data_files/server5.key" \
2022 "$G_CLI " \
2023 0 \
2024 -c "Handshake was completed" \
2025
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002026# Tests for auth_mode
2027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002028run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002029 "$P_SRV crt_file=data_files/server5-badsign.crt \
2030 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002031 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002032 1 \
2033 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002034 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002035 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002036 -c "X509 - Certificate verification failed"
2037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002038run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002039 "$P_SRV crt_file=data_files/server5-badsign.crt \
2040 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002041 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002042 0 \
2043 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002044 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002045 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002046 -C "X509 - Certificate verification failed"
2047
Hanno Beckere6706e62017-05-15 16:05:15 +01002048run_test "Authentication: server goodcert, client optional, no trusted CA" \
2049 "$P_SRV" \
2050 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2051 0 \
2052 -c "x509_verify_cert() returned" \
2053 -c "! The certificate is not correctly signed by the trusted CA" \
2054 -c "! Certificate verification flags"\
2055 -C "! mbedtls_ssl_handshake returned" \
2056 -C "X509 - Certificate verification failed" \
2057 -C "SSL - No CA Chain is set, but required to operate"
2058
2059run_test "Authentication: server goodcert, client required, no trusted CA" \
2060 "$P_SRV" \
2061 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2062 1 \
2063 -c "x509_verify_cert() returned" \
2064 -c "! The certificate is not correctly signed by the trusted CA" \
2065 -c "! Certificate verification flags"\
2066 -c "! mbedtls_ssl_handshake returned" \
2067 -c "SSL - No CA Chain is set, but required to operate"
2068
2069# The purpose of the next two tests is to test the client's behaviour when receiving a server
2070# certificate with an unsupported elliptic curve. This should usually not happen because
2071# the client informs the server about the supported curves - it does, though, in the
2072# corner case of a static ECDH suite, because the server doesn't check the curve on that
2073# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2074# different means to have the server ignoring the client's supported curve list.
2075
2076requires_config_enabled MBEDTLS_ECP_C
2077run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2078 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2079 crt_file=data_files/server5.ku-ka.crt" \
2080 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2081 1 \
2082 -c "bad certificate (EC key curve)"\
2083 -c "! Certificate verification flags"\
2084 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2085
2086requires_config_enabled MBEDTLS_ECP_C
2087run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2088 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2089 crt_file=data_files/server5.ku-ka.crt" \
2090 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2091 1 \
2092 -c "bad certificate (EC key curve)"\
2093 -c "! Certificate verification flags"\
2094 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2095
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002096run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002097 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002098 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002099 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002100 0 \
2101 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002102 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002103 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002104 -C "X509 - Certificate verification failed"
2105
Simon Butcher99000142016-10-13 17:21:01 +01002106run_test "Authentication: client SHA256, server required" \
2107 "$P_SRV auth_mode=required" \
2108 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2109 key_file=data_files/server6.key \
2110 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2111 0 \
2112 -c "Supported Signature Algorithm found: 4," \
2113 -c "Supported Signature Algorithm found: 5,"
2114
2115run_test "Authentication: client SHA384, server required" \
2116 "$P_SRV auth_mode=required" \
2117 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2118 key_file=data_files/server6.key \
2119 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2120 0 \
2121 -c "Supported Signature Algorithm found: 4," \
2122 -c "Supported Signature Algorithm found: 5,"
2123
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002124requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2125run_test "Authentication: client has no cert, server required (SSLv3)" \
2126 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2127 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2128 key_file=data_files/server5.key" \
2129 1 \
2130 -S "skip write certificate request" \
2131 -C "skip parse certificate request" \
2132 -c "got a certificate request" \
2133 -c "got no certificate to send" \
2134 -S "x509_verify_cert() returned" \
2135 -s "client has no certificate" \
2136 -s "! mbedtls_ssl_handshake returned" \
2137 -c "! mbedtls_ssl_handshake returned" \
2138 -s "No client certification received from the client, but required by the authentication mode"
2139
2140run_test "Authentication: client has no cert, server required (TLS)" \
2141 "$P_SRV debug_level=3 auth_mode=required" \
2142 "$P_CLI debug_level=3 crt_file=none \
2143 key_file=data_files/server5.key" \
2144 1 \
2145 -S "skip write certificate request" \
2146 -C "skip parse certificate request" \
2147 -c "got a certificate request" \
2148 -c "= write certificate$" \
2149 -C "skip write certificate$" \
2150 -S "x509_verify_cert() returned" \
2151 -s "client has no certificate" \
2152 -s "! mbedtls_ssl_handshake returned" \
2153 -c "! mbedtls_ssl_handshake returned" \
2154 -s "No client certification received from the client, but required by the authentication mode"
2155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002156run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002157 "$P_SRV debug_level=3 auth_mode=required" \
2158 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002159 key_file=data_files/server5.key" \
2160 1 \
2161 -S "skip write certificate request" \
2162 -C "skip parse certificate request" \
2163 -c "got a certificate request" \
2164 -C "skip write certificate" \
2165 -C "skip write certificate verify" \
2166 -S "skip parse certificate verify" \
2167 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002168 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002169 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002170 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002171 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002172 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002173# We don't check that the client receives the alert because it might
2174# detect that its write end of the connection is closed and abort
2175# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002176
Janos Follath89baba22017-04-10 14:34:35 +01002177run_test "Authentication: client cert not trusted, server required" \
2178 "$P_SRV debug_level=3 auth_mode=required" \
2179 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2180 key_file=data_files/server5.key" \
2181 1 \
2182 -S "skip write certificate request" \
2183 -C "skip parse certificate request" \
2184 -c "got a certificate request" \
2185 -C "skip write certificate" \
2186 -C "skip write certificate verify" \
2187 -S "skip parse certificate verify" \
2188 -s "x509_verify_cert() returned" \
2189 -s "! The certificate is not correctly signed by the trusted CA" \
2190 -s "! mbedtls_ssl_handshake returned" \
2191 -c "! mbedtls_ssl_handshake returned" \
2192 -s "X509 - Certificate verification failed"
2193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002194run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002195 "$P_SRV debug_level=3 auth_mode=optional" \
2196 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002197 key_file=data_files/server5.key" \
2198 0 \
2199 -S "skip write certificate request" \
2200 -C "skip parse certificate request" \
2201 -c "got a certificate request" \
2202 -C "skip write certificate" \
2203 -C "skip write certificate verify" \
2204 -S "skip parse certificate verify" \
2205 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002206 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002207 -S "! mbedtls_ssl_handshake returned" \
2208 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002209 -S "X509 - Certificate verification failed"
2210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002211run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002212 "$P_SRV debug_level=3 auth_mode=none" \
2213 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002214 key_file=data_files/server5.key" \
2215 0 \
2216 -s "skip write certificate request" \
2217 -C "skip parse certificate request" \
2218 -c "got no certificate request" \
2219 -c "skip write certificate" \
2220 -c "skip write certificate verify" \
2221 -s "skip parse certificate verify" \
2222 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002223 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002224 -S "! mbedtls_ssl_handshake returned" \
2225 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002226 -S "X509 - Certificate verification failed"
2227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002228run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002229 "$P_SRV debug_level=3 auth_mode=optional" \
2230 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002231 0 \
2232 -S "skip write certificate request" \
2233 -C "skip parse certificate request" \
2234 -c "got a certificate request" \
2235 -C "skip write certificate$" \
2236 -C "got no certificate to send" \
2237 -S "SSLv3 client has no certificate" \
2238 -c "skip write certificate verify" \
2239 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002240 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002241 -S "! mbedtls_ssl_handshake returned" \
2242 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002243 -S "X509 - Certificate verification failed"
2244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002245run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002246 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002247 "$O_CLI" \
2248 0 \
2249 -S "skip write certificate request" \
2250 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002251 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002252 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002253 -S "X509 - Certificate verification failed"
2254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002255run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002256 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002257 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002258 0 \
2259 -C "skip parse certificate request" \
2260 -c "got a certificate request" \
2261 -C "skip write certificate$" \
2262 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002263 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002264
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002265run_test "Authentication: client no cert, openssl server required" \
2266 "$O_SRV -Verify 10" \
2267 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2268 1 \
2269 -C "skip parse certificate request" \
2270 -c "got a certificate request" \
2271 -C "skip write certificate$" \
2272 -c "skip write certificate verify" \
2273 -c "! mbedtls_ssl_handshake returned"
2274
Janos Follathe2681a42016-03-07 15:57:05 +00002275requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002276run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002277 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002278 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002279 0 \
2280 -S "skip write certificate request" \
2281 -C "skip parse certificate request" \
2282 -c "got a certificate request" \
2283 -C "skip write certificate$" \
2284 -c "skip write certificate verify" \
2285 -c "got no certificate to send" \
2286 -s "SSLv3 client has no certificate" \
2287 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002288 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002289 -S "! mbedtls_ssl_handshake returned" \
2290 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002291 -S "X509 - Certificate verification failed"
2292
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002293# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2294# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002295
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002296MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002297MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002298
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002299if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002300 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002301 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002302 printf "test value of ${MAX_IM_CA}. \n"
2303 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002304 printf "The tests assume this value and if it changes, the tests in this\n"
2305 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002306 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002307
2308 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002309fi
2310
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002311run_test "Authentication: server max_int chain, client default" \
2312 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2313 key_file=data_files/dir-maxpath/09.key" \
2314 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2315 0 \
2316 -C "X509 - A fatal error occured"
2317
2318run_test "Authentication: server max_int+1 chain, client default" \
2319 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2320 key_file=data_files/dir-maxpath/10.key" \
2321 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2322 1 \
2323 -c "X509 - A fatal error occured"
2324
2325run_test "Authentication: server max_int+1 chain, client optional" \
2326 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2327 key_file=data_files/dir-maxpath/10.key" \
2328 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2329 auth_mode=optional" \
2330 1 \
2331 -c "X509 - A fatal error occured"
2332
2333run_test "Authentication: server max_int+1 chain, client none" \
2334 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2335 key_file=data_files/dir-maxpath/10.key" \
2336 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2337 auth_mode=none" \
2338 0 \
2339 -C "X509 - A fatal error occured"
2340
2341run_test "Authentication: client max_int+1 chain, server default" \
2342 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2343 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2344 key_file=data_files/dir-maxpath/10.key" \
2345 0 \
2346 -S "X509 - A fatal error occured"
2347
2348run_test "Authentication: client max_int+1 chain, server optional" \
2349 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2350 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2351 key_file=data_files/dir-maxpath/10.key" \
2352 1 \
2353 -s "X509 - A fatal error occured"
2354
2355run_test "Authentication: client max_int+1 chain, server required" \
2356 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2357 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2358 key_file=data_files/dir-maxpath/10.key" \
2359 1 \
2360 -s "X509 - A fatal error occured"
2361
2362run_test "Authentication: client max_int chain, server required" \
2363 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2364 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2365 key_file=data_files/dir-maxpath/09.key" \
2366 0 \
2367 -S "X509 - A fatal error occured"
2368
Janos Follath89baba22017-04-10 14:34:35 +01002369# Tests for CA list in CertificateRequest messages
2370
2371run_test "Authentication: send CA list in CertificateRequest (default)" \
2372 "$P_SRV debug_level=3 auth_mode=required" \
2373 "$P_CLI crt_file=data_files/server6.crt \
2374 key_file=data_files/server6.key" \
2375 0 \
2376 -s "requested DN"
2377
2378run_test "Authentication: do not send CA list in CertificateRequest" \
2379 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2380 "$P_CLI crt_file=data_files/server6.crt \
2381 key_file=data_files/server6.key" \
2382 0 \
2383 -S "requested DN"
2384
2385run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2386 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2387 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2388 key_file=data_files/server5.key" \
2389 1 \
2390 -S "requested DN" \
2391 -s "x509_verify_cert() returned" \
2392 -s "! The certificate is not correctly signed by the trusted CA" \
2393 -s "! mbedtls_ssl_handshake returned" \
2394 -c "! mbedtls_ssl_handshake returned" \
2395 -s "X509 - Certificate verification failed"
2396
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002397# Tests for certificate selection based on SHA verson
2398
2399run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2400 "$P_SRV crt_file=data_files/server5.crt \
2401 key_file=data_files/server5.key \
2402 crt_file2=data_files/server5-sha1.crt \
2403 key_file2=data_files/server5.key" \
2404 "$P_CLI force_version=tls1_2" \
2405 0 \
2406 -c "signed using.*ECDSA with SHA256" \
2407 -C "signed using.*ECDSA with SHA1"
2408
2409run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2410 "$P_SRV crt_file=data_files/server5.crt \
2411 key_file=data_files/server5.key \
2412 crt_file2=data_files/server5-sha1.crt \
2413 key_file2=data_files/server5.key" \
2414 "$P_CLI force_version=tls1_1" \
2415 0 \
2416 -C "signed using.*ECDSA with SHA256" \
2417 -c "signed using.*ECDSA with SHA1"
2418
2419run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2420 "$P_SRV crt_file=data_files/server5.crt \
2421 key_file=data_files/server5.key \
2422 crt_file2=data_files/server5-sha1.crt \
2423 key_file2=data_files/server5.key" \
2424 "$P_CLI force_version=tls1" \
2425 0 \
2426 -C "signed using.*ECDSA with SHA256" \
2427 -c "signed using.*ECDSA with SHA1"
2428
2429run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2430 "$P_SRV crt_file=data_files/server5.crt \
2431 key_file=data_files/server5.key \
2432 crt_file2=data_files/server6.crt \
2433 key_file2=data_files/server6.key" \
2434 "$P_CLI force_version=tls1_1" \
2435 0 \
2436 -c "serial number.*09" \
2437 -c "signed using.*ECDSA with SHA256" \
2438 -C "signed using.*ECDSA with SHA1"
2439
2440run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2441 "$P_SRV crt_file=data_files/server6.crt \
2442 key_file=data_files/server6.key \
2443 crt_file2=data_files/server5.crt \
2444 key_file2=data_files/server5.key" \
2445 "$P_CLI force_version=tls1_1" \
2446 0 \
2447 -c "serial number.*0A" \
2448 -c "signed using.*ECDSA with SHA256" \
2449 -C "signed using.*ECDSA with SHA1"
2450
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002451# tests for SNI
2452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002453run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002454 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002455 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002456 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002457 0 \
2458 -S "parse ServerName extension" \
2459 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2460 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002462run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002463 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002464 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002465 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 +02002466 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002467 0 \
2468 -s "parse ServerName extension" \
2469 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2470 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002472run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002473 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002474 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002475 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 +02002476 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002477 0 \
2478 -s "parse ServerName extension" \
2479 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2480 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002482run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002483 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002484 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002485 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 +02002486 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002487 1 \
2488 -s "parse ServerName extension" \
2489 -s "ssl_sni_wrapper() returned" \
2490 -s "mbedtls_ssl_handshake returned" \
2491 -c "mbedtls_ssl_handshake returned" \
2492 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002493
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002494run_test "SNI: client auth no override: optional" \
2495 "$P_SRV debug_level=3 auth_mode=optional \
2496 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2497 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2498 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002499 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002500 -S "skip write certificate request" \
2501 -C "skip parse certificate request" \
2502 -c "got a certificate request" \
2503 -C "skip write certificate" \
2504 -C "skip write certificate verify" \
2505 -S "skip parse certificate verify"
2506
2507run_test "SNI: client auth override: none -> optional" \
2508 "$P_SRV debug_level=3 auth_mode=none \
2509 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2510 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2511 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002512 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002513 -S "skip write certificate request" \
2514 -C "skip parse certificate request" \
2515 -c "got a certificate request" \
2516 -C "skip write certificate" \
2517 -C "skip write certificate verify" \
2518 -S "skip parse certificate verify"
2519
2520run_test "SNI: client auth override: optional -> none" \
2521 "$P_SRV debug_level=3 auth_mode=optional \
2522 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2523 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2524 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002525 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002526 -s "skip write certificate request" \
2527 -C "skip parse certificate request" \
2528 -c "got no certificate request" \
2529 -c "skip write certificate" \
2530 -c "skip write certificate verify" \
2531 -s "skip parse certificate verify"
2532
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002533run_test "SNI: CA no override" \
2534 "$P_SRV debug_level=3 auth_mode=optional \
2535 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2536 ca_file=data_files/test-ca.crt \
2537 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2538 "$P_CLI debug_level=3 server_name=localhost \
2539 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2540 1 \
2541 -S "skip write certificate request" \
2542 -C "skip parse certificate request" \
2543 -c "got a certificate request" \
2544 -C "skip write certificate" \
2545 -C "skip write certificate verify" \
2546 -S "skip parse certificate verify" \
2547 -s "x509_verify_cert() returned" \
2548 -s "! The certificate is not correctly signed by the trusted CA" \
2549 -S "The certificate has been revoked (is on a CRL)"
2550
2551run_test "SNI: CA override" \
2552 "$P_SRV debug_level=3 auth_mode=optional \
2553 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2554 ca_file=data_files/test-ca.crt \
2555 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2556 "$P_CLI debug_level=3 server_name=localhost \
2557 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2558 0 \
2559 -S "skip write certificate request" \
2560 -C "skip parse certificate request" \
2561 -c "got a certificate request" \
2562 -C "skip write certificate" \
2563 -C "skip write certificate verify" \
2564 -S "skip parse certificate verify" \
2565 -S "x509_verify_cert() returned" \
2566 -S "! The certificate is not correctly signed by the trusted CA" \
2567 -S "The certificate has been revoked (is on a CRL)"
2568
2569run_test "SNI: CA override with CRL" \
2570 "$P_SRV debug_level=3 auth_mode=optional \
2571 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2572 ca_file=data_files/test-ca.crt \
2573 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2574 "$P_CLI debug_level=3 server_name=localhost \
2575 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2576 1 \
2577 -S "skip write certificate request" \
2578 -C "skip parse certificate request" \
2579 -c "got a certificate request" \
2580 -C "skip write certificate" \
2581 -C "skip write certificate verify" \
2582 -S "skip parse certificate verify" \
2583 -s "x509_verify_cert() returned" \
2584 -S "! The certificate is not correctly signed by the trusted CA" \
2585 -s "The certificate has been revoked (is on a CRL)"
2586
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002587# Tests for non-blocking I/O: exercise a variety of handshake flows
2588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002589run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002590 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2591 "$P_CLI nbio=2 tickets=0" \
2592 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002593 -S "mbedtls_ssl_handshake returned" \
2594 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002595 -c "Read from server: .* bytes read"
2596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002597run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002598 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2599 "$P_CLI nbio=2 tickets=0" \
2600 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002601 -S "mbedtls_ssl_handshake returned" \
2602 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002603 -c "Read from server: .* bytes read"
2604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002605run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002606 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2607 "$P_CLI nbio=2 tickets=1" \
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é-Gonnard0b6609b2014-02-26 14:45:12 +01002611 -c "Read from server: .* bytes read"
2612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002613run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002614 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2615 "$P_CLI nbio=2 tickets=1" \
2616 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002617 -S "mbedtls_ssl_handshake returned" \
2618 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002619 -c "Read from server: .* bytes read"
2620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002621run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002622 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2623 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2624 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002625 -S "mbedtls_ssl_handshake returned" \
2626 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002627 -c "Read from server: .* bytes read"
2628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002629run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002630 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2631 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2632 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002633 -S "mbedtls_ssl_handshake returned" \
2634 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002635 -c "Read from server: .* bytes read"
2636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002637run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002638 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2639 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2640 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002641 -S "mbedtls_ssl_handshake returned" \
2642 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002643 -c "Read from server: .* bytes read"
2644
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002645# Tests for version negotiation
2646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002647run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002648 "$P_SRV" \
2649 "$P_CLI" \
2650 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002651 -S "mbedtls_ssl_handshake returned" \
2652 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002653 -s "Protocol is TLSv1.2" \
2654 -c "Protocol is TLSv1.2"
2655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002656run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002657 "$P_SRV" \
2658 "$P_CLI max_version=tls1_1" \
2659 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002660 -S "mbedtls_ssl_handshake returned" \
2661 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002662 -s "Protocol is TLSv1.1" \
2663 -c "Protocol is TLSv1.1"
2664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002665run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002666 "$P_SRV max_version=tls1_1" \
2667 "$P_CLI" \
2668 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002669 -S "mbedtls_ssl_handshake returned" \
2670 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002671 -s "Protocol is TLSv1.1" \
2672 -c "Protocol is TLSv1.1"
2673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002674run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002675 "$P_SRV max_version=tls1_1" \
2676 "$P_CLI max_version=tls1_1" \
2677 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002678 -S "mbedtls_ssl_handshake returned" \
2679 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002680 -s "Protocol is TLSv1.1" \
2681 -c "Protocol is TLSv1.1"
2682
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002683run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002684 "$P_SRV min_version=tls1_1" \
2685 "$P_CLI max_version=tls1_1" \
2686 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002687 -S "mbedtls_ssl_handshake returned" \
2688 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002689 -s "Protocol is TLSv1.1" \
2690 -c "Protocol is TLSv1.1"
2691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002692run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002693 "$P_SRV max_version=tls1_1" \
2694 "$P_CLI min_version=tls1_1" \
2695 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002696 -S "mbedtls_ssl_handshake returned" \
2697 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002698 -s "Protocol is TLSv1.1" \
2699 -c "Protocol is TLSv1.1"
2700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002701run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002702 "$P_SRV max_version=tls1_1" \
2703 "$P_CLI min_version=tls1_2" \
2704 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002705 -s "mbedtls_ssl_handshake returned" \
2706 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002707 -c "SSL - Handshake protocol not within min/max boundaries"
2708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002709run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002710 "$P_SRV min_version=tls1_2" \
2711 "$P_CLI max_version=tls1_1" \
2712 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002713 -s "mbedtls_ssl_handshake returned" \
2714 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002715 -s "SSL - Handshake protocol not within min/max boundaries"
2716
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002717# Tests for ALPN extension
2718
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002719run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002720 "$P_SRV debug_level=3" \
2721 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002722 0 \
2723 -C "client hello, adding alpn extension" \
2724 -S "found alpn extension" \
2725 -C "got an alert message, type: \\[2:120]" \
2726 -S "server hello, adding alpn extension" \
2727 -C "found alpn extension " \
2728 -C "Application Layer Protocol is" \
2729 -S "Application Layer Protocol is"
2730
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002731run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002732 "$P_SRV debug_level=3" \
2733 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002734 0 \
2735 -c "client hello, adding alpn extension" \
2736 -s "found alpn extension" \
2737 -C "got an alert message, type: \\[2:120]" \
2738 -S "server hello, adding alpn extension" \
2739 -C "found alpn extension " \
2740 -c "Application Layer Protocol is (none)" \
2741 -S "Application Layer Protocol is"
2742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002743run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002744 "$P_SRV debug_level=3 alpn=abc,1234" \
2745 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002746 0 \
2747 -C "client hello, adding alpn extension" \
2748 -S "found alpn extension" \
2749 -C "got an alert message, type: \\[2:120]" \
2750 -S "server hello, adding alpn extension" \
2751 -C "found alpn extension " \
2752 -C "Application Layer Protocol is" \
2753 -s "Application Layer Protocol is (none)"
2754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002755run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002756 "$P_SRV debug_level=3 alpn=abc,1234" \
2757 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002758 0 \
2759 -c "client hello, adding alpn extension" \
2760 -s "found alpn extension" \
2761 -C "got an alert message, type: \\[2:120]" \
2762 -s "server hello, adding alpn extension" \
2763 -c "found alpn extension" \
2764 -c "Application Layer Protocol is abc" \
2765 -s "Application Layer Protocol is abc"
2766
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002767run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002768 "$P_SRV debug_level=3 alpn=abc,1234" \
2769 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002770 0 \
2771 -c "client hello, adding alpn extension" \
2772 -s "found alpn extension" \
2773 -C "got an alert message, type: \\[2:120]" \
2774 -s "server hello, adding alpn extension" \
2775 -c "found alpn extension" \
2776 -c "Application Layer Protocol is abc" \
2777 -s "Application Layer Protocol is abc"
2778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002779run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002780 "$P_SRV debug_level=3 alpn=abc,1234" \
2781 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002782 0 \
2783 -c "client hello, adding alpn extension" \
2784 -s "found alpn extension" \
2785 -C "got an alert message, type: \\[2:120]" \
2786 -s "server hello, adding alpn extension" \
2787 -c "found alpn extension" \
2788 -c "Application Layer Protocol is 1234" \
2789 -s "Application Layer Protocol is 1234"
2790
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002791run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002792 "$P_SRV debug_level=3 alpn=abc,123" \
2793 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002794 1 \
2795 -c "client hello, adding alpn extension" \
2796 -s "found alpn extension" \
2797 -c "got an alert message, type: \\[2:120]" \
2798 -S "server hello, adding alpn extension" \
2799 -C "found alpn extension" \
2800 -C "Application Layer Protocol is 1234" \
2801 -S "Application Layer Protocol is 1234"
2802
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002803
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002804# Tests for keyUsage in leaf certificates, part 1:
2805# server-side certificate/suite selection
2806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002807run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002808 "$P_SRV key_file=data_files/server2.key \
2809 crt_file=data_files/server2.ku-ds.crt" \
2810 "$P_CLI" \
2811 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002812 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002813
2814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002815run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002816 "$P_SRV key_file=data_files/server2.key \
2817 crt_file=data_files/server2.ku-ke.crt" \
2818 "$P_CLI" \
2819 0 \
2820 -c "Ciphersuite is TLS-RSA-WITH-"
2821
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002822run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002823 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002824 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002825 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002826 1 \
2827 -C "Ciphersuite is "
2828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002829run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002830 "$P_SRV key_file=data_files/server5.key \
2831 crt_file=data_files/server5.ku-ds.crt" \
2832 "$P_CLI" \
2833 0 \
2834 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2835
2836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002837run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002838 "$P_SRV key_file=data_files/server5.key \
2839 crt_file=data_files/server5.ku-ka.crt" \
2840 "$P_CLI" \
2841 0 \
2842 -c "Ciphersuite is TLS-ECDH-"
2843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002844run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002845 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002846 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002847 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002848 1 \
2849 -C "Ciphersuite is "
2850
2851# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002852# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002854run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002855 "$O_SRV -key data_files/server2.key \
2856 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002857 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002858 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2859 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002860 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002861 -C "Processing of the Certificate handshake message failed" \
2862 -c "Ciphersuite is TLS-"
2863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002864run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002865 "$O_SRV -key data_files/server2.key \
2866 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002867 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002868 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2869 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002870 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002871 -C "Processing of the Certificate handshake message failed" \
2872 -c "Ciphersuite is TLS-"
2873
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002874run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002875 "$O_SRV -key data_files/server2.key \
2876 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002877 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002878 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2879 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002880 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002881 -C "Processing of the Certificate handshake message failed" \
2882 -c "Ciphersuite is TLS-"
2883
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002884run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002885 "$O_SRV -key data_files/server2.key \
2886 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002887 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002888 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2889 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002890 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002891 -c "Processing of the Certificate handshake message failed" \
2892 -C "Ciphersuite is TLS-"
2893
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002894run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2895 "$O_SRV -key data_files/server2.key \
2896 -cert data_files/server2.ku-ke.crt" \
2897 "$P_CLI debug_level=1 auth_mode=optional \
2898 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2899 0 \
2900 -c "bad certificate (usage extensions)" \
2901 -C "Processing of the Certificate handshake message failed" \
2902 -c "Ciphersuite is TLS-" \
2903 -c "! Usage does not match the keyUsage extension"
2904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002905run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002906 "$O_SRV -key data_files/server2.key \
2907 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002908 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002909 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2910 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002911 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002912 -C "Processing of the Certificate handshake message failed" \
2913 -c "Ciphersuite is TLS-"
2914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002915run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002916 "$O_SRV -key data_files/server2.key \
2917 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002918 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002919 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2920 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002921 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002922 -c "Processing of the Certificate handshake message failed" \
2923 -C "Ciphersuite is TLS-"
2924
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002925run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2926 "$O_SRV -key data_files/server2.key \
2927 -cert data_files/server2.ku-ds.crt" \
2928 "$P_CLI debug_level=1 auth_mode=optional \
2929 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2930 0 \
2931 -c "bad certificate (usage extensions)" \
2932 -C "Processing of the Certificate handshake message failed" \
2933 -c "Ciphersuite is TLS-" \
2934 -c "! Usage does not match the keyUsage extension"
2935
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002936# Tests for keyUsage in leaf certificates, part 3:
2937# server-side checking of client cert
2938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002939run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002940 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002941 "$O_CLI -key data_files/server2.key \
2942 -cert data_files/server2.ku-ds.crt" \
2943 0 \
2944 -S "bad certificate (usage extensions)" \
2945 -S "Processing of the Certificate handshake message failed"
2946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002947run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002948 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002949 "$O_CLI -key data_files/server2.key \
2950 -cert data_files/server2.ku-ke.crt" \
2951 0 \
2952 -s "bad certificate (usage extensions)" \
2953 -S "Processing of the Certificate handshake message failed"
2954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002955run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002956 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002957 "$O_CLI -key data_files/server2.key \
2958 -cert data_files/server2.ku-ke.crt" \
2959 1 \
2960 -s "bad certificate (usage extensions)" \
2961 -s "Processing of the Certificate handshake message failed"
2962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002963run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002964 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002965 "$O_CLI -key data_files/server5.key \
2966 -cert data_files/server5.ku-ds.crt" \
2967 0 \
2968 -S "bad certificate (usage extensions)" \
2969 -S "Processing of the Certificate handshake message failed"
2970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002971run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002972 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002973 "$O_CLI -key data_files/server5.key \
2974 -cert data_files/server5.ku-ka.crt" \
2975 0 \
2976 -s "bad certificate (usage extensions)" \
2977 -S "Processing of the Certificate handshake message failed"
2978
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002979# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002981run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002982 "$P_SRV key_file=data_files/server5.key \
2983 crt_file=data_files/server5.eku-srv.crt" \
2984 "$P_CLI" \
2985 0
2986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002987run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002988 "$P_SRV key_file=data_files/server5.key \
2989 crt_file=data_files/server5.eku-srv.crt" \
2990 "$P_CLI" \
2991 0
2992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002993run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002994 "$P_SRV key_file=data_files/server5.key \
2995 crt_file=data_files/server5.eku-cs_any.crt" \
2996 "$P_CLI" \
2997 0
2998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002999run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003000 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003001 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003002 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003003 1
3004
3005# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003007run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003008 "$O_SRV -key data_files/server5.key \
3009 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003010 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003011 0 \
3012 -C "bad certificate (usage extensions)" \
3013 -C "Processing of the Certificate handshake message failed" \
3014 -c "Ciphersuite is TLS-"
3015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003016run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003017 "$O_SRV -key data_files/server5.key \
3018 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003019 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003020 0 \
3021 -C "bad certificate (usage extensions)" \
3022 -C "Processing of the Certificate handshake message failed" \
3023 -c "Ciphersuite is TLS-"
3024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003025run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003026 "$O_SRV -key data_files/server5.key \
3027 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003028 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003029 0 \
3030 -C "bad certificate (usage extensions)" \
3031 -C "Processing of the Certificate handshake message failed" \
3032 -c "Ciphersuite is TLS-"
3033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003034run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003035 "$O_SRV -key data_files/server5.key \
3036 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003037 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003038 1 \
3039 -c "bad certificate (usage extensions)" \
3040 -c "Processing of the Certificate handshake message failed" \
3041 -C "Ciphersuite is TLS-"
3042
3043# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003045run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003046 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003047 "$O_CLI -key data_files/server5.key \
3048 -cert data_files/server5.eku-cli.crt" \
3049 0 \
3050 -S "bad certificate (usage extensions)" \
3051 -S "Processing of the Certificate handshake message failed"
3052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003053run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003054 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003055 "$O_CLI -key data_files/server5.key \
3056 -cert data_files/server5.eku-srv_cli.crt" \
3057 0 \
3058 -S "bad certificate (usage extensions)" \
3059 -S "Processing of the Certificate handshake message failed"
3060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003061run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003062 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003063 "$O_CLI -key data_files/server5.key \
3064 -cert data_files/server5.eku-cs_any.crt" \
3065 0 \
3066 -S "bad certificate (usage extensions)" \
3067 -S "Processing of the Certificate handshake message failed"
3068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003069run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003070 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003071 "$O_CLI -key data_files/server5.key \
3072 -cert data_files/server5.eku-cs.crt" \
3073 0 \
3074 -s "bad certificate (usage extensions)" \
3075 -S "Processing of the Certificate handshake message failed"
3076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003077run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003078 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003079 "$O_CLI -key data_files/server5.key \
3080 -cert data_files/server5.eku-cs.crt" \
3081 1 \
3082 -s "bad certificate (usage extensions)" \
3083 -s "Processing of the Certificate handshake message failed"
3084
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003085# Tests for DHM parameters loading
3086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003087run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003088 "$P_SRV" \
3089 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3090 debug_level=3" \
3091 0 \
3092 -c "value of 'DHM: P ' (2048 bits)" \
3093 -c "value of 'DHM: G ' (2048 bits)"
3094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003095run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003096 "$P_SRV dhm_file=data_files/dhparams.pem" \
3097 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3098 debug_level=3" \
3099 0 \
3100 -c "value of 'DHM: P ' (1024 bits)" \
3101 -c "value of 'DHM: G ' (2 bits)"
3102
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003103# Tests for DHM client-side size checking
3104
3105run_test "DHM size: server default, client default, OK" \
3106 "$P_SRV" \
3107 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3108 debug_level=1" \
3109 0 \
3110 -C "DHM prime too short:"
3111
3112run_test "DHM size: server default, client 2048, OK" \
3113 "$P_SRV" \
3114 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3115 debug_level=1 dhmlen=2048" \
3116 0 \
3117 -C "DHM prime too short:"
3118
3119run_test "DHM size: server 1024, client default, OK" \
3120 "$P_SRV dhm_file=data_files/dhparams.pem" \
3121 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3122 debug_level=1" \
3123 0 \
3124 -C "DHM prime too short:"
3125
3126run_test "DHM size: server 1000, client default, rejected" \
3127 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3128 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3129 debug_level=1" \
3130 1 \
3131 -c "DHM prime too short:"
3132
3133run_test "DHM size: server default, client 2049, rejected" \
3134 "$P_SRV" \
3135 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3136 debug_level=1 dhmlen=2049" \
3137 1 \
3138 -c "DHM prime too short:"
3139
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003140# Tests for PSK callback
3141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003142run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003143 "$P_SRV psk=abc123 psk_identity=foo" \
3144 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3145 psk_identity=foo psk=abc123" \
3146 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003147 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003148 -S "SSL - Unknown identity received" \
3149 -S "SSL - Verification of the message MAC failed"
3150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003151run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003152 "$P_SRV" \
3153 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3154 psk_identity=foo psk=abc123" \
3155 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003156 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003157 -S "SSL - Unknown identity received" \
3158 -S "SSL - Verification of the message MAC failed"
3159
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003160run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003161 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3162 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3163 psk_identity=foo psk=abc123" \
3164 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003165 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003166 -s "SSL - Unknown identity received" \
3167 -S "SSL - Verification of the message MAC failed"
3168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003169run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003170 "$P_SRV psk_list=abc,dead,def,beef" \
3171 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3172 psk_identity=abc psk=dead" \
3173 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003174 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003175 -S "SSL - Unknown identity received" \
3176 -S "SSL - Verification of the message MAC failed"
3177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003178run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003179 "$P_SRV psk_list=abc,dead,def,beef" \
3180 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3181 psk_identity=def psk=beef" \
3182 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003183 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003184 -S "SSL - Unknown identity received" \
3185 -S "SSL - Verification of the message MAC failed"
3186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003187run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003188 "$P_SRV psk_list=abc,dead,def,beef" \
3189 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3190 psk_identity=ghi psk=beef" \
3191 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003192 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003193 -s "SSL - Unknown identity received" \
3194 -S "SSL - Verification of the message MAC failed"
3195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003196run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003197 "$P_SRV psk_list=abc,dead,def,beef" \
3198 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3199 psk_identity=abc psk=beef" \
3200 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003201 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003202 -S "SSL - Unknown identity received" \
3203 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003204
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003205# Tests for EC J-PAKE
3206
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003207requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003208run_test "ECJPAKE: client not configured" \
3209 "$P_SRV debug_level=3" \
3210 "$P_CLI debug_level=3" \
3211 0 \
3212 -C "add ciphersuite: c0ff" \
3213 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003214 -S "found ecjpake kkpp extension" \
3215 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003216 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003217 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003218 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003219 -S "None of the common ciphersuites is usable"
3220
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003221requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003222run_test "ECJPAKE: server not configured" \
3223 "$P_SRV debug_level=3" \
3224 "$P_CLI debug_level=3 ecjpake_pw=bla \
3225 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3226 1 \
3227 -c "add ciphersuite: c0ff" \
3228 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003229 -s "found ecjpake kkpp extension" \
3230 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003231 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003232 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003233 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003234 -s "None of the common ciphersuites is usable"
3235
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003236requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003237run_test "ECJPAKE: working, TLS" \
3238 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3239 "$P_CLI debug_level=3 ecjpake_pw=bla \
3240 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003241 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003242 -c "add ciphersuite: c0ff" \
3243 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003244 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003245 -s "found ecjpake kkpp extension" \
3246 -S "skip ecjpake kkpp extension" \
3247 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003248 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003249 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003250 -S "None of the common ciphersuites is usable" \
3251 -S "SSL - Verification of the message MAC failed"
3252
Janos Follath74537a62016-09-02 13:45:28 +01003253server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003254requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003255run_test "ECJPAKE: password mismatch, TLS" \
3256 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3257 "$P_CLI debug_level=3 ecjpake_pw=bad \
3258 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3259 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003260 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003261 -s "SSL - Verification of the message MAC failed"
3262
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003263requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003264run_test "ECJPAKE: working, DTLS" \
3265 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3266 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3267 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3268 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003269 -c "re-using cached ecjpake parameters" \
3270 -S "SSL - Verification of the message MAC failed"
3271
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003272requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003273run_test "ECJPAKE: working, DTLS, no cookie" \
3274 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3275 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3276 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3277 0 \
3278 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003279 -S "SSL - Verification of the message MAC failed"
3280
Janos Follath74537a62016-09-02 13:45:28 +01003281server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003282requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003283run_test "ECJPAKE: password mismatch, DTLS" \
3284 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3285 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3286 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3287 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003288 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003289 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003290
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003291# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003292requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003293run_test "ECJPAKE: working, DTLS, nolog" \
3294 "$P_SRV dtls=1 ecjpake_pw=bla" \
3295 "$P_CLI dtls=1 ecjpake_pw=bla \
3296 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3297 0
3298
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003299# Tests for ciphersuites per version
3300
Janos Follathe2681a42016-03-07 15:57:05 +00003301requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003302run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003303 "$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 +02003304 "$P_CLI force_version=ssl3" \
3305 0 \
3306 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003308run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003309 "$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 +01003310 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003311 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003312 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003314run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003315 "$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 +02003316 "$P_CLI force_version=tls1_1" \
3317 0 \
3318 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003320run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003321 "$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 +02003322 "$P_CLI force_version=tls1_2" \
3323 0 \
3324 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3325
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003326# Test for ClientHello without extensions
3327
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003328requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003329run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003330 "$P_SRV debug_level=3" \
3331 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3332 0 \
3333 -s "dumping 'client hello extensions' (0 bytes)"
3334
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003335requires_gnutls
3336run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3337 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3338 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3339 0 \
3340 -s "dumping 'client hello extensions' (0 bytes)"
3341
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003342# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003343
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003344run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003345 "$P_SRV" \
3346 "$P_CLI request_size=100" \
3347 0 \
3348 -s "Read from client: 100 bytes read$"
3349
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003350run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003351 "$P_SRV" \
3352 "$P_CLI request_size=500" \
3353 0 \
3354 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003355
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003356# Tests for small packets
3357
Janos Follathe2681a42016-03-07 15:57:05 +00003358requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003359run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003360 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003361 "$P_CLI request_size=1 force_version=ssl3 \
3362 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3363 0 \
3364 -s "Read from client: 1 bytes read"
3365
Janos Follathe2681a42016-03-07 15:57:05 +00003366requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003367run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003368 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003369 "$P_CLI request_size=1 force_version=ssl3 \
3370 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3371 0 \
3372 -s "Read from client: 1 bytes read"
3373
3374run_test "Small packet TLS 1.0 BlockCipher" \
3375 "$P_SRV" \
3376 "$P_CLI request_size=1 force_version=tls1 \
3377 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3378 0 \
3379 -s "Read from client: 1 bytes read"
3380
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003381run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3382 "$P_SRV" \
3383 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3384 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3385 0 \
3386 -s "Read from client: 1 bytes read"
3387
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003388run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3389 "$P_SRV" \
3390 "$P_CLI request_size=1 force_version=tls1 \
3391 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3392 trunc_hmac=1" \
3393 0 \
3394 -s "Read from client: 1 bytes read"
3395
3396run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003397 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003398 "$P_CLI request_size=1 force_version=tls1 \
3399 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3400 trunc_hmac=1" \
3401 0 \
3402 -s "Read from client: 1 bytes read"
3403
3404run_test "Small packet TLS 1.1 BlockCipher" \
3405 "$P_SRV" \
3406 "$P_CLI request_size=1 force_version=tls1_1 \
3407 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3408 0 \
3409 -s "Read from client: 1 bytes read"
3410
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003411run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3412 "$P_SRV" \
3413 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3414 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3415 0 \
3416 -s "Read from client: 1 bytes read"
3417
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003418run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003419 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003420 "$P_CLI request_size=1 force_version=tls1_1 \
3421 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3422 0 \
3423 -s "Read from client: 1 bytes read"
3424
3425run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3426 "$P_SRV" \
3427 "$P_CLI request_size=1 force_version=tls1_1 \
3428 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3429 trunc_hmac=1" \
3430 0 \
3431 -s "Read from client: 1 bytes read"
3432
3433run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003434 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003435 "$P_CLI request_size=1 force_version=tls1_1 \
3436 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3437 trunc_hmac=1" \
3438 0 \
3439 -s "Read from client: 1 bytes read"
3440
3441run_test "Small packet TLS 1.2 BlockCipher" \
3442 "$P_SRV" \
3443 "$P_CLI request_size=1 force_version=tls1_2 \
3444 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3445 0 \
3446 -s "Read from client: 1 bytes read"
3447
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003448run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3449 "$P_SRV" \
3450 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3451 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3452 0 \
3453 -s "Read from client: 1 bytes read"
3454
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003455run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3456 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003457 "$P_CLI request_size=1 force_version=tls1_2 \
3458 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003459 0 \
3460 -s "Read from client: 1 bytes read"
3461
3462run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3463 "$P_SRV" \
3464 "$P_CLI request_size=1 force_version=tls1_2 \
3465 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3466 trunc_hmac=1" \
3467 0 \
3468 -s "Read from client: 1 bytes read"
3469
3470run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003471 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003472 "$P_CLI request_size=1 force_version=tls1_2 \
3473 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3474 0 \
3475 -s "Read from client: 1 bytes read"
3476
3477run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003478 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003479 "$P_CLI request_size=1 force_version=tls1_2 \
3480 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3481 trunc_hmac=1" \
3482 0 \
3483 -s "Read from client: 1 bytes read"
3484
3485run_test "Small packet TLS 1.2 AEAD" \
3486 "$P_SRV" \
3487 "$P_CLI request_size=1 force_version=tls1_2 \
3488 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3489 0 \
3490 -s "Read from client: 1 bytes read"
3491
3492run_test "Small packet TLS 1.2 AEAD shorter tag" \
3493 "$P_SRV" \
3494 "$P_CLI request_size=1 force_version=tls1_2 \
3495 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3496 0 \
3497 -s "Read from client: 1 bytes read"
3498
Janos Follath00efff72016-05-06 13:48:23 +01003499# A test for extensions in SSLv3
3500
3501requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3502run_test "SSLv3 with extensions, server side" \
3503 "$P_SRV min_version=ssl3 debug_level=3" \
3504 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3505 0 \
3506 -S "dumping 'client hello extensions'" \
3507 -S "server hello, total extension length:"
3508
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003509# Test for large packets
3510
Janos Follathe2681a42016-03-07 15:57:05 +00003511requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003512run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003513 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003514 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003515 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3516 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003517 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003518 -s "Read from client: 16384 bytes read"
3519
Janos Follathe2681a42016-03-07 15:57:05 +00003520requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003521run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003522 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003523 "$P_CLI request_size=16384 force_version=ssl3 \
3524 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3525 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003526 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003527 -s "Read from client: 16384 bytes read"
3528
3529run_test "Large packet TLS 1.0 BlockCipher" \
3530 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003531 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003532 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3533 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003534 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003535 -s "Read from client: 16384 bytes read"
3536
3537run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3538 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003539 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003540 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3541 trunc_hmac=1" \
3542 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003543 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003544 -s "Read from client: 16384 bytes read"
3545
3546run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003547 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003548 "$P_CLI request_size=16384 force_version=tls1 \
3549 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3550 trunc_hmac=1" \
3551 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003552 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003553 -s "Read from client: 16384 bytes read"
3554
3555run_test "Large packet TLS 1.1 BlockCipher" \
3556 "$P_SRV" \
3557 "$P_CLI request_size=16384 force_version=tls1_1 \
3558 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3559 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003560 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003561 -s "Read from client: 16384 bytes read"
3562
3563run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003564 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003565 "$P_CLI request_size=16384 force_version=tls1_1 \
3566 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3567 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003568 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003569 -s "Read from client: 16384 bytes read"
3570
3571run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3572 "$P_SRV" \
3573 "$P_CLI request_size=16384 force_version=tls1_1 \
3574 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3575 trunc_hmac=1" \
3576 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003577 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003578 -s "Read from client: 16384 bytes read"
3579
3580run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003581 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003582 "$P_CLI request_size=16384 force_version=tls1_1 \
3583 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3584 trunc_hmac=1" \
3585 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003586 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003587 -s "Read from client: 16384 bytes read"
3588
3589run_test "Large packet TLS 1.2 BlockCipher" \
3590 "$P_SRV" \
3591 "$P_CLI request_size=16384 force_version=tls1_2 \
3592 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3593 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003594 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003595 -s "Read from client: 16384 bytes read"
3596
3597run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3598 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003599 "$P_CLI request_size=16384 force_version=tls1_2 \
3600 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003601 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003602 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003603 -s "Read from client: 16384 bytes read"
3604
3605run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3606 "$P_SRV" \
3607 "$P_CLI request_size=16384 force_version=tls1_2 \
3608 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3609 trunc_hmac=1" \
3610 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003611 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003612 -s "Read from client: 16384 bytes read"
3613
3614run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003615 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003616 "$P_CLI request_size=16384 force_version=tls1_2 \
3617 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3618 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003619 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003620 -s "Read from client: 16384 bytes read"
3621
3622run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003623 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003624 "$P_CLI request_size=16384 force_version=tls1_2 \
3625 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3626 trunc_hmac=1" \
3627 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003628 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003629 -s "Read from client: 16384 bytes read"
3630
3631run_test "Large packet TLS 1.2 AEAD" \
3632 "$P_SRV" \
3633 "$P_CLI request_size=16384 force_version=tls1_2 \
3634 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3635 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003636 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003637 -s "Read from client: 16384 bytes read"
3638
3639run_test "Large packet TLS 1.2 AEAD shorter tag" \
3640 "$P_SRV" \
3641 "$P_CLI request_size=16384 force_version=tls1_2 \
3642 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3643 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003644 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003645 -s "Read from client: 16384 bytes read"
3646
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003647# Tests for DTLS HelloVerifyRequest
3648
3649run_test "DTLS cookie: enabled" \
3650 "$P_SRV dtls=1 debug_level=2" \
3651 "$P_CLI dtls=1 debug_level=2" \
3652 0 \
3653 -s "cookie verification failed" \
3654 -s "cookie verification passed" \
3655 -S "cookie verification skipped" \
3656 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003657 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003658 -S "SSL - The requested feature is not available"
3659
3660run_test "DTLS cookie: disabled" \
3661 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3662 "$P_CLI dtls=1 debug_level=2" \
3663 0 \
3664 -S "cookie verification failed" \
3665 -S "cookie verification passed" \
3666 -s "cookie verification skipped" \
3667 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003668 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003669 -S "SSL - The requested feature is not available"
3670
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003671run_test "DTLS cookie: default (failing)" \
3672 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3673 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3674 1 \
3675 -s "cookie verification failed" \
3676 -S "cookie verification passed" \
3677 -S "cookie verification skipped" \
3678 -C "received hello verify request" \
3679 -S "hello verification requested" \
3680 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003681
3682requires_ipv6
3683run_test "DTLS cookie: enabled, IPv6" \
3684 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3685 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3686 0 \
3687 -s "cookie verification failed" \
3688 -s "cookie verification passed" \
3689 -S "cookie verification skipped" \
3690 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003691 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003692 -S "SSL - The requested feature is not available"
3693
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003694run_test "DTLS cookie: enabled, nbio" \
3695 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3696 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3697 0 \
3698 -s "cookie verification failed" \
3699 -s "cookie verification passed" \
3700 -S "cookie verification skipped" \
3701 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003702 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003703 -S "SSL - The requested feature is not available"
3704
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003705# Tests for client reconnecting from the same port with DTLS
3706
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003707not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003708run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003709 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3710 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003711 0 \
3712 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003713 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003714 -S "Client initiated reconnection from same port"
3715
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003716not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003717run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003718 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3719 "$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 +02003720 0 \
3721 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003722 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003723 -s "Client initiated reconnection from same port"
3724
Paul Bakker362689d2016-05-13 10:33:25 +01003725not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3726run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003727 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3728 "$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 +02003729 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003730 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003731 -s "Client initiated reconnection from same port"
3732
Paul Bakker362689d2016-05-13 10:33:25 +01003733only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3734run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3735 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3736 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3737 0 \
3738 -S "The operation timed out" \
3739 -s "Client initiated reconnection from same port"
3740
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003741run_test "DTLS client reconnect from same port: no cookies" \
3742 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003743 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3744 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003745 -s "The operation timed out" \
3746 -S "Client initiated reconnection from same port"
3747
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003748# Tests for various cases of client authentication with DTLS
3749# (focused on handshake flows and message parsing)
3750
3751run_test "DTLS client auth: required" \
3752 "$P_SRV dtls=1 auth_mode=required" \
3753 "$P_CLI dtls=1" \
3754 0 \
3755 -s "Verifying peer X.509 certificate... ok"
3756
3757run_test "DTLS client auth: optional, client has no cert" \
3758 "$P_SRV dtls=1 auth_mode=optional" \
3759 "$P_CLI dtls=1 crt_file=none key_file=none" \
3760 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003761 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003762
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003763run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003764 "$P_SRV dtls=1 auth_mode=none" \
3765 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3766 0 \
3767 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003768 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003769
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003770run_test "DTLS wrong PSK: badmac alert" \
3771 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3772 "$P_CLI dtls=1 psk=abc124" \
3773 1 \
3774 -s "SSL - Verification of the message MAC failed" \
3775 -c "SSL - A fatal alert message was received from our peer"
3776
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003777# Tests for receiving fragmented handshake messages with DTLS
3778
3779requires_gnutls
3780run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3781 "$G_SRV -u --mtu 2048 -a" \
3782 "$P_CLI dtls=1 debug_level=2" \
3783 0 \
3784 -C "found fragmented DTLS handshake message" \
3785 -C "error"
3786
3787requires_gnutls
3788run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3789 "$G_SRV -u --mtu 512" \
3790 "$P_CLI dtls=1 debug_level=2" \
3791 0 \
3792 -c "found fragmented DTLS handshake message" \
3793 -C "error"
3794
3795requires_gnutls
3796run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3797 "$G_SRV -u --mtu 128" \
3798 "$P_CLI dtls=1 debug_level=2" \
3799 0 \
3800 -c "found fragmented DTLS handshake message" \
3801 -C "error"
3802
3803requires_gnutls
3804run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3805 "$G_SRV -u --mtu 128" \
3806 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3807 0 \
3808 -c "found fragmented DTLS handshake message" \
3809 -C "error"
3810
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003811requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003812requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003813run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3814 "$G_SRV -u --mtu 256" \
3815 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3816 0 \
3817 -c "found fragmented DTLS handshake message" \
3818 -c "client hello, adding renegotiation extension" \
3819 -c "found renegotiation extension" \
3820 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003821 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003822 -C "error" \
3823 -s "Extra-header:"
3824
3825requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003826requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003827run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3828 "$G_SRV -u --mtu 256" \
3829 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3830 0 \
3831 -c "found fragmented DTLS handshake message" \
3832 -c "client hello, adding renegotiation extension" \
3833 -c "found renegotiation extension" \
3834 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003835 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003836 -C "error" \
3837 -s "Extra-header:"
3838
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003839run_test "DTLS reassembly: no fragmentation (openssl server)" \
3840 "$O_SRV -dtls1 -mtu 2048" \
3841 "$P_CLI dtls=1 debug_level=2" \
3842 0 \
3843 -C "found fragmented DTLS handshake message" \
3844 -C "error"
3845
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003846run_test "DTLS reassembly: some fragmentation (openssl server)" \
3847 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003848 "$P_CLI dtls=1 debug_level=2" \
3849 0 \
3850 -c "found fragmented DTLS handshake message" \
3851 -C "error"
3852
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003853run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003854 "$O_SRV -dtls1 -mtu 256" \
3855 "$P_CLI dtls=1 debug_level=2" \
3856 0 \
3857 -c "found fragmented DTLS handshake message" \
3858 -C "error"
3859
3860run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3861 "$O_SRV -dtls1 -mtu 256" \
3862 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3863 0 \
3864 -c "found fragmented DTLS handshake message" \
3865 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003866
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003867# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003868
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003869not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003870run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003871 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003872 "$P_SRV dtls=1 debug_level=2" \
3873 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003874 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003875 -C "replayed record" \
3876 -S "replayed record" \
3877 -C "record from another epoch" \
3878 -S "record from another epoch" \
3879 -C "discarding invalid record" \
3880 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003881 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003882 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003883 -c "HTTP/1.0 200 OK"
3884
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003885not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003886run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003887 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003888 "$P_SRV dtls=1 debug_level=2" \
3889 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003890 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003891 -c "replayed record" \
3892 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003893 -c "discarding invalid record" \
3894 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003895 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003896 -s "Extra-header:" \
3897 -c "HTTP/1.0 200 OK"
3898
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003899run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3900 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003901 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3902 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003903 0 \
3904 -c "replayed record" \
3905 -S "replayed record" \
3906 -c "discarding invalid record" \
3907 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003908 -c "resend" \
3909 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003910 -s "Extra-header:" \
3911 -c "HTTP/1.0 200 OK"
3912
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003913run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003914 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003915 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003916 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003917 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003918 -c "discarding invalid record (mac)" \
3919 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003920 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003921 -c "HTTP/1.0 200 OK" \
3922 -S "too many records with bad MAC" \
3923 -S "Verification of the message MAC failed"
3924
3925run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3926 -p "$P_PXY bad_ad=1" \
3927 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3928 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3929 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003930 -C "discarding invalid record (mac)" \
3931 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003932 -S "Extra-header:" \
3933 -C "HTTP/1.0 200 OK" \
3934 -s "too many records with bad MAC" \
3935 -s "Verification of the message MAC failed"
3936
3937run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3938 -p "$P_PXY bad_ad=1" \
3939 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3940 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3941 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003942 -c "discarding invalid record (mac)" \
3943 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003944 -s "Extra-header:" \
3945 -c "HTTP/1.0 200 OK" \
3946 -S "too many records with bad MAC" \
3947 -S "Verification of the message MAC failed"
3948
3949run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3950 -p "$P_PXY bad_ad=1" \
3951 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3952 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3953 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003954 -c "discarding invalid record (mac)" \
3955 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003956 -s "Extra-header:" \
3957 -c "HTTP/1.0 200 OK" \
3958 -s "too many records with bad MAC" \
3959 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003960
3961run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003962 -p "$P_PXY delay_ccs=1" \
3963 "$P_SRV dtls=1 debug_level=1" \
3964 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003965 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003966 -c "record from another epoch" \
3967 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003968 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003969 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003970 -s "Extra-header:" \
3971 -c "HTTP/1.0 200 OK"
3972
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003973# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003974
Janos Follath74537a62016-09-02 13:45:28 +01003975client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003976run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003977 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003978 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3979 psk=abc123" \
3980 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003981 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3982 0 \
3983 -s "Extra-header:" \
3984 -c "HTTP/1.0 200 OK"
3985
Janos Follath74537a62016-09-02 13:45:28 +01003986client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003987run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3988 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003989 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3990 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003991 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3992 0 \
3993 -s "Extra-header:" \
3994 -c "HTTP/1.0 200 OK"
3995
Janos Follath74537a62016-09-02 13:45:28 +01003996client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003997run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3998 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003999 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4000 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004001 0 \
4002 -s "Extra-header:" \
4003 -c "HTTP/1.0 200 OK"
4004
Janos Follath74537a62016-09-02 13:45:28 +01004005client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004006run_test "DTLS proxy: 3d, FS, client auth" \
4007 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004008 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4009 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004010 0 \
4011 -s "Extra-header:" \
4012 -c "HTTP/1.0 200 OK"
4013
Janos Follath74537a62016-09-02 13:45:28 +01004014client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004015run_test "DTLS proxy: 3d, FS, ticket" \
4016 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004017 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4018 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004019 0 \
4020 -s "Extra-header:" \
4021 -c "HTTP/1.0 200 OK"
4022
Janos Follath74537a62016-09-02 13:45:28 +01004023client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004024run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4025 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004026 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4027 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004028 0 \
4029 -s "Extra-header:" \
4030 -c "HTTP/1.0 200 OK"
4031
Janos Follath74537a62016-09-02 13:45:28 +01004032client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004033run_test "DTLS proxy: 3d, max handshake, nbio" \
4034 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004035 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4036 auth_mode=required" \
4037 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004038 0 \
4039 -s "Extra-header:" \
4040 -c "HTTP/1.0 200 OK"
4041
Janos Follath74537a62016-09-02 13:45:28 +01004042client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004043run_test "DTLS proxy: 3d, min handshake, resumption" \
4044 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4045 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4046 psk=abc123 debug_level=3" \
4047 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4048 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4049 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4050 0 \
4051 -s "a session has been resumed" \
4052 -c "a session has been resumed" \
4053 -s "Extra-header:" \
4054 -c "HTTP/1.0 200 OK"
4055
Janos Follath74537a62016-09-02 13:45:28 +01004056client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004057run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4058 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4059 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4060 psk=abc123 debug_level=3 nbio=2" \
4061 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4062 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4063 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4064 0 \
4065 -s "a session has been resumed" \
4066 -c "a session has been resumed" \
4067 -s "Extra-header:" \
4068 -c "HTTP/1.0 200 OK"
4069
Janos Follath74537a62016-09-02 13:45:28 +01004070client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004071requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004072run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004073 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004074 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4075 psk=abc123 renegotiation=1 debug_level=2" \
4076 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4077 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004078 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4079 0 \
4080 -c "=> renegotiate" \
4081 -s "=> renegotiate" \
4082 -s "Extra-header:" \
4083 -c "HTTP/1.0 200 OK"
4084
Janos Follath74537a62016-09-02 13:45:28 +01004085client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004086requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004087run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4088 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004089 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4090 psk=abc123 renegotiation=1 debug_level=2" \
4091 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4092 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004093 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4094 0 \
4095 -c "=> renegotiate" \
4096 -s "=> renegotiate" \
4097 -s "Extra-header:" \
4098 -c "HTTP/1.0 200 OK"
4099
Janos Follath74537a62016-09-02 13:45:28 +01004100client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004101requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004102run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004103 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004104 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004105 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004106 debug_level=2" \
4107 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004108 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004109 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4110 0 \
4111 -c "=> renegotiate" \
4112 -s "=> renegotiate" \
4113 -s "Extra-header:" \
4114 -c "HTTP/1.0 200 OK"
4115
Janos Follath74537a62016-09-02 13:45:28 +01004116client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004117requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004118run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004119 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004120 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004121 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004122 debug_level=2 nbio=2" \
4123 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004124 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004125 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4126 0 \
4127 -c "=> renegotiate" \
4128 -s "=> renegotiate" \
4129 -s "Extra-header:" \
4130 -c "HTTP/1.0 200 OK"
4131
Janos Follath74537a62016-09-02 13:45:28 +01004132client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004133not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004134run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004135 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4136 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004137 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004138 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004139 -c "HTTP/1.0 200 OK"
4140
Janos Follath74537a62016-09-02 13:45:28 +01004141client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004142not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004143run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4144 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4145 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004146 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004147 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004148 -c "HTTP/1.0 200 OK"
4149
Janos Follath74537a62016-09-02 13:45:28 +01004150client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004151not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004152run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4153 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4154 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004155 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004156 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004157 -c "HTTP/1.0 200 OK"
4158
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004159requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004160client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004161not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004162run_test "DTLS proxy: 3d, gnutls server" \
4163 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4164 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004165 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004166 0 \
4167 -s "Extra-header:" \
4168 -c "Extra-header:"
4169
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004170requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004171client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004172not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004173run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4174 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4175 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004176 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004177 0 \
4178 -s "Extra-header:" \
4179 -c "Extra-header:"
4180
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004181requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004182client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004183not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004184run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4185 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4186 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004187 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004188 0 \
4189 -s "Extra-header:" \
4190 -c "Extra-header:"
4191
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004192# Final report
4193
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004194echo "------------------------------------------------------------------------"
4195
4196if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004197 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004198else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004199 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004200fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004201PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004202echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004203
4204exit $FAILS