blob: 8697db922818b45689f4e81e4fee66fc04ae3e6f [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200125# skip next test if the flag is enabled in config.h
126requires_config_disabled() {
127 if grep "^#define $1" $CONFIG_H > /dev/null; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200132# skip next test if OpenSSL doesn't support FALLBACK_SCSV
133requires_openssl_with_fallback_scsv() {
134 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
135 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
136 then
137 OPENSSL_HAS_FBSCSV="YES"
138 else
139 OPENSSL_HAS_FBSCSV="NO"
140 fi
141 fi
142 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
143 SKIP_NEXT="YES"
144 fi
145}
146
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200147# skip next test if GnuTLS isn't available
148requires_gnutls() {
149 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200150 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151 GNUTLS_AVAILABLE="YES"
152 else
153 GNUTLS_AVAILABLE="NO"
154 fi
155 fi
156 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200161# skip next test if IPv6 isn't available on this host
162requires_ipv6() {
163 if [ -z "${HAS_IPV6:-}" ]; then
164 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
165 SRV_PID=$!
166 sleep 1
167 kill $SRV_PID >/dev/null 2>&1
168 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
169 HAS_IPV6="NO"
170 else
171 HAS_IPV6="YES"
172 fi
173 rm -r $SRV_OUT
174 fi
175
176 if [ "$HAS_IPV6" = "NO" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200181# skip the next test if valgrind is in use
182not_with_valgrind() {
183 if [ "$MEMCHECK" -gt 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Paul Bakker362689d2016-05-13 10:33:25 +0100188# skip the next test if valgrind is NOT in use
189only_with_valgrind() {
190 if [ "$MEMCHECK" -eq 0 ]; then
191 SKIP_NEXT="YES"
192 fi
193}
194
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200195# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100196client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200197 CLI_DELAY_FACTOR=$1
198}
199
Janos Follath74537a62016-09-02 13:45:28 +0100200# wait for the given seconds after the client finished in the next test
201server_needs_more_time() {
202 SRV_DELAY_SECONDS=$1
203}
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205# print_name <name>
206print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100207 TESTS=$(( $TESTS + 1 ))
208 LINE=""
209
210 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
211 LINE="$TESTS "
212 fi
213
214 LINE="$LINE$1"
215 printf "$LINE "
216 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100217 for i in `seq 1 $LEN`; do printf '.'; done
218 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100220}
221
222# fail <message>
223fail() {
224 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100225 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200227 mv $SRV_OUT o-srv-${TESTS}.log
228 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if [ -n "$PXY_CMD" ]; then
230 mv $PXY_OUT o-pxy-${TESTS}.log
231 fi
232 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100233
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
235 echo " ! server output:"
236 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200237 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200238 echo " ! client output:"
239 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200240 if [ -n "$PXY_CMD" ]; then
241 echo " ! ========================================================"
242 echo " ! proxy output:"
243 cat o-pxy-${TESTS}.log
244 fi
245 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200246 fi
247
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200248 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249}
250
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251# is_polar <cmd_line>
252is_polar() {
253 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
254}
255
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200256# openssl s_server doesn't have -www with DTLS
257check_osrv_dtls() {
258 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
259 NEEDS_INPUT=1
260 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
261 else
262 NEEDS_INPUT=0
263 fi
264}
265
266# provide input to commands that need it
267provide_input() {
268 if [ $NEEDS_INPUT -eq 0 ]; then
269 return
270 fi
271
272 while true; do
273 echo "HTTP/1.0 200 OK"
274 sleep 1
275 done
276}
277
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100278# has_mem_err <log_file_name>
279has_mem_err() {
280 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
281 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
282 then
283 return 1 # false: does not have errors
284 else
285 return 0 # true: has errors
286 fi
287}
288
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200289# wait for server to start: two versions depending on lsof availability
290wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200291 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200292 START_TIME=$( date +%s )
293 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200294
295 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200296 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200297 while [ $DONE -eq 0 ]; do
298 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
299 then
300 DONE=1
301 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
302 echo "SERVERSTART TIMEOUT"
303 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
304 DONE=1
305 fi
306 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200307 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200308 while [ $DONE -eq 0 ]; do
309 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
310 then
311 DONE=1
312 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
313 echo "SERVERSTART TIMEOUT"
314 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
315 DONE=1
316 fi
317 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200318 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200319 else
320 sleep "$START_DELAY"
321 fi
322}
323
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100324# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100325# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100326# acceptable bounds
327check_server_hello_time() {
328 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100329 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100330 # Get the Unix timestamp for now
331 CUR_TIME=$(date +'%s')
332 THRESHOLD_IN_SECS=300
333
334 # Check if the ServerHello time was printed
335 if [ -z "$SERVER_HELLO_TIME" ]; then
336 return 1
337 fi
338
339 # Check the time in ServerHello is within acceptable bounds
340 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
341 # The time in ServerHello is at least 5 minutes before now
342 return 1
343 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100344 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100345 return 1
346 else
347 return 0
348 fi
349}
350
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200351# wait for client to terminate and set CLI_EXIT
352# must be called right after starting the client
353wait_client_done() {
354 CLI_PID=$!
355
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200356 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
357 CLI_DELAY_FACTOR=1
358
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200359 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200360 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200361
362 wait $CLI_PID
363 CLI_EXIT=$?
364
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200365 kill $DOG_PID >/dev/null 2>&1
366 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200367
368 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100369
370 sleep $SRV_DELAY_SECONDS
371 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200372}
373
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200374# check if the given command uses dtls and sets global variable DTLS
375detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200376 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200377 DTLS=1
378 else
379 DTLS=0
380 fi
381}
382
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200383# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100384# Options: -s pattern pattern that must be present in server output
385# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100386# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100387# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100388# -S pattern pattern that must be absent in server output
389# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100390# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100391# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100392run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100393 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200394 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100396 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
397 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200398 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100399 return
400 fi
401
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100403
Paul Bakkerb7584a52016-05-10 10:50:43 +0100404 # Do we only run numbered tests?
405 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
406 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
407 else
408 SKIP_NEXT="YES"
409 fi
410
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200411 # should we skip?
412 if [ "X$SKIP_NEXT" = "XYES" ]; then
413 SKIP_NEXT="NO"
414 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200415 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200416 return
417 fi
418
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200419 # does this test use a proxy?
420 if [ "X$1" = "X-p" ]; then
421 PXY_CMD="$2"
422 shift 2
423 else
424 PXY_CMD=""
425 fi
426
427 # get commands and client output
428 SRV_CMD="$1"
429 CLI_CMD="$2"
430 CLI_EXPECT="$3"
431 shift 3
432
433 # fix client port
434 if [ -n "$PXY_CMD" ]; then
435 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
436 else
437 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
438 fi
439
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200440 # update DTLS variable
441 detect_dtls "$SRV_CMD"
442
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100443 # prepend valgrind to our commands if active
444 if [ "$MEMCHECK" -gt 0 ]; then
445 if is_polar "$SRV_CMD"; then
446 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
447 fi
448 if is_polar "$CLI_CMD"; then
449 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
450 fi
451 fi
452
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200453 TIMES_LEFT=2
454 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200455 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200456
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200457 # run the commands
458 if [ -n "$PXY_CMD" ]; then
459 echo "$PXY_CMD" > $PXY_OUT
460 $PXY_CMD >> $PXY_OUT 2>&1 &
461 PXY_PID=$!
462 # assume proxy starts faster than server
463 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200464
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200465 check_osrv_dtls
466 echo "$SRV_CMD" > $SRV_OUT
467 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
468 SRV_PID=$!
469 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200470
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200471 echo "$CLI_CMD" > $CLI_OUT
472 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
473 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100474
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200475 # terminate the server (and the proxy)
476 kill $SRV_PID
477 wait $SRV_PID
478 if [ -n "$PXY_CMD" ]; then
479 kill $PXY_PID >/dev/null 2>&1
480 wait $PXY_PID
481 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100482
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200483 # retry only on timeouts
484 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
485 printf "RETRY "
486 else
487 TIMES_LEFT=0
488 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200489 done
490
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100491 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200492 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100493 # expected client exit to incorrectly succeed in case of catastrophic
494 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100495 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200496 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100497 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100498 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100499 return
500 fi
501 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100502 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200503 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100504 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100505 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100506 return
507 fi
508 fi
509
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100510 # check server exit code
511 if [ $? != 0 ]; then
512 fail "server fail"
513 return
514 fi
515
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100516 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100517 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
518 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100519 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200520 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100521 return
522 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100523
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100524 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200525 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100526 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100527 while [ $# -gt 0 ]
528 do
529 case $1 in
530 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100531 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100532 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100533 return
534 fi
535 ;;
536
537 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100538 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100539 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100540 return
541 fi
542 ;;
543
544 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100545 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100546 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100547 return
548 fi
549 ;;
550
551 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100552 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100553 fail "pattern '$2' MUST NOT be present in the Client output"
554 return
555 fi
556 ;;
557
558 # The filtering in the following two options (-u and -U) do the following
559 # - ignore valgrind output
560 # - filter out everything but lines right after the pattern occurances
561 # - keep one of each non-unique line
562 # - count how many lines remain
563 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
564 # if there were no duplicates.
565 "-U")
566 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
567 fail "lines following pattern '$2' must be unique in Server output"
568 return
569 fi
570 ;;
571
572 "-u")
573 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
574 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100575 return
576 fi
577 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100578 "-F")
579 if ! $2 "$SRV_OUT"; then
580 fail "function call to '$2' failed on Server output"
581 return
582 fi
583 ;;
584 "-f")
585 if ! $2 "$CLI_OUT"; then
586 fail "function call to '$2' failed on Client output"
587 return
588 fi
589 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100590
591 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200592 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100593 exit 1
594 esac
595 shift 2
596 done
597
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100598 # check valgrind's results
599 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200600 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100601 fail "Server has memory errors"
602 return
603 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200604 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100605 fail "Client has memory errors"
606 return
607 fi
608 fi
609
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100610 # if we're here, everything is ok
611 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100612 if [ "$PRESERVE_LOGS" -gt 0 ]; then
613 mv $SRV_OUT o-srv-${TESTS}.log
614 mv $CLI_OUT o-cli-${TESTS}.log
615 fi
616
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100618}
619
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100620cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200621 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200622 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
623 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
624 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
625 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100626 exit 1
627}
628
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100629#
630# MAIN
631#
632
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000633if cd $( dirname $0 ); then :; else
634 echo "cd $( dirname $0 ) failed" >&2
635 exit 1
636fi
637
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100638get_options "$@"
639
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100640# sanity checks, avoid an avalanche of errors
641if [ ! -x "$P_SRV" ]; then
642 echo "Command '$P_SRV' is not an executable file"
643 exit 1
644fi
645if [ ! -x "$P_CLI" ]; then
646 echo "Command '$P_CLI' is not an executable file"
647 exit 1
648fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200649if [ ! -x "$P_PXY" ]; then
650 echo "Command '$P_PXY' is not an executable file"
651 exit 1
652fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100653if [ "$MEMCHECK" -gt 0 ]; then
654 if which valgrind >/dev/null 2>&1; then :; else
655 echo "Memcheck not possible. Valgrind not found"
656 exit 1
657 fi
658fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100659if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
660 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100661 exit 1
662fi
663
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200664# used by watchdog
665MAIN_PID="$$"
666
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200667# be more patient with valgrind
668if [ "$MEMCHECK" -gt 0 ]; then
669 START_DELAY=3
670 DOG_DELAY=30
671else
672 START_DELAY=1
673 DOG_DELAY=10
674fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200675CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100676SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200677
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200678# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000679# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200680P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
681P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100682P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200683O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200684O_CLI="$O_CLI -connect localhost:+SRV_PORT"
685G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000686G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200687
Gilles Peskine62469d92017-05-10 10:13:59 +0200688# Allow SHA-1, because many of our test certificates use it
689P_SRV="$P_SRV allow_sha1=1"
690P_CLI="$P_CLI allow_sha1=1"
691
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200692# Also pick a unique name for intermediate files
693SRV_OUT="srv_out.$$"
694CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200695PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200696SESSION="session.$$"
697
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200698SKIP_NEXT="NO"
699
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100700trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100701
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200702# Basic test
703
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200704# Checks that:
705# - things work with all ciphersuites active (used with config-full in all.sh)
706# - the expected (highest security) parameters are selected
707# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200708run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200709 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200710 "$P_CLI" \
711 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200712 -s "Protocol is TLSv1.2" \
713 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
714 -s "client hello v3, signature_algorithm ext: 6" \
715 -s "ECDHE curve: secp521r1" \
716 -S "error" \
717 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200718
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000719run_test "Default, DTLS" \
720 "$P_SRV dtls=1" \
721 "$P_CLI dtls=1" \
722 0 \
723 -s "Protocol is DTLSv1.2" \
724 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
725
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100726# Test current time in ServerHello
727requires_config_enabled MBEDTLS_HAVE_TIME
728run_test "Default, ServerHello contains gmt_unix_time" \
729 "$P_SRV debug_level=3" \
730 "$P_CLI debug_level=3" \
731 0 \
732 -s "Protocol is TLSv1.2" \
733 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
734 -s "client hello v3, signature_algorithm ext: 6" \
735 -s "ECDHE curve: secp521r1" \
736 -S "error" \
737 -C "error" \
738 -f "check_server_hello_time" \
739 -F "check_server_hello_time"
740
Simon Butcher8e004102016-10-14 00:48:33 +0100741# Test for uniqueness of IVs in AEAD ciphersuites
742run_test "Unique IV in GCM" \
743 "$P_SRV exchanges=20 debug_level=4" \
744 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
745 0 \
746 -u "IV used" \
747 -U "IV used"
748
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100749# Tests for rc4 option
750
Simon Butchera410af52016-05-19 22:12:18 +0100751requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100752run_test "RC4: server disabled, client enabled" \
753 "$P_SRV" \
754 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
755 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100756 -s "SSL - The server has no ciphersuites in common"
757
Simon Butchera410af52016-05-19 22:12:18 +0100758requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100759run_test "RC4: server half, client enabled" \
760 "$P_SRV arc4=1" \
761 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
762 1 \
763 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100764
765run_test "RC4: server enabled, client disabled" \
766 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
767 "$P_CLI" \
768 1 \
769 -s "SSL - The server has no ciphersuites in common"
770
771run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100772 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100773 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
774 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100775 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100776 -S "SSL - The server has no ciphersuites in common"
777
Gilles Peskinebc70a182017-05-09 15:59:24 +0200778# Tests for SHA-1 support
779
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200780requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200781run_test "SHA-1 forbidden by default in server certificate" \
782 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
783 "$P_CLI debug_level=2 allow_sha1=0" \
784 1 \
785 -c "The certificate is signed with an unacceptable hash"
786
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200787requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
788run_test "SHA-1 forbidden by default in server certificate" \
789 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
790 "$P_CLI debug_level=2 allow_sha1=0" \
791 0
792
Gilles Peskinebc70a182017-05-09 15:59:24 +0200793run_test "SHA-1 explicitly allowed in server certificate" \
794 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
795 "$P_CLI allow_sha1=1" \
796 0
797
798run_test "SHA-256 allowed by default in server certificate" \
799 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
800 "$P_CLI allow_sha1=0" \
801 0
802
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200803requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200804run_test "SHA-1 forbidden by default in client certificate" \
805 "$P_SRV auth_mode=required allow_sha1=0" \
806 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
807 1 \
808 -s "The certificate is signed with an unacceptable hash"
809
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200810requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
811run_test "SHA-1 forbidden by default in client certificate" \
812 "$P_SRV auth_mode=required allow_sha1=0" \
813 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
814 0
815
Gilles Peskinebc70a182017-05-09 15:59:24 +0200816run_test "SHA-1 explicitly allowed in client certificate" \
817 "$P_SRV auth_mode=required allow_sha1=1" \
818 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
819 0
820
821run_test "SHA-256 allowed by default in client certificate" \
822 "$P_SRV auth_mode=required allow_sha1=0" \
823 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
824 0
825
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100826# Tests for Truncated HMAC extension
827
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100828run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200829 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100830 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100831 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000832 -s "dumping 'expected mac' (20 bytes)" \
833 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100834
Hanno Becker32c55012017-11-10 08:42:54 +0000835requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100836run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200837 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100838 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
839 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100840 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000841 -s "dumping 'expected mac' (20 bytes)" \
842 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100843
Hanno Becker32c55012017-11-10 08:42:54 +0000844requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100845run_test "Truncated HMAC: client enabled, server default" \
846 "$P_SRV debug_level=4" \
847 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
848 trunc_hmac=1" \
849 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000850 -s "dumping 'expected mac' (20 bytes)" \
851 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100852
Hanno Becker32c55012017-11-10 08:42:54 +0000853requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100854run_test "Truncated HMAC: client enabled, server disabled" \
855 "$P_SRV debug_level=4 trunc_hmac=0" \
856 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
857 trunc_hmac=1" \
858 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000859 -s "dumping 'expected mac' (20 bytes)" \
860 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100861
Hanno Becker32c55012017-11-10 08:42:54 +0000862requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000863run_test "Truncated HMAC: client disabled, server enabled" \
864 "$P_SRV debug_level=4 trunc_hmac=1" \
865 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
866 trunc_hmac=0" \
867 0 \
868 -s "dumping 'expected mac' (20 bytes)" \
869 -S "dumping 'expected mac' (10 bytes)"
870
871requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100872run_test "Truncated HMAC: client enabled, server enabled" \
873 "$P_SRV debug_level=4 trunc_hmac=1" \
874 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
875 trunc_hmac=1" \
876 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000877 -S "dumping 'expected mac' (20 bytes)" \
878 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100879
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100880# Tests for Encrypt-then-MAC extension
881
882run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100883 "$P_SRV debug_level=3 \
884 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100885 "$P_CLI debug_level=3" \
886 0 \
887 -c "client hello, adding encrypt_then_mac extension" \
888 -s "found encrypt then mac extension" \
889 -s "server hello, adding encrypt then mac extension" \
890 -c "found encrypt_then_mac extension" \
891 -c "using encrypt then mac" \
892 -s "using encrypt then mac"
893
894run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100895 "$P_SRV debug_level=3 etm=0 \
896 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100897 "$P_CLI debug_level=3 etm=1" \
898 0 \
899 -c "client hello, adding encrypt_then_mac extension" \
900 -s "found encrypt then mac extension" \
901 -S "server hello, adding encrypt then mac extension" \
902 -C "found encrypt_then_mac extension" \
903 -C "using encrypt then mac" \
904 -S "using encrypt then mac"
905
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100906run_test "Encrypt then MAC: client enabled, aead cipher" \
907 "$P_SRV debug_level=3 etm=1 \
908 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
909 "$P_CLI debug_level=3 etm=1" \
910 0 \
911 -c "client hello, adding encrypt_then_mac extension" \
912 -s "found encrypt then mac extension" \
913 -S "server hello, adding encrypt then mac extension" \
914 -C "found encrypt_then_mac extension" \
915 -C "using encrypt then mac" \
916 -S "using encrypt then mac"
917
918run_test "Encrypt then MAC: client enabled, stream cipher" \
919 "$P_SRV debug_level=3 etm=1 \
920 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100921 "$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 +0100922 0 \
923 -c "client hello, adding encrypt_then_mac extension" \
924 -s "found encrypt then mac extension" \
925 -S "server hello, adding encrypt then mac extension" \
926 -C "found encrypt_then_mac extension" \
927 -C "using encrypt then mac" \
928 -S "using encrypt then mac"
929
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100930run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100931 "$P_SRV debug_level=3 etm=1 \
932 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100933 "$P_CLI debug_level=3 etm=0" \
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 SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100944 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100945 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100946 "$P_CLI debug_level=3 force_version=ssl3" \
947 0 \
948 -C "client hello, adding encrypt_then_mac extension" \
949 -S "found encrypt then mac extension" \
950 -S "server hello, adding encrypt then mac extension" \
951 -C "found encrypt_then_mac extension" \
952 -C "using encrypt then mac" \
953 -S "using encrypt then mac"
954
Janos Follathe2681a42016-03-07 15:57:05 +0000955requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100956run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100957 "$P_SRV debug_level=3 force_version=ssl3 \
958 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100959 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100960 0 \
961 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100962 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100963 -S "server hello, adding encrypt then mac extension" \
964 -C "found encrypt_then_mac extension" \
965 -C "using encrypt then mac" \
966 -S "using encrypt then mac"
967
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200968# Tests for Extended Master Secret extension
969
970run_test "Extended Master Secret: default" \
971 "$P_SRV debug_level=3" \
972 "$P_CLI debug_level=3" \
973 0 \
974 -c "client hello, adding extended_master_secret extension" \
975 -s "found extended master secret extension" \
976 -s "server hello, adding extended master secret extension" \
977 -c "found extended_master_secret extension" \
978 -c "using extended master secret" \
979 -s "using extended master secret"
980
981run_test "Extended Master Secret: client enabled, server disabled" \
982 "$P_SRV debug_level=3 extended_ms=0" \
983 "$P_CLI debug_level=3 extended_ms=1" \
984 0 \
985 -c "client hello, adding extended_master_secret extension" \
986 -s "found extended master secret extension" \
987 -S "server hello, adding extended master secret extension" \
988 -C "found extended_master_secret extension" \
989 -C "using extended master secret" \
990 -S "using extended master secret"
991
992run_test "Extended Master Secret: client disabled, server enabled" \
993 "$P_SRV debug_level=3 extended_ms=1" \
994 "$P_CLI debug_level=3 extended_ms=0" \
995 0 \
996 -C "client hello, adding extended_master_secret extension" \
997 -S "found extended master secret extension" \
998 -S "server hello, adding extended master secret extension" \
999 -C "found extended_master_secret extension" \
1000 -C "using extended master secret" \
1001 -S "using extended master secret"
1002
Janos Follathe2681a42016-03-07 15:57:05 +00001003requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001004run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001005 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001006 "$P_CLI debug_level=3 force_version=ssl3" \
1007 0 \
1008 -C "client hello, adding extended_master_secret extension" \
1009 -S "found extended master secret extension" \
1010 -S "server hello, adding extended master secret extension" \
1011 -C "found extended_master_secret extension" \
1012 -C "using extended master secret" \
1013 -S "using extended master secret"
1014
Janos Follathe2681a42016-03-07 15:57:05 +00001015requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001016run_test "Extended Master Secret: client enabled, server SSLv3" \
1017 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001018 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001019 0 \
1020 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001021 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001022 -S "server hello, adding extended master secret extension" \
1023 -C "found extended_master_secret extension" \
1024 -C "using extended master secret" \
1025 -S "using extended master secret"
1026
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001027# Tests for FALLBACK_SCSV
1028
1029run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001030 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001031 "$P_CLI debug_level=3 force_version=tls1_1" \
1032 0 \
1033 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001034 -S "received FALLBACK_SCSV" \
1035 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001036 -C "is a fatal alert message (msg 86)"
1037
1038run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001039 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001040 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1041 0 \
1042 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001043 -S "received FALLBACK_SCSV" \
1044 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001045 -C "is a fatal alert message (msg 86)"
1046
1047run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001048 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001049 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001050 1 \
1051 -c "adding FALLBACK_SCSV" \
1052 -s "received FALLBACK_SCSV" \
1053 -s "inapropriate fallback" \
1054 -c "is a fatal alert message (msg 86)"
1055
1056run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001057 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001058 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001059 0 \
1060 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001061 -s "received FALLBACK_SCSV" \
1062 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001063 -C "is a fatal alert message (msg 86)"
1064
1065requires_openssl_with_fallback_scsv
1066run_test "Fallback SCSV: default, openssl server" \
1067 "$O_SRV" \
1068 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1069 0 \
1070 -C "adding FALLBACK_SCSV" \
1071 -C "is a fatal alert message (msg 86)"
1072
1073requires_openssl_with_fallback_scsv
1074run_test "Fallback SCSV: enabled, openssl server" \
1075 "$O_SRV" \
1076 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1077 1 \
1078 -c "adding FALLBACK_SCSV" \
1079 -c "is a fatal alert message (msg 86)"
1080
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001081requires_openssl_with_fallback_scsv
1082run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001083 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001084 "$O_CLI -tls1_1" \
1085 0 \
1086 -S "received FALLBACK_SCSV" \
1087 -S "inapropriate fallback"
1088
1089requires_openssl_with_fallback_scsv
1090run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001091 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001092 "$O_CLI -tls1_1 -fallback_scsv" \
1093 1 \
1094 -s "received FALLBACK_SCSV" \
1095 -s "inapropriate fallback"
1096
1097requires_openssl_with_fallback_scsv
1098run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001099 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001100 "$O_CLI -fallback_scsv" \
1101 0 \
1102 -s "received FALLBACK_SCSV" \
1103 -S "inapropriate fallback"
1104
Gilles Peskined50177f2017-05-16 17:53:03 +02001105## ClientHello generated with
1106## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1107## then manually twiddling the ciphersuite list.
1108## The ClientHello content is spelled out below as a hex string as
1109## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1110## The expected response is an inappropriate_fallback alert.
1111requires_openssl_with_fallback_scsv
1112run_test "Fallback SCSV: beginning of list" \
1113 "$P_SRV debug_level=2" \
1114 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1115 0 \
1116 -s "received FALLBACK_SCSV" \
1117 -s "inapropriate fallback"
1118
1119requires_openssl_with_fallback_scsv
1120run_test "Fallback SCSV: end of list" \
1121 "$P_SRV debug_level=2" \
1122 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1123 0 \
1124 -s "received FALLBACK_SCSV" \
1125 -s "inapropriate fallback"
1126
1127## Here the expected response is a valid ServerHello prefix, up to the random.
1128requires_openssl_with_fallback_scsv
1129run_test "Fallback SCSV: not in list" \
1130 "$P_SRV debug_level=2" \
1131 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1132 0 \
1133 -S "received FALLBACK_SCSV" \
1134 -S "inapropriate fallback"
1135
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001136# Tests for CBC 1/n-1 record splitting
1137
1138run_test "CBC Record splitting: TLS 1.2, no splitting" \
1139 "$P_SRV" \
1140 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1141 request_size=123 force_version=tls1_2" \
1142 0 \
1143 -s "Read from client: 123 bytes read" \
1144 -S "Read from client: 1 bytes read" \
1145 -S "122 bytes read"
1146
1147run_test "CBC Record splitting: TLS 1.1, no splitting" \
1148 "$P_SRV" \
1149 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1150 request_size=123 force_version=tls1_1" \
1151 0 \
1152 -s "Read from client: 123 bytes read" \
1153 -S "Read from client: 1 bytes read" \
1154 -S "122 bytes read"
1155
1156run_test "CBC Record splitting: TLS 1.0, splitting" \
1157 "$P_SRV" \
1158 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1159 request_size=123 force_version=tls1" \
1160 0 \
1161 -S "Read from client: 123 bytes read" \
1162 -s "Read from client: 1 bytes read" \
1163 -s "122 bytes read"
1164
Janos Follathe2681a42016-03-07 15:57:05 +00001165requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001166run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001167 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001168 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1169 request_size=123 force_version=ssl3" \
1170 0 \
1171 -S "Read from client: 123 bytes read" \
1172 -s "Read from client: 1 bytes read" \
1173 -s "122 bytes read"
1174
1175run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001176 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001177 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1178 request_size=123 force_version=tls1" \
1179 0 \
1180 -s "Read from client: 123 bytes read" \
1181 -S "Read from client: 1 bytes read" \
1182 -S "122 bytes read"
1183
1184run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1185 "$P_SRV" \
1186 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1187 request_size=123 force_version=tls1 recsplit=0" \
1188 0 \
1189 -s "Read from client: 123 bytes read" \
1190 -S "Read from client: 1 bytes read" \
1191 -S "122 bytes read"
1192
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001193run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1194 "$P_SRV nbio=2" \
1195 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1196 request_size=123 force_version=tls1" \
1197 0 \
1198 -S "Read from client: 123 bytes read" \
1199 -s "Read from client: 1 bytes read" \
1200 -s "122 bytes read"
1201
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001202# Tests for Session Tickets
1203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001204run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001205 "$P_SRV debug_level=3 tickets=1" \
1206 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001207 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001208 -c "client hello, adding session ticket extension" \
1209 -s "found session ticket extension" \
1210 -s "server hello, adding session ticket extension" \
1211 -c "found session_ticket extension" \
1212 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001213 -S "session successfully restored from cache" \
1214 -s "session successfully restored from ticket" \
1215 -s "a session has been resumed" \
1216 -c "a session has been resumed"
1217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001218run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001219 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1220 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001221 0 \
1222 -c "client hello, adding session ticket extension" \
1223 -s "found session ticket extension" \
1224 -s "server hello, adding session ticket extension" \
1225 -c "found session_ticket extension" \
1226 -c "parse new session ticket" \
1227 -S "session successfully restored from cache" \
1228 -s "session successfully restored from ticket" \
1229 -s "a session has been resumed" \
1230 -c "a session has been resumed"
1231
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001232run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001233 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1234 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001235 0 \
1236 -c "client hello, adding session ticket extension" \
1237 -s "found session ticket extension" \
1238 -s "server hello, adding session ticket extension" \
1239 -c "found session_ticket extension" \
1240 -c "parse new session ticket" \
1241 -S "session successfully restored from cache" \
1242 -S "session successfully restored from ticket" \
1243 -S "a session has been resumed" \
1244 -C "a session has been resumed"
1245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001246run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001247 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001248 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001249 0 \
1250 -c "client hello, adding session ticket extension" \
1251 -c "found session_ticket extension" \
1252 -c "parse new session ticket" \
1253 -c "a session has been resumed"
1254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001255run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001256 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001257 "( $O_CLI -sess_out $SESSION; \
1258 $O_CLI -sess_in $SESSION; \
1259 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001260 0 \
1261 -s "found session ticket extension" \
1262 -s "server hello, adding session ticket extension" \
1263 -S "session successfully restored from cache" \
1264 -s "session successfully restored from ticket" \
1265 -s "a session has been resumed"
1266
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001267# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001269run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001270 "$P_SRV debug_level=3 tickets=0" \
1271 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001272 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001273 -c "client hello, adding session ticket extension" \
1274 -s "found session ticket extension" \
1275 -S "server hello, adding session ticket extension" \
1276 -C "found session_ticket extension" \
1277 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001278 -s "session successfully restored from cache" \
1279 -S "session successfully restored from ticket" \
1280 -s "a session has been resumed" \
1281 -c "a session has been resumed"
1282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001283run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001284 "$P_SRV debug_level=3 tickets=1" \
1285 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001286 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001287 -C "client hello, adding session ticket extension" \
1288 -S "found session ticket extension" \
1289 -S "server hello, adding session ticket extension" \
1290 -C "found session_ticket extension" \
1291 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001292 -s "session successfully restored from cache" \
1293 -S "session successfully restored from ticket" \
1294 -s "a session has been resumed" \
1295 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001297run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001298 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1299 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001300 0 \
1301 -S "session successfully restored from cache" \
1302 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001303 -S "a session has been resumed" \
1304 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001306run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001307 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1308 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001309 0 \
1310 -s "session successfully restored from cache" \
1311 -S "session successfully restored from ticket" \
1312 -s "a session has been resumed" \
1313 -c "a session has been resumed"
1314
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001315run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001316 "$P_SRV debug_level=3 tickets=0" \
1317 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001318 0 \
1319 -s "session successfully restored from cache" \
1320 -S "session successfully restored from ticket" \
1321 -s "a session has been resumed" \
1322 -c "a session has been resumed"
1323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001324run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001325 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1326 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001327 0 \
1328 -S "session successfully restored from cache" \
1329 -S "session successfully restored from ticket" \
1330 -S "a session has been resumed" \
1331 -C "a session has been resumed"
1332
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001333run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001334 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1335 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001336 0 \
1337 -s "session successfully restored from cache" \
1338 -S "session successfully restored from ticket" \
1339 -s "a session has been resumed" \
1340 -c "a session has been resumed"
1341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001342run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001343 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001344 "( $O_CLI -sess_out $SESSION; \
1345 $O_CLI -sess_in $SESSION; \
1346 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001347 0 \
1348 -s "found session ticket extension" \
1349 -S "server hello, adding session ticket extension" \
1350 -s "session successfully restored from cache" \
1351 -S "session successfully restored from ticket" \
1352 -s "a session has been resumed"
1353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001354run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001355 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001356 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001357 0 \
1358 -C "found session_ticket extension" \
1359 -C "parse new session ticket" \
1360 -c "a session has been resumed"
1361
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001362# Tests for Max Fragment Length extension
1363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001364run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001365 "$P_SRV debug_level=3" \
1366 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001367 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001368 -c "Maximum fragment length is 16384" \
1369 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001370 -C "client hello, adding max_fragment_length extension" \
1371 -S "found max fragment length extension" \
1372 -S "server hello, max_fragment_length extension" \
1373 -C "found max_fragment_length extension"
1374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001376 "$P_SRV debug_level=3" \
1377 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001378 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001379 -c "Maximum fragment length is 4096" \
1380 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001381 -c "client hello, adding max_fragment_length extension" \
1382 -s "found max fragment length extension" \
1383 -s "server hello, max_fragment_length extension" \
1384 -c "found max_fragment_length extension"
1385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001386run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001387 "$P_SRV debug_level=3 max_frag_len=4096" \
1388 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001389 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001390 -c "Maximum fragment length is 16384" \
1391 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001392 -C "client hello, adding max_fragment_length extension" \
1393 -S "found max fragment length extension" \
1394 -S "server hello, max_fragment_length extension" \
1395 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001397requires_gnutls
1398run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001399 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001400 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001401 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001402 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001403 -c "client hello, adding max_fragment_length extension" \
1404 -c "found max_fragment_length extension"
1405
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001406run_test "Max fragment length: client, message just fits" \
1407 "$P_SRV debug_level=3" \
1408 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
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 "2048 bytes written in 1 fragments" \
1417 -s "2048 bytes read"
1418
1419run_test "Max fragment length: client, larger message" \
1420 "$P_SRV debug_level=3" \
1421 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1422 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001423 -c "Maximum fragment length is 2048" \
1424 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001425 -c "client hello, adding max_fragment_length extension" \
1426 -s "found max fragment length extension" \
1427 -s "server hello, max_fragment_length extension" \
1428 -c "found max_fragment_length extension" \
1429 -c "2345 bytes written in 2 fragments" \
1430 -s "2048 bytes read" \
1431 -s "297 bytes read"
1432
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001433run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001434 "$P_SRV debug_level=3 dtls=1" \
1435 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1436 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001437 -c "Maximum fragment length is 2048" \
1438 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001439 -c "client hello, adding max_fragment_length extension" \
1440 -s "found max fragment length extension" \
1441 -s "server hello, max_fragment_length extension" \
1442 -c "found max_fragment_length extension" \
1443 -c "fragment larger than.*maximum"
1444
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001445# Tests for renegotiation
1446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001447run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001448 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001449 "$P_CLI debug_level=3 exchanges=2" \
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: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001461 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001462 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001473run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001474 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001475 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001476 0 \
1477 -c "client hello, adding renegotiation extension" \
1478 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1479 -s "found renegotiation extension" \
1480 -s "server hello, secure renegotiation extension" \
1481 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001482 -c "=> renegotiate" \
1483 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001484 -s "write hello request"
1485
Janos Follathb0f148c2017-10-05 12:29:42 +01001486# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1487# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1488# algorithm stronger than SHA-1 is enabled in config.h
1489run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1490 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1491 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1492 0 \
1493 -c "client hello, adding renegotiation extension" \
1494 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1495 -s "found renegotiation extension" \
1496 -s "server hello, secure renegotiation extension" \
1497 -c "found renegotiation extension" \
1498 -c "=> renegotiate" \
1499 -s "=> renegotiate" \
1500 -S "write hello request" \
1501 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1502
1503# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1504# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1505# algorithm stronger than SHA-1 is enabled in config.h
1506run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1507 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1508 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1509 0 \
1510 -c "client hello, adding renegotiation extension" \
1511 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1512 -s "found renegotiation extension" \
1513 -s "server hello, secure renegotiation extension" \
1514 -c "found renegotiation extension" \
1515 -c "=> renegotiate" \
1516 -s "=> renegotiate" \
1517 -s "write hello request" \
1518 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001520run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001521 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
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 0 \
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é-Gonnard780d6712014-02-20 17:19:59 +01001531 -s "write hello request"
1532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001533run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001534 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001535 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001536 1 \
1537 -c "client hello, adding renegotiation extension" \
1538 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1539 -S "found renegotiation extension" \
1540 -s "server hello, secure renegotiation extension" \
1541 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001542 -c "=> renegotiate" \
1543 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001544 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001545 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001546 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001547
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001548run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001549 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001550 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001551 0 \
1552 -C "client hello, adding renegotiation extension" \
1553 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1554 -S "found renegotiation extension" \
1555 -s "server hello, secure renegotiation extension" \
1556 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001557 -C "=> renegotiate" \
1558 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001559 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001560 -S "SSL - An unexpected message was received from our peer" \
1561 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001563run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001564 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001565 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001566 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001567 0 \
1568 -C "client hello, adding renegotiation extension" \
1569 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1570 -S "found renegotiation extension" \
1571 -s "server hello, secure renegotiation extension" \
1572 -c "found renegotiation extension" \
1573 -C "=> renegotiate" \
1574 -S "=> renegotiate" \
1575 -s "write hello request" \
1576 -S "SSL - An unexpected message was received from our peer" \
1577 -S "failed"
1578
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001579# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001580run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001581 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001582 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001583 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001584 0 \
1585 -C "client hello, adding renegotiation extension" \
1586 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1587 -S "found renegotiation extension" \
1588 -s "server hello, secure renegotiation extension" \
1589 -c "found renegotiation extension" \
1590 -C "=> renegotiate" \
1591 -S "=> renegotiate" \
1592 -s "write hello request" \
1593 -S "SSL - An unexpected message was received from our peer" \
1594 -S "failed"
1595
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001596run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001597 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001598 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001599 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001600 0 \
1601 -C "client hello, adding renegotiation extension" \
1602 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1603 -S "found renegotiation extension" \
1604 -s "server hello, secure renegotiation extension" \
1605 -c "found renegotiation extension" \
1606 -C "=> renegotiate" \
1607 -S "=> renegotiate" \
1608 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001609 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001611run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001612 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001613 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001614 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001615 0 \
1616 -c "client hello, adding renegotiation extension" \
1617 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1618 -s "found renegotiation extension" \
1619 -s "server hello, secure renegotiation extension" \
1620 -c "found renegotiation extension" \
1621 -c "=> renegotiate" \
1622 -s "=> renegotiate" \
1623 -s "write hello request" \
1624 -S "SSL - An unexpected message was received from our peer" \
1625 -S "failed"
1626
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001627run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001628 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001629 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1630 0 \
1631 -C "client hello, adding renegotiation extension" \
1632 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1633 -S "found renegotiation extension" \
1634 -s "server hello, secure renegotiation extension" \
1635 -c "found renegotiation extension" \
1636 -S "record counter limit reached: renegotiate" \
1637 -C "=> renegotiate" \
1638 -S "=> renegotiate" \
1639 -S "write hello request" \
1640 -S "SSL - An unexpected message was received from our peer" \
1641 -S "failed"
1642
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001643# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001644run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001645 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001646 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001647 0 \
1648 -c "client hello, adding renegotiation extension" \
1649 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1650 -s "found renegotiation extension" \
1651 -s "server hello, secure renegotiation extension" \
1652 -c "found renegotiation extension" \
1653 -s "record counter limit reached: renegotiate" \
1654 -c "=> renegotiate" \
1655 -s "=> renegotiate" \
1656 -s "write hello request" \
1657 -S "SSL - An unexpected message was received from our peer" \
1658 -S "failed"
1659
1660run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001661 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001662 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001663 0 \
1664 -c "client hello, adding renegotiation extension" \
1665 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1666 -s "found renegotiation extension" \
1667 -s "server hello, secure renegotiation extension" \
1668 -c "found renegotiation extension" \
1669 -s "record counter limit reached: renegotiate" \
1670 -c "=> renegotiate" \
1671 -s "=> renegotiate" \
1672 -s "write hello request" \
1673 -S "SSL - An unexpected message was received from our peer" \
1674 -S "failed"
1675
1676run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001677 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001678 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1679 0 \
1680 -C "client hello, adding renegotiation extension" \
1681 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1682 -S "found renegotiation extension" \
1683 -s "server hello, secure renegotiation extension" \
1684 -c "found renegotiation extension" \
1685 -S "record counter limit reached: renegotiate" \
1686 -C "=> renegotiate" \
1687 -S "=> renegotiate" \
1688 -S "write hello request" \
1689 -S "SSL - An unexpected message was received from our peer" \
1690 -S "failed"
1691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001692run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001693 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=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 renegotiate=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: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001706 "$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 +02001707 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001708 0 \
1709 -c "client hello, adding renegotiation extension" \
1710 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1711 -s "found renegotiation extension" \
1712 -s "server hello, secure renegotiation extension" \
1713 -c "found renegotiation extension" \
1714 -c "=> renegotiate" \
1715 -s "=> renegotiate" \
1716 -s "write hello request"
1717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001718run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001719 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001720 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001721 0 \
1722 -c "client hello, adding renegotiation extension" \
1723 -c "found renegotiation extension" \
1724 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001725 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001726 -C "error" \
1727 -c "HTTP/1.0 200 [Oo][Kk]"
1728
Paul Bakker539d9722015-02-08 16:18:35 +01001729requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001730run_test "Renegotiation: gnutls server strict, client-initiated" \
1731 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001732 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001733 0 \
1734 -c "client hello, adding renegotiation extension" \
1735 -c "found renegotiation extension" \
1736 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001737 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001738 -C "error" \
1739 -c "HTTP/1.0 200 [Oo][Kk]"
1740
Paul Bakker539d9722015-02-08 16:18:35 +01001741requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001742run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1743 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1744 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
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 no legacy" \
1755 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1756 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1757 allow_legacy=0" \
1758 1 \
1759 -c "client hello, adding renegotiation extension" \
1760 -C "found renegotiation extension" \
1761 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001762 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001763 -c "error" \
1764 -C "HTTP/1.0 200 [Oo][Kk]"
1765
Paul Bakker539d9722015-02-08 16:18:35 +01001766requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001767run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1768 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1769 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1770 allow_legacy=1" \
1771 0 \
1772 -c "client hello, adding renegotiation extension" \
1773 -C "found renegotiation extension" \
1774 -c "=> renegotiate" \
1775 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001776 -C "error" \
1777 -c "HTTP/1.0 200 [Oo][Kk]"
1778
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001779run_test "Renegotiation: DTLS, client-initiated" \
1780 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1781 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1782 0 \
1783 -c "client hello, adding renegotiation extension" \
1784 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1785 -s "found renegotiation extension" \
1786 -s "server hello, secure renegotiation extension" \
1787 -c "found renegotiation extension" \
1788 -c "=> renegotiate" \
1789 -s "=> renegotiate" \
1790 -S "write hello request"
1791
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001792run_test "Renegotiation: DTLS, server-initiated" \
1793 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001794 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1795 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001796 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 -c "found renegotiation extension" \
1802 -c "=> renegotiate" \
1803 -s "=> renegotiate" \
1804 -s "write hello request"
1805
Andres AG692ad842017-01-19 16:30:57 +00001806run_test "Renegotiation: DTLS, renego_period overflow" \
1807 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1808 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1809 0 \
1810 -c "client hello, adding renegotiation extension" \
1811 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1812 -s "found renegotiation extension" \
1813 -s "server hello, secure renegotiation extension" \
1814 -s "record counter limit reached: renegotiate" \
1815 -c "=> renegotiate" \
1816 -s "=> renegotiate" \
1817 -s "write hello request" \
1818
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001819requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001820run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1821 "$G_SRV -u --mtu 4096" \
1822 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1823 0 \
1824 -c "client hello, adding renegotiation extension" \
1825 -c "found renegotiation extension" \
1826 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001827 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001828 -C "error" \
1829 -s "Extra-header:"
1830
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001831# Test for the "secure renegotation" extension only (no actual renegotiation)
1832
Paul Bakker539d9722015-02-08 16:18:35 +01001833requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001834run_test "Renego ext: gnutls server strict, client default" \
1835 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1836 "$P_CLI debug_level=3" \
1837 0 \
1838 -c "found renegotiation extension" \
1839 -C "error" \
1840 -c "HTTP/1.0 200 [Oo][Kk]"
1841
Paul Bakker539d9722015-02-08 16:18:35 +01001842requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001843run_test "Renego ext: gnutls server unsafe, client default" \
1844 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1845 "$P_CLI debug_level=3" \
1846 0 \
1847 -C "found renegotiation extension" \
1848 -C "error" \
1849 -c "HTTP/1.0 200 [Oo][Kk]"
1850
Paul Bakker539d9722015-02-08 16:18:35 +01001851requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001852run_test "Renego ext: gnutls server unsafe, client break legacy" \
1853 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1854 "$P_CLI debug_level=3 allow_legacy=-1" \
1855 1 \
1856 -C "found renegotiation extension" \
1857 -c "error" \
1858 -C "HTTP/1.0 200 [Oo][Kk]"
1859
Paul Bakker539d9722015-02-08 16:18:35 +01001860requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001861run_test "Renego ext: gnutls client strict, server default" \
1862 "$P_SRV debug_level=3" \
1863 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1864 0 \
1865 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1866 -s "server hello, secure renegotiation extension"
1867
Paul Bakker539d9722015-02-08 16:18:35 +01001868requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001869run_test "Renego ext: gnutls client unsafe, server default" \
1870 "$P_SRV debug_level=3" \
1871 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1872 0 \
1873 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1874 -S "server hello, secure renegotiation extension"
1875
Paul Bakker539d9722015-02-08 16:18:35 +01001876requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001877run_test "Renego ext: gnutls client unsafe, server break legacy" \
1878 "$P_SRV debug_level=3 allow_legacy=-1" \
1879 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1880 1 \
1881 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1882 -S "server hello, secure renegotiation extension"
1883
Janos Follath0b242342016-02-17 10:11:21 +00001884# Tests for silently dropping trailing extra bytes in .der certificates
1885
1886requires_gnutls
1887run_test "DER format: no trailing bytes" \
1888 "$P_SRV crt_file=data_files/server5-der0.crt \
1889 key_file=data_files/server5.key" \
1890 "$G_CLI " \
1891 0 \
1892 -c "Handshake was completed" \
1893
1894requires_gnutls
1895run_test "DER format: with a trailing zero byte" \
1896 "$P_SRV crt_file=data_files/server5-der1a.crt \
1897 key_file=data_files/server5.key" \
1898 "$G_CLI " \
1899 0 \
1900 -c "Handshake was completed" \
1901
1902requires_gnutls
1903run_test "DER format: with a trailing random byte" \
1904 "$P_SRV crt_file=data_files/server5-der1b.crt \
1905 key_file=data_files/server5.key" \
1906 "$G_CLI " \
1907 0 \
1908 -c "Handshake was completed" \
1909
1910requires_gnutls
1911run_test "DER format: with 2 trailing random bytes" \
1912 "$P_SRV crt_file=data_files/server5-der2.crt \
1913 key_file=data_files/server5.key" \
1914 "$G_CLI " \
1915 0 \
1916 -c "Handshake was completed" \
1917
1918requires_gnutls
1919run_test "DER format: with 4 trailing random bytes" \
1920 "$P_SRV crt_file=data_files/server5-der4.crt \
1921 key_file=data_files/server5.key" \
1922 "$G_CLI " \
1923 0 \
1924 -c "Handshake was completed" \
1925
1926requires_gnutls
1927run_test "DER format: with 8 trailing random bytes" \
1928 "$P_SRV crt_file=data_files/server5-der8.crt \
1929 key_file=data_files/server5.key" \
1930 "$G_CLI " \
1931 0 \
1932 -c "Handshake was completed" \
1933
1934requires_gnutls
1935run_test "DER format: with 9 trailing random bytes" \
1936 "$P_SRV crt_file=data_files/server5-der9.crt \
1937 key_file=data_files/server5.key" \
1938 "$G_CLI " \
1939 0 \
1940 -c "Handshake was completed" \
1941
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001942# Tests for auth_mode
1943
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001944run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001945 "$P_SRV crt_file=data_files/server5-badsign.crt \
1946 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001947 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001948 1 \
1949 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001950 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001951 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001952 -c "X509 - Certificate verification failed"
1953
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001954run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001955 "$P_SRV crt_file=data_files/server5-badsign.crt \
1956 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001957 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001958 0 \
1959 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001960 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001961 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001962 -C "X509 - Certificate verification failed"
1963
Hanno Beckere6706e62017-05-15 16:05:15 +01001964run_test "Authentication: server goodcert, client optional, no trusted CA" \
1965 "$P_SRV" \
1966 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1967 0 \
1968 -c "x509_verify_cert() returned" \
1969 -c "! The certificate is not correctly signed by the trusted CA" \
1970 -c "! Certificate verification flags"\
1971 -C "! mbedtls_ssl_handshake returned" \
1972 -C "X509 - Certificate verification failed" \
1973 -C "SSL - No CA Chain is set, but required to operate"
1974
1975run_test "Authentication: server goodcert, client required, no trusted CA" \
1976 "$P_SRV" \
1977 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1978 1 \
1979 -c "x509_verify_cert() returned" \
1980 -c "! The certificate is not correctly signed by the trusted CA" \
1981 -c "! Certificate verification flags"\
1982 -c "! mbedtls_ssl_handshake returned" \
1983 -c "SSL - No CA Chain is set, but required to operate"
1984
1985# The purpose of the next two tests is to test the client's behaviour when receiving a server
1986# certificate with an unsupported elliptic curve. This should usually not happen because
1987# the client informs the server about the supported curves - it does, though, in the
1988# corner case of a static ECDH suite, because the server doesn't check the curve on that
1989# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1990# different means to have the server ignoring the client's supported curve list.
1991
1992requires_config_enabled MBEDTLS_ECP_C
1993run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1994 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1995 crt_file=data_files/server5.ku-ka.crt" \
1996 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1997 1 \
1998 -c "bad certificate (EC key curve)"\
1999 -c "! Certificate verification flags"\
2000 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2001
2002requires_config_enabled MBEDTLS_ECP_C
2003run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2004 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2005 crt_file=data_files/server5.ku-ka.crt" \
2006 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2007 1 \
2008 -c "bad certificate (EC key curve)"\
2009 -c "! Certificate verification flags"\
2010 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002012run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002013 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002014 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002015 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002016 0 \
2017 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002018 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002019 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002020 -C "X509 - Certificate verification failed"
2021
Simon Butcher99000142016-10-13 17:21:01 +01002022run_test "Authentication: client SHA256, server required" \
2023 "$P_SRV auth_mode=required" \
2024 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2025 key_file=data_files/server6.key \
2026 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2027 0 \
2028 -c "Supported Signature Algorithm found: 4," \
2029 -c "Supported Signature Algorithm found: 5,"
2030
2031run_test "Authentication: client SHA384, server required" \
2032 "$P_SRV auth_mode=required" \
2033 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2034 key_file=data_files/server6.key \
2035 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2036 0 \
2037 -c "Supported Signature Algorithm found: 4," \
2038 -c "Supported Signature Algorithm found: 5,"
2039
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002040requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2041run_test "Authentication: client has no cert, server required (SSLv3)" \
2042 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2043 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2044 key_file=data_files/server5.key" \
2045 1 \
2046 -S "skip write certificate request" \
2047 -C "skip parse certificate request" \
2048 -c "got a certificate request" \
2049 -c "got no certificate to send" \
2050 -S "x509_verify_cert() returned" \
2051 -s "client has no certificate" \
2052 -s "! mbedtls_ssl_handshake returned" \
2053 -c "! mbedtls_ssl_handshake returned" \
2054 -s "No client certification received from the client, but required by the authentication mode"
2055
2056run_test "Authentication: client has no cert, server required (TLS)" \
2057 "$P_SRV debug_level=3 auth_mode=required" \
2058 "$P_CLI debug_level=3 crt_file=none \
2059 key_file=data_files/server5.key" \
2060 1 \
2061 -S "skip write certificate request" \
2062 -C "skip parse certificate request" \
2063 -c "got a certificate request" \
2064 -c "= write certificate$" \
2065 -C "skip write certificate$" \
2066 -S "x509_verify_cert() returned" \
2067 -s "client has no certificate" \
2068 -s "! mbedtls_ssl_handshake returned" \
2069 -c "! mbedtls_ssl_handshake returned" \
2070 -s "No client certification received from the client, but required by the authentication mode"
2071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002072run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002073 "$P_SRV debug_level=3 auth_mode=required" \
2074 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002075 key_file=data_files/server5.key" \
2076 1 \
2077 -S "skip write certificate request" \
2078 -C "skip parse certificate request" \
2079 -c "got a certificate request" \
2080 -C "skip write certificate" \
2081 -C "skip write certificate verify" \
2082 -S "skip parse certificate verify" \
2083 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002084 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002085 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002086 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002087 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002088 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002089# We don't check that the client receives the alert because it might
2090# detect that its write end of the connection is closed and abort
2091# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002092
Janos Follath89baba22017-04-10 14:34:35 +01002093run_test "Authentication: client cert not trusted, server required" \
2094 "$P_SRV debug_level=3 auth_mode=required" \
2095 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2096 key_file=data_files/server5.key" \
2097 1 \
2098 -S "skip write certificate request" \
2099 -C "skip parse certificate request" \
2100 -c "got a certificate request" \
2101 -C "skip write certificate" \
2102 -C "skip write certificate verify" \
2103 -S "skip parse certificate verify" \
2104 -s "x509_verify_cert() returned" \
2105 -s "! The certificate is not correctly signed by the trusted CA" \
2106 -s "! mbedtls_ssl_handshake returned" \
2107 -c "! mbedtls_ssl_handshake returned" \
2108 -s "X509 - Certificate verification failed"
2109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002110run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002111 "$P_SRV debug_level=3 auth_mode=optional" \
2112 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002113 key_file=data_files/server5.key" \
2114 0 \
2115 -S "skip write certificate request" \
2116 -C "skip parse certificate request" \
2117 -c "got a certificate request" \
2118 -C "skip write certificate" \
2119 -C "skip write certificate verify" \
2120 -S "skip parse certificate verify" \
2121 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002122 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002123 -S "! mbedtls_ssl_handshake returned" \
2124 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002125 -S "X509 - Certificate verification failed"
2126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002127run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002128 "$P_SRV debug_level=3 auth_mode=none" \
2129 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002130 key_file=data_files/server5.key" \
2131 0 \
2132 -s "skip write certificate request" \
2133 -C "skip parse certificate request" \
2134 -c "got no certificate request" \
2135 -c "skip write certificate" \
2136 -c "skip write certificate verify" \
2137 -s "skip parse certificate verify" \
2138 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002139 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002140 -S "! mbedtls_ssl_handshake returned" \
2141 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002142 -S "X509 - Certificate verification failed"
2143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002144run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002145 "$P_SRV debug_level=3 auth_mode=optional" \
2146 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002147 0 \
2148 -S "skip write certificate request" \
2149 -C "skip parse certificate request" \
2150 -c "got a certificate request" \
2151 -C "skip write certificate$" \
2152 -C "got no certificate to send" \
2153 -S "SSLv3 client has no certificate" \
2154 -c "skip write certificate verify" \
2155 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002156 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002157 -S "! mbedtls_ssl_handshake returned" \
2158 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002159 -S "X509 - Certificate verification failed"
2160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002161run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002162 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002163 "$O_CLI" \
2164 0 \
2165 -S "skip write certificate request" \
2166 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002167 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002168 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002169 -S "X509 - Certificate verification failed"
2170
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002171run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002172 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002173 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002174 0 \
2175 -C "skip parse certificate request" \
2176 -c "got a certificate request" \
2177 -C "skip write certificate$" \
2178 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002179 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002180
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002181run_test "Authentication: client no cert, openssl server required" \
2182 "$O_SRV -Verify 10" \
2183 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2184 1 \
2185 -C "skip parse certificate request" \
2186 -c "got a certificate request" \
2187 -C "skip write certificate$" \
2188 -c "skip write certificate verify" \
2189 -c "! mbedtls_ssl_handshake returned"
2190
Janos Follathe2681a42016-03-07 15:57:05 +00002191requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002192run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002193 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002194 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002195 0 \
2196 -S "skip write certificate request" \
2197 -C "skip parse certificate request" \
2198 -c "got a certificate request" \
2199 -C "skip write certificate$" \
2200 -c "skip write certificate verify" \
2201 -c "got no certificate to send" \
2202 -s "SSLv3 client has no certificate" \
2203 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002204 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002205 -S "! mbedtls_ssl_handshake returned" \
2206 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002207 -S "X509 - Certificate verification failed"
2208
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002209# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2210# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002211
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002212MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002213MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002214
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002215if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002216 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002217 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002218 printf "test value of ${MAX_IM_CA}. \n"
2219 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002220 printf "The tests assume this value and if it changes, the tests in this\n"
2221 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002222 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002223
2224 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002225fi
2226
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002227run_test "Authentication: server max_int chain, client default" \
2228 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2229 key_file=data_files/dir-maxpath/09.key" \
2230 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2231 0 \
2232 -C "X509 - A fatal error occured"
2233
2234run_test "Authentication: server max_int+1 chain, client default" \
2235 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2236 key_file=data_files/dir-maxpath/10.key" \
2237 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2238 1 \
2239 -c "X509 - A fatal error occured"
2240
2241run_test "Authentication: server max_int+1 chain, client optional" \
2242 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2243 key_file=data_files/dir-maxpath/10.key" \
2244 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2245 auth_mode=optional" \
2246 1 \
2247 -c "X509 - A fatal error occured"
2248
2249run_test "Authentication: server max_int+1 chain, client none" \
2250 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2251 key_file=data_files/dir-maxpath/10.key" \
2252 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2253 auth_mode=none" \
2254 0 \
2255 -C "X509 - A fatal error occured"
2256
2257run_test "Authentication: client max_int+1 chain, server default" \
2258 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2259 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2260 key_file=data_files/dir-maxpath/10.key" \
2261 0 \
2262 -S "X509 - A fatal error occured"
2263
2264run_test "Authentication: client max_int+1 chain, server optional" \
2265 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2266 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2267 key_file=data_files/dir-maxpath/10.key" \
2268 1 \
2269 -s "X509 - A fatal error occured"
2270
2271run_test "Authentication: client max_int+1 chain, server required" \
2272 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2273 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2274 key_file=data_files/dir-maxpath/10.key" \
2275 1 \
2276 -s "X509 - A fatal error occured"
2277
2278run_test "Authentication: client max_int chain, server required" \
2279 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2280 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2281 key_file=data_files/dir-maxpath/09.key" \
2282 0 \
2283 -S "X509 - A fatal error occured"
2284
Janos Follath89baba22017-04-10 14:34:35 +01002285# Tests for CA list in CertificateRequest messages
2286
2287run_test "Authentication: send CA list in CertificateRequest (default)" \
2288 "$P_SRV debug_level=3 auth_mode=required" \
2289 "$P_CLI crt_file=data_files/server6.crt \
2290 key_file=data_files/server6.key" \
2291 0 \
2292 -s "requested DN"
2293
2294run_test "Authentication: do not send CA list in CertificateRequest" \
2295 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2296 "$P_CLI crt_file=data_files/server6.crt \
2297 key_file=data_files/server6.key" \
2298 0 \
2299 -S "requested DN"
2300
2301run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2302 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2303 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2304 key_file=data_files/server5.key" \
2305 1 \
2306 -S "requested DN" \
2307 -s "x509_verify_cert() returned" \
2308 -s "! The certificate is not correctly signed by the trusted CA" \
2309 -s "! mbedtls_ssl_handshake returned" \
2310 -c "! mbedtls_ssl_handshake returned" \
2311 -s "X509 - Certificate verification failed"
2312
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002313# Tests for certificate selection based on SHA verson
2314
2315run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2316 "$P_SRV crt_file=data_files/server5.crt \
2317 key_file=data_files/server5.key \
2318 crt_file2=data_files/server5-sha1.crt \
2319 key_file2=data_files/server5.key" \
2320 "$P_CLI force_version=tls1_2" \
2321 0 \
2322 -c "signed using.*ECDSA with SHA256" \
2323 -C "signed using.*ECDSA with SHA1"
2324
2325run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2326 "$P_SRV crt_file=data_files/server5.crt \
2327 key_file=data_files/server5.key \
2328 crt_file2=data_files/server5-sha1.crt \
2329 key_file2=data_files/server5.key" \
2330 "$P_CLI force_version=tls1_1" \
2331 0 \
2332 -C "signed using.*ECDSA with SHA256" \
2333 -c "signed using.*ECDSA with SHA1"
2334
2335run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2336 "$P_SRV crt_file=data_files/server5.crt \
2337 key_file=data_files/server5.key \
2338 crt_file2=data_files/server5-sha1.crt \
2339 key_file2=data_files/server5.key" \
2340 "$P_CLI force_version=tls1" \
2341 0 \
2342 -C "signed using.*ECDSA with SHA256" \
2343 -c "signed using.*ECDSA with SHA1"
2344
2345run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2346 "$P_SRV crt_file=data_files/server5.crt \
2347 key_file=data_files/server5.key \
2348 crt_file2=data_files/server6.crt \
2349 key_file2=data_files/server6.key" \
2350 "$P_CLI force_version=tls1_1" \
2351 0 \
2352 -c "serial number.*09" \
2353 -c "signed using.*ECDSA with SHA256" \
2354 -C "signed using.*ECDSA with SHA1"
2355
2356run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2357 "$P_SRV crt_file=data_files/server6.crt \
2358 key_file=data_files/server6.key \
2359 crt_file2=data_files/server5.crt \
2360 key_file2=data_files/server5.key" \
2361 "$P_CLI force_version=tls1_1" \
2362 0 \
2363 -c "serial number.*0A" \
2364 -c "signed using.*ECDSA with SHA256" \
2365 -C "signed using.*ECDSA with SHA1"
2366
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002367# tests for SNI
2368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002369run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002370 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002371 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002372 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002373 0 \
2374 -S "parse ServerName extension" \
2375 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2376 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002378run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002379 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002380 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002381 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 +02002382 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002383 0 \
2384 -s "parse ServerName extension" \
2385 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2386 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002388run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002389 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002390 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002391 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 +02002392 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002393 0 \
2394 -s "parse ServerName extension" \
2395 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2396 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002397
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002398run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002399 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002400 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002401 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 +02002402 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002403 1 \
2404 -s "parse ServerName extension" \
2405 -s "ssl_sni_wrapper() returned" \
2406 -s "mbedtls_ssl_handshake returned" \
2407 -c "mbedtls_ssl_handshake returned" \
2408 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002409
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002410run_test "SNI: client auth no override: optional" \
2411 "$P_SRV debug_level=3 auth_mode=optional \
2412 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2413 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
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: none -> optional" \
2424 "$P_SRV debug_level=3 auth_mode=none \
2425 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2426 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
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 a certificate request" \
2432 -C "skip write certificate" \
2433 -C "skip write certificate verify" \
2434 -S "skip parse certificate verify"
2435
2436run_test "SNI: client auth override: optional -> none" \
2437 "$P_SRV debug_level=3 auth_mode=optional \
2438 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2439 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2440 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002441 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002442 -s "skip write certificate request" \
2443 -C "skip parse certificate request" \
2444 -c "got no certificate request" \
2445 -c "skip write certificate" \
2446 -c "skip write certificate verify" \
2447 -s "skip parse certificate verify"
2448
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002449run_test "SNI: CA no override" \
2450 "$P_SRV debug_level=3 auth_mode=optional \
2451 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2452 ca_file=data_files/test-ca.crt \
2453 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2454 "$P_CLI debug_level=3 server_name=localhost \
2455 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2456 1 \
2457 -S "skip write certificate request" \
2458 -C "skip parse certificate request" \
2459 -c "got a certificate request" \
2460 -C "skip write certificate" \
2461 -C "skip write certificate verify" \
2462 -S "skip parse certificate verify" \
2463 -s "x509_verify_cert() returned" \
2464 -s "! The certificate is not correctly signed by the trusted CA" \
2465 -S "The certificate has been revoked (is on a CRL)"
2466
2467run_test "SNI: CA override" \
2468 "$P_SRV debug_level=3 auth_mode=optional \
2469 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2470 ca_file=data_files/test-ca.crt \
2471 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2472 "$P_CLI debug_level=3 server_name=localhost \
2473 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2474 0 \
2475 -S "skip write certificate request" \
2476 -C "skip parse certificate request" \
2477 -c "got a certificate request" \
2478 -C "skip write certificate" \
2479 -C "skip write certificate verify" \
2480 -S "skip parse certificate verify" \
2481 -S "x509_verify_cert() returned" \
2482 -S "! The certificate is not correctly signed by the trusted CA" \
2483 -S "The certificate has been revoked (is on a CRL)"
2484
2485run_test "SNI: CA override with CRL" \
2486 "$P_SRV debug_level=3 auth_mode=optional \
2487 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2488 ca_file=data_files/test-ca.crt \
2489 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2490 "$P_CLI debug_level=3 server_name=localhost \
2491 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2492 1 \
2493 -S "skip write certificate request" \
2494 -C "skip parse certificate request" \
2495 -c "got a certificate request" \
2496 -C "skip write certificate" \
2497 -C "skip write certificate verify" \
2498 -S "skip parse certificate verify" \
2499 -s "x509_verify_cert() returned" \
2500 -S "! The certificate is not correctly signed by the trusted CA" \
2501 -s "The certificate has been revoked (is on a CRL)"
2502
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002503# Tests for non-blocking I/O: exercise a variety of handshake flows
2504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002505run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002506 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2507 "$P_CLI nbio=2 tickets=0" \
2508 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002509 -S "mbedtls_ssl_handshake returned" \
2510 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002511 -c "Read from server: .* bytes read"
2512
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002513run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002514 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2515 "$P_CLI nbio=2 tickets=0" \
2516 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002517 -S "mbedtls_ssl_handshake returned" \
2518 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002519 -c "Read from server: .* bytes read"
2520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002521run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002522 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2523 "$P_CLI nbio=2 tickets=1" \
2524 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002525 -S "mbedtls_ssl_handshake returned" \
2526 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002527 -c "Read from server: .* bytes read"
2528
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002529run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002530 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2531 "$P_CLI nbio=2 tickets=1" \
2532 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002533 -S "mbedtls_ssl_handshake returned" \
2534 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002535 -c "Read from server: .* bytes read"
2536
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002537run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002538 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2539 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2540 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002541 -S "mbedtls_ssl_handshake returned" \
2542 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002543 -c "Read from server: .* bytes read"
2544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002545run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002546 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2547 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2548 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002549 -S "mbedtls_ssl_handshake returned" \
2550 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002551 -c "Read from server: .* bytes read"
2552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002553run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002554 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2555 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2556 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002557 -S "mbedtls_ssl_handshake returned" \
2558 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002559 -c "Read from server: .* bytes read"
2560
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002561# Tests for version negotiation
2562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002563run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002564 "$P_SRV" \
2565 "$P_CLI" \
2566 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002567 -S "mbedtls_ssl_handshake returned" \
2568 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002569 -s "Protocol is TLSv1.2" \
2570 -c "Protocol is TLSv1.2"
2571
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002572run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002573 "$P_SRV" \
2574 "$P_CLI max_version=tls1_1" \
2575 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002576 -S "mbedtls_ssl_handshake returned" \
2577 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002578 -s "Protocol is TLSv1.1" \
2579 -c "Protocol is TLSv1.1"
2580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002581run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002582 "$P_SRV max_version=tls1_1" \
2583 "$P_CLI" \
2584 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002585 -S "mbedtls_ssl_handshake returned" \
2586 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002587 -s "Protocol is TLSv1.1" \
2588 -c "Protocol is TLSv1.1"
2589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002590run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002591 "$P_SRV max_version=tls1_1" \
2592 "$P_CLI max_version=tls1_1" \
2593 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002594 -S "mbedtls_ssl_handshake returned" \
2595 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002596 -s "Protocol is TLSv1.1" \
2597 -c "Protocol is TLSv1.1"
2598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002599run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002600 "$P_SRV min_version=tls1_1" \
2601 "$P_CLI max_version=tls1_1" \
2602 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002603 -S "mbedtls_ssl_handshake returned" \
2604 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002605 -s "Protocol is TLSv1.1" \
2606 -c "Protocol is TLSv1.1"
2607
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002608run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002609 "$P_SRV max_version=tls1_1" \
2610 "$P_CLI min_version=tls1_1" \
2611 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002612 -S "mbedtls_ssl_handshake returned" \
2613 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002614 -s "Protocol is TLSv1.1" \
2615 -c "Protocol is TLSv1.1"
2616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002617run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002618 "$P_SRV max_version=tls1_1" \
2619 "$P_CLI min_version=tls1_2" \
2620 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002621 -s "mbedtls_ssl_handshake returned" \
2622 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002623 -c "SSL - Handshake protocol not within min/max boundaries"
2624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002625run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002626 "$P_SRV min_version=tls1_2" \
2627 "$P_CLI max_version=tls1_1" \
2628 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002629 -s "mbedtls_ssl_handshake returned" \
2630 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002631 -s "SSL - Handshake protocol not within min/max boundaries"
2632
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002633# Tests for ALPN extension
2634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002635run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002636 "$P_SRV debug_level=3" \
2637 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002638 0 \
2639 -C "client hello, adding alpn extension" \
2640 -S "found alpn extension" \
2641 -C "got an alert message, type: \\[2:120]" \
2642 -S "server hello, adding alpn extension" \
2643 -C "found alpn extension " \
2644 -C "Application Layer Protocol is" \
2645 -S "Application Layer Protocol is"
2646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002647run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002648 "$P_SRV debug_level=3" \
2649 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002650 0 \
2651 -c "client hello, adding alpn extension" \
2652 -s "found alpn extension" \
2653 -C "got an alert message, type: \\[2:120]" \
2654 -S "server hello, adding alpn extension" \
2655 -C "found alpn extension " \
2656 -c "Application Layer Protocol is (none)" \
2657 -S "Application Layer Protocol is"
2658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002659run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002660 "$P_SRV debug_level=3 alpn=abc,1234" \
2661 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002662 0 \
2663 -C "client hello, adding alpn extension" \
2664 -S "found alpn extension" \
2665 -C "got an alert message, type: \\[2:120]" \
2666 -S "server hello, adding alpn extension" \
2667 -C "found alpn extension " \
2668 -C "Application Layer Protocol is" \
2669 -s "Application Layer Protocol is (none)"
2670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002671run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002672 "$P_SRV debug_level=3 alpn=abc,1234" \
2673 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002674 0 \
2675 -c "client hello, adding alpn extension" \
2676 -s "found alpn extension" \
2677 -C "got an alert message, type: \\[2:120]" \
2678 -s "server hello, adding alpn extension" \
2679 -c "found alpn extension" \
2680 -c "Application Layer Protocol is abc" \
2681 -s "Application Layer Protocol is abc"
2682
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002683run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002684 "$P_SRV debug_level=3 alpn=abc,1234" \
2685 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002686 0 \
2687 -c "client hello, adding alpn extension" \
2688 -s "found alpn extension" \
2689 -C "got an alert message, type: \\[2:120]" \
2690 -s "server hello, adding alpn extension" \
2691 -c "found alpn extension" \
2692 -c "Application Layer Protocol is abc" \
2693 -s "Application Layer Protocol is abc"
2694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002695run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002696 "$P_SRV debug_level=3 alpn=abc,1234" \
2697 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002698 0 \
2699 -c "client hello, adding alpn extension" \
2700 -s "found alpn extension" \
2701 -C "got an alert message, type: \\[2:120]" \
2702 -s "server hello, adding alpn extension" \
2703 -c "found alpn extension" \
2704 -c "Application Layer Protocol is 1234" \
2705 -s "Application Layer Protocol is 1234"
2706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002707run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002708 "$P_SRV debug_level=3 alpn=abc,123" \
2709 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002710 1 \
2711 -c "client hello, adding alpn extension" \
2712 -s "found alpn extension" \
2713 -c "got an alert message, type: \\[2:120]" \
2714 -S "server hello, adding alpn extension" \
2715 -C "found alpn extension" \
2716 -C "Application Layer Protocol is 1234" \
2717 -S "Application Layer Protocol is 1234"
2718
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002719
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002720# Tests for keyUsage in leaf certificates, part 1:
2721# server-side certificate/suite selection
2722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002723run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002724 "$P_SRV key_file=data_files/server2.key \
2725 crt_file=data_files/server2.ku-ds.crt" \
2726 "$P_CLI" \
2727 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002728 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002729
2730
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002731run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002732 "$P_SRV key_file=data_files/server2.key \
2733 crt_file=data_files/server2.ku-ke.crt" \
2734 "$P_CLI" \
2735 0 \
2736 -c "Ciphersuite is TLS-RSA-WITH-"
2737
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002738run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002739 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002740 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002741 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002742 1 \
2743 -C "Ciphersuite is "
2744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002745run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002746 "$P_SRV key_file=data_files/server5.key \
2747 crt_file=data_files/server5.ku-ds.crt" \
2748 "$P_CLI" \
2749 0 \
2750 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2751
2752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002753run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002754 "$P_SRV key_file=data_files/server5.key \
2755 crt_file=data_files/server5.ku-ka.crt" \
2756 "$P_CLI" \
2757 0 \
2758 -c "Ciphersuite is TLS-ECDH-"
2759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002760run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002761 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002762 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002763 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002764 1 \
2765 -C "Ciphersuite is "
2766
2767# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002768# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002769
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002770run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002771 "$O_SRV -key data_files/server2.key \
2772 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002773 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002774 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2775 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002776 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002777 -C "Processing of the Certificate handshake message failed" \
2778 -c "Ciphersuite is TLS-"
2779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002780run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002781 "$O_SRV -key data_files/server2.key \
2782 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002783 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002784 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2785 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002786 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002787 -C "Processing of the Certificate handshake message failed" \
2788 -c "Ciphersuite is TLS-"
2789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002790run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002791 "$O_SRV -key data_files/server2.key \
2792 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002793 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002794 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2795 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002796 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002797 -C "Processing of the Certificate handshake message failed" \
2798 -c "Ciphersuite is TLS-"
2799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002800run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002801 "$O_SRV -key data_files/server2.key \
2802 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002803 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002804 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2805 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002806 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002807 -c "Processing of the Certificate handshake message failed" \
2808 -C "Ciphersuite is TLS-"
2809
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002810run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2811 "$O_SRV -key data_files/server2.key \
2812 -cert data_files/server2.ku-ke.crt" \
2813 "$P_CLI debug_level=1 auth_mode=optional \
2814 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2815 0 \
2816 -c "bad certificate (usage extensions)" \
2817 -C "Processing of the Certificate handshake message failed" \
2818 -c "Ciphersuite is TLS-" \
2819 -c "! Usage does not match the keyUsage extension"
2820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002821run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002822 "$O_SRV -key data_files/server2.key \
2823 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002824 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002825 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2826 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002827 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002828 -C "Processing of the Certificate handshake message failed" \
2829 -c "Ciphersuite is TLS-"
2830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002831run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002832 "$O_SRV -key data_files/server2.key \
2833 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002834 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002835 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2836 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002837 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002838 -c "Processing of the Certificate handshake message failed" \
2839 -C "Ciphersuite is TLS-"
2840
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002841run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2842 "$O_SRV -key data_files/server2.key \
2843 -cert data_files/server2.ku-ds.crt" \
2844 "$P_CLI debug_level=1 auth_mode=optional \
2845 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2846 0 \
2847 -c "bad certificate (usage extensions)" \
2848 -C "Processing of the Certificate handshake message failed" \
2849 -c "Ciphersuite is TLS-" \
2850 -c "! Usage does not match the keyUsage extension"
2851
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002852# Tests for keyUsage in leaf certificates, part 3:
2853# server-side checking of client cert
2854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002855run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002856 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002857 "$O_CLI -key data_files/server2.key \
2858 -cert data_files/server2.ku-ds.crt" \
2859 0 \
2860 -S "bad certificate (usage extensions)" \
2861 -S "Processing of the Certificate handshake message failed"
2862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002863run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002864 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002865 "$O_CLI -key data_files/server2.key \
2866 -cert data_files/server2.ku-ke.crt" \
2867 0 \
2868 -s "bad certificate (usage extensions)" \
2869 -S "Processing of the Certificate handshake message failed"
2870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002871run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002872 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002873 "$O_CLI -key data_files/server2.key \
2874 -cert data_files/server2.ku-ke.crt" \
2875 1 \
2876 -s "bad certificate (usage extensions)" \
2877 -s "Processing of the Certificate handshake message failed"
2878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002879run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002880 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002881 "$O_CLI -key data_files/server5.key \
2882 -cert data_files/server5.ku-ds.crt" \
2883 0 \
2884 -S "bad certificate (usage extensions)" \
2885 -S "Processing of the Certificate handshake message failed"
2886
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002887run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002888 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002889 "$O_CLI -key data_files/server5.key \
2890 -cert data_files/server5.ku-ka.crt" \
2891 0 \
2892 -s "bad certificate (usage extensions)" \
2893 -S "Processing of the Certificate handshake message failed"
2894
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002895# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002897run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002898 "$P_SRV key_file=data_files/server5.key \
2899 crt_file=data_files/server5.eku-srv.crt" \
2900 "$P_CLI" \
2901 0
2902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002903run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002904 "$P_SRV key_file=data_files/server5.key \
2905 crt_file=data_files/server5.eku-srv.crt" \
2906 "$P_CLI" \
2907 0
2908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002909run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002910 "$P_SRV key_file=data_files/server5.key \
2911 crt_file=data_files/server5.eku-cs_any.crt" \
2912 "$P_CLI" \
2913 0
2914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002915run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002916 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002917 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002918 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002919 1
2920
2921# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002923run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002924 "$O_SRV -key data_files/server5.key \
2925 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002926 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002927 0 \
2928 -C "bad certificate (usage extensions)" \
2929 -C "Processing of the Certificate handshake message failed" \
2930 -c "Ciphersuite is TLS-"
2931
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002932run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002933 "$O_SRV -key data_files/server5.key \
2934 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002935 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002936 0 \
2937 -C "bad certificate (usage extensions)" \
2938 -C "Processing of the Certificate handshake message failed" \
2939 -c "Ciphersuite is TLS-"
2940
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002941run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002942 "$O_SRV -key data_files/server5.key \
2943 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002944 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002945 0 \
2946 -C "bad certificate (usage extensions)" \
2947 -C "Processing of the Certificate handshake message failed" \
2948 -c "Ciphersuite is TLS-"
2949
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002950run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002951 "$O_SRV -key data_files/server5.key \
2952 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002953 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002954 1 \
2955 -c "bad certificate (usage extensions)" \
2956 -c "Processing of the Certificate handshake message failed" \
2957 -C "Ciphersuite is TLS-"
2958
2959# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002961run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002962 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002963 "$O_CLI -key data_files/server5.key \
2964 -cert data_files/server5.eku-cli.crt" \
2965 0 \
2966 -S "bad certificate (usage extensions)" \
2967 -S "Processing of the Certificate handshake message failed"
2968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002969run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002970 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002971 "$O_CLI -key data_files/server5.key \
2972 -cert data_files/server5.eku-srv_cli.crt" \
2973 0 \
2974 -S "bad certificate (usage extensions)" \
2975 -S "Processing of the Certificate handshake message failed"
2976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002977run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002978 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002979 "$O_CLI -key data_files/server5.key \
2980 -cert data_files/server5.eku-cs_any.crt" \
2981 0 \
2982 -S "bad certificate (usage extensions)" \
2983 -S "Processing of the Certificate handshake message failed"
2984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002985run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002986 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002987 "$O_CLI -key data_files/server5.key \
2988 -cert data_files/server5.eku-cs.crt" \
2989 0 \
2990 -s "bad certificate (usage extensions)" \
2991 -S "Processing of the Certificate handshake message failed"
2992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002993run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002994 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002995 "$O_CLI -key data_files/server5.key \
2996 -cert data_files/server5.eku-cs.crt" \
2997 1 \
2998 -s "bad certificate (usage extensions)" \
2999 -s "Processing of the Certificate handshake message failed"
3000
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003001# Tests for DHM parameters loading
3002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003003run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003004 "$P_SRV" \
3005 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3006 debug_level=3" \
3007 0 \
3008 -c "value of 'DHM: P ' (2048 bits)" \
3009 -c "value of 'DHM: G ' (2048 bits)"
3010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003011run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003012 "$P_SRV dhm_file=data_files/dhparams.pem" \
3013 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3014 debug_level=3" \
3015 0 \
3016 -c "value of 'DHM: P ' (1024 bits)" \
3017 -c "value of 'DHM: G ' (2 bits)"
3018
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003019# Tests for DHM client-side size checking
3020
3021run_test "DHM size: server default, client default, OK" \
3022 "$P_SRV" \
3023 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3024 debug_level=1" \
3025 0 \
3026 -C "DHM prime too short:"
3027
3028run_test "DHM size: server default, client 2048, OK" \
3029 "$P_SRV" \
3030 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3031 debug_level=1 dhmlen=2048" \
3032 0 \
3033 -C "DHM prime too short:"
3034
3035run_test "DHM size: server 1024, client default, OK" \
3036 "$P_SRV dhm_file=data_files/dhparams.pem" \
3037 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3038 debug_level=1" \
3039 0 \
3040 -C "DHM prime too short:"
3041
3042run_test "DHM size: server 1000, client default, rejected" \
3043 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3044 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3045 debug_level=1" \
3046 1 \
3047 -c "DHM prime too short:"
3048
3049run_test "DHM size: server default, client 2049, rejected" \
3050 "$P_SRV" \
3051 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3052 debug_level=1 dhmlen=2049" \
3053 1 \
3054 -c "DHM prime too short:"
3055
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003056# Tests for PSK callback
3057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003058run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003059 "$P_SRV psk=abc123 psk_identity=foo" \
3060 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3061 psk_identity=foo psk=abc123" \
3062 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003063 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003064 -S "SSL - Unknown identity received" \
3065 -S "SSL - Verification of the message MAC failed"
3066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003067run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003068 "$P_SRV" \
3069 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3070 psk_identity=foo psk=abc123" \
3071 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003072 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003073 -S "SSL - Unknown identity received" \
3074 -S "SSL - Verification of the message MAC failed"
3075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003076run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003077 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3078 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3079 psk_identity=foo psk=abc123" \
3080 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003081 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003082 -s "SSL - Unknown identity received" \
3083 -S "SSL - Verification of the message MAC failed"
3084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003085run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003086 "$P_SRV psk_list=abc,dead,def,beef" \
3087 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3088 psk_identity=abc psk=dead" \
3089 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003090 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003091 -S "SSL - Unknown identity received" \
3092 -S "SSL - Verification of the message MAC failed"
3093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003094run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003095 "$P_SRV psk_list=abc,dead,def,beef" \
3096 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3097 psk_identity=def psk=beef" \
3098 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003099 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003100 -S "SSL - Unknown identity received" \
3101 -S "SSL - Verification of the message MAC failed"
3102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003103run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003104 "$P_SRV psk_list=abc,dead,def,beef" \
3105 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3106 psk_identity=ghi psk=beef" \
3107 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003108 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003109 -s "SSL - Unknown identity received" \
3110 -S "SSL - Verification of the message MAC failed"
3111
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003112run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003113 "$P_SRV psk_list=abc,dead,def,beef" \
3114 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3115 psk_identity=abc psk=beef" \
3116 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003117 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003118 -S "SSL - Unknown identity received" \
3119 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003120
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003121# Tests for EC J-PAKE
3122
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003123requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003124run_test "ECJPAKE: client not configured" \
3125 "$P_SRV debug_level=3" \
3126 "$P_CLI debug_level=3" \
3127 0 \
3128 -C "add ciphersuite: c0ff" \
3129 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003130 -S "found ecjpake kkpp extension" \
3131 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003132 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003133 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003134 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003135 -S "None of the common ciphersuites is usable"
3136
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003137requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003138run_test "ECJPAKE: server not configured" \
3139 "$P_SRV debug_level=3" \
3140 "$P_CLI debug_level=3 ecjpake_pw=bla \
3141 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3142 1 \
3143 -c "add ciphersuite: c0ff" \
3144 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003145 -s "found ecjpake kkpp extension" \
3146 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003147 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003148 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003149 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003150 -s "None of the common ciphersuites is usable"
3151
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003152requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003153run_test "ECJPAKE: working, TLS" \
3154 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3155 "$P_CLI debug_level=3 ecjpake_pw=bla \
3156 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003157 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003158 -c "add ciphersuite: c0ff" \
3159 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003160 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003161 -s "found ecjpake kkpp extension" \
3162 -S "skip ecjpake kkpp extension" \
3163 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003164 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003165 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003166 -S "None of the common ciphersuites is usable" \
3167 -S "SSL - Verification of the message MAC failed"
3168
Janos Follath74537a62016-09-02 13:45:28 +01003169server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003170requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003171run_test "ECJPAKE: password mismatch, TLS" \
3172 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3173 "$P_CLI debug_level=3 ecjpake_pw=bad \
3174 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3175 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003176 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003177 -s "SSL - Verification of the message MAC failed"
3178
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003179requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003180run_test "ECJPAKE: working, DTLS" \
3181 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3182 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3183 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3184 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003185 -c "re-using cached ecjpake parameters" \
3186 -S "SSL - Verification of the message MAC failed"
3187
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003188requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003189run_test "ECJPAKE: working, DTLS, no cookie" \
3190 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3191 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3192 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3193 0 \
3194 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003195 -S "SSL - Verification of the message MAC failed"
3196
Janos Follath74537a62016-09-02 13:45:28 +01003197server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003198requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003199run_test "ECJPAKE: password mismatch, DTLS" \
3200 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3201 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3202 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3203 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003204 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003205 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003206
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003207# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003208requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003209run_test "ECJPAKE: working, DTLS, nolog" \
3210 "$P_SRV dtls=1 ecjpake_pw=bla" \
3211 "$P_CLI dtls=1 ecjpake_pw=bla \
3212 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3213 0
3214
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003215# Tests for ciphersuites per version
3216
Janos Follathe2681a42016-03-07 15:57:05 +00003217requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003218run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003219 "$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 +02003220 "$P_CLI force_version=ssl3" \
3221 0 \
3222 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003224run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003225 "$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 +01003226 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003227 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003228 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003229
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003230run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003231 "$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 +02003232 "$P_CLI force_version=tls1_1" \
3233 0 \
3234 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3235
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003236run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003237 "$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 +02003238 "$P_CLI force_version=tls1_2" \
3239 0 \
3240 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3241
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003242# Test for ClientHello without extensions
3243
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003244requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003245run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003246 "$P_SRV debug_level=3" \
3247 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3248 0 \
3249 -s "dumping 'client hello extensions' (0 bytes)"
3250
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003251requires_gnutls
3252run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3253 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3254 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3255 0 \
3256 -s "dumping 'client hello extensions' (0 bytes)"
3257
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003258# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003259
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003260run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003261 "$P_SRV" \
3262 "$P_CLI request_size=100" \
3263 0 \
3264 -s "Read from client: 100 bytes read$"
3265
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003266run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003267 "$P_SRV" \
3268 "$P_CLI request_size=500" \
3269 0 \
3270 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003271
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003272# Tests for small packets
3273
Janos Follathe2681a42016-03-07 15:57:05 +00003274requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003275run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003276 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003277 "$P_CLI request_size=1 force_version=ssl3 \
3278 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3279 0 \
3280 -s "Read from client: 1 bytes read"
3281
Janos Follathe2681a42016-03-07 15:57:05 +00003282requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003283run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003284 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003285 "$P_CLI request_size=1 force_version=ssl3 \
3286 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3287 0 \
3288 -s "Read from client: 1 bytes read"
3289
3290run_test "Small packet TLS 1.0 BlockCipher" \
3291 "$P_SRV" \
3292 "$P_CLI request_size=1 force_version=tls1 \
3293 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3294 0 \
3295 -s "Read from client: 1 bytes read"
3296
Hanno Becker8501f982017-11-10 08:59:04 +00003297run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003298 "$P_SRV" \
3299 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3300 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3301 0 \
3302 -s "Read from client: 1 bytes read"
3303
Hanno Becker32c55012017-11-10 08:42:54 +00003304requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003305run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003306 "$P_SRV" \
3307 "$P_CLI request_size=1 force_version=tls1 \
3308 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3309 trunc_hmac=1" \
3310 0 \
3311 -s "Read from client: 1 bytes read"
3312
Hanno Becker32c55012017-11-10 08:42:54 +00003313requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003314run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
3315 "$P_SRV" \
3316 "$P_CLI request_size=1 force_version=tls1 \
3317 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3318 trunc_hmac=1 \
3319 etm=0" \
3320 0 \
3321 -s "Read from client: 1 bytes read"
3322
3323run_test "Small packet TLS 1.0 StreamCipher" \
3324 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3325 "$P_CLI request_size=1 force_version=tls1 \
3326 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3327 0 \
3328 -s "Read from client: 1 bytes read"
3329
3330run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3331 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3332 "$P_CLI request_size=1 force_version=tls1 \
3333 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3334 etm=0" \
3335 0 \
3336 -s "Read from client: 1 bytes read"
3337
3338requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3339run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003340 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003341 "$P_CLI request_size=1 force_version=tls1 \
3342 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3343 trunc_hmac=1" \
3344 0 \
3345 -s "Read from client: 1 bytes read"
3346
Hanno Becker8501f982017-11-10 08:59:04 +00003347requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3348run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
3349 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3350 "$P_CLI request_size=1 force_version=tls1 \
3351 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3352 trunc_hmac=1 \
3353 etm=0" \
3354 0 \
3355 -s "Read from client: 1 bytes read"
3356
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003357run_test "Small packet TLS 1.1 BlockCipher" \
3358 "$P_SRV" \
3359 "$P_CLI request_size=1 force_version=tls1_1 \
3360 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3361 0 \
3362 -s "Read from client: 1 bytes read"
3363
Hanno Becker8501f982017-11-10 08:59:04 +00003364run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003365 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003366 "$P_CLI request_size=1 force_version=tls1_1 \
3367 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA
3368 etm=0" \
3369 0 \
3370 -s "Read from client: 1 bytes read"
3371
3372requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3373run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
3374 "$P_SRV" \
3375 "$P_CLI request_size=1 force_version=tls1_1 \
3376 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3377 trunc_hmac=1" \
3378 0 \
3379 -s "Read from client: 1 bytes read"
3380
3381requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3382run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
3383 "$P_SRV" \
3384 "$P_CLI request_size=1 force_version=tls1_1 \
3385 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3386 trunc_hmac=1 \
3387 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003388 0 \
3389 -s "Read from client: 1 bytes read"
3390
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003391run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003392 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003393 "$P_CLI request_size=1 force_version=tls1_1 \
3394 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3395 0 \
3396 -s "Read from client: 1 bytes read"
3397
Hanno Becker8501f982017-11-10 08:59:04 +00003398run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3399 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003400 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003401 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3402 etm=0" \
3403 0 \
3404 -s "Read from client: 1 bytes read"
3405
3406requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3407run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
3408 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3409 "$P_CLI request_size=1 force_version=tls1_1 \
3410 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003411 trunc_hmac=1" \
3412 0 \
3413 -s "Read from client: 1 bytes read"
3414
Hanno Becker32c55012017-11-10 08:42:54 +00003415requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003416run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003417 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003418 "$P_CLI request_size=1 force_version=tls1_1 \
3419 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
Hanno Becker8501f982017-11-10 08:59:04 +00003420 trunc_hmac=1 \
3421 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003422 0 \
3423 -s "Read from client: 1 bytes read"
3424
3425run_test "Small packet TLS 1.2 BlockCipher" \
3426 "$P_SRV" \
3427 "$P_CLI request_size=1 force_version=tls1_2 \
3428 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3429 0 \
3430 -s "Read from client: 1 bytes read"
3431
Hanno Becker8501f982017-11-10 08:59:04 +00003432run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003433 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003434 "$P_CLI request_size=1 force_version=tls1_2 \
3435 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3436 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003437 0 \
3438 -s "Read from client: 1 bytes read"
3439
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003440run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3441 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003442 "$P_CLI request_size=1 force_version=tls1_2 \
3443 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003444 0 \
3445 -s "Read from client: 1 bytes read"
3446
Hanno Becker32c55012017-11-10 08:42:54 +00003447requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003448run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003449 "$P_SRV" \
3450 "$P_CLI request_size=1 force_version=tls1_2 \
3451 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3452 trunc_hmac=1" \
3453 0 \
3454 -s "Read from client: 1 bytes read"
3455
Hanno Becker8501f982017-11-10 08:59:04 +00003456requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3457run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
3458 "$P_SRV" \
3459 "$P_CLI request_size=1 force_version=tls1_2 \
3460 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3461 trunc_hmac=1 \
3462 etm=0" \
3463 0 \
3464 -s "Read from client: 1 bytes read"
3465
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003466run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003467 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003468 "$P_CLI request_size=1 force_version=tls1_2 \
3469 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3470 0 \
3471 -s "Read from client: 1 bytes read"
3472
Hanno Becker8501f982017-11-10 08:59:04 +00003473run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
3474 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3475 "$P_CLI request_size=1 force_version=tls1_2 \
3476 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3477 etm=0" \
3478 0 \
3479 -s "Read from client: 1 bytes read"
3480
Hanno Becker32c55012017-11-10 08:42:54 +00003481requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003482run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003483 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003484 "$P_CLI request_size=1 force_version=tls1_2 \
3485 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3486 trunc_hmac=1" \
3487 0 \
3488 -s "Read from client: 1 bytes read"
3489
Hanno Becker8501f982017-11-10 08:59:04 +00003490requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3491run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
3492 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3493 "$P_CLI request_size=1 force_version=tls1_2 \
3494 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3495 trunc_hmac=1 \
3496 etm=0" \
3497 0 \
3498 -s "Read from client: 1 bytes read"
3499
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003500run_test "Small packet TLS 1.2 AEAD" \
3501 "$P_SRV" \
3502 "$P_CLI request_size=1 force_version=tls1_2 \
3503 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3504 0 \
3505 -s "Read from client: 1 bytes read"
3506
3507run_test "Small packet TLS 1.2 AEAD shorter tag" \
3508 "$P_SRV" \
3509 "$P_CLI request_size=1 force_version=tls1_2 \
3510 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3511 0 \
3512 -s "Read from client: 1 bytes read"
3513
Hanno Beckere2148042017-11-10 08:59:18 +00003514# Tests for small packets in DTLS
3515
3516requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3517run_test "Small packet DTLS 1.0" \
3518 "$P_SRV dtls=1 force_version=dtls1" \
3519 "$P_CLI dtls=1 request_size=1 \
3520 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3521 0 \
3522 -s "Read from client: 1 bytes read"
3523
3524requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3525run_test "Small packet DTLS 1.0, without EtM" \
3526 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3527 "$P_CLI dtls=1 request_size=1 \
3528 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3529 0 \
3530 -s "Read from client: 1 bytes read"
3531
3532requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3533requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3534run_test "Small packet DTLS 1.0, truncated hmac" \
3535 "$P_SRV dtls=1 force_version=dtls1" \
3536 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
3537 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3538 0 \
3539 -s "Read from client: 1 bytes read"
3540
3541requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3542requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3543run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
3544 "$P_SRV dtls=1 force_version=dtls1 \
3545 etm=0" \
3546 "$P_CLI dtls=1 request_size=1 \
3547 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3548 trunc_hmac=1"\
3549 0 \
3550 -s "Read from client: 1 bytes read"
3551
3552requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3553run_test "Small packet DTLS 1.2" \
3554 "$P_SRV dtls=1 force_version=dtls1_2" \
3555 "$P_CLI dtls=1 request_size=1 \
3556 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3557 0 \
3558 -s "Read from client: 1 bytes read"
3559
3560requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3561run_test "Small packet DTLS 1.2, without EtM" \
3562 "$P_SRV dtls=1 force_version=dtls1_2 \
3563 etm=0" \
3564 "$P_CLI dtls=1 request_size=1 \
3565 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3566 0 \
3567 -s "Read from client: 1 bytes read"
3568
3569requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3570requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3571run_test "Small packet DTLS 1.2, truncated hmac" \
3572 "$P_SRV dtls=1 force_version=dtls1_2" \
3573 "$P_CLI dtls=1 request_size=1 \
3574 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3575 trunc_hmac=1" \
3576 0 \
3577 -s "Read from client: 1 bytes read"
3578
3579requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3580requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3581run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
3582 "$P_SRV dtls=1 force_version=dtls1_2 \
3583 etm=0" \
3584 "$P_CLI dtls=1 request_size=1 \
3585 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3586 trunc_hmac=1"\
3587 0 \
3588 -s "Read from client: 1 bytes read"
3589
Janos Follath00efff72016-05-06 13:48:23 +01003590# A test for extensions in SSLv3
3591
3592requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3593run_test "SSLv3 with extensions, server side" \
3594 "$P_SRV min_version=ssl3 debug_level=3" \
3595 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3596 0 \
3597 -S "dumping 'client hello extensions'" \
3598 -S "server hello, total extension length:"
3599
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003600# Test for large packets
3601
Janos Follathe2681a42016-03-07 15:57:05 +00003602requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003603run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003604 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003605 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003606 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3607 0 \
3608 -s "Read from client: 16384 bytes read"
3609
Janos Follathe2681a42016-03-07 15:57:05 +00003610requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003611run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003612 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003613 "$P_CLI request_size=16384 force_version=ssl3 \
3614 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3615 0 \
3616 -s "Read from client: 16384 bytes read"
3617
3618run_test "Large packet TLS 1.0 BlockCipher" \
3619 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003620 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003621 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3622 0 \
3623 -s "Read from client: 16384 bytes read"
3624
Hanno Becker278fc7a2017-11-10 09:16:28 +00003625run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
3626 "$P_SRV" \
3627 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3628 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3629 0 \
3630 -s "Read from client: 16384 bytes read"
3631
Hanno Becker32c55012017-11-10 08:42:54 +00003632requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003633run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003634 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003635 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003636 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3637 trunc_hmac=1" \
3638 0 \
3639 -s "Read from client: 16384 bytes read"
3640
Hanno Becker32c55012017-11-10 08:42:54 +00003641requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003642run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
3643 "$P_SRV" \
3644 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3645 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3646 trunc_hmac=1" \
3647 0 \
3648 -s "Read from client: 16384 bytes read"
3649
3650run_test "Large packet TLS 1.0 StreamCipher" \
3651 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3652 "$P_CLI request_size=16384 force_version=tls1 \
3653 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3654 0 \
3655 -s "Read from client: 16384 bytes read"
3656
3657run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3658 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3659 "$P_CLI request_size=16384 force_version=tls1 \
3660 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3661 etm=0" \
3662 0 \
3663 -s "Read from client: 16384 bytes read"
3664
3665requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3666run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003667 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003668 "$P_CLI request_size=16384 force_version=tls1 \
3669 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3670 trunc_hmac=1" \
3671 0 \
3672 -s "Read from client: 16384 bytes read"
3673
Hanno Becker278fc7a2017-11-10 09:16:28 +00003674requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3675run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
3676 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3677 "$P_CLI request_size=16384 force_version=tls1 \
3678 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3679 trunc_hmac=1 etm=0" \
3680 0 \
3681 -s "Read from client: 16384 bytes read"
3682
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003683run_test "Large packet TLS 1.1 BlockCipher" \
3684 "$P_SRV" \
3685 "$P_CLI request_size=16384 force_version=tls1_1 \
3686 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3687 0 \
3688 -s "Read from client: 16384 bytes read"
3689
Hanno Becker278fc7a2017-11-10 09:16:28 +00003690run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3691 "$P_SRV" \
3692 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3693 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003694 0 \
3695 -s "Read from client: 16384 bytes read"
3696
Hanno Becker32c55012017-11-10 08:42:54 +00003697requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003698run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003699 "$P_SRV" \
3700 "$P_CLI request_size=16384 force_version=tls1_1 \
3701 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3702 trunc_hmac=1" \
3703 0 \
3704 -s "Read from client: 16384 bytes read"
3705
Hanno Becker32c55012017-11-10 08:42:54 +00003706requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003707run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
3708 "$P_SRV" \
3709 "$P_CLI request_size=16384 force_version=tls1_1 \
3710 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3711 trunc_hmac=1 etm=0" \
3712 0 \
3713 -s "Read from client: 16384 bytes read"
3714
3715run_test "Large packet TLS 1.1 StreamCipher" \
3716 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3717 "$P_CLI request_size=16384 force_version=tls1_1 \
3718 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3719 0 \
3720 -s "Read from client: 16384 bytes read"
3721
3722run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
3723 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3724 "$P_CLI request_size=16384 force_version=tls1_1 \
3725 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3726 etm=0" \
3727 0 \
3728 -s "Read from client: 16384 bytes read"
3729
3730requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3731run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003732 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003733 "$P_CLI request_size=16384 force_version=tls1_1 \
3734 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3735 trunc_hmac=1" \
3736 0 \
3737 -s "Read from client: 16384 bytes read"
3738
Hanno Becker278fc7a2017-11-10 09:16:28 +00003739requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3740run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
3741 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3742 "$P_CLI request_size=16384 force_version=tls1_1 \
3743 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3744 trunc_hmac=1 etm=0" \
3745 0 \
3746 -s "Read from client: 16384 bytes read"
3747
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003748run_test "Large packet TLS 1.2 BlockCipher" \
3749 "$P_SRV" \
3750 "$P_CLI request_size=16384 force_version=tls1_2 \
3751 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3752 0 \
3753 -s "Read from client: 16384 bytes read"
3754
Hanno Becker278fc7a2017-11-10 09:16:28 +00003755run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
3756 "$P_SRV" \
3757 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
3758 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3759 0 \
3760 -s "Read from client: 16384 bytes read"
3761
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003762run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3763 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003764 "$P_CLI request_size=16384 force_version=tls1_2 \
3765 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003766 0 \
3767 -s "Read from client: 16384 bytes read"
3768
Hanno Becker32c55012017-11-10 08:42:54 +00003769requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003770run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003771 "$P_SRV" \
3772 "$P_CLI request_size=16384 force_version=tls1_2 \
3773 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3774 trunc_hmac=1" \
3775 0 \
3776 -s "Read from client: 16384 bytes read"
3777
Hanno Becker278fc7a2017-11-10 09:16:28 +00003778requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3779run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
3780 "$P_SRV" \
3781 "$P_CLI request_size=16384 force_version=tls1_2 \
3782 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3783 trunc_hmac=1 etm=0" \
3784 0 \
3785 -s "Read from client: 16384 bytes read"
3786
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003787run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003788 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003789 "$P_CLI request_size=16384 force_version=tls1_2 \
3790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3791 0 \
3792 -s "Read from client: 16384 bytes read"
3793
Hanno Becker278fc7a2017-11-10 09:16:28 +00003794run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
3795 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3796 "$P_CLI request_size=16384 force_version=tls1_2 \
3797 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
3798 0 \
3799 -s "Read from client: 16384 bytes read"
3800
Hanno Becker32c55012017-11-10 08:42:54 +00003801requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003802run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003803 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003804 "$P_CLI request_size=16384 force_version=tls1_2 \
3805 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3806 trunc_hmac=1" \
3807 0 \
3808 -s "Read from client: 16384 bytes read"
3809
Hanno Becker278fc7a2017-11-10 09:16:28 +00003810requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3811run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
3812 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3813 "$P_CLI request_size=16384 force_version=tls1_2 \
3814 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3815 trunc_hmac=1 etm=0" \
3816 0 \
3817 -s "Read from client: 16384 bytes read"
3818
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003819run_test "Large packet TLS 1.2 AEAD" \
3820 "$P_SRV" \
3821 "$P_CLI request_size=16384 force_version=tls1_2 \
3822 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3823 0 \
3824 -s "Read from client: 16384 bytes read"
3825
3826run_test "Large packet TLS 1.2 AEAD shorter tag" \
3827 "$P_SRV" \
3828 "$P_CLI request_size=16384 force_version=tls1_2 \
3829 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3830 0 \
3831 -s "Read from client: 16384 bytes read"
3832
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003833# Tests for DTLS HelloVerifyRequest
3834
3835run_test "DTLS cookie: enabled" \
3836 "$P_SRV dtls=1 debug_level=2" \
3837 "$P_CLI dtls=1 debug_level=2" \
3838 0 \
3839 -s "cookie verification failed" \
3840 -s "cookie verification passed" \
3841 -S "cookie verification skipped" \
3842 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003843 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003844 -S "SSL - The requested feature is not available"
3845
3846run_test "DTLS cookie: disabled" \
3847 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3848 "$P_CLI dtls=1 debug_level=2" \
3849 0 \
3850 -S "cookie verification failed" \
3851 -S "cookie verification passed" \
3852 -s "cookie verification skipped" \
3853 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003854 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003855 -S "SSL - The requested feature is not available"
3856
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003857run_test "DTLS cookie: default (failing)" \
3858 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3859 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3860 1 \
3861 -s "cookie verification failed" \
3862 -S "cookie verification passed" \
3863 -S "cookie verification skipped" \
3864 -C "received hello verify request" \
3865 -S "hello verification requested" \
3866 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003867
3868requires_ipv6
3869run_test "DTLS cookie: enabled, IPv6" \
3870 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3871 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3872 0 \
3873 -s "cookie verification failed" \
3874 -s "cookie verification passed" \
3875 -S "cookie verification skipped" \
3876 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003877 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003878 -S "SSL - The requested feature is not available"
3879
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003880run_test "DTLS cookie: enabled, nbio" \
3881 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3882 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3883 0 \
3884 -s "cookie verification failed" \
3885 -s "cookie verification passed" \
3886 -S "cookie verification skipped" \
3887 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003888 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003889 -S "SSL - The requested feature is not available"
3890
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003891# Tests for client reconnecting from the same port with DTLS
3892
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003893not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003894run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003895 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3896 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003897 0 \
3898 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003899 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003900 -S "Client initiated reconnection from same port"
3901
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003902not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003903run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003904 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3905 "$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 +02003906 0 \
3907 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003908 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003909 -s "Client initiated reconnection from same port"
3910
Paul Bakker362689d2016-05-13 10:33:25 +01003911not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3912run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003913 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3914 "$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 +02003915 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003916 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003917 -s "Client initiated reconnection from same port"
3918
Paul Bakker362689d2016-05-13 10:33:25 +01003919only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3920run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3921 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3922 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3923 0 \
3924 -S "The operation timed out" \
3925 -s "Client initiated reconnection from same port"
3926
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003927run_test "DTLS client reconnect from same port: no cookies" \
3928 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003929 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3930 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003931 -s "The operation timed out" \
3932 -S "Client initiated reconnection from same port"
3933
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003934# Tests for various cases of client authentication with DTLS
3935# (focused on handshake flows and message parsing)
3936
3937run_test "DTLS client auth: required" \
3938 "$P_SRV dtls=1 auth_mode=required" \
3939 "$P_CLI dtls=1" \
3940 0 \
3941 -s "Verifying peer X.509 certificate... ok"
3942
3943run_test "DTLS client auth: optional, client has no cert" \
3944 "$P_SRV dtls=1 auth_mode=optional" \
3945 "$P_CLI dtls=1 crt_file=none key_file=none" \
3946 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003947 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003948
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003949run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003950 "$P_SRV dtls=1 auth_mode=none" \
3951 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3952 0 \
3953 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003954 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003955
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003956run_test "DTLS wrong PSK: badmac alert" \
3957 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3958 "$P_CLI dtls=1 psk=abc124" \
3959 1 \
3960 -s "SSL - Verification of the message MAC failed" \
3961 -c "SSL - A fatal alert message was received from our peer"
3962
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003963# Tests for receiving fragmented handshake messages with DTLS
3964
3965requires_gnutls
3966run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3967 "$G_SRV -u --mtu 2048 -a" \
3968 "$P_CLI dtls=1 debug_level=2" \
3969 0 \
3970 -C "found fragmented DTLS handshake message" \
3971 -C "error"
3972
3973requires_gnutls
3974run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3975 "$G_SRV -u --mtu 512" \
3976 "$P_CLI dtls=1 debug_level=2" \
3977 0 \
3978 -c "found fragmented DTLS handshake message" \
3979 -C "error"
3980
3981requires_gnutls
3982run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3983 "$G_SRV -u --mtu 128" \
3984 "$P_CLI dtls=1 debug_level=2" \
3985 0 \
3986 -c "found fragmented DTLS handshake message" \
3987 -C "error"
3988
3989requires_gnutls
3990run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3991 "$G_SRV -u --mtu 128" \
3992 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3993 0 \
3994 -c "found fragmented DTLS handshake message" \
3995 -C "error"
3996
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003997requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003998run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3999 "$G_SRV -u --mtu 256" \
4000 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4001 0 \
4002 -c "found fragmented DTLS handshake message" \
4003 -c "client hello, adding renegotiation extension" \
4004 -c "found renegotiation extension" \
4005 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004006 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004007 -C "error" \
4008 -s "Extra-header:"
4009
4010requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004011run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4012 "$G_SRV -u --mtu 256" \
4013 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4014 0 \
4015 -c "found fragmented DTLS handshake message" \
4016 -c "client hello, adding renegotiation extension" \
4017 -c "found renegotiation extension" \
4018 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004019 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004020 -C "error" \
4021 -s "Extra-header:"
4022
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004023run_test "DTLS reassembly: no fragmentation (openssl server)" \
4024 "$O_SRV -dtls1 -mtu 2048" \
4025 "$P_CLI dtls=1 debug_level=2" \
4026 0 \
4027 -C "found fragmented DTLS handshake message" \
4028 -C "error"
4029
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004030run_test "DTLS reassembly: some fragmentation (openssl server)" \
4031 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004032 "$P_CLI dtls=1 debug_level=2" \
4033 0 \
4034 -c "found fragmented DTLS handshake message" \
4035 -C "error"
4036
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004037run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004038 "$O_SRV -dtls1 -mtu 256" \
4039 "$P_CLI dtls=1 debug_level=2" \
4040 0 \
4041 -c "found fragmented DTLS handshake message" \
4042 -C "error"
4043
4044run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4045 "$O_SRV -dtls1 -mtu 256" \
4046 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4047 0 \
4048 -c "found fragmented DTLS handshake message" \
4049 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004050
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004051# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004052
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004053not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004054run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004055 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004056 "$P_SRV dtls=1 debug_level=2" \
4057 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004058 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004059 -C "replayed record" \
4060 -S "replayed record" \
4061 -C "record from another epoch" \
4062 -S "record from another epoch" \
4063 -C "discarding invalid record" \
4064 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004065 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004066 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004067 -c "HTTP/1.0 200 OK"
4068
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004069not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004070run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004071 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004072 "$P_SRV dtls=1 debug_level=2" \
4073 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004074 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004075 -c "replayed record" \
4076 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004077 -c "discarding invalid record" \
4078 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004079 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004080 -s "Extra-header:" \
4081 -c "HTTP/1.0 200 OK"
4082
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004083run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4084 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004085 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4086 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004087 0 \
4088 -c "replayed record" \
4089 -S "replayed record" \
4090 -c "discarding invalid record" \
4091 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004092 -c "resend" \
4093 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004094 -s "Extra-header:" \
4095 -c "HTTP/1.0 200 OK"
4096
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004097run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004098 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004099 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004100 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004101 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004102 -c "discarding invalid record (mac)" \
4103 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004104 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004105 -c "HTTP/1.0 200 OK" \
4106 -S "too many records with bad MAC" \
4107 -S "Verification of the message MAC failed"
4108
4109run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4110 -p "$P_PXY bad_ad=1" \
4111 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4112 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4113 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004114 -C "discarding invalid record (mac)" \
4115 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004116 -S "Extra-header:" \
4117 -C "HTTP/1.0 200 OK" \
4118 -s "too many records with bad MAC" \
4119 -s "Verification of the message MAC failed"
4120
4121run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4122 -p "$P_PXY bad_ad=1" \
4123 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4124 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4125 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004126 -c "discarding invalid record (mac)" \
4127 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004128 -s "Extra-header:" \
4129 -c "HTTP/1.0 200 OK" \
4130 -S "too many records with bad MAC" \
4131 -S "Verification of the message MAC failed"
4132
4133run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4134 -p "$P_PXY bad_ad=1" \
4135 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4136 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4137 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004138 -c "discarding invalid record (mac)" \
4139 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004140 -s "Extra-header:" \
4141 -c "HTTP/1.0 200 OK" \
4142 -s "too many records with bad MAC" \
4143 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004144
4145run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004146 -p "$P_PXY delay_ccs=1" \
4147 "$P_SRV dtls=1 debug_level=1" \
4148 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004149 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004150 -c "record from another epoch" \
4151 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004152 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004153 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004154 -s "Extra-header:" \
4155 -c "HTTP/1.0 200 OK"
4156
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004157# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004158
Janos Follath74537a62016-09-02 13:45:28 +01004159client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004160run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004161 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004162 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4163 psk=abc123" \
4164 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004165 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4166 0 \
4167 -s "Extra-header:" \
4168 -c "HTTP/1.0 200 OK"
4169
Janos Follath74537a62016-09-02 13:45:28 +01004170client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004171run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4172 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004173 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4174 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004175 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4176 0 \
4177 -s "Extra-header:" \
4178 -c "HTTP/1.0 200 OK"
4179
Janos Follath74537a62016-09-02 13:45:28 +01004180client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004181run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4182 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004183 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4184 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004185 0 \
4186 -s "Extra-header:" \
4187 -c "HTTP/1.0 200 OK"
4188
Janos Follath74537a62016-09-02 13:45:28 +01004189client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004190run_test "DTLS proxy: 3d, FS, client auth" \
4191 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004192 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4193 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004194 0 \
4195 -s "Extra-header:" \
4196 -c "HTTP/1.0 200 OK"
4197
Janos Follath74537a62016-09-02 13:45:28 +01004198client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004199run_test "DTLS proxy: 3d, FS, ticket" \
4200 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004201 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4202 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004203 0 \
4204 -s "Extra-header:" \
4205 -c "HTTP/1.0 200 OK"
4206
Janos Follath74537a62016-09-02 13:45:28 +01004207client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004208run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4209 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004210 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4211 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004212 0 \
4213 -s "Extra-header:" \
4214 -c "HTTP/1.0 200 OK"
4215
Janos Follath74537a62016-09-02 13:45:28 +01004216client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004217run_test "DTLS proxy: 3d, max handshake, nbio" \
4218 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004219 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4220 auth_mode=required" \
4221 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004222 0 \
4223 -s "Extra-header:" \
4224 -c "HTTP/1.0 200 OK"
4225
Janos Follath74537a62016-09-02 13:45:28 +01004226client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004227run_test "DTLS proxy: 3d, min handshake, resumption" \
4228 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4229 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4230 psk=abc123 debug_level=3" \
4231 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4232 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4233 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4234 0 \
4235 -s "a session has been resumed" \
4236 -c "a session has been resumed" \
4237 -s "Extra-header:" \
4238 -c "HTTP/1.0 200 OK"
4239
Janos Follath74537a62016-09-02 13:45:28 +01004240client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004241run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4242 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4243 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4244 psk=abc123 debug_level=3 nbio=2" \
4245 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4246 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4247 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4248 0 \
4249 -s "a session has been resumed" \
4250 -c "a session has been resumed" \
4251 -s "Extra-header:" \
4252 -c "HTTP/1.0 200 OK"
4253
Janos Follath74537a62016-09-02 13:45:28 +01004254client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004255run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004256 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004257 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4258 psk=abc123 renegotiation=1 debug_level=2" \
4259 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4260 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004261 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4262 0 \
4263 -c "=> renegotiate" \
4264 -s "=> renegotiate" \
4265 -s "Extra-header:" \
4266 -c "HTTP/1.0 200 OK"
4267
Janos Follath74537a62016-09-02 13:45:28 +01004268client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004269run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4270 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004271 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4272 psk=abc123 renegotiation=1 debug_level=2" \
4273 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4274 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004275 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4276 0 \
4277 -c "=> renegotiate" \
4278 -s "=> renegotiate" \
4279 -s "Extra-header:" \
4280 -c "HTTP/1.0 200 OK"
4281
Janos Follath74537a62016-09-02 13:45:28 +01004282client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004283run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004284 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004285 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004286 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004287 debug_level=2" \
4288 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004289 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004290 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4291 0 \
4292 -c "=> renegotiate" \
4293 -s "=> renegotiate" \
4294 -s "Extra-header:" \
4295 -c "HTTP/1.0 200 OK"
4296
Janos Follath74537a62016-09-02 13:45:28 +01004297client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004298run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004299 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004300 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004301 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004302 debug_level=2 nbio=2" \
4303 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004304 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004305 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4306 0 \
4307 -c "=> renegotiate" \
4308 -s "=> renegotiate" \
4309 -s "Extra-header:" \
4310 -c "HTTP/1.0 200 OK"
4311
Janos Follath74537a62016-09-02 13:45:28 +01004312client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004313not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004314run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004315 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4316 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004317 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004318 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004319 -c "HTTP/1.0 200 OK"
4320
Janos Follath74537a62016-09-02 13:45:28 +01004321client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004322not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004323run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4324 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4325 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004326 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004327 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004328 -c "HTTP/1.0 200 OK"
4329
Janos Follath74537a62016-09-02 13:45:28 +01004330client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004331not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004332run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4333 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4334 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004335 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004336 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004337 -c "HTTP/1.0 200 OK"
4338
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004339requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004340client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004341not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004342run_test "DTLS proxy: 3d, gnutls server" \
4343 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4344 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004345 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004346 0 \
4347 -s "Extra-header:" \
4348 -c "Extra-header:"
4349
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004350requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004351client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004352not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004353run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4354 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4355 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004356 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004357 0 \
4358 -s "Extra-header:" \
4359 -c "Extra-header:"
4360
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004361requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004362client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004363not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004364run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4365 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4366 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004367 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004368 0 \
4369 -s "Extra-header:" \
4370 -c "Extra-header:"
4371
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004372# Final report
4373
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004374echo "------------------------------------------------------------------------"
4375
4376if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004377 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004378else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004379 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004380fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004381PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004382echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004383
4384exit $FAILS