blob: 64f26a0cf0d0ca6883af9bcf1196755e1eb044cf [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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001351run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001352 "$P_SRV debug_level=3" \
1353 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001354 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001355 -c "Maximum fragment length is 16384" \
1356 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001357 -C "client hello, adding max_fragment_length extension" \
1358 -S "found max fragment length extension" \
1359 -S "server hello, max_fragment_length extension" \
1360 -C "found max_fragment_length extension"
1361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001362run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001363 "$P_SRV debug_level=3" \
1364 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001365 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001366 -c "Maximum fragment length is 4096" \
1367 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001368 -c "client hello, adding max_fragment_length extension" \
1369 -s "found max fragment length extension" \
1370 -s "server hello, max_fragment_length extension" \
1371 -c "found max_fragment_length extension"
1372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001373run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001374 "$P_SRV debug_level=3 max_frag_len=4096" \
1375 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001376 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001377 -c "Maximum fragment length is 16384" \
1378 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001379 -C "client hello, adding max_fragment_length extension" \
1380 -S "found max fragment length extension" \
1381 -S "server hello, max_fragment_length extension" \
1382 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001384requires_gnutls
1385run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001386 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001387 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001388 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001389 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001390 -c "client hello, adding max_fragment_length extension" \
1391 -c "found max_fragment_length extension"
1392
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001393run_test "Max fragment length: client, message just fits" \
1394 "$P_SRV debug_level=3" \
1395 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1396 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001397 -c "Maximum fragment length is 2048" \
1398 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001399 -c "client hello, adding max_fragment_length extension" \
1400 -s "found max fragment length extension" \
1401 -s "server hello, max_fragment_length extension" \
1402 -c "found max_fragment_length extension" \
1403 -c "2048 bytes written in 1 fragments" \
1404 -s "2048 bytes read"
1405
1406run_test "Max fragment length: client, larger message" \
1407 "$P_SRV debug_level=3" \
1408 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1409 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001410 -c "Maximum fragment length is 2048" \
1411 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001412 -c "client hello, adding max_fragment_length extension" \
1413 -s "found max fragment length extension" \
1414 -s "server hello, max_fragment_length extension" \
1415 -c "found max_fragment_length extension" \
1416 -c "2345 bytes written in 2 fragments" \
1417 -s "2048 bytes read" \
1418 -s "297 bytes read"
1419
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001420run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001421 "$P_SRV debug_level=3 dtls=1" \
1422 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1423 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001424 -c "Maximum fragment length is 2048" \
1425 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001426 -c "client hello, adding max_fragment_length extension" \
1427 -s "found max fragment length extension" \
1428 -s "server hello, max_fragment_length extension" \
1429 -c "found max_fragment_length extension" \
1430 -c "fragment larger than.*maximum"
1431
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001432# Tests for renegotiation
1433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001434run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001435 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001436 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001437 0 \
1438 -C "client hello, adding renegotiation extension" \
1439 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1440 -S "found renegotiation extension" \
1441 -s "server hello, secure renegotiation extension" \
1442 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001443 -C "=> renegotiate" \
1444 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001445 -S "write hello request"
1446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001447run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001448 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001449 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001450 0 \
1451 -c "client hello, adding renegotiation extension" \
1452 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1453 -s "found renegotiation extension" \
1454 -s "server hello, secure renegotiation extension" \
1455 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001456 -c "=> renegotiate" \
1457 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001458 -S "write hello request"
1459
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001460run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001461 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001462 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001463 0 \
1464 -c "client hello, adding renegotiation extension" \
1465 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1466 -s "found renegotiation extension" \
1467 -s "server hello, secure renegotiation extension" \
1468 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001469 -c "=> renegotiate" \
1470 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001471 -s "write hello request"
1472
Janos Follathb0f148c2017-10-05 12:29:42 +01001473# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1474# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1475# algorithm stronger than SHA-1 is enabled in config.h
1476run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1477 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1478 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1479 0 \
1480 -c "client hello, adding renegotiation extension" \
1481 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1482 -s "found renegotiation extension" \
1483 -s "server hello, secure renegotiation extension" \
1484 -c "found renegotiation extension" \
1485 -c "=> renegotiate" \
1486 -s "=> renegotiate" \
1487 -S "write hello request" \
1488 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1489
1490# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1491# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1492# algorithm stronger than SHA-1 is enabled in config.h
1493run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1494 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1495 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1496 0 \
1497 -c "client hello, adding renegotiation extension" \
1498 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1499 -s "found renegotiation extension" \
1500 -s "server hello, secure renegotiation extension" \
1501 -c "found renegotiation extension" \
1502 -c "=> renegotiate" \
1503 -s "=> renegotiate" \
1504 -s "write hello request" \
1505 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001508 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001509 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001510 0 \
1511 -c "client hello, adding renegotiation extension" \
1512 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1513 -s "found renegotiation extension" \
1514 -s "server hello, secure renegotiation extension" \
1515 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001516 -c "=> renegotiate" \
1517 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001518 -s "write hello request"
1519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001520run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001521 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001522 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001523 1 \
1524 -c "client hello, adding renegotiation extension" \
1525 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1526 -S "found renegotiation extension" \
1527 -s "server hello, secure renegotiation extension" \
1528 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001529 -c "=> renegotiate" \
1530 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001531 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001532 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001533 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001534
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001535run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001536 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001537 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001538 0 \
1539 -C "client hello, adding renegotiation extension" \
1540 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1541 -S "found renegotiation extension" \
1542 -s "server hello, secure renegotiation extension" \
1543 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001544 -C "=> renegotiate" \
1545 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001546 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001547 -S "SSL - An unexpected message was received from our peer" \
1548 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001550run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001551 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001552 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001553 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001554 0 \
1555 -C "client hello, adding renegotiation extension" \
1556 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1557 -S "found renegotiation extension" \
1558 -s "server hello, secure renegotiation extension" \
1559 -c "found renegotiation extension" \
1560 -C "=> renegotiate" \
1561 -S "=> renegotiate" \
1562 -s "write hello request" \
1563 -S "SSL - An unexpected message was received from our peer" \
1564 -S "failed"
1565
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001566# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001567run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001568 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001569 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001570 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001571 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 "SSL - An unexpected message was received from our peer" \
1581 -S "failed"
1582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001583run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001584 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001585 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001586 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001587 0 \
1588 -C "client hello, adding renegotiation extension" \
1589 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1590 -S "found renegotiation extension" \
1591 -s "server hello, secure renegotiation extension" \
1592 -c "found renegotiation extension" \
1593 -C "=> renegotiate" \
1594 -S "=> renegotiate" \
1595 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001596 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001598run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001599 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001600 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001601 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001602 0 \
1603 -c "client hello, adding renegotiation extension" \
1604 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1605 -s "found renegotiation extension" \
1606 -s "server hello, secure renegotiation extension" \
1607 -c "found renegotiation extension" \
1608 -c "=> renegotiate" \
1609 -s "=> renegotiate" \
1610 -s "write hello request" \
1611 -S "SSL - An unexpected message was received from our peer" \
1612 -S "failed"
1613
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001614run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001615 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001616 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1617 0 \
1618 -C "client hello, adding renegotiation extension" \
1619 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1620 -S "found renegotiation extension" \
1621 -s "server hello, secure renegotiation extension" \
1622 -c "found renegotiation extension" \
1623 -S "record counter limit reached: renegotiate" \
1624 -C "=> renegotiate" \
1625 -S "=> renegotiate" \
1626 -S "write hello request" \
1627 -S "SSL - An unexpected message was received from our peer" \
1628 -S "failed"
1629
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001630# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001631run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001632 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001633 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001634 0 \
1635 -c "client hello, adding renegotiation extension" \
1636 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1637 -s "found renegotiation extension" \
1638 -s "server hello, secure renegotiation extension" \
1639 -c "found renegotiation extension" \
1640 -s "record counter limit reached: renegotiate" \
1641 -c "=> renegotiate" \
1642 -s "=> renegotiate" \
1643 -s "write hello request" \
1644 -S "SSL - An unexpected message was received from our peer" \
1645 -S "failed"
1646
1647run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001648 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001649 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001650 0 \
1651 -c "client hello, adding renegotiation extension" \
1652 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1653 -s "found renegotiation extension" \
1654 -s "server hello, secure renegotiation extension" \
1655 -c "found renegotiation extension" \
1656 -s "record counter limit reached: renegotiate" \
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
1663run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001664 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001665 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1666 0 \
1667 -C "client hello, adding renegotiation extension" \
1668 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1669 -S "found renegotiation extension" \
1670 -s "server hello, secure renegotiation extension" \
1671 -c "found renegotiation extension" \
1672 -S "record counter limit reached: renegotiate" \
1673 -C "=> renegotiate" \
1674 -S "=> renegotiate" \
1675 -S "write hello request" \
1676 -S "SSL - An unexpected message was received from our peer" \
1677 -S "failed"
1678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001679run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001680 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001681 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001682 0 \
1683 -c "client hello, adding renegotiation extension" \
1684 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1685 -s "found renegotiation extension" \
1686 -s "server hello, secure renegotiation extension" \
1687 -c "found renegotiation extension" \
1688 -c "=> renegotiate" \
1689 -s "=> renegotiate" \
1690 -S "write hello request"
1691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001692run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001693 "$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 +02001694 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001695 0 \
1696 -c "client hello, adding renegotiation extension" \
1697 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1698 -s "found renegotiation extension" \
1699 -s "server hello, secure renegotiation extension" \
1700 -c "found renegotiation extension" \
1701 -c "=> renegotiate" \
1702 -s "=> renegotiate" \
1703 -s "write hello request"
1704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001705run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001706 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001707 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001708 0 \
1709 -c "client hello, adding renegotiation extension" \
1710 -c "found renegotiation extension" \
1711 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001712 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001713 -C "error" \
1714 -c "HTTP/1.0 200 [Oo][Kk]"
1715
Paul Bakker539d9722015-02-08 16:18:35 +01001716requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001717run_test "Renegotiation: gnutls server strict, client-initiated" \
1718 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001719 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001720 0 \
1721 -c "client hello, adding renegotiation extension" \
1722 -c "found renegotiation extension" \
1723 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001724 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001725 -C "error" \
1726 -c "HTTP/1.0 200 [Oo][Kk]"
1727
Paul Bakker539d9722015-02-08 16:18:35 +01001728requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001729run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1730 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1731 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1732 1 \
1733 -c "client hello, adding renegotiation extension" \
1734 -C "found renegotiation extension" \
1735 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001736 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001737 -c "error" \
1738 -C "HTTP/1.0 200 [Oo][Kk]"
1739
Paul Bakker539d9722015-02-08 16:18:35 +01001740requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001741run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1742 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1743 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1744 allow_legacy=0" \
1745 1 \
1746 -c "client hello, adding renegotiation extension" \
1747 -C "found renegotiation extension" \
1748 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001749 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001750 -c "error" \
1751 -C "HTTP/1.0 200 [Oo][Kk]"
1752
Paul Bakker539d9722015-02-08 16:18:35 +01001753requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001754run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1755 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1756 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1757 allow_legacy=1" \
1758 0 \
1759 -c "client hello, adding renegotiation extension" \
1760 -C "found renegotiation extension" \
1761 -c "=> renegotiate" \
1762 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001763 -C "error" \
1764 -c "HTTP/1.0 200 [Oo][Kk]"
1765
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001766run_test "Renegotiation: DTLS, client-initiated" \
1767 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1768 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1769 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
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001779run_test "Renegotiation: DTLS, server-initiated" \
1780 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001781 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1782 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +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
Andres AG692ad842017-01-19 16:30:57 +00001793run_test "Renegotiation: DTLS, renego_period overflow" \
1794 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1795 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1796 0 \
1797 -c "client hello, adding renegotiation extension" \
1798 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1799 -s "found renegotiation extension" \
1800 -s "server hello, secure renegotiation extension" \
1801 -s "record counter limit reached: renegotiate" \
1802 -c "=> renegotiate" \
1803 -s "=> renegotiate" \
1804 -s "write hello request" \
1805
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001806requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001807run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1808 "$G_SRV -u --mtu 4096" \
1809 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1810 0 \
1811 -c "client hello, adding renegotiation extension" \
1812 -c "found renegotiation extension" \
1813 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001814 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001815 -C "error" \
1816 -s "Extra-header:"
1817
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001818# Test for the "secure renegotation" extension only (no actual renegotiation)
1819
Paul Bakker539d9722015-02-08 16:18:35 +01001820requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001821run_test "Renego ext: gnutls server strict, client default" \
1822 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1823 "$P_CLI debug_level=3" \
1824 0 \
1825 -c "found renegotiation extension" \
1826 -C "error" \
1827 -c "HTTP/1.0 200 [Oo][Kk]"
1828
Paul Bakker539d9722015-02-08 16:18:35 +01001829requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001830run_test "Renego ext: gnutls server unsafe, client default" \
1831 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1832 "$P_CLI debug_level=3" \
1833 0 \
1834 -C "found renegotiation extension" \
1835 -C "error" \
1836 -c "HTTP/1.0 200 [Oo][Kk]"
1837
Paul Bakker539d9722015-02-08 16:18:35 +01001838requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001839run_test "Renego ext: gnutls server unsafe, client break legacy" \
1840 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1841 "$P_CLI debug_level=3 allow_legacy=-1" \
1842 1 \
1843 -C "found renegotiation extension" \
1844 -c "error" \
1845 -C "HTTP/1.0 200 [Oo][Kk]"
1846
Paul Bakker539d9722015-02-08 16:18:35 +01001847requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001848run_test "Renego ext: gnutls client strict, server default" \
1849 "$P_SRV debug_level=3" \
1850 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1851 0 \
1852 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1853 -s "server hello, secure renegotiation extension"
1854
Paul Bakker539d9722015-02-08 16:18:35 +01001855requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001856run_test "Renego ext: gnutls client unsafe, server default" \
1857 "$P_SRV debug_level=3" \
1858 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1859 0 \
1860 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1861 -S "server hello, secure renegotiation extension"
1862
Paul Bakker539d9722015-02-08 16:18:35 +01001863requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001864run_test "Renego ext: gnutls client unsafe, server break legacy" \
1865 "$P_SRV debug_level=3 allow_legacy=-1" \
1866 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1867 1 \
1868 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1869 -S "server hello, secure renegotiation extension"
1870
Janos Follath0b242342016-02-17 10:11:21 +00001871# Tests for silently dropping trailing extra bytes in .der certificates
1872
1873requires_gnutls
1874run_test "DER format: no trailing bytes" \
1875 "$P_SRV crt_file=data_files/server5-der0.crt \
1876 key_file=data_files/server5.key" \
1877 "$G_CLI " \
1878 0 \
1879 -c "Handshake was completed" \
1880
1881requires_gnutls
1882run_test "DER format: with a trailing zero byte" \
1883 "$P_SRV crt_file=data_files/server5-der1a.crt \
1884 key_file=data_files/server5.key" \
1885 "$G_CLI " \
1886 0 \
1887 -c "Handshake was completed" \
1888
1889requires_gnutls
1890run_test "DER format: with a trailing random byte" \
1891 "$P_SRV crt_file=data_files/server5-der1b.crt \
1892 key_file=data_files/server5.key" \
1893 "$G_CLI " \
1894 0 \
1895 -c "Handshake was completed" \
1896
1897requires_gnutls
1898run_test "DER format: with 2 trailing random bytes" \
1899 "$P_SRV crt_file=data_files/server5-der2.crt \
1900 key_file=data_files/server5.key" \
1901 "$G_CLI " \
1902 0 \
1903 -c "Handshake was completed" \
1904
1905requires_gnutls
1906run_test "DER format: with 4 trailing random bytes" \
1907 "$P_SRV crt_file=data_files/server5-der4.crt \
1908 key_file=data_files/server5.key" \
1909 "$G_CLI " \
1910 0 \
1911 -c "Handshake was completed" \
1912
1913requires_gnutls
1914run_test "DER format: with 8 trailing random bytes" \
1915 "$P_SRV crt_file=data_files/server5-der8.crt \
1916 key_file=data_files/server5.key" \
1917 "$G_CLI " \
1918 0 \
1919 -c "Handshake was completed" \
1920
1921requires_gnutls
1922run_test "DER format: with 9 trailing random bytes" \
1923 "$P_SRV crt_file=data_files/server5-der9.crt \
1924 key_file=data_files/server5.key" \
1925 "$G_CLI " \
1926 0 \
1927 -c "Handshake was completed" \
1928
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001929# Tests for auth_mode
1930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001931run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001932 "$P_SRV crt_file=data_files/server5-badsign.crt \
1933 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001934 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001935 1 \
1936 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001937 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001938 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001939 -c "X509 - Certificate verification failed"
1940
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001941run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001942 "$P_SRV crt_file=data_files/server5-badsign.crt \
1943 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001944 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001945 0 \
1946 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001947 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001948 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001949 -C "X509 - Certificate verification failed"
1950
Hanno Beckere6706e62017-05-15 16:05:15 +01001951run_test "Authentication: server goodcert, client optional, no trusted CA" \
1952 "$P_SRV" \
1953 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1954 0 \
1955 -c "x509_verify_cert() returned" \
1956 -c "! The certificate is not correctly signed by the trusted CA" \
1957 -c "! Certificate verification flags"\
1958 -C "! mbedtls_ssl_handshake returned" \
1959 -C "X509 - Certificate verification failed" \
1960 -C "SSL - No CA Chain is set, but required to operate"
1961
1962run_test "Authentication: server goodcert, client required, no trusted CA" \
1963 "$P_SRV" \
1964 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1965 1 \
1966 -c "x509_verify_cert() returned" \
1967 -c "! The certificate is not correctly signed by the trusted CA" \
1968 -c "! Certificate verification flags"\
1969 -c "! mbedtls_ssl_handshake returned" \
1970 -c "SSL - No CA Chain is set, but required to operate"
1971
1972# The purpose of the next two tests is to test the client's behaviour when receiving a server
1973# certificate with an unsupported elliptic curve. This should usually not happen because
1974# the client informs the server about the supported curves - it does, though, in the
1975# corner case of a static ECDH suite, because the server doesn't check the curve on that
1976# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1977# different means to have the server ignoring the client's supported curve list.
1978
1979requires_config_enabled MBEDTLS_ECP_C
1980run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1981 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1982 crt_file=data_files/server5.ku-ka.crt" \
1983 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1984 1 \
1985 -c "bad certificate (EC key curve)"\
1986 -c "! Certificate verification flags"\
1987 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1988
1989requires_config_enabled MBEDTLS_ECP_C
1990run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1991 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1992 crt_file=data_files/server5.ku-ka.crt" \
1993 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1994 1 \
1995 -c "bad certificate (EC key curve)"\
1996 -c "! Certificate verification flags"\
1997 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001999run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002000 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002001 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002002 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002003 0 \
2004 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002005 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002006 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002007 -C "X509 - Certificate verification failed"
2008
Simon Butcher99000142016-10-13 17:21:01 +01002009run_test "Authentication: client SHA256, server required" \
2010 "$P_SRV auth_mode=required" \
2011 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2012 key_file=data_files/server6.key \
2013 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2014 0 \
2015 -c "Supported Signature Algorithm found: 4," \
2016 -c "Supported Signature Algorithm found: 5,"
2017
2018run_test "Authentication: client SHA384, server required" \
2019 "$P_SRV auth_mode=required" \
2020 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2021 key_file=data_files/server6.key \
2022 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2023 0 \
2024 -c "Supported Signature Algorithm found: 4," \
2025 -c "Supported Signature Algorithm found: 5,"
2026
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002027requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2028run_test "Authentication: client has no cert, server required (SSLv3)" \
2029 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2030 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2031 key_file=data_files/server5.key" \
2032 1 \
2033 -S "skip write certificate request" \
2034 -C "skip parse certificate request" \
2035 -c "got a certificate request" \
2036 -c "got no certificate to send" \
2037 -S "x509_verify_cert() returned" \
2038 -s "client has no certificate" \
2039 -s "! mbedtls_ssl_handshake returned" \
2040 -c "! mbedtls_ssl_handshake returned" \
2041 -s "No client certification received from the client, but required by the authentication mode"
2042
2043run_test "Authentication: client has no cert, server required (TLS)" \
2044 "$P_SRV debug_level=3 auth_mode=required" \
2045 "$P_CLI debug_level=3 crt_file=none \
2046 key_file=data_files/server5.key" \
2047 1 \
2048 -S "skip write certificate request" \
2049 -C "skip parse certificate request" \
2050 -c "got a certificate request" \
2051 -c "= write certificate$" \
2052 -C "skip write certificate$" \
2053 -S "x509_verify_cert() returned" \
2054 -s "client has no certificate" \
2055 -s "! mbedtls_ssl_handshake returned" \
2056 -c "! mbedtls_ssl_handshake returned" \
2057 -s "No client certification received from the client, but required by the authentication mode"
2058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002059run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002060 "$P_SRV debug_level=3 auth_mode=required" \
2061 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002062 key_file=data_files/server5.key" \
2063 1 \
2064 -S "skip write certificate request" \
2065 -C "skip parse certificate request" \
2066 -c "got a certificate request" \
2067 -C "skip write certificate" \
2068 -C "skip write certificate verify" \
2069 -S "skip parse certificate verify" \
2070 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002071 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002072 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002073 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002074 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002075 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002076# We don't check that the client receives the alert because it might
2077# detect that its write end of the connection is closed and abort
2078# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002079
Janos Follath89baba22017-04-10 14:34:35 +01002080run_test "Authentication: client cert not trusted, server required" \
2081 "$P_SRV debug_level=3 auth_mode=required" \
2082 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2083 key_file=data_files/server5.key" \
2084 1 \
2085 -S "skip write certificate request" \
2086 -C "skip parse certificate request" \
2087 -c "got a certificate request" \
2088 -C "skip write certificate" \
2089 -C "skip write certificate verify" \
2090 -S "skip parse certificate verify" \
2091 -s "x509_verify_cert() returned" \
2092 -s "! The certificate is not correctly signed by the trusted CA" \
2093 -s "! mbedtls_ssl_handshake returned" \
2094 -c "! mbedtls_ssl_handshake returned" \
2095 -s "X509 - Certificate verification failed"
2096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002097run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002098 "$P_SRV debug_level=3 auth_mode=optional" \
2099 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002100 key_file=data_files/server5.key" \
2101 0 \
2102 -S "skip write certificate request" \
2103 -C "skip parse certificate request" \
2104 -c "got a certificate request" \
2105 -C "skip write certificate" \
2106 -C "skip write certificate verify" \
2107 -S "skip parse certificate verify" \
2108 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002109 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002110 -S "! mbedtls_ssl_handshake returned" \
2111 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002112 -S "X509 - Certificate verification failed"
2113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002114run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002115 "$P_SRV debug_level=3 auth_mode=none" \
2116 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002117 key_file=data_files/server5.key" \
2118 0 \
2119 -s "skip write certificate request" \
2120 -C "skip parse certificate request" \
2121 -c "got no certificate request" \
2122 -c "skip write certificate" \
2123 -c "skip write certificate verify" \
2124 -s "skip parse certificate verify" \
2125 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002126 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002127 -S "! mbedtls_ssl_handshake returned" \
2128 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002129 -S "X509 - Certificate verification failed"
2130
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002131run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002132 "$P_SRV debug_level=3 auth_mode=optional" \
2133 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002134 0 \
2135 -S "skip write certificate request" \
2136 -C "skip parse certificate request" \
2137 -c "got a certificate request" \
2138 -C "skip write certificate$" \
2139 -C "got no certificate to send" \
2140 -S "SSLv3 client has no certificate" \
2141 -c "skip write certificate verify" \
2142 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002143 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002144 -S "! mbedtls_ssl_handshake returned" \
2145 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002146 -S "X509 - Certificate verification failed"
2147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002148run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002149 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002150 "$O_CLI" \
2151 0 \
2152 -S "skip write certificate request" \
2153 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002154 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002155 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002156 -S "X509 - Certificate verification failed"
2157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002158run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002159 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002160 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002161 0 \
2162 -C "skip parse certificate request" \
2163 -c "got a certificate request" \
2164 -C "skip write certificate$" \
2165 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002166 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002167
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002168run_test "Authentication: client no cert, openssl server required" \
2169 "$O_SRV -Verify 10" \
2170 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2171 1 \
2172 -C "skip parse certificate request" \
2173 -c "got a certificate request" \
2174 -C "skip write certificate$" \
2175 -c "skip write certificate verify" \
2176 -c "! mbedtls_ssl_handshake returned"
2177
Janos Follathe2681a42016-03-07 15:57:05 +00002178requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002179run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002180 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002181 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002182 0 \
2183 -S "skip write certificate request" \
2184 -C "skip parse certificate request" \
2185 -c "got a certificate request" \
2186 -C "skip write certificate$" \
2187 -c "skip write certificate verify" \
2188 -c "got no certificate to send" \
2189 -s "SSLv3 client has no certificate" \
2190 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002191 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002192 -S "! mbedtls_ssl_handshake returned" \
2193 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002194 -S "X509 - Certificate verification failed"
2195
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002196# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2197# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002198
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002199MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002200MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002201
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002202if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002203 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002204 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002205 printf "test value of ${MAX_IM_CA}. \n"
2206 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002207 printf "The tests assume this value and if it changes, the tests in this\n"
2208 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002209 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002210
2211 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002212fi
2213
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002214run_test "Authentication: server max_int chain, client default" \
2215 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2216 key_file=data_files/dir-maxpath/09.key" \
2217 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2218 0 \
2219 -C "X509 - A fatal error occured"
2220
2221run_test "Authentication: server max_int+1 chain, client default" \
2222 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2223 key_file=data_files/dir-maxpath/10.key" \
2224 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2225 1 \
2226 -c "X509 - A fatal error occured"
2227
2228run_test "Authentication: server max_int+1 chain, client optional" \
2229 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2230 key_file=data_files/dir-maxpath/10.key" \
2231 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2232 auth_mode=optional" \
2233 1 \
2234 -c "X509 - A fatal error occured"
2235
2236run_test "Authentication: server max_int+1 chain, client none" \
2237 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2238 key_file=data_files/dir-maxpath/10.key" \
2239 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2240 auth_mode=none" \
2241 0 \
2242 -C "X509 - A fatal error occured"
2243
2244run_test "Authentication: client max_int+1 chain, server default" \
2245 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2246 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2247 key_file=data_files/dir-maxpath/10.key" \
2248 0 \
2249 -S "X509 - A fatal error occured"
2250
2251run_test "Authentication: client max_int+1 chain, server optional" \
2252 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2253 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2254 key_file=data_files/dir-maxpath/10.key" \
2255 1 \
2256 -s "X509 - A fatal error occured"
2257
2258run_test "Authentication: client max_int+1 chain, server required" \
2259 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2260 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2261 key_file=data_files/dir-maxpath/10.key" \
2262 1 \
2263 -s "X509 - A fatal error occured"
2264
2265run_test "Authentication: client max_int chain, server required" \
2266 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2267 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2268 key_file=data_files/dir-maxpath/09.key" \
2269 0 \
2270 -S "X509 - A fatal error occured"
2271
Janos Follath89baba22017-04-10 14:34:35 +01002272# Tests for CA list in CertificateRequest messages
2273
2274run_test "Authentication: send CA list in CertificateRequest (default)" \
2275 "$P_SRV debug_level=3 auth_mode=required" \
2276 "$P_CLI crt_file=data_files/server6.crt \
2277 key_file=data_files/server6.key" \
2278 0 \
2279 -s "requested DN"
2280
2281run_test "Authentication: do not send CA list in CertificateRequest" \
2282 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2283 "$P_CLI crt_file=data_files/server6.crt \
2284 key_file=data_files/server6.key" \
2285 0 \
2286 -S "requested DN"
2287
2288run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2289 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2290 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2291 key_file=data_files/server5.key" \
2292 1 \
2293 -S "requested DN" \
2294 -s "x509_verify_cert() returned" \
2295 -s "! The certificate is not correctly signed by the trusted CA" \
2296 -s "! mbedtls_ssl_handshake returned" \
2297 -c "! mbedtls_ssl_handshake returned" \
2298 -s "X509 - Certificate verification failed"
2299
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002300# Tests for certificate selection based on SHA verson
2301
2302run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2303 "$P_SRV crt_file=data_files/server5.crt \
2304 key_file=data_files/server5.key \
2305 crt_file2=data_files/server5-sha1.crt \
2306 key_file2=data_files/server5.key" \
2307 "$P_CLI force_version=tls1_2" \
2308 0 \
2309 -c "signed using.*ECDSA with SHA256" \
2310 -C "signed using.*ECDSA with SHA1"
2311
2312run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2313 "$P_SRV crt_file=data_files/server5.crt \
2314 key_file=data_files/server5.key \
2315 crt_file2=data_files/server5-sha1.crt \
2316 key_file2=data_files/server5.key" \
2317 "$P_CLI force_version=tls1_1" \
2318 0 \
2319 -C "signed using.*ECDSA with SHA256" \
2320 -c "signed using.*ECDSA with SHA1"
2321
2322run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2323 "$P_SRV crt_file=data_files/server5.crt \
2324 key_file=data_files/server5.key \
2325 crt_file2=data_files/server5-sha1.crt \
2326 key_file2=data_files/server5.key" \
2327 "$P_CLI force_version=tls1" \
2328 0 \
2329 -C "signed using.*ECDSA with SHA256" \
2330 -c "signed using.*ECDSA with SHA1"
2331
2332run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2333 "$P_SRV crt_file=data_files/server5.crt \
2334 key_file=data_files/server5.key \
2335 crt_file2=data_files/server6.crt \
2336 key_file2=data_files/server6.key" \
2337 "$P_CLI force_version=tls1_1" \
2338 0 \
2339 -c "serial number.*09" \
2340 -c "signed using.*ECDSA with SHA256" \
2341 -C "signed using.*ECDSA with SHA1"
2342
2343run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2344 "$P_SRV crt_file=data_files/server6.crt \
2345 key_file=data_files/server6.key \
2346 crt_file2=data_files/server5.crt \
2347 key_file2=data_files/server5.key" \
2348 "$P_CLI force_version=tls1_1" \
2349 0 \
2350 -c "serial number.*0A" \
2351 -c "signed using.*ECDSA with SHA256" \
2352 -C "signed using.*ECDSA with SHA1"
2353
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002354# tests for SNI
2355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002356run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002357 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002358 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002359 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002360 0 \
2361 -S "parse ServerName extension" \
2362 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2363 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002365run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002366 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002367 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002368 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 +02002369 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002370 0 \
2371 -s "parse ServerName extension" \
2372 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2373 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002375run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002376 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002377 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002378 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 +02002379 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002380 0 \
2381 -s "parse ServerName extension" \
2382 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2383 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002385run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002386 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002387 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002388 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 +02002389 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002390 1 \
2391 -s "parse ServerName extension" \
2392 -s "ssl_sni_wrapper() returned" \
2393 -s "mbedtls_ssl_handshake returned" \
2394 -c "mbedtls_ssl_handshake returned" \
2395 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002396
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002397run_test "SNI: client auth no override: optional" \
2398 "$P_SRV debug_level=3 auth_mode=optional \
2399 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2400 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2401 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002402 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002403 -S "skip write certificate request" \
2404 -C "skip parse certificate request" \
2405 -c "got a certificate request" \
2406 -C "skip write certificate" \
2407 -C "skip write certificate verify" \
2408 -S "skip parse certificate verify"
2409
2410run_test "SNI: client auth override: none -> optional" \
2411 "$P_SRV debug_level=3 auth_mode=none \
2412 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2413 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2414 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002415 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002416 -S "skip write certificate request" \
2417 -C "skip parse certificate request" \
2418 -c "got a certificate request" \
2419 -C "skip write certificate" \
2420 -C "skip write certificate verify" \
2421 -S "skip parse certificate verify"
2422
2423run_test "SNI: client auth override: optional -> none" \
2424 "$P_SRV debug_level=3 auth_mode=optional \
2425 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2426 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2427 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002428 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002429 -s "skip write certificate request" \
2430 -C "skip parse certificate request" \
2431 -c "got no certificate request" \
2432 -c "skip write certificate" \
2433 -c "skip write certificate verify" \
2434 -s "skip parse certificate verify"
2435
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002436run_test "SNI: CA no override" \
2437 "$P_SRV debug_level=3 auth_mode=optional \
2438 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2439 ca_file=data_files/test-ca.crt \
2440 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2441 "$P_CLI debug_level=3 server_name=localhost \
2442 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2443 1 \
2444 -S "skip write certificate request" \
2445 -C "skip parse certificate request" \
2446 -c "got a certificate request" \
2447 -C "skip write certificate" \
2448 -C "skip write certificate verify" \
2449 -S "skip parse certificate verify" \
2450 -s "x509_verify_cert() returned" \
2451 -s "! The certificate is not correctly signed by the trusted CA" \
2452 -S "The certificate has been revoked (is on a CRL)"
2453
2454run_test "SNI: CA override" \
2455 "$P_SRV debug_level=3 auth_mode=optional \
2456 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2457 ca_file=data_files/test-ca.crt \
2458 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2459 "$P_CLI debug_level=3 server_name=localhost \
2460 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2461 0 \
2462 -S "skip write certificate request" \
2463 -C "skip parse certificate request" \
2464 -c "got a certificate request" \
2465 -C "skip write certificate" \
2466 -C "skip write certificate verify" \
2467 -S "skip parse certificate verify" \
2468 -S "x509_verify_cert() returned" \
2469 -S "! The certificate is not correctly signed by the trusted CA" \
2470 -S "The certificate has been revoked (is on a CRL)"
2471
2472run_test "SNI: CA override with CRL" \
2473 "$P_SRV debug_level=3 auth_mode=optional \
2474 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2475 ca_file=data_files/test-ca.crt \
2476 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2477 "$P_CLI debug_level=3 server_name=localhost \
2478 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2479 1 \
2480 -S "skip write certificate request" \
2481 -C "skip parse certificate request" \
2482 -c "got a certificate request" \
2483 -C "skip write certificate" \
2484 -C "skip write certificate verify" \
2485 -S "skip parse certificate verify" \
2486 -s "x509_verify_cert() returned" \
2487 -S "! The certificate is not correctly signed by the trusted CA" \
2488 -s "The certificate has been revoked (is on a CRL)"
2489
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002490# Tests for non-blocking I/O: exercise a variety of handshake flows
2491
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002492run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002493 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2494 "$P_CLI nbio=2 tickets=0" \
2495 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002496 -S "mbedtls_ssl_handshake returned" \
2497 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002498 -c "Read from server: .* bytes read"
2499
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002500run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002501 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2502 "$P_CLI nbio=2 tickets=0" \
2503 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002504 -S "mbedtls_ssl_handshake returned" \
2505 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002506 -c "Read from server: .* bytes read"
2507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002508run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002509 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2510 "$P_CLI nbio=2 tickets=1" \
2511 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002512 -S "mbedtls_ssl_handshake returned" \
2513 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002514 -c "Read from server: .* bytes read"
2515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002516run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002517 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2518 "$P_CLI nbio=2 tickets=1" \
2519 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002520 -S "mbedtls_ssl_handshake returned" \
2521 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002522 -c "Read from server: .* bytes read"
2523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002524run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002525 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2526 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2527 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002528 -S "mbedtls_ssl_handshake returned" \
2529 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002530 -c "Read from server: .* bytes read"
2531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002532run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002533 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2534 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2535 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002536 -S "mbedtls_ssl_handshake returned" \
2537 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002538 -c "Read from server: .* bytes read"
2539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002540run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002541 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2542 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2543 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002544 -S "mbedtls_ssl_handshake returned" \
2545 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002546 -c "Read from server: .* bytes read"
2547
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002548# Tests for version negotiation
2549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002550run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002551 "$P_SRV" \
2552 "$P_CLI" \
2553 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002554 -S "mbedtls_ssl_handshake returned" \
2555 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002556 -s "Protocol is TLSv1.2" \
2557 -c "Protocol is TLSv1.2"
2558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002559run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002560 "$P_SRV" \
2561 "$P_CLI max_version=tls1_1" \
2562 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002563 -S "mbedtls_ssl_handshake returned" \
2564 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002565 -s "Protocol is TLSv1.1" \
2566 -c "Protocol is TLSv1.1"
2567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002568run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002569 "$P_SRV max_version=tls1_1" \
2570 "$P_CLI" \
2571 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002572 -S "mbedtls_ssl_handshake returned" \
2573 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002574 -s "Protocol is TLSv1.1" \
2575 -c "Protocol is TLSv1.1"
2576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002577run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002578 "$P_SRV max_version=tls1_1" \
2579 "$P_CLI max_version=tls1_1" \
2580 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002581 -S "mbedtls_ssl_handshake returned" \
2582 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002583 -s "Protocol is TLSv1.1" \
2584 -c "Protocol is TLSv1.1"
2585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002586run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002587 "$P_SRV min_version=tls1_1" \
2588 "$P_CLI max_version=tls1_1" \
2589 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002590 -S "mbedtls_ssl_handshake returned" \
2591 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002592 -s "Protocol is TLSv1.1" \
2593 -c "Protocol is TLSv1.1"
2594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002595run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002596 "$P_SRV max_version=tls1_1" \
2597 "$P_CLI min_version=tls1_1" \
2598 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002599 -S "mbedtls_ssl_handshake returned" \
2600 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002601 -s "Protocol is TLSv1.1" \
2602 -c "Protocol is TLSv1.1"
2603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002604run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002605 "$P_SRV max_version=tls1_1" \
2606 "$P_CLI min_version=tls1_2" \
2607 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002608 -s "mbedtls_ssl_handshake returned" \
2609 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002610 -c "SSL - Handshake protocol not within min/max boundaries"
2611
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002612run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002613 "$P_SRV min_version=tls1_2" \
2614 "$P_CLI max_version=tls1_1" \
2615 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002616 -s "mbedtls_ssl_handshake returned" \
2617 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002618 -s "SSL - Handshake protocol not within min/max boundaries"
2619
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002620# Tests for ALPN extension
2621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002622run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002623 "$P_SRV debug_level=3" \
2624 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002625 0 \
2626 -C "client hello, adding alpn extension" \
2627 -S "found alpn extension" \
2628 -C "got an alert message, type: \\[2:120]" \
2629 -S "server hello, adding alpn extension" \
2630 -C "found alpn extension " \
2631 -C "Application Layer Protocol is" \
2632 -S "Application Layer Protocol is"
2633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002634run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002635 "$P_SRV debug_level=3" \
2636 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002637 0 \
2638 -c "client hello, adding alpn extension" \
2639 -s "found alpn extension" \
2640 -C "got an alert message, type: \\[2:120]" \
2641 -S "server hello, adding alpn extension" \
2642 -C "found alpn extension " \
2643 -c "Application Layer Protocol is (none)" \
2644 -S "Application Layer Protocol is"
2645
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002646run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002647 "$P_SRV debug_level=3 alpn=abc,1234" \
2648 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002649 0 \
2650 -C "client hello, adding alpn extension" \
2651 -S "found alpn extension" \
2652 -C "got an alert message, type: \\[2:120]" \
2653 -S "server hello, adding alpn extension" \
2654 -C "found alpn extension " \
2655 -C "Application Layer Protocol is" \
2656 -s "Application Layer Protocol is (none)"
2657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002658run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002659 "$P_SRV debug_level=3 alpn=abc,1234" \
2660 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002661 0 \
2662 -c "client hello, adding alpn extension" \
2663 -s "found alpn extension" \
2664 -C "got an alert message, type: \\[2:120]" \
2665 -s "server hello, adding alpn extension" \
2666 -c "found alpn extension" \
2667 -c "Application Layer Protocol is abc" \
2668 -s "Application Layer Protocol is abc"
2669
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002670run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002671 "$P_SRV debug_level=3 alpn=abc,1234" \
2672 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002673 0 \
2674 -c "client hello, adding alpn extension" \
2675 -s "found alpn extension" \
2676 -C "got an alert message, type: \\[2:120]" \
2677 -s "server hello, adding alpn extension" \
2678 -c "found alpn extension" \
2679 -c "Application Layer Protocol is abc" \
2680 -s "Application Layer Protocol is abc"
2681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002682run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002683 "$P_SRV debug_level=3 alpn=abc,1234" \
2684 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002685 0 \
2686 -c "client hello, adding alpn extension" \
2687 -s "found alpn extension" \
2688 -C "got an alert message, type: \\[2:120]" \
2689 -s "server hello, adding alpn extension" \
2690 -c "found alpn extension" \
2691 -c "Application Layer Protocol is 1234" \
2692 -s "Application Layer Protocol is 1234"
2693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002694run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002695 "$P_SRV debug_level=3 alpn=abc,123" \
2696 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002697 1 \
2698 -c "client hello, adding alpn extension" \
2699 -s "found alpn extension" \
2700 -c "got an alert message, type: \\[2:120]" \
2701 -S "server hello, adding alpn extension" \
2702 -C "found alpn extension" \
2703 -C "Application Layer Protocol is 1234" \
2704 -S "Application Layer Protocol is 1234"
2705
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002706
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002707# Tests for keyUsage in leaf certificates, part 1:
2708# server-side certificate/suite selection
2709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002710run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002711 "$P_SRV key_file=data_files/server2.key \
2712 crt_file=data_files/server2.ku-ds.crt" \
2713 "$P_CLI" \
2714 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002715 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002716
2717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002718run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002719 "$P_SRV key_file=data_files/server2.key \
2720 crt_file=data_files/server2.ku-ke.crt" \
2721 "$P_CLI" \
2722 0 \
2723 -c "Ciphersuite is TLS-RSA-WITH-"
2724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002725run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002726 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002727 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002728 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002729 1 \
2730 -C "Ciphersuite is "
2731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002732run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002733 "$P_SRV key_file=data_files/server5.key \
2734 crt_file=data_files/server5.ku-ds.crt" \
2735 "$P_CLI" \
2736 0 \
2737 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2738
2739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002740run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002741 "$P_SRV key_file=data_files/server5.key \
2742 crt_file=data_files/server5.ku-ka.crt" \
2743 "$P_CLI" \
2744 0 \
2745 -c "Ciphersuite is TLS-ECDH-"
2746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002747run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002748 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002749 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002750 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002751 1 \
2752 -C "Ciphersuite is "
2753
2754# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002755# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002757run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002758 "$O_SRV -key data_files/server2.key \
2759 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002760 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002761 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2762 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002763 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002764 -C "Processing of the Certificate handshake message failed" \
2765 -c "Ciphersuite is TLS-"
2766
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002767run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002768 "$O_SRV -key data_files/server2.key \
2769 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002770 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002771 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2772 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002773 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002774 -C "Processing of the Certificate handshake message failed" \
2775 -c "Ciphersuite is TLS-"
2776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002777run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002778 "$O_SRV -key data_files/server2.key \
2779 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002780 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002781 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2782 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002783 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002784 -C "Processing of the Certificate handshake message failed" \
2785 -c "Ciphersuite is TLS-"
2786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002787run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002788 "$O_SRV -key data_files/server2.key \
2789 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002790 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002791 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2792 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002793 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002794 -c "Processing of the Certificate handshake message failed" \
2795 -C "Ciphersuite is TLS-"
2796
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002797run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2798 "$O_SRV -key data_files/server2.key \
2799 -cert data_files/server2.ku-ke.crt" \
2800 "$P_CLI debug_level=1 auth_mode=optional \
2801 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2802 0 \
2803 -c "bad certificate (usage extensions)" \
2804 -C "Processing of the Certificate handshake message failed" \
2805 -c "Ciphersuite is TLS-" \
2806 -c "! Usage does not match the keyUsage extension"
2807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002808run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002809 "$O_SRV -key data_files/server2.key \
2810 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002811 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002812 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2813 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002814 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002815 -C "Processing of the Certificate handshake message failed" \
2816 -c "Ciphersuite is TLS-"
2817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002818run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002819 "$O_SRV -key data_files/server2.key \
2820 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002821 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002822 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2823 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002824 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002825 -c "Processing of the Certificate handshake message failed" \
2826 -C "Ciphersuite is TLS-"
2827
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002828run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2829 "$O_SRV -key data_files/server2.key \
2830 -cert data_files/server2.ku-ds.crt" \
2831 "$P_CLI debug_level=1 auth_mode=optional \
2832 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2833 0 \
2834 -c "bad certificate (usage extensions)" \
2835 -C "Processing of the Certificate handshake message failed" \
2836 -c "Ciphersuite is TLS-" \
2837 -c "! Usage does not match the keyUsage extension"
2838
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002839# Tests for keyUsage in leaf certificates, part 3:
2840# server-side checking of client cert
2841
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002842run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002843 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002844 "$O_CLI -key data_files/server2.key \
2845 -cert data_files/server2.ku-ds.crt" \
2846 0 \
2847 -S "bad certificate (usage extensions)" \
2848 -S "Processing of the Certificate handshake message failed"
2849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002850run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002851 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002852 "$O_CLI -key data_files/server2.key \
2853 -cert data_files/server2.ku-ke.crt" \
2854 0 \
2855 -s "bad certificate (usage extensions)" \
2856 -S "Processing of the Certificate handshake message failed"
2857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002858run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002859 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002860 "$O_CLI -key data_files/server2.key \
2861 -cert data_files/server2.ku-ke.crt" \
2862 1 \
2863 -s "bad certificate (usage extensions)" \
2864 -s "Processing of the Certificate handshake message failed"
2865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002866run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002867 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002868 "$O_CLI -key data_files/server5.key \
2869 -cert data_files/server5.ku-ds.crt" \
2870 0 \
2871 -S "bad certificate (usage extensions)" \
2872 -S "Processing of the Certificate handshake message failed"
2873
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002874run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002875 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002876 "$O_CLI -key data_files/server5.key \
2877 -cert data_files/server5.ku-ka.crt" \
2878 0 \
2879 -s "bad certificate (usage extensions)" \
2880 -S "Processing of the Certificate handshake message failed"
2881
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002882# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2883
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002884run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002885 "$P_SRV key_file=data_files/server5.key \
2886 crt_file=data_files/server5.eku-srv.crt" \
2887 "$P_CLI" \
2888 0
2889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002890run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002891 "$P_SRV key_file=data_files/server5.key \
2892 crt_file=data_files/server5.eku-srv.crt" \
2893 "$P_CLI" \
2894 0
2895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002896run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002897 "$P_SRV key_file=data_files/server5.key \
2898 crt_file=data_files/server5.eku-cs_any.crt" \
2899 "$P_CLI" \
2900 0
2901
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002902run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002903 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002904 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002905 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002906 1
2907
2908# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2909
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002910run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002911 "$O_SRV -key data_files/server5.key \
2912 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002913 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002914 0 \
2915 -C "bad certificate (usage extensions)" \
2916 -C "Processing of the Certificate handshake message failed" \
2917 -c "Ciphersuite is TLS-"
2918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002919run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002920 "$O_SRV -key data_files/server5.key \
2921 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002922 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002923 0 \
2924 -C "bad certificate (usage extensions)" \
2925 -C "Processing of the Certificate handshake message failed" \
2926 -c "Ciphersuite is TLS-"
2927
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002928run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002929 "$O_SRV -key data_files/server5.key \
2930 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002931 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002932 0 \
2933 -C "bad certificate (usage extensions)" \
2934 -C "Processing of the Certificate handshake message failed" \
2935 -c "Ciphersuite is TLS-"
2936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002937run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002938 "$O_SRV -key data_files/server5.key \
2939 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002940 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002941 1 \
2942 -c "bad certificate (usage extensions)" \
2943 -c "Processing of the Certificate handshake message failed" \
2944 -C "Ciphersuite is TLS-"
2945
2946# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2947
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002948run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002949 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002950 "$O_CLI -key data_files/server5.key \
2951 -cert data_files/server5.eku-cli.crt" \
2952 0 \
2953 -S "bad certificate (usage extensions)" \
2954 -S "Processing of the Certificate handshake message failed"
2955
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002956run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002957 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002958 "$O_CLI -key data_files/server5.key \
2959 -cert data_files/server5.eku-srv_cli.crt" \
2960 0 \
2961 -S "bad certificate (usage extensions)" \
2962 -S "Processing of the Certificate handshake message failed"
2963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002964run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002965 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002966 "$O_CLI -key data_files/server5.key \
2967 -cert data_files/server5.eku-cs_any.crt" \
2968 0 \
2969 -S "bad certificate (usage extensions)" \
2970 -S "Processing of the Certificate handshake message failed"
2971
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002972run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002973 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002974 "$O_CLI -key data_files/server5.key \
2975 -cert data_files/server5.eku-cs.crt" \
2976 0 \
2977 -s "bad certificate (usage extensions)" \
2978 -S "Processing of the Certificate handshake message failed"
2979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002980run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002981 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002982 "$O_CLI -key data_files/server5.key \
2983 -cert data_files/server5.eku-cs.crt" \
2984 1 \
2985 -s "bad certificate (usage extensions)" \
2986 -s "Processing of the Certificate handshake message failed"
2987
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002988# Tests for DHM parameters loading
2989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002990run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002991 "$P_SRV" \
2992 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2993 debug_level=3" \
2994 0 \
2995 -c "value of 'DHM: P ' (2048 bits)" \
2996 -c "value of 'DHM: G ' (2048 bits)"
2997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002998run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002999 "$P_SRV dhm_file=data_files/dhparams.pem" \
3000 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3001 debug_level=3" \
3002 0 \
3003 -c "value of 'DHM: P ' (1024 bits)" \
3004 -c "value of 'DHM: G ' (2 bits)"
3005
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003006# Tests for DHM client-side size checking
3007
3008run_test "DHM size: server default, client default, OK" \
3009 "$P_SRV" \
3010 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3011 debug_level=1" \
3012 0 \
3013 -C "DHM prime too short:"
3014
3015run_test "DHM size: server default, client 2048, OK" \
3016 "$P_SRV" \
3017 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3018 debug_level=1 dhmlen=2048" \
3019 0 \
3020 -C "DHM prime too short:"
3021
3022run_test "DHM size: server 1024, client default, OK" \
3023 "$P_SRV dhm_file=data_files/dhparams.pem" \
3024 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3025 debug_level=1" \
3026 0 \
3027 -C "DHM prime too short:"
3028
3029run_test "DHM size: server 1000, client default, rejected" \
3030 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3031 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3032 debug_level=1" \
3033 1 \
3034 -c "DHM prime too short:"
3035
3036run_test "DHM size: server default, client 2049, rejected" \
3037 "$P_SRV" \
3038 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3039 debug_level=1 dhmlen=2049" \
3040 1 \
3041 -c "DHM prime too short:"
3042
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003043# Tests for PSK callback
3044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003045run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003046 "$P_SRV psk=abc123 psk_identity=foo" \
3047 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3048 psk_identity=foo psk=abc123" \
3049 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003050 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003051 -S "SSL - Unknown identity received" \
3052 -S "SSL - Verification of the message MAC failed"
3053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003054run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003055 "$P_SRV" \
3056 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3057 psk_identity=foo psk=abc123" \
3058 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003059 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003060 -S "SSL - Unknown identity received" \
3061 -S "SSL - Verification of the message MAC failed"
3062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003063run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003064 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3065 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3066 psk_identity=foo psk=abc123" \
3067 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003068 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003069 -s "SSL - Unknown identity received" \
3070 -S "SSL - Verification of the message MAC failed"
3071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003072run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003073 "$P_SRV psk_list=abc,dead,def,beef" \
3074 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3075 psk_identity=abc psk=dead" \
3076 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003077 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003078 -S "SSL - Unknown identity received" \
3079 -S "SSL - Verification of the message MAC failed"
3080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003081run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003082 "$P_SRV psk_list=abc,dead,def,beef" \
3083 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3084 psk_identity=def psk=beef" \
3085 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003086 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003087 -S "SSL - Unknown identity received" \
3088 -S "SSL - Verification of the message MAC failed"
3089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003090run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003091 "$P_SRV psk_list=abc,dead,def,beef" \
3092 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3093 psk_identity=ghi psk=beef" \
3094 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003095 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003096 -s "SSL - Unknown identity received" \
3097 -S "SSL - Verification of the message MAC failed"
3098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003099run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003100 "$P_SRV psk_list=abc,dead,def,beef" \
3101 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3102 psk_identity=abc psk=beef" \
3103 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003104 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003105 -S "SSL - Unknown identity received" \
3106 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003107
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003108# Tests for EC J-PAKE
3109
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003110requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003111run_test "ECJPAKE: client not configured" \
3112 "$P_SRV debug_level=3" \
3113 "$P_CLI debug_level=3" \
3114 0 \
3115 -C "add ciphersuite: c0ff" \
3116 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003117 -S "found ecjpake kkpp extension" \
3118 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003119 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003120 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003121 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003122 -S "None of the common ciphersuites is usable"
3123
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003124requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003125run_test "ECJPAKE: server not configured" \
3126 "$P_SRV debug_level=3" \
3127 "$P_CLI debug_level=3 ecjpake_pw=bla \
3128 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3129 1 \
3130 -c "add ciphersuite: c0ff" \
3131 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003132 -s "found ecjpake kkpp extension" \
3133 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003134 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003135 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003136 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003137 -s "None of the common ciphersuites is usable"
3138
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003139requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003140run_test "ECJPAKE: working, TLS" \
3141 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3142 "$P_CLI debug_level=3 ecjpake_pw=bla \
3143 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003144 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003145 -c "add ciphersuite: c0ff" \
3146 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003147 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003148 -s "found ecjpake kkpp extension" \
3149 -S "skip ecjpake kkpp extension" \
3150 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003151 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003152 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003153 -S "None of the common ciphersuites is usable" \
3154 -S "SSL - Verification of the message MAC failed"
3155
Janos Follath74537a62016-09-02 13:45:28 +01003156server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003157requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003158run_test "ECJPAKE: password mismatch, TLS" \
3159 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3160 "$P_CLI debug_level=3 ecjpake_pw=bad \
3161 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3162 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003163 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003164 -s "SSL - Verification of the message MAC failed"
3165
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003166requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003167run_test "ECJPAKE: working, DTLS" \
3168 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3169 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3170 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3171 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003172 -c "re-using cached ecjpake parameters" \
3173 -S "SSL - Verification of the message MAC failed"
3174
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003175requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003176run_test "ECJPAKE: working, DTLS, no cookie" \
3177 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3178 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3179 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3180 0 \
3181 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003182 -S "SSL - Verification of the message MAC failed"
3183
Janos Follath74537a62016-09-02 13:45:28 +01003184server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003185requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003186run_test "ECJPAKE: password mismatch, DTLS" \
3187 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3188 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3189 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3190 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003191 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003192 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003193
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003194# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003195requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003196run_test "ECJPAKE: working, DTLS, nolog" \
3197 "$P_SRV dtls=1 ecjpake_pw=bla" \
3198 "$P_CLI dtls=1 ecjpake_pw=bla \
3199 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3200 0
3201
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003202# Tests for ciphersuites per version
3203
Janos Follathe2681a42016-03-07 15:57:05 +00003204requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003205run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003206 "$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 +02003207 "$P_CLI force_version=ssl3" \
3208 0 \
3209 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003211run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003212 "$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 +01003213 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003214 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003215 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003216
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003217run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003218 "$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 +02003219 "$P_CLI force_version=tls1_1" \
3220 0 \
3221 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003223run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003224 "$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 +02003225 "$P_CLI force_version=tls1_2" \
3226 0 \
3227 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3228
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003229# Test for ClientHello without extensions
3230
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003231requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003232run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003233 "$P_SRV debug_level=3" \
3234 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3235 0 \
3236 -s "dumping 'client hello extensions' (0 bytes)"
3237
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003238requires_gnutls
3239run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3240 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3241 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3242 0 \
3243 -s "dumping 'client hello extensions' (0 bytes)"
3244
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003245# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003246
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003247run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003248 "$P_SRV" \
3249 "$P_CLI request_size=100" \
3250 0 \
3251 -s "Read from client: 100 bytes read$"
3252
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003253run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003254 "$P_SRV" \
3255 "$P_CLI request_size=500" \
3256 0 \
3257 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003258
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003259# Tests for small packets
3260
Janos Follathe2681a42016-03-07 15:57:05 +00003261requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003262run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003263 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003264 "$P_CLI request_size=1 force_version=ssl3 \
3265 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3266 0 \
3267 -s "Read from client: 1 bytes read"
3268
Janos Follathe2681a42016-03-07 15:57:05 +00003269requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003270run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003271 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003272 "$P_CLI request_size=1 force_version=ssl3 \
3273 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3274 0 \
3275 -s "Read from client: 1 bytes read"
3276
3277run_test "Small packet TLS 1.0 BlockCipher" \
3278 "$P_SRV" \
3279 "$P_CLI request_size=1 force_version=tls1 \
3280 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3281 0 \
3282 -s "Read from client: 1 bytes read"
3283
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003284run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3285 "$P_SRV" \
3286 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3287 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3288 0 \
3289 -s "Read from client: 1 bytes read"
3290
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003291run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3292 "$P_SRV" \
3293 "$P_CLI request_size=1 force_version=tls1 \
3294 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3295 trunc_hmac=1" \
3296 0 \
3297 -s "Read from client: 1 bytes read"
3298
3299run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003300 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003301 "$P_CLI request_size=1 force_version=tls1 \
3302 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3303 trunc_hmac=1" \
3304 0 \
3305 -s "Read from client: 1 bytes read"
3306
3307run_test "Small packet TLS 1.1 BlockCipher" \
3308 "$P_SRV" \
3309 "$P_CLI request_size=1 force_version=tls1_1 \
3310 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3311 0 \
3312 -s "Read from client: 1 bytes read"
3313
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003314run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3315 "$P_SRV" \
3316 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3317 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3318 0 \
3319 -s "Read from client: 1 bytes read"
3320
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003321run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003322 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003323 "$P_CLI request_size=1 force_version=tls1_1 \
3324 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3325 0 \
3326 -s "Read from client: 1 bytes read"
3327
3328run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3329 "$P_SRV" \
3330 "$P_CLI request_size=1 force_version=tls1_1 \
3331 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3332 trunc_hmac=1" \
3333 0 \
3334 -s "Read from client: 1 bytes read"
3335
3336run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003337 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003338 "$P_CLI request_size=1 force_version=tls1_1 \
3339 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3340 trunc_hmac=1" \
3341 0 \
3342 -s "Read from client: 1 bytes read"
3343
3344run_test "Small packet TLS 1.2 BlockCipher" \
3345 "$P_SRV" \
3346 "$P_CLI request_size=1 force_version=tls1_2 \
3347 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3348 0 \
3349 -s "Read from client: 1 bytes read"
3350
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003351run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3352 "$P_SRV" \
3353 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3354 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3355 0 \
3356 -s "Read from client: 1 bytes read"
3357
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003358run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3359 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003360 "$P_CLI request_size=1 force_version=tls1_2 \
3361 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003362 0 \
3363 -s "Read from client: 1 bytes read"
3364
3365run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3366 "$P_SRV" \
3367 "$P_CLI request_size=1 force_version=tls1_2 \
3368 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3369 trunc_hmac=1" \
3370 0 \
3371 -s "Read from client: 1 bytes read"
3372
3373run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003374 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003375 "$P_CLI request_size=1 force_version=tls1_2 \
3376 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3377 0 \
3378 -s "Read from client: 1 bytes read"
3379
3380run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003381 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003382 "$P_CLI request_size=1 force_version=tls1_2 \
3383 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3384 trunc_hmac=1" \
3385 0 \
3386 -s "Read from client: 1 bytes read"
3387
3388run_test "Small packet TLS 1.2 AEAD" \
3389 "$P_SRV" \
3390 "$P_CLI request_size=1 force_version=tls1_2 \
3391 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3392 0 \
3393 -s "Read from client: 1 bytes read"
3394
3395run_test "Small packet TLS 1.2 AEAD shorter tag" \
3396 "$P_SRV" \
3397 "$P_CLI request_size=1 force_version=tls1_2 \
3398 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3399 0 \
3400 -s "Read from client: 1 bytes read"
3401
Janos Follath00efff72016-05-06 13:48:23 +01003402# A test for extensions in SSLv3
3403
3404requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3405run_test "SSLv3 with extensions, server side" \
3406 "$P_SRV min_version=ssl3 debug_level=3" \
3407 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3408 0 \
3409 -S "dumping 'client hello extensions'" \
3410 -S "server hello, total extension length:"
3411
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003412# Test for large packets
3413
Janos Follathe2681a42016-03-07 15:57:05 +00003414requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003415run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003416 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003417 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003418 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3419 0 \
3420 -s "Read from client: 16384 bytes read"
3421
Janos Follathe2681a42016-03-07 15:57:05 +00003422requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003423run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003424 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003425 "$P_CLI request_size=16384 force_version=ssl3 \
3426 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3427 0 \
3428 -s "Read from client: 16384 bytes read"
3429
3430run_test "Large packet TLS 1.0 BlockCipher" \
3431 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003432 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003433 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3434 0 \
3435 -s "Read from client: 16384 bytes read"
3436
3437run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3438 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003439 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003440 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3441 trunc_hmac=1" \
3442 0 \
3443 -s "Read from client: 16384 bytes read"
3444
3445run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003446 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003447 "$P_CLI request_size=16384 force_version=tls1 \
3448 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3449 trunc_hmac=1" \
3450 0 \
3451 -s "Read from client: 16384 bytes read"
3452
3453run_test "Large packet TLS 1.1 BlockCipher" \
3454 "$P_SRV" \
3455 "$P_CLI request_size=16384 force_version=tls1_1 \
3456 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3457 0 \
3458 -s "Read from client: 16384 bytes read"
3459
3460run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003461 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003462 "$P_CLI request_size=16384 force_version=tls1_1 \
3463 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3464 0 \
3465 -s "Read from client: 16384 bytes read"
3466
3467run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3468 "$P_SRV" \
3469 "$P_CLI request_size=16384 force_version=tls1_1 \
3470 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3471 trunc_hmac=1" \
3472 0 \
3473 -s "Read from client: 16384 bytes read"
3474
3475run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003476 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003477 "$P_CLI request_size=16384 force_version=tls1_1 \
3478 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3479 trunc_hmac=1" \
3480 0 \
3481 -s "Read from client: 16384 bytes read"
3482
3483run_test "Large packet TLS 1.2 BlockCipher" \
3484 "$P_SRV" \
3485 "$P_CLI request_size=16384 force_version=tls1_2 \
3486 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3487 0 \
3488 -s "Read from client: 16384 bytes read"
3489
3490run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3491 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003492 "$P_CLI request_size=16384 force_version=tls1_2 \
3493 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003494 0 \
3495 -s "Read from client: 16384 bytes read"
3496
3497run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3498 "$P_SRV" \
3499 "$P_CLI request_size=16384 force_version=tls1_2 \
3500 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3501 trunc_hmac=1" \
3502 0 \
3503 -s "Read from client: 16384 bytes read"
3504
3505run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003506 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003507 "$P_CLI request_size=16384 force_version=tls1_2 \
3508 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3509 0 \
3510 -s "Read from client: 16384 bytes read"
3511
3512run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003513 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003514 "$P_CLI request_size=16384 force_version=tls1_2 \
3515 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3516 trunc_hmac=1" \
3517 0 \
3518 -s "Read from client: 16384 bytes read"
3519
3520run_test "Large packet TLS 1.2 AEAD" \
3521 "$P_SRV" \
3522 "$P_CLI request_size=16384 force_version=tls1_2 \
3523 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3524 0 \
3525 -s "Read from client: 16384 bytes read"
3526
3527run_test "Large packet TLS 1.2 AEAD shorter tag" \
3528 "$P_SRV" \
3529 "$P_CLI request_size=16384 force_version=tls1_2 \
3530 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3531 0 \
3532 -s "Read from client: 16384 bytes read"
3533
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003534# Tests for DTLS HelloVerifyRequest
3535
3536run_test "DTLS cookie: enabled" \
3537 "$P_SRV dtls=1 debug_level=2" \
3538 "$P_CLI dtls=1 debug_level=2" \
3539 0 \
3540 -s "cookie verification failed" \
3541 -s "cookie verification passed" \
3542 -S "cookie verification skipped" \
3543 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003544 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003545 -S "SSL - The requested feature is not available"
3546
3547run_test "DTLS cookie: disabled" \
3548 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3549 "$P_CLI dtls=1 debug_level=2" \
3550 0 \
3551 -S "cookie verification failed" \
3552 -S "cookie verification passed" \
3553 -s "cookie verification skipped" \
3554 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003555 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003556 -S "SSL - The requested feature is not available"
3557
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003558run_test "DTLS cookie: default (failing)" \
3559 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3560 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3561 1 \
3562 -s "cookie verification failed" \
3563 -S "cookie verification passed" \
3564 -S "cookie verification skipped" \
3565 -C "received hello verify request" \
3566 -S "hello verification requested" \
3567 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003568
3569requires_ipv6
3570run_test "DTLS cookie: enabled, IPv6" \
3571 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3572 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3573 0 \
3574 -s "cookie verification failed" \
3575 -s "cookie verification passed" \
3576 -S "cookie verification skipped" \
3577 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003578 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003579 -S "SSL - The requested feature is not available"
3580
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003581run_test "DTLS cookie: enabled, nbio" \
3582 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3583 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3584 0 \
3585 -s "cookie verification failed" \
3586 -s "cookie verification passed" \
3587 -S "cookie verification skipped" \
3588 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003589 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003590 -S "SSL - The requested feature is not available"
3591
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003592# Tests for client reconnecting from the same port with DTLS
3593
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003594not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003595run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003596 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3597 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003598 0 \
3599 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003600 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003601 -S "Client initiated reconnection from same port"
3602
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003603not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003604run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003605 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3606 "$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 +02003607 0 \
3608 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003609 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003610 -s "Client initiated reconnection from same port"
3611
Paul Bakker362689d2016-05-13 10:33:25 +01003612not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3613run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003614 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3615 "$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 +02003616 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003617 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003618 -s "Client initiated reconnection from same port"
3619
Paul Bakker362689d2016-05-13 10:33:25 +01003620only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3621run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3622 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3623 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3624 0 \
3625 -S "The operation timed out" \
3626 -s "Client initiated reconnection from same port"
3627
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003628run_test "DTLS client reconnect from same port: no cookies" \
3629 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003630 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3631 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003632 -s "The operation timed out" \
3633 -S "Client initiated reconnection from same port"
3634
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003635# Tests for various cases of client authentication with DTLS
3636# (focused on handshake flows and message parsing)
3637
3638run_test "DTLS client auth: required" \
3639 "$P_SRV dtls=1 auth_mode=required" \
3640 "$P_CLI dtls=1" \
3641 0 \
3642 -s "Verifying peer X.509 certificate... ok"
3643
3644run_test "DTLS client auth: optional, client has no cert" \
3645 "$P_SRV dtls=1 auth_mode=optional" \
3646 "$P_CLI dtls=1 crt_file=none key_file=none" \
3647 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003648 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003649
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003650run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003651 "$P_SRV dtls=1 auth_mode=none" \
3652 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3653 0 \
3654 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003655 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003656
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003657run_test "DTLS wrong PSK: badmac alert" \
3658 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3659 "$P_CLI dtls=1 psk=abc124" \
3660 1 \
3661 -s "SSL - Verification of the message MAC failed" \
3662 -c "SSL - A fatal alert message was received from our peer"
3663
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003664# Tests for receiving fragmented handshake messages with DTLS
3665
3666requires_gnutls
3667run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3668 "$G_SRV -u --mtu 2048 -a" \
3669 "$P_CLI dtls=1 debug_level=2" \
3670 0 \
3671 -C "found fragmented DTLS handshake message" \
3672 -C "error"
3673
3674requires_gnutls
3675run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3676 "$G_SRV -u --mtu 512" \
3677 "$P_CLI dtls=1 debug_level=2" \
3678 0 \
3679 -c "found fragmented DTLS handshake message" \
3680 -C "error"
3681
3682requires_gnutls
3683run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3684 "$G_SRV -u --mtu 128" \
3685 "$P_CLI dtls=1 debug_level=2" \
3686 0 \
3687 -c "found fragmented DTLS handshake message" \
3688 -C "error"
3689
3690requires_gnutls
3691run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3692 "$G_SRV -u --mtu 128" \
3693 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3694 0 \
3695 -c "found fragmented DTLS handshake message" \
3696 -C "error"
3697
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003698requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003699run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3700 "$G_SRV -u --mtu 256" \
3701 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3702 0 \
3703 -c "found fragmented DTLS handshake message" \
3704 -c "client hello, adding renegotiation extension" \
3705 -c "found renegotiation extension" \
3706 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003707 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003708 -C "error" \
3709 -s "Extra-header:"
3710
3711requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003712run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3713 "$G_SRV -u --mtu 256" \
3714 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3715 0 \
3716 -c "found fragmented DTLS handshake message" \
3717 -c "client hello, adding renegotiation extension" \
3718 -c "found renegotiation extension" \
3719 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003720 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003721 -C "error" \
3722 -s "Extra-header:"
3723
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003724run_test "DTLS reassembly: no fragmentation (openssl server)" \
3725 "$O_SRV -dtls1 -mtu 2048" \
3726 "$P_CLI dtls=1 debug_level=2" \
3727 0 \
3728 -C "found fragmented DTLS handshake message" \
3729 -C "error"
3730
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003731run_test "DTLS reassembly: some fragmentation (openssl server)" \
3732 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003733 "$P_CLI dtls=1 debug_level=2" \
3734 0 \
3735 -c "found fragmented DTLS handshake message" \
3736 -C "error"
3737
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003738run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003739 "$O_SRV -dtls1 -mtu 256" \
3740 "$P_CLI dtls=1 debug_level=2" \
3741 0 \
3742 -c "found fragmented DTLS handshake message" \
3743 -C "error"
3744
3745run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3746 "$O_SRV -dtls1 -mtu 256" \
3747 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3748 0 \
3749 -c "found fragmented DTLS handshake message" \
3750 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003751
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003752# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003753
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003754not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003755run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003756 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003757 "$P_SRV dtls=1 debug_level=2" \
3758 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003759 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003760 -C "replayed record" \
3761 -S "replayed record" \
3762 -C "record from another epoch" \
3763 -S "record from another epoch" \
3764 -C "discarding invalid record" \
3765 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003766 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003767 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003768 -c "HTTP/1.0 200 OK"
3769
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003770not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003771run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003772 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003773 "$P_SRV dtls=1 debug_level=2" \
3774 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003775 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003776 -c "replayed record" \
3777 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003778 -c "discarding invalid record" \
3779 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003780 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003781 -s "Extra-header:" \
3782 -c "HTTP/1.0 200 OK"
3783
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003784run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3785 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003786 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3787 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003788 0 \
3789 -c "replayed record" \
3790 -S "replayed record" \
3791 -c "discarding invalid record" \
3792 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003793 -c "resend" \
3794 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003795 -s "Extra-header:" \
3796 -c "HTTP/1.0 200 OK"
3797
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003798run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003799 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003800 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003801 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003802 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003803 -c "discarding invalid record (mac)" \
3804 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003805 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003806 -c "HTTP/1.0 200 OK" \
3807 -S "too many records with bad MAC" \
3808 -S "Verification of the message MAC failed"
3809
3810run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3811 -p "$P_PXY bad_ad=1" \
3812 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3813 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3814 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003815 -C "discarding invalid record (mac)" \
3816 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003817 -S "Extra-header:" \
3818 -C "HTTP/1.0 200 OK" \
3819 -s "too many records with bad MAC" \
3820 -s "Verification of the message MAC failed"
3821
3822run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3823 -p "$P_PXY bad_ad=1" \
3824 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3825 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3826 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003827 -c "discarding invalid record (mac)" \
3828 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003829 -s "Extra-header:" \
3830 -c "HTTP/1.0 200 OK" \
3831 -S "too many records with bad MAC" \
3832 -S "Verification of the message MAC failed"
3833
3834run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3835 -p "$P_PXY bad_ad=1" \
3836 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3837 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3838 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003839 -c "discarding invalid record (mac)" \
3840 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003841 -s "Extra-header:" \
3842 -c "HTTP/1.0 200 OK" \
3843 -s "too many records with bad MAC" \
3844 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003845
3846run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003847 -p "$P_PXY delay_ccs=1" \
3848 "$P_SRV dtls=1 debug_level=1" \
3849 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003850 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003851 -c "record from another epoch" \
3852 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003853 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003854 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003855 -s "Extra-header:" \
3856 -c "HTTP/1.0 200 OK"
3857
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003858# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003859
Janos Follath74537a62016-09-02 13:45:28 +01003860client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003861run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003862 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003863 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3864 psk=abc123" \
3865 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003866 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3867 0 \
3868 -s "Extra-header:" \
3869 -c "HTTP/1.0 200 OK"
3870
Janos Follath74537a62016-09-02 13:45:28 +01003871client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003872run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3873 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003874 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3875 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003876 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3877 0 \
3878 -s "Extra-header:" \
3879 -c "HTTP/1.0 200 OK"
3880
Janos Follath74537a62016-09-02 13:45:28 +01003881client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003882run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3883 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003884 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3885 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003886 0 \
3887 -s "Extra-header:" \
3888 -c "HTTP/1.0 200 OK"
3889
Janos Follath74537a62016-09-02 13:45:28 +01003890client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003891run_test "DTLS proxy: 3d, FS, client auth" \
3892 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003893 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3894 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003895 0 \
3896 -s "Extra-header:" \
3897 -c "HTTP/1.0 200 OK"
3898
Janos Follath74537a62016-09-02 13:45:28 +01003899client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003900run_test "DTLS proxy: 3d, FS, ticket" \
3901 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003902 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3903 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003904 0 \
3905 -s "Extra-header:" \
3906 -c "HTTP/1.0 200 OK"
3907
Janos Follath74537a62016-09-02 13:45:28 +01003908client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003909run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3910 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003911 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3912 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003913 0 \
3914 -s "Extra-header:" \
3915 -c "HTTP/1.0 200 OK"
3916
Janos Follath74537a62016-09-02 13:45:28 +01003917client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003918run_test "DTLS proxy: 3d, max handshake, nbio" \
3919 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003920 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3921 auth_mode=required" \
3922 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003923 0 \
3924 -s "Extra-header:" \
3925 -c "HTTP/1.0 200 OK"
3926
Janos Follath74537a62016-09-02 13:45:28 +01003927client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003928run_test "DTLS proxy: 3d, min handshake, resumption" \
3929 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3930 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3931 psk=abc123 debug_level=3" \
3932 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3933 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3934 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3935 0 \
3936 -s "a session has been resumed" \
3937 -c "a session has been resumed" \
3938 -s "Extra-header:" \
3939 -c "HTTP/1.0 200 OK"
3940
Janos Follath74537a62016-09-02 13:45:28 +01003941client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003942run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3943 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3944 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3945 psk=abc123 debug_level=3 nbio=2" \
3946 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3947 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3948 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3949 0 \
3950 -s "a session has been resumed" \
3951 -c "a session has been resumed" \
3952 -s "Extra-header:" \
3953 -c "HTTP/1.0 200 OK"
3954
Janos Follath74537a62016-09-02 13:45:28 +01003955client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003956run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003957 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003958 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3959 psk=abc123 renegotiation=1 debug_level=2" \
3960 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3961 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003962 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3963 0 \
3964 -c "=> renegotiate" \
3965 -s "=> renegotiate" \
3966 -s "Extra-header:" \
3967 -c "HTTP/1.0 200 OK"
3968
Janos Follath74537a62016-09-02 13:45:28 +01003969client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003970run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3971 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003972 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3973 psk=abc123 renegotiation=1 debug_level=2" \
3974 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3975 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003976 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3977 0 \
3978 -c "=> renegotiate" \
3979 -s "=> renegotiate" \
3980 -s "Extra-header:" \
3981 -c "HTTP/1.0 200 OK"
3982
Janos Follath74537a62016-09-02 13:45:28 +01003983client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003984run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003985 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003986 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003987 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003988 debug_level=2" \
3989 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003990 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003991 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3992 0 \
3993 -c "=> renegotiate" \
3994 -s "=> renegotiate" \
3995 -s "Extra-header:" \
3996 -c "HTTP/1.0 200 OK"
3997
Janos Follath74537a62016-09-02 13:45:28 +01003998client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003999run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004000 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004001 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004002 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004003 debug_level=2 nbio=2" \
4004 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004005 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004006 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4007 0 \
4008 -c "=> renegotiate" \
4009 -s "=> renegotiate" \
4010 -s "Extra-header:" \
4011 -c "HTTP/1.0 200 OK"
4012
Janos Follath74537a62016-09-02 13:45:28 +01004013client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004014not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004015run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004016 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4017 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004018 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004019 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004020 -c "HTTP/1.0 200 OK"
4021
Janos Follath74537a62016-09-02 13:45:28 +01004022client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004023not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004024run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4025 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4026 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004027 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004028 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004029 -c "HTTP/1.0 200 OK"
4030
Janos Follath74537a62016-09-02 13:45:28 +01004031client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004032not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004033run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4034 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4035 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004036 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004037 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004038 -c "HTTP/1.0 200 OK"
4039
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004040requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004041client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004042not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004043run_test "DTLS proxy: 3d, gnutls server" \
4044 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4045 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004046 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004047 0 \
4048 -s "Extra-header:" \
4049 -c "Extra-header:"
4050
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004051requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004052client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004053not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004054run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4055 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4056 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004057 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004058 0 \
4059 -s "Extra-header:" \
4060 -c "Extra-header:"
4061
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004062requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004063client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004064not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004065run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4066 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4067 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004068 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004069 0 \
4070 -s "Extra-header:" \
4071 -c "Extra-header:"
4072
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004073# Final report
4074
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004075echo "------------------------------------------------------------------------"
4076
4077if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004078 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004079else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004080 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004081fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004082PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004083echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004084
4085exit $FAILS