blob: 0082f6a328ef85d8cb33483ec2caff66f45936f5 [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
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100863run_test "Truncated HMAC: client enabled, 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=1" \
867 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000868 -S "dumping 'expected mac' (20 bytes)" \
869 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100870
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100871# Tests for Encrypt-then-MAC extension
872
873run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100874 "$P_SRV debug_level=3 \
875 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100876 "$P_CLI debug_level=3" \
877 0 \
878 -c "client hello, adding encrypt_then_mac extension" \
879 -s "found encrypt then mac extension" \
880 -s "server hello, adding encrypt then mac extension" \
881 -c "found encrypt_then_mac extension" \
882 -c "using encrypt then mac" \
883 -s "using encrypt then mac"
884
885run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100886 "$P_SRV debug_level=3 etm=0 \
887 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100888 "$P_CLI debug_level=3 etm=1" \
889 0 \
890 -c "client hello, adding encrypt_then_mac extension" \
891 -s "found encrypt then mac extension" \
892 -S "server hello, adding encrypt then mac extension" \
893 -C "found encrypt_then_mac extension" \
894 -C "using encrypt then mac" \
895 -S "using encrypt then mac"
896
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100897run_test "Encrypt then MAC: client enabled, aead cipher" \
898 "$P_SRV debug_level=3 etm=1 \
899 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
900 "$P_CLI debug_level=3 etm=1" \
901 0 \
902 -c "client hello, adding encrypt_then_mac extension" \
903 -s "found encrypt then mac extension" \
904 -S "server hello, adding encrypt then mac extension" \
905 -C "found encrypt_then_mac extension" \
906 -C "using encrypt then mac" \
907 -S "using encrypt then mac"
908
909run_test "Encrypt then MAC: client enabled, stream cipher" \
910 "$P_SRV debug_level=3 etm=1 \
911 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100912 "$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 +0100913 0 \
914 -c "client hello, adding encrypt_then_mac extension" \
915 -s "found encrypt then mac extension" \
916 -S "server hello, adding encrypt then mac extension" \
917 -C "found encrypt_then_mac extension" \
918 -C "using encrypt then mac" \
919 -S "using encrypt then mac"
920
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100921run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100922 "$P_SRV debug_level=3 etm=1 \
923 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100924 "$P_CLI debug_level=3 etm=0" \
925 0 \
926 -C "client hello, adding encrypt_then_mac extension" \
927 -S "found encrypt then mac extension" \
928 -S "server hello, adding encrypt then mac extension" \
929 -C "found encrypt_then_mac extension" \
930 -C "using encrypt then mac" \
931 -S "using encrypt then mac"
932
Janos Follathe2681a42016-03-07 15:57:05 +0000933requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100934run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100935 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100936 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100937 "$P_CLI debug_level=3 force_version=ssl3" \
938 0 \
939 -C "client hello, adding encrypt_then_mac extension" \
940 -S "found encrypt then mac extension" \
941 -S "server hello, adding encrypt then mac extension" \
942 -C "found encrypt_then_mac extension" \
943 -C "using encrypt then mac" \
944 -S "using encrypt then mac"
945
Janos Follathe2681a42016-03-07 15:57:05 +0000946requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100947run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100948 "$P_SRV debug_level=3 force_version=ssl3 \
949 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100950 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100951 0 \
952 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100953 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100954 -S "server hello, adding encrypt then mac extension" \
955 -C "found encrypt_then_mac extension" \
956 -C "using encrypt then mac" \
957 -S "using encrypt then mac"
958
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200959# Tests for Extended Master Secret extension
960
961run_test "Extended Master Secret: default" \
962 "$P_SRV debug_level=3" \
963 "$P_CLI debug_level=3" \
964 0 \
965 -c "client hello, adding extended_master_secret extension" \
966 -s "found extended master secret extension" \
967 -s "server hello, adding extended master secret extension" \
968 -c "found extended_master_secret extension" \
969 -c "using extended master secret" \
970 -s "using extended master secret"
971
972run_test "Extended Master Secret: client enabled, server disabled" \
973 "$P_SRV debug_level=3 extended_ms=0" \
974 "$P_CLI debug_level=3 extended_ms=1" \
975 0 \
976 -c "client hello, adding extended_master_secret extension" \
977 -s "found extended master secret extension" \
978 -S "server hello, adding extended master secret extension" \
979 -C "found extended_master_secret extension" \
980 -C "using extended master secret" \
981 -S "using extended master secret"
982
983run_test "Extended Master Secret: client disabled, server enabled" \
984 "$P_SRV debug_level=3 extended_ms=1" \
985 "$P_CLI debug_level=3 extended_ms=0" \
986 0 \
987 -C "client hello, adding extended_master_secret extension" \
988 -S "found extended master secret extension" \
989 -S "server hello, adding extended master secret extension" \
990 -C "found extended_master_secret extension" \
991 -C "using extended master secret" \
992 -S "using extended master secret"
993
Janos Follathe2681a42016-03-07 15:57:05 +0000994requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200995run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100996 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200997 "$P_CLI debug_level=3 force_version=ssl3" \
998 0 \
999 -C "client hello, adding extended_master_secret extension" \
1000 -S "found extended master secret extension" \
1001 -S "server hello, adding extended master secret extension" \
1002 -C "found extended_master_secret extension" \
1003 -C "using extended master secret" \
1004 -S "using extended master secret"
1005
Janos Follathe2681a42016-03-07 15:57:05 +00001006requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001007run_test "Extended Master Secret: client enabled, server SSLv3" \
1008 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001009 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001010 0 \
1011 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001012 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001013 -S "server hello, adding extended master secret extension" \
1014 -C "found extended_master_secret extension" \
1015 -C "using extended master secret" \
1016 -S "using extended master secret"
1017
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001018# Tests for FALLBACK_SCSV
1019
1020run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001021 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001022 "$P_CLI debug_level=3 force_version=tls1_1" \
1023 0 \
1024 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001025 -S "received FALLBACK_SCSV" \
1026 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001027 -C "is a fatal alert message (msg 86)"
1028
1029run_test "Fallback SCSV: explicitly disabled" \
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 fallback=0" \
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: enabled" \
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=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001041 1 \
1042 -c "adding FALLBACK_SCSV" \
1043 -s "received FALLBACK_SCSV" \
1044 -s "inapropriate fallback" \
1045 -c "is a fatal alert message (msg 86)"
1046
1047run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001048 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001049 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001050 0 \
1051 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001052 -s "received FALLBACK_SCSV" \
1053 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001054 -C "is a fatal alert message (msg 86)"
1055
1056requires_openssl_with_fallback_scsv
1057run_test "Fallback SCSV: default, openssl server" \
1058 "$O_SRV" \
1059 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1060 0 \
1061 -C "adding FALLBACK_SCSV" \
1062 -C "is a fatal alert message (msg 86)"
1063
1064requires_openssl_with_fallback_scsv
1065run_test "Fallback SCSV: enabled, openssl server" \
1066 "$O_SRV" \
1067 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1068 1 \
1069 -c "adding FALLBACK_SCSV" \
1070 -c "is a fatal alert message (msg 86)"
1071
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001072requires_openssl_with_fallback_scsv
1073run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001074 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001075 "$O_CLI -tls1_1" \
1076 0 \
1077 -S "received FALLBACK_SCSV" \
1078 -S "inapropriate fallback"
1079
1080requires_openssl_with_fallback_scsv
1081run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001082 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001083 "$O_CLI -tls1_1 -fallback_scsv" \
1084 1 \
1085 -s "received FALLBACK_SCSV" \
1086 -s "inapropriate fallback"
1087
1088requires_openssl_with_fallback_scsv
1089run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001090 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001091 "$O_CLI -fallback_scsv" \
1092 0 \
1093 -s "received FALLBACK_SCSV" \
1094 -S "inapropriate fallback"
1095
Gilles Peskined50177f2017-05-16 17:53:03 +02001096## ClientHello generated with
1097## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1098## then manually twiddling the ciphersuite list.
1099## The ClientHello content is spelled out below as a hex string as
1100## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1101## The expected response is an inappropriate_fallback alert.
1102requires_openssl_with_fallback_scsv
1103run_test "Fallback SCSV: beginning of list" \
1104 "$P_SRV debug_level=2" \
1105 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1106 0 \
1107 -s "received FALLBACK_SCSV" \
1108 -s "inapropriate fallback"
1109
1110requires_openssl_with_fallback_scsv
1111run_test "Fallback SCSV: end of list" \
1112 "$P_SRV debug_level=2" \
1113 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1114 0 \
1115 -s "received FALLBACK_SCSV" \
1116 -s "inapropriate fallback"
1117
1118## Here the expected response is a valid ServerHello prefix, up to the random.
1119requires_openssl_with_fallback_scsv
1120run_test "Fallback SCSV: not in list" \
1121 "$P_SRV debug_level=2" \
1122 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1123 0 \
1124 -S "received FALLBACK_SCSV" \
1125 -S "inapropriate fallback"
1126
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001127# Tests for CBC 1/n-1 record splitting
1128
1129run_test "CBC Record splitting: TLS 1.2, no splitting" \
1130 "$P_SRV" \
1131 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1132 request_size=123 force_version=tls1_2" \
1133 0 \
1134 -s "Read from client: 123 bytes read" \
1135 -S "Read from client: 1 bytes read" \
1136 -S "122 bytes read"
1137
1138run_test "CBC Record splitting: TLS 1.1, no splitting" \
1139 "$P_SRV" \
1140 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1141 request_size=123 force_version=tls1_1" \
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.0, splitting" \
1148 "$P_SRV" \
1149 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1150 request_size=123 force_version=tls1" \
1151 0 \
1152 -S "Read from client: 123 bytes read" \
1153 -s "Read from client: 1 bytes read" \
1154 -s "122 bytes read"
1155
Janos Follathe2681a42016-03-07 15:57:05 +00001156requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001157run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001158 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001159 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1160 request_size=123 force_version=ssl3" \
1161 0 \
1162 -S "Read from client: 123 bytes read" \
1163 -s "Read from client: 1 bytes read" \
1164 -s "122 bytes read"
1165
1166run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001167 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001168 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1169 request_size=123 force_version=tls1" \
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, splitting disabled" \
1176 "$P_SRV" \
1177 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1178 request_size=123 force_version=tls1 recsplit=0" \
1179 0 \
1180 -s "Read from client: 123 bytes read" \
1181 -S "Read from client: 1 bytes read" \
1182 -S "122 bytes read"
1183
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001184run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1185 "$P_SRV nbio=2" \
1186 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1187 request_size=123 force_version=tls1" \
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é-Gonnard780d6712014-02-20 17:19:59 +01001193# Tests for Session Tickets
1194
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001195run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001196 "$P_SRV debug_level=3 tickets=1" \
1197 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001198 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001199 -c "client hello, adding session ticket extension" \
1200 -s "found session ticket extension" \
1201 -s "server hello, adding session ticket extension" \
1202 -c "found session_ticket extension" \
1203 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001204 -S "session successfully restored from cache" \
1205 -s "session successfully restored from ticket" \
1206 -s "a session has been resumed" \
1207 -c "a session has been resumed"
1208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001209run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001210 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1211 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001212 0 \
1213 -c "client hello, adding session ticket extension" \
1214 -s "found session ticket extension" \
1215 -s "server hello, adding session ticket extension" \
1216 -c "found session_ticket extension" \
1217 -c "parse new session ticket" \
1218 -S "session successfully restored from cache" \
1219 -s "session successfully restored from ticket" \
1220 -s "a session has been resumed" \
1221 -c "a session has been resumed"
1222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001223run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001224 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1225 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001226 0 \
1227 -c "client hello, adding session ticket extension" \
1228 -s "found session ticket extension" \
1229 -s "server hello, adding session ticket extension" \
1230 -c "found session_ticket extension" \
1231 -c "parse new session ticket" \
1232 -S "session successfully restored from cache" \
1233 -S "session successfully restored from ticket" \
1234 -S "a session has been resumed" \
1235 -C "a session has been resumed"
1236
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001237run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001238 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001239 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001240 0 \
1241 -c "client hello, adding session ticket extension" \
1242 -c "found session_ticket extension" \
1243 -c "parse new session ticket" \
1244 -c "a session has been resumed"
1245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001246run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001247 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001248 "( $O_CLI -sess_out $SESSION; \
1249 $O_CLI -sess_in $SESSION; \
1250 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001251 0 \
1252 -s "found session ticket extension" \
1253 -s "server hello, adding session ticket extension" \
1254 -S "session successfully restored from cache" \
1255 -s "session successfully restored from ticket" \
1256 -s "a session has been resumed"
1257
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001258# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001259
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001260run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001261 "$P_SRV debug_level=3 tickets=0" \
1262 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001263 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001264 -c "client hello, adding session ticket extension" \
1265 -s "found session ticket extension" \
1266 -S "server hello, adding session ticket extension" \
1267 -C "found session_ticket extension" \
1268 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001269 -s "session successfully restored from cache" \
1270 -S "session successfully restored from ticket" \
1271 -s "a session has been resumed" \
1272 -c "a session has been resumed"
1273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001274run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001275 "$P_SRV debug_level=3 tickets=1" \
1276 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001277 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001278 -C "client hello, adding session ticket extension" \
1279 -S "found session ticket extension" \
1280 -S "server hello, adding session ticket extension" \
1281 -C "found session_ticket extension" \
1282 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001283 -s "session successfully restored from cache" \
1284 -S "session successfully restored from ticket" \
1285 -s "a session has been resumed" \
1286 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001288run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001289 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1290 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001291 0 \
1292 -S "session successfully restored from cache" \
1293 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001294 -S "a session has been resumed" \
1295 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001297run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001298 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1299 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001300 0 \
1301 -s "session successfully restored from cache" \
1302 -S "session successfully restored from ticket" \
1303 -s "a session has been resumed" \
1304 -c "a session has been resumed"
1305
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001306run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001307 "$P_SRV debug_level=3 tickets=0" \
1308 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
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é-Gonnard8e03c712014-08-30 21:42:40 +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 cache_timeout=1" \
1317 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
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: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001325 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1326 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +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: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001334 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001335 "( $O_CLI -sess_out $SESSION; \
1336 $O_CLI -sess_in $SESSION; \
1337 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001338 0 \
1339 -s "found session ticket extension" \
1340 -S "server hello, adding session ticket extension" \
1341 -s "session successfully restored from cache" \
1342 -S "session successfully restored from ticket" \
1343 -s "a session has been resumed"
1344
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001345run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001346 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001348 0 \
1349 -C "found session_ticket extension" \
1350 -C "parse new session ticket" \
1351 -c "a session has been resumed"
1352
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001353# Tests for Max Fragment Length extension
1354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001355run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001356 "$P_SRV debug_level=3" \
1357 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001358 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001359 -c "Maximum fragment length is 16384" \
1360 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001361 -C "client hello, adding max_fragment_length extension" \
1362 -S "found max fragment length extension" \
1363 -S "server hello, max_fragment_length extension" \
1364 -C "found max_fragment_length extension"
1365
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001366run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001367 "$P_SRV debug_level=3" \
1368 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001369 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001370 -c "Maximum fragment length is 4096" \
1371 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001372 -c "client hello, adding max_fragment_length extension" \
1373 -s "found max fragment length extension" \
1374 -s "server hello, max_fragment_length extension" \
1375 -c "found max_fragment_length extension"
1376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001377run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001378 "$P_SRV debug_level=3 max_frag_len=4096" \
1379 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001380 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001381 -c "Maximum fragment length is 16384" \
1382 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001383 -C "client hello, adding max_fragment_length extension" \
1384 -S "found max fragment length extension" \
1385 -S "server hello, max_fragment_length extension" \
1386 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001388requires_gnutls
1389run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001390 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001391 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001392 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001393 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001394 -c "client hello, adding max_fragment_length extension" \
1395 -c "found max_fragment_length extension"
1396
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001397run_test "Max fragment length: client, message just fits" \
1398 "$P_SRV debug_level=3" \
1399 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1400 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001401 -c "Maximum fragment length is 2048" \
1402 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001403 -c "client hello, adding max_fragment_length extension" \
1404 -s "found max fragment length extension" \
1405 -s "server hello, max_fragment_length extension" \
1406 -c "found max_fragment_length extension" \
1407 -c "2048 bytes written in 1 fragments" \
1408 -s "2048 bytes read"
1409
1410run_test "Max fragment length: client, larger message" \
1411 "$P_SRV debug_level=3" \
1412 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1413 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001414 -c "Maximum fragment length is 2048" \
1415 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001416 -c "client hello, adding max_fragment_length extension" \
1417 -s "found max fragment length extension" \
1418 -s "server hello, max_fragment_length extension" \
1419 -c "found max_fragment_length extension" \
1420 -c "2345 bytes written in 2 fragments" \
1421 -s "2048 bytes read" \
1422 -s "297 bytes read"
1423
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001424run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001425 "$P_SRV debug_level=3 dtls=1" \
1426 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1427 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001428 -c "Maximum fragment length is 2048" \
1429 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001430 -c "client hello, adding max_fragment_length extension" \
1431 -s "found max fragment length extension" \
1432 -s "server hello, max_fragment_length extension" \
1433 -c "found max_fragment_length extension" \
1434 -c "fragment larger than.*maximum"
1435
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001436# Tests for renegotiation
1437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001438run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001439 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001440 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001441 0 \
1442 -C "client hello, adding renegotiation extension" \
1443 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1444 -S "found renegotiation extension" \
1445 -s "server hello, secure renegotiation extension" \
1446 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001447 -C "=> renegotiate" \
1448 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001449 -S "write hello request"
1450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001451run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001452 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001453 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001454 0 \
1455 -c "client hello, adding renegotiation extension" \
1456 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1457 -s "found renegotiation extension" \
1458 -s "server hello, secure renegotiation extension" \
1459 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001460 -c "=> renegotiate" \
1461 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001462 -S "write hello request"
1463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001464run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001465 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001466 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001467 0 \
1468 -c "client hello, adding renegotiation extension" \
1469 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1470 -s "found renegotiation extension" \
1471 -s "server hello, secure renegotiation extension" \
1472 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001473 -c "=> renegotiate" \
1474 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001475 -s "write hello request"
1476
Janos Follathb0f148c2017-10-05 12:29:42 +01001477# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1478# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1479# algorithm stronger than SHA-1 is enabled in config.h
1480run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1481 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1482 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1483 0 \
1484 -c "client hello, adding renegotiation extension" \
1485 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1486 -s "found renegotiation extension" \
1487 -s "server hello, secure renegotiation extension" \
1488 -c "found renegotiation extension" \
1489 -c "=> renegotiate" \
1490 -s "=> renegotiate" \
1491 -S "write hello request" \
1492 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1493
1494# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1495# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1496# algorithm stronger than SHA-1 is enabled in config.h
1497run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1498 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1499 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1500 0 \
1501 -c "client hello, adding renegotiation extension" \
1502 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1503 -s "found renegotiation extension" \
1504 -s "server hello, secure renegotiation extension" \
1505 -c "found renegotiation extension" \
1506 -c "=> renegotiate" \
1507 -s "=> renegotiate" \
1508 -s "write hello request" \
1509 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001511run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001512 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001513 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001514 0 \
1515 -c "client hello, adding renegotiation extension" \
1516 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1517 -s "found renegotiation extension" \
1518 -s "server hello, secure renegotiation extension" \
1519 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001520 -c "=> renegotiate" \
1521 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001522 -s "write hello request"
1523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001524run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001525 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001526 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001527 1 \
1528 -c "client hello, adding renegotiation extension" \
1529 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1530 -S "found renegotiation extension" \
1531 -s "server hello, secure renegotiation extension" \
1532 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001533 -c "=> renegotiate" \
1534 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001535 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001536 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001537 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001538
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001539run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001540 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001541 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001542 0 \
1543 -C "client hello, adding renegotiation extension" \
1544 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1545 -S "found renegotiation extension" \
1546 -s "server hello, secure renegotiation extension" \
1547 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001548 -C "=> renegotiate" \
1549 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001550 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001551 -S "SSL - An unexpected message was received from our peer" \
1552 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001553
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001554run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001555 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001556 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001557 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001558 0 \
1559 -C "client hello, adding renegotiation extension" \
1560 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1561 -S "found renegotiation extension" \
1562 -s "server hello, secure renegotiation extension" \
1563 -c "found renegotiation extension" \
1564 -C "=> renegotiate" \
1565 -S "=> renegotiate" \
1566 -s "write hello request" \
1567 -S "SSL - An unexpected message was received from our peer" \
1568 -S "failed"
1569
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001570# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001571run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001572 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001573 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001574 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001575 0 \
1576 -C "client hello, adding renegotiation extension" \
1577 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1578 -S "found renegotiation extension" \
1579 -s "server hello, secure renegotiation extension" \
1580 -c "found renegotiation extension" \
1581 -C "=> renegotiate" \
1582 -S "=> renegotiate" \
1583 -s "write hello request" \
1584 -S "SSL - An unexpected message was received from our peer" \
1585 -S "failed"
1586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001587run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001588 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001589 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001590 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001591 0 \
1592 -C "client hello, adding renegotiation extension" \
1593 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1594 -S "found renegotiation extension" \
1595 -s "server hello, secure renegotiation extension" \
1596 -c "found renegotiation extension" \
1597 -C "=> renegotiate" \
1598 -S "=> renegotiate" \
1599 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001600 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001602run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001603 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001604 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001605 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001606 0 \
1607 -c "client hello, adding renegotiation extension" \
1608 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1609 -s "found renegotiation extension" \
1610 -s "server hello, secure renegotiation extension" \
1611 -c "found renegotiation extension" \
1612 -c "=> renegotiate" \
1613 -s "=> renegotiate" \
1614 -s "write hello request" \
1615 -S "SSL - An unexpected message was received from our peer" \
1616 -S "failed"
1617
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001618run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001619 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001620 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1621 0 \
1622 -C "client hello, adding renegotiation extension" \
1623 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1624 -S "found renegotiation extension" \
1625 -s "server hello, secure renegotiation extension" \
1626 -c "found renegotiation extension" \
1627 -S "record counter limit reached: renegotiate" \
1628 -C "=> renegotiate" \
1629 -S "=> renegotiate" \
1630 -S "write hello request" \
1631 -S "SSL - An unexpected message was received from our peer" \
1632 -S "failed"
1633
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001634# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001635run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001636 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001637 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001638 0 \
1639 -c "client hello, adding renegotiation extension" \
1640 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1641 -s "found renegotiation extension" \
1642 -s "server hello, secure renegotiation extension" \
1643 -c "found renegotiation extension" \
1644 -s "record counter limit reached: renegotiate" \
1645 -c "=> renegotiate" \
1646 -s "=> renegotiate" \
1647 -s "write hello request" \
1648 -S "SSL - An unexpected message was received from our peer" \
1649 -S "failed"
1650
1651run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001652 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001653 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001654 0 \
1655 -c "client hello, adding renegotiation extension" \
1656 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1657 -s "found renegotiation extension" \
1658 -s "server hello, secure renegotiation extension" \
1659 -c "found renegotiation extension" \
1660 -s "record counter limit reached: renegotiate" \
1661 -c "=> renegotiate" \
1662 -s "=> renegotiate" \
1663 -s "write hello request" \
1664 -S "SSL - An unexpected message was received from our peer" \
1665 -S "failed"
1666
1667run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001668 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001669 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1670 0 \
1671 -C "client hello, adding renegotiation extension" \
1672 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1673 -S "found renegotiation extension" \
1674 -s "server hello, secure renegotiation extension" \
1675 -c "found renegotiation extension" \
1676 -S "record counter limit reached: renegotiate" \
1677 -C "=> renegotiate" \
1678 -S "=> renegotiate" \
1679 -S "write hello request" \
1680 -S "SSL - An unexpected message was received from our peer" \
1681 -S "failed"
1682
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001683run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001684 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001685 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001686 0 \
1687 -c "client hello, adding renegotiation extension" \
1688 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1689 -s "found renegotiation extension" \
1690 -s "server hello, secure renegotiation extension" \
1691 -c "found renegotiation extension" \
1692 -c "=> renegotiate" \
1693 -s "=> renegotiate" \
1694 -S "write hello request"
1695
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001696run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001697 "$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 +02001698 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001699 0 \
1700 -c "client hello, adding renegotiation extension" \
1701 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1702 -s "found renegotiation extension" \
1703 -s "server hello, secure renegotiation extension" \
1704 -c "found renegotiation extension" \
1705 -c "=> renegotiate" \
1706 -s "=> renegotiate" \
1707 -s "write hello request"
1708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001709run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001710 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001711 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001712 0 \
1713 -c "client hello, adding renegotiation extension" \
1714 -c "found renegotiation extension" \
1715 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001716 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001717 -C "error" \
1718 -c "HTTP/1.0 200 [Oo][Kk]"
1719
Paul Bakker539d9722015-02-08 16:18:35 +01001720requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001721run_test "Renegotiation: gnutls server strict, client-initiated" \
1722 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001723 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001724 0 \
1725 -c "client hello, adding renegotiation extension" \
1726 -c "found renegotiation extension" \
1727 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001728 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001729 -C "error" \
1730 -c "HTTP/1.0 200 [Oo][Kk]"
1731
Paul Bakker539d9722015-02-08 16:18:35 +01001732requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001733run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1734 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1735 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1736 1 \
1737 -c "client hello, adding renegotiation extension" \
1738 -C "found renegotiation extension" \
1739 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001740 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001741 -c "error" \
1742 -C "HTTP/1.0 200 [Oo][Kk]"
1743
Paul Bakker539d9722015-02-08 16:18:35 +01001744requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001745run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1746 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1747 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1748 allow_legacy=0" \
1749 1 \
1750 -c "client hello, adding renegotiation extension" \
1751 -C "found renegotiation extension" \
1752 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001753 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001754 -c "error" \
1755 -C "HTTP/1.0 200 [Oo][Kk]"
1756
Paul Bakker539d9722015-02-08 16:18:35 +01001757requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001758run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1759 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1760 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1761 allow_legacy=1" \
1762 0 \
1763 -c "client hello, adding renegotiation extension" \
1764 -C "found renegotiation extension" \
1765 -c "=> renegotiate" \
1766 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001767 -C "error" \
1768 -c "HTTP/1.0 200 [Oo][Kk]"
1769
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001770run_test "Renegotiation: DTLS, client-initiated" \
1771 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1772 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1773 0 \
1774 -c "client hello, adding renegotiation extension" \
1775 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1776 -s "found renegotiation extension" \
1777 -s "server hello, secure renegotiation extension" \
1778 -c "found renegotiation extension" \
1779 -c "=> renegotiate" \
1780 -s "=> renegotiate" \
1781 -S "write hello request"
1782
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001783run_test "Renegotiation: DTLS, server-initiated" \
1784 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001785 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1786 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001787 0 \
1788 -c "client hello, adding renegotiation extension" \
1789 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1790 -s "found renegotiation extension" \
1791 -s "server hello, secure renegotiation extension" \
1792 -c "found renegotiation extension" \
1793 -c "=> renegotiate" \
1794 -s "=> renegotiate" \
1795 -s "write hello request"
1796
Andres AG692ad842017-01-19 16:30:57 +00001797run_test "Renegotiation: DTLS, renego_period overflow" \
1798 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1799 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1800 0 \
1801 -c "client hello, adding renegotiation extension" \
1802 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1803 -s "found renegotiation extension" \
1804 -s "server hello, secure renegotiation extension" \
1805 -s "record counter limit reached: renegotiate" \
1806 -c "=> renegotiate" \
1807 -s "=> renegotiate" \
1808 -s "write hello request" \
1809
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001810requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001811run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1812 "$G_SRV -u --mtu 4096" \
1813 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1814 0 \
1815 -c "client hello, adding renegotiation extension" \
1816 -c "found renegotiation extension" \
1817 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001818 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001819 -C "error" \
1820 -s "Extra-header:"
1821
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001822# Test for the "secure renegotation" extension only (no actual renegotiation)
1823
Paul Bakker539d9722015-02-08 16:18:35 +01001824requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001825run_test "Renego ext: gnutls server strict, client default" \
1826 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1827 "$P_CLI debug_level=3" \
1828 0 \
1829 -c "found renegotiation extension" \
1830 -C "error" \
1831 -c "HTTP/1.0 200 [Oo][Kk]"
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 unsafe, client default" \
1835 "$G_SRV --priority=NORMAL:%DISABLE_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 break legacy" \
1844 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1845 "$P_CLI debug_level=3 allow_legacy=-1" \
1846 1 \
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 client strict, server default" \
1853 "$P_SRV debug_level=3" \
1854 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1855 0 \
1856 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1857 -s "server hello, secure renegotiation extension"
1858
Paul Bakker539d9722015-02-08 16:18:35 +01001859requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001860run_test "Renego ext: gnutls client unsafe, server default" \
1861 "$P_SRV debug_level=3" \
1862 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1863 0 \
1864 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1865 -S "server hello, secure renegotiation extension"
1866
Paul Bakker539d9722015-02-08 16:18:35 +01001867requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001868run_test "Renego ext: gnutls client unsafe, server break legacy" \
1869 "$P_SRV debug_level=3 allow_legacy=-1" \
1870 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1871 1 \
1872 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1873 -S "server hello, secure renegotiation extension"
1874
Janos Follath0b242342016-02-17 10:11:21 +00001875# Tests for silently dropping trailing extra bytes in .der certificates
1876
1877requires_gnutls
1878run_test "DER format: no trailing bytes" \
1879 "$P_SRV crt_file=data_files/server5-der0.crt \
1880 key_file=data_files/server5.key" \
1881 "$G_CLI " \
1882 0 \
1883 -c "Handshake was completed" \
1884
1885requires_gnutls
1886run_test "DER format: with a trailing zero byte" \
1887 "$P_SRV crt_file=data_files/server5-der1a.crt \
1888 key_file=data_files/server5.key" \
1889 "$G_CLI " \
1890 0 \
1891 -c "Handshake was completed" \
1892
1893requires_gnutls
1894run_test "DER format: with a trailing random byte" \
1895 "$P_SRV crt_file=data_files/server5-der1b.crt \
1896 key_file=data_files/server5.key" \
1897 "$G_CLI " \
1898 0 \
1899 -c "Handshake was completed" \
1900
1901requires_gnutls
1902run_test "DER format: with 2 trailing random bytes" \
1903 "$P_SRV crt_file=data_files/server5-der2.crt \
1904 key_file=data_files/server5.key" \
1905 "$G_CLI " \
1906 0 \
1907 -c "Handshake was completed" \
1908
1909requires_gnutls
1910run_test "DER format: with 4 trailing random bytes" \
1911 "$P_SRV crt_file=data_files/server5-der4.crt \
1912 key_file=data_files/server5.key" \
1913 "$G_CLI " \
1914 0 \
1915 -c "Handshake was completed" \
1916
1917requires_gnutls
1918run_test "DER format: with 8 trailing random bytes" \
1919 "$P_SRV crt_file=data_files/server5-der8.crt \
1920 key_file=data_files/server5.key" \
1921 "$G_CLI " \
1922 0 \
1923 -c "Handshake was completed" \
1924
1925requires_gnutls
1926run_test "DER format: with 9 trailing random bytes" \
1927 "$P_SRV crt_file=data_files/server5-der9.crt \
1928 key_file=data_files/server5.key" \
1929 "$G_CLI " \
1930 0 \
1931 -c "Handshake was completed" \
1932
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001933# Tests for auth_mode
1934
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001935run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001936 "$P_SRV crt_file=data_files/server5-badsign.crt \
1937 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001938 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001939 1 \
1940 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001941 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001942 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001943 -c "X509 - Certificate verification failed"
1944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001945run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001946 "$P_SRV crt_file=data_files/server5-badsign.crt \
1947 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001948 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001949 0 \
1950 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001951 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001952 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001953 -C "X509 - Certificate verification failed"
1954
Hanno Beckere6706e62017-05-15 16:05:15 +01001955run_test "Authentication: server goodcert, client optional, no trusted CA" \
1956 "$P_SRV" \
1957 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1958 0 \
1959 -c "x509_verify_cert() returned" \
1960 -c "! The certificate is not correctly signed by the trusted CA" \
1961 -c "! Certificate verification flags"\
1962 -C "! mbedtls_ssl_handshake returned" \
1963 -C "X509 - Certificate verification failed" \
1964 -C "SSL - No CA Chain is set, but required to operate"
1965
1966run_test "Authentication: server goodcert, client required, no trusted CA" \
1967 "$P_SRV" \
1968 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1969 1 \
1970 -c "x509_verify_cert() returned" \
1971 -c "! The certificate is not correctly signed by the trusted CA" \
1972 -c "! Certificate verification flags"\
1973 -c "! mbedtls_ssl_handshake returned" \
1974 -c "SSL - No CA Chain is set, but required to operate"
1975
1976# The purpose of the next two tests is to test the client's behaviour when receiving a server
1977# certificate with an unsupported elliptic curve. This should usually not happen because
1978# the client informs the server about the supported curves - it does, though, in the
1979# corner case of a static ECDH suite, because the server doesn't check the curve on that
1980# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1981# different means to have the server ignoring the client's supported curve list.
1982
1983requires_config_enabled MBEDTLS_ECP_C
1984run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1985 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1986 crt_file=data_files/server5.ku-ka.crt" \
1987 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1988 1 \
1989 -c "bad certificate (EC key curve)"\
1990 -c "! Certificate verification flags"\
1991 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1992
1993requires_config_enabled MBEDTLS_ECP_C
1994run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1995 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1996 crt_file=data_files/server5.ku-ka.crt" \
1997 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1998 1 \
1999 -c "bad certificate (EC key curve)"\
2000 -c "! Certificate verification flags"\
2001 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002003run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002004 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002005 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002006 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002007 0 \
2008 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002009 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002010 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002011 -C "X509 - Certificate verification failed"
2012
Simon Butcher99000142016-10-13 17:21:01 +01002013run_test "Authentication: client SHA256, server required" \
2014 "$P_SRV auth_mode=required" \
2015 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2016 key_file=data_files/server6.key \
2017 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2018 0 \
2019 -c "Supported Signature Algorithm found: 4," \
2020 -c "Supported Signature Algorithm found: 5,"
2021
2022run_test "Authentication: client SHA384, 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-128-GCM-SHA256" \
2027 0 \
2028 -c "Supported Signature Algorithm found: 4," \
2029 -c "Supported Signature Algorithm found: 5,"
2030
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002031requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2032run_test "Authentication: client has no cert, server required (SSLv3)" \
2033 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2034 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2035 key_file=data_files/server5.key" \
2036 1 \
2037 -S "skip write certificate request" \
2038 -C "skip parse certificate request" \
2039 -c "got a certificate request" \
2040 -c "got no certificate to send" \
2041 -S "x509_verify_cert() returned" \
2042 -s "client has no certificate" \
2043 -s "! mbedtls_ssl_handshake returned" \
2044 -c "! mbedtls_ssl_handshake returned" \
2045 -s "No client certification received from the client, but required by the authentication mode"
2046
2047run_test "Authentication: client has no cert, server required (TLS)" \
2048 "$P_SRV debug_level=3 auth_mode=required" \
2049 "$P_CLI debug_level=3 crt_file=none \
2050 key_file=data_files/server5.key" \
2051 1 \
2052 -S "skip write certificate request" \
2053 -C "skip parse certificate request" \
2054 -c "got a certificate request" \
2055 -c "= write certificate$" \
2056 -C "skip write certificate$" \
2057 -S "x509_verify_cert() returned" \
2058 -s "client has no certificate" \
2059 -s "! mbedtls_ssl_handshake returned" \
2060 -c "! mbedtls_ssl_handshake returned" \
2061 -s "No client certification received from the client, but required by the authentication mode"
2062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002063run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002064 "$P_SRV debug_level=3 auth_mode=required" \
2065 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002066 key_file=data_files/server5.key" \
2067 1 \
2068 -S "skip write certificate request" \
2069 -C "skip parse certificate request" \
2070 -c "got a certificate request" \
2071 -C "skip write certificate" \
2072 -C "skip write certificate verify" \
2073 -S "skip parse certificate verify" \
2074 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002075 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002076 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002077 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002078 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002079 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002080# We don't check that the client receives the alert because it might
2081# detect that its write end of the connection is closed and abort
2082# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002083
Janos Follath89baba22017-04-10 14:34:35 +01002084run_test "Authentication: client cert not trusted, server required" \
2085 "$P_SRV debug_level=3 auth_mode=required" \
2086 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2087 key_file=data_files/server5.key" \
2088 1 \
2089 -S "skip write certificate request" \
2090 -C "skip parse certificate request" \
2091 -c "got a certificate request" \
2092 -C "skip write certificate" \
2093 -C "skip write certificate verify" \
2094 -S "skip parse certificate verify" \
2095 -s "x509_verify_cert() returned" \
2096 -s "! The certificate is not correctly signed by the trusted CA" \
2097 -s "! mbedtls_ssl_handshake returned" \
2098 -c "! mbedtls_ssl_handshake returned" \
2099 -s "X509 - Certificate verification failed"
2100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002101run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002102 "$P_SRV debug_level=3 auth_mode=optional" \
2103 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002104 key_file=data_files/server5.key" \
2105 0 \
2106 -S "skip write certificate request" \
2107 -C "skip parse certificate request" \
2108 -c "got a certificate request" \
2109 -C "skip write certificate" \
2110 -C "skip write certificate verify" \
2111 -S "skip parse certificate verify" \
2112 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002113 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002114 -S "! mbedtls_ssl_handshake returned" \
2115 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002116 -S "X509 - Certificate verification failed"
2117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002118run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002119 "$P_SRV debug_level=3 auth_mode=none" \
2120 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002121 key_file=data_files/server5.key" \
2122 0 \
2123 -s "skip write certificate request" \
2124 -C "skip parse certificate request" \
2125 -c "got no certificate request" \
2126 -c "skip write certificate" \
2127 -c "skip write certificate verify" \
2128 -s "skip parse certificate verify" \
2129 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002130 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002131 -S "! mbedtls_ssl_handshake returned" \
2132 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002133 -S "X509 - Certificate verification failed"
2134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002135run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002136 "$P_SRV debug_level=3 auth_mode=optional" \
2137 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002138 0 \
2139 -S "skip write certificate request" \
2140 -C "skip parse certificate request" \
2141 -c "got a certificate request" \
2142 -C "skip write certificate$" \
2143 -C "got no certificate to send" \
2144 -S "SSLv3 client has no certificate" \
2145 -c "skip write certificate verify" \
2146 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002147 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002148 -S "! mbedtls_ssl_handshake returned" \
2149 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002150 -S "X509 - Certificate verification failed"
2151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002152run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002153 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002154 "$O_CLI" \
2155 0 \
2156 -S "skip write certificate request" \
2157 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002158 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002159 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002160 -S "X509 - Certificate verification failed"
2161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002162run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002163 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002164 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002165 0 \
2166 -C "skip parse certificate request" \
2167 -c "got a certificate request" \
2168 -C "skip write certificate$" \
2169 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002170 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002171
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002172run_test "Authentication: client no cert, openssl server required" \
2173 "$O_SRV -Verify 10" \
2174 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2175 1 \
2176 -C "skip parse certificate request" \
2177 -c "got a certificate request" \
2178 -C "skip write certificate$" \
2179 -c "skip write certificate verify" \
2180 -c "! mbedtls_ssl_handshake returned"
2181
Janos Follathe2681a42016-03-07 15:57:05 +00002182requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002183run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002184 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002185 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002186 0 \
2187 -S "skip write certificate request" \
2188 -C "skip parse certificate request" \
2189 -c "got a certificate request" \
2190 -C "skip write certificate$" \
2191 -c "skip write certificate verify" \
2192 -c "got no certificate to send" \
2193 -s "SSLv3 client has no certificate" \
2194 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002195 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002196 -S "! mbedtls_ssl_handshake returned" \
2197 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002198 -S "X509 - Certificate verification failed"
2199
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002200# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2201# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002202
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002203MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002204MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002205
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002206if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002207 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002208 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002209 printf "test value of ${MAX_IM_CA}. \n"
2210 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002211 printf "The tests assume this value and if it changes, the tests in this\n"
2212 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002213 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002214
2215 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002216fi
2217
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002218run_test "Authentication: server max_int chain, client default" \
2219 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2220 key_file=data_files/dir-maxpath/09.key" \
2221 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2222 0 \
2223 -C "X509 - A fatal error occured"
2224
2225run_test "Authentication: server max_int+1 chain, client default" \
2226 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2227 key_file=data_files/dir-maxpath/10.key" \
2228 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2229 1 \
2230 -c "X509 - A fatal error occured"
2231
2232run_test "Authentication: server max_int+1 chain, client optional" \
2233 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2234 key_file=data_files/dir-maxpath/10.key" \
2235 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2236 auth_mode=optional" \
2237 1 \
2238 -c "X509 - A fatal error occured"
2239
2240run_test "Authentication: server max_int+1 chain, client none" \
2241 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2242 key_file=data_files/dir-maxpath/10.key" \
2243 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2244 auth_mode=none" \
2245 0 \
2246 -C "X509 - A fatal error occured"
2247
2248run_test "Authentication: client max_int+1 chain, server default" \
2249 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2250 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2251 key_file=data_files/dir-maxpath/10.key" \
2252 0 \
2253 -S "X509 - A fatal error occured"
2254
2255run_test "Authentication: client max_int+1 chain, server optional" \
2256 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2257 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2258 key_file=data_files/dir-maxpath/10.key" \
2259 1 \
2260 -s "X509 - A fatal error occured"
2261
2262run_test "Authentication: client max_int+1 chain, server required" \
2263 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2264 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2265 key_file=data_files/dir-maxpath/10.key" \
2266 1 \
2267 -s "X509 - A fatal error occured"
2268
2269run_test "Authentication: client max_int chain, server required" \
2270 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2271 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2272 key_file=data_files/dir-maxpath/09.key" \
2273 0 \
2274 -S "X509 - A fatal error occured"
2275
Janos Follath89baba22017-04-10 14:34:35 +01002276# Tests for CA list in CertificateRequest messages
2277
2278run_test "Authentication: send CA list in CertificateRequest (default)" \
2279 "$P_SRV debug_level=3 auth_mode=required" \
2280 "$P_CLI crt_file=data_files/server6.crt \
2281 key_file=data_files/server6.key" \
2282 0 \
2283 -s "requested DN"
2284
2285run_test "Authentication: do not send CA list in CertificateRequest" \
2286 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2287 "$P_CLI crt_file=data_files/server6.crt \
2288 key_file=data_files/server6.key" \
2289 0 \
2290 -S "requested DN"
2291
2292run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2293 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2294 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2295 key_file=data_files/server5.key" \
2296 1 \
2297 -S "requested DN" \
2298 -s "x509_verify_cert() returned" \
2299 -s "! The certificate is not correctly signed by the trusted CA" \
2300 -s "! mbedtls_ssl_handshake returned" \
2301 -c "! mbedtls_ssl_handshake returned" \
2302 -s "X509 - Certificate verification failed"
2303
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002304# Tests for certificate selection based on SHA verson
2305
2306run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2307 "$P_SRV crt_file=data_files/server5.crt \
2308 key_file=data_files/server5.key \
2309 crt_file2=data_files/server5-sha1.crt \
2310 key_file2=data_files/server5.key" \
2311 "$P_CLI force_version=tls1_2" \
2312 0 \
2313 -c "signed using.*ECDSA with SHA256" \
2314 -C "signed using.*ECDSA with SHA1"
2315
2316run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2317 "$P_SRV crt_file=data_files/server5.crt \
2318 key_file=data_files/server5.key \
2319 crt_file2=data_files/server5-sha1.crt \
2320 key_file2=data_files/server5.key" \
2321 "$P_CLI force_version=tls1_1" \
2322 0 \
2323 -C "signed using.*ECDSA with SHA256" \
2324 -c "signed using.*ECDSA with SHA1"
2325
2326run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2327 "$P_SRV crt_file=data_files/server5.crt \
2328 key_file=data_files/server5.key \
2329 crt_file2=data_files/server5-sha1.crt \
2330 key_file2=data_files/server5.key" \
2331 "$P_CLI force_version=tls1" \
2332 0 \
2333 -C "signed using.*ECDSA with SHA256" \
2334 -c "signed using.*ECDSA with SHA1"
2335
2336run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2337 "$P_SRV crt_file=data_files/server5.crt \
2338 key_file=data_files/server5.key \
2339 crt_file2=data_files/server6.crt \
2340 key_file2=data_files/server6.key" \
2341 "$P_CLI force_version=tls1_1" \
2342 0 \
2343 -c "serial number.*09" \
2344 -c "signed using.*ECDSA with SHA256" \
2345 -C "signed using.*ECDSA with SHA1"
2346
2347run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2348 "$P_SRV crt_file=data_files/server6.crt \
2349 key_file=data_files/server6.key \
2350 crt_file2=data_files/server5.crt \
2351 key_file2=data_files/server5.key" \
2352 "$P_CLI force_version=tls1_1" \
2353 0 \
2354 -c "serial number.*0A" \
2355 -c "signed using.*ECDSA with SHA256" \
2356 -C "signed using.*ECDSA with SHA1"
2357
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002358# tests for SNI
2359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002360run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002361 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002362 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002363 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002364 0 \
2365 -S "parse ServerName extension" \
2366 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2367 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002369run_test "SNI: matching cert 1" \
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é-Gonnard4d6f1782015-06-19 14:40:39 +02002372 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 +02002373 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002374 0 \
2375 -s "parse ServerName extension" \
2376 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2377 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002379run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002380 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002381 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002382 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 +02002383 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002384 0 \
2385 -s "parse ServerName extension" \
2386 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2387 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002388
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002389run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002390 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002391 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002392 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 +02002393 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002394 1 \
2395 -s "parse ServerName extension" \
2396 -s "ssl_sni_wrapper() returned" \
2397 -s "mbedtls_ssl_handshake returned" \
2398 -c "mbedtls_ssl_handshake returned" \
2399 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002400
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002401run_test "SNI: client auth no override: optional" \
2402 "$P_SRV debug_level=3 auth_mode=optional \
2403 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2404 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2405 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002406 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002407 -S "skip write certificate request" \
2408 -C "skip parse certificate request" \
2409 -c "got a certificate request" \
2410 -C "skip write certificate" \
2411 -C "skip write certificate verify" \
2412 -S "skip parse certificate verify"
2413
2414run_test "SNI: client auth override: none -> optional" \
2415 "$P_SRV debug_level=3 auth_mode=none \
2416 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2417 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2418 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002419 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002420 -S "skip write certificate request" \
2421 -C "skip parse certificate request" \
2422 -c "got a certificate request" \
2423 -C "skip write certificate" \
2424 -C "skip write certificate verify" \
2425 -S "skip parse certificate verify"
2426
2427run_test "SNI: client auth override: optional -> none" \
2428 "$P_SRV debug_level=3 auth_mode=optional \
2429 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2430 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2431 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002432 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002433 -s "skip write certificate request" \
2434 -C "skip parse certificate request" \
2435 -c "got no certificate request" \
2436 -c "skip write certificate" \
2437 -c "skip write certificate verify" \
2438 -s "skip parse certificate verify"
2439
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002440run_test "SNI: CA no override" \
2441 "$P_SRV debug_level=3 auth_mode=optional \
2442 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2443 ca_file=data_files/test-ca.crt \
2444 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2445 "$P_CLI debug_level=3 server_name=localhost \
2446 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2447 1 \
2448 -S "skip write certificate request" \
2449 -C "skip parse certificate request" \
2450 -c "got a certificate request" \
2451 -C "skip write certificate" \
2452 -C "skip write certificate verify" \
2453 -S "skip parse certificate verify" \
2454 -s "x509_verify_cert() returned" \
2455 -s "! The certificate is not correctly signed by the trusted CA" \
2456 -S "The certificate has been revoked (is on a CRL)"
2457
2458run_test "SNI: CA override" \
2459 "$P_SRV debug_level=3 auth_mode=optional \
2460 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2461 ca_file=data_files/test-ca.crt \
2462 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2463 "$P_CLI debug_level=3 server_name=localhost \
2464 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2465 0 \
2466 -S "skip write certificate request" \
2467 -C "skip parse certificate request" \
2468 -c "got a certificate request" \
2469 -C "skip write certificate" \
2470 -C "skip write certificate verify" \
2471 -S "skip parse certificate verify" \
2472 -S "x509_verify_cert() returned" \
2473 -S "! The certificate is not correctly signed by the trusted CA" \
2474 -S "The certificate has been revoked (is on a CRL)"
2475
2476run_test "SNI: CA override with CRL" \
2477 "$P_SRV debug_level=3 auth_mode=optional \
2478 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2479 ca_file=data_files/test-ca.crt \
2480 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2481 "$P_CLI debug_level=3 server_name=localhost \
2482 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2483 1 \
2484 -S "skip write certificate request" \
2485 -C "skip parse certificate request" \
2486 -c "got a certificate request" \
2487 -C "skip write certificate" \
2488 -C "skip write certificate verify" \
2489 -S "skip parse certificate verify" \
2490 -s "x509_verify_cert() returned" \
2491 -S "! The certificate is not correctly signed by the trusted CA" \
2492 -s "The certificate has been revoked (is on a CRL)"
2493
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002494# Tests for non-blocking I/O: exercise a variety of handshake flows
2495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002496run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002497 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2498 "$P_CLI nbio=2 tickets=0" \
2499 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002500 -S "mbedtls_ssl_handshake returned" \
2501 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002502 -c "Read from server: .* bytes read"
2503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002504run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002505 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2506 "$P_CLI nbio=2 tickets=0" \
2507 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002508 -S "mbedtls_ssl_handshake returned" \
2509 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002510 -c "Read from server: .* bytes read"
2511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002512run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002513 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2514 "$P_CLI nbio=2 tickets=1" \
2515 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002516 -S "mbedtls_ssl_handshake returned" \
2517 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002518 -c "Read from server: .* bytes read"
2519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002520run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002521 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2522 "$P_CLI nbio=2 tickets=1" \
2523 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002524 -S "mbedtls_ssl_handshake returned" \
2525 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002526 -c "Read from server: .* bytes read"
2527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002528run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002529 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2530 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2531 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002532 -S "mbedtls_ssl_handshake returned" \
2533 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002534 -c "Read from server: .* bytes read"
2535
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002536run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002537 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2538 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2539 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002540 -S "mbedtls_ssl_handshake returned" \
2541 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002542 -c "Read from server: .* bytes read"
2543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002544run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002545 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2546 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2547 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002548 -S "mbedtls_ssl_handshake returned" \
2549 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002550 -c "Read from server: .* bytes read"
2551
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002552# Tests for version negotiation
2553
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002554run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002555 "$P_SRV" \
2556 "$P_CLI" \
2557 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002558 -S "mbedtls_ssl_handshake returned" \
2559 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002560 -s "Protocol is TLSv1.2" \
2561 -c "Protocol is TLSv1.2"
2562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002563run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002564 "$P_SRV" \
2565 "$P_CLI max_version=tls1_1" \
2566 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002567 -S "mbedtls_ssl_handshake returned" \
2568 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002569 -s "Protocol is TLSv1.1" \
2570 -c "Protocol is TLSv1.1"
2571
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002572run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002573 "$P_SRV max_version=tls1_1" \
2574 "$P_CLI" \
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: cli+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 max_version=tls1_1" \
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 max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002591 "$P_SRV min_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 min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002600 "$P_SRV max_version=tls1_1" \
2601 "$P_CLI min_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.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002609 "$P_SRV max_version=tls1_1" \
2610 "$P_CLI min_version=tls1_2" \
2611 1 \
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 -c "SSL - Handshake protocol not within min/max boundaries"
2615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002616run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002617 "$P_SRV min_version=tls1_2" \
2618 "$P_CLI max_version=tls1_1" \
2619 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002620 -s "mbedtls_ssl_handshake returned" \
2621 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002622 -s "SSL - Handshake protocol not within min/max boundaries"
2623
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002624# Tests for ALPN extension
2625
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002626run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002627 "$P_SRV debug_level=3" \
2628 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002629 0 \
2630 -C "client hello, adding alpn extension" \
2631 -S "found alpn extension" \
2632 -C "got an alert message, type: \\[2:120]" \
2633 -S "server hello, adding alpn extension" \
2634 -C "found alpn extension " \
2635 -C "Application Layer Protocol is" \
2636 -S "Application Layer Protocol is"
2637
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002638run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002639 "$P_SRV debug_level=3" \
2640 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002641 0 \
2642 -c "client hello, adding alpn extension" \
2643 -s "found alpn extension" \
2644 -C "got an alert message, type: \\[2:120]" \
2645 -S "server hello, adding alpn extension" \
2646 -C "found alpn extension " \
2647 -c "Application Layer Protocol is (none)" \
2648 -S "Application Layer Protocol is"
2649
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002650run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002651 "$P_SRV debug_level=3 alpn=abc,1234" \
2652 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002653 0 \
2654 -C "client hello, adding alpn extension" \
2655 -S "found alpn extension" \
2656 -C "got an alert message, type: \\[2:120]" \
2657 -S "server hello, adding alpn extension" \
2658 -C "found alpn extension " \
2659 -C "Application Layer Protocol is" \
2660 -s "Application Layer Protocol is (none)"
2661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002662run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002663 "$P_SRV debug_level=3 alpn=abc,1234" \
2664 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002665 0 \
2666 -c "client hello, adding alpn extension" \
2667 -s "found alpn extension" \
2668 -C "got an alert message, type: \\[2:120]" \
2669 -s "server hello, adding alpn extension" \
2670 -c "found alpn extension" \
2671 -c "Application Layer Protocol is abc" \
2672 -s "Application Layer Protocol is abc"
2673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002674run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002675 "$P_SRV debug_level=3 alpn=abc,1234" \
2676 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002677 0 \
2678 -c "client hello, adding alpn extension" \
2679 -s "found alpn extension" \
2680 -C "got an alert message, type: \\[2:120]" \
2681 -s "server hello, adding alpn extension" \
2682 -c "found alpn extension" \
2683 -c "Application Layer Protocol is abc" \
2684 -s "Application Layer Protocol is abc"
2685
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002686run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002687 "$P_SRV debug_level=3 alpn=abc,1234" \
2688 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002689 0 \
2690 -c "client hello, adding alpn extension" \
2691 -s "found alpn extension" \
2692 -C "got an alert message, type: \\[2:120]" \
2693 -s "server hello, adding alpn extension" \
2694 -c "found alpn extension" \
2695 -c "Application Layer Protocol is 1234" \
2696 -s "Application Layer Protocol is 1234"
2697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002698run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002699 "$P_SRV debug_level=3 alpn=abc,123" \
2700 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002701 1 \
2702 -c "client hello, adding alpn extension" \
2703 -s "found alpn extension" \
2704 -c "got an alert message, type: \\[2:120]" \
2705 -S "server hello, adding alpn extension" \
2706 -C "found alpn extension" \
2707 -C "Application Layer Protocol is 1234" \
2708 -S "Application Layer Protocol is 1234"
2709
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002710
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002711# Tests for keyUsage in leaf certificates, part 1:
2712# server-side certificate/suite selection
2713
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002714run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002715 "$P_SRV key_file=data_files/server2.key \
2716 crt_file=data_files/server2.ku-ds.crt" \
2717 "$P_CLI" \
2718 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002719 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002720
2721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002722run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002723 "$P_SRV key_file=data_files/server2.key \
2724 crt_file=data_files/server2.ku-ke.crt" \
2725 "$P_CLI" \
2726 0 \
2727 -c "Ciphersuite is TLS-RSA-WITH-"
2728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002729run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002730 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002731 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002732 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002733 1 \
2734 -C "Ciphersuite is "
2735
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002736run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002737 "$P_SRV key_file=data_files/server5.key \
2738 crt_file=data_files/server5.ku-ds.crt" \
2739 "$P_CLI" \
2740 0 \
2741 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2742
2743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002744run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002745 "$P_SRV key_file=data_files/server5.key \
2746 crt_file=data_files/server5.ku-ka.crt" \
2747 "$P_CLI" \
2748 0 \
2749 -c "Ciphersuite is TLS-ECDH-"
2750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002751run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002752 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002753 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002754 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002755 1 \
2756 -C "Ciphersuite is "
2757
2758# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002759# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002760
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002761run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002762 "$O_SRV -key data_files/server2.key \
2763 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002764 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002765 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2766 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002767 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002768 -C "Processing of the Certificate handshake message failed" \
2769 -c "Ciphersuite is TLS-"
2770
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002771run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002772 "$O_SRV -key data_files/server2.key \
2773 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002774 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002775 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2776 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002777 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002778 -C "Processing of the Certificate handshake message failed" \
2779 -c "Ciphersuite is TLS-"
2780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002781run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002782 "$O_SRV -key data_files/server2.key \
2783 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002784 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002785 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2786 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002787 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002788 -C "Processing of the Certificate handshake message failed" \
2789 -c "Ciphersuite is TLS-"
2790
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002791run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002792 "$O_SRV -key data_files/server2.key \
2793 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002794 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002795 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2796 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002797 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002798 -c "Processing of the Certificate handshake message failed" \
2799 -C "Ciphersuite is TLS-"
2800
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002801run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2802 "$O_SRV -key data_files/server2.key \
2803 -cert data_files/server2.ku-ke.crt" \
2804 "$P_CLI debug_level=1 auth_mode=optional \
2805 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2806 0 \
2807 -c "bad certificate (usage extensions)" \
2808 -C "Processing of the Certificate handshake message failed" \
2809 -c "Ciphersuite is TLS-" \
2810 -c "! Usage does not match the keyUsage extension"
2811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002812run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002813 "$O_SRV -key data_files/server2.key \
2814 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002815 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002816 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2817 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002818 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002819 -C "Processing of the Certificate handshake message failed" \
2820 -c "Ciphersuite is TLS-"
2821
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002822run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002823 "$O_SRV -key data_files/server2.key \
2824 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002825 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002826 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2827 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002828 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002829 -c "Processing of the Certificate handshake message failed" \
2830 -C "Ciphersuite is TLS-"
2831
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002832run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2833 "$O_SRV -key data_files/server2.key \
2834 -cert data_files/server2.ku-ds.crt" \
2835 "$P_CLI debug_level=1 auth_mode=optional \
2836 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2837 0 \
2838 -c "bad certificate (usage extensions)" \
2839 -C "Processing of the Certificate handshake message failed" \
2840 -c "Ciphersuite is TLS-" \
2841 -c "! Usage does not match the keyUsage extension"
2842
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002843# Tests for keyUsage in leaf certificates, part 3:
2844# server-side checking of client cert
2845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002846run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002847 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002848 "$O_CLI -key data_files/server2.key \
2849 -cert data_files/server2.ku-ds.crt" \
2850 0 \
2851 -S "bad certificate (usage extensions)" \
2852 -S "Processing of the Certificate handshake message failed"
2853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002854run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002855 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002856 "$O_CLI -key data_files/server2.key \
2857 -cert data_files/server2.ku-ke.crt" \
2858 0 \
2859 -s "bad certificate (usage extensions)" \
2860 -S "Processing of the Certificate handshake message failed"
2861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002862run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002863 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002864 "$O_CLI -key data_files/server2.key \
2865 -cert data_files/server2.ku-ke.crt" \
2866 1 \
2867 -s "bad certificate (usage extensions)" \
2868 -s "Processing of the Certificate handshake message failed"
2869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002870run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002871 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002872 "$O_CLI -key data_files/server5.key \
2873 -cert data_files/server5.ku-ds.crt" \
2874 0 \
2875 -S "bad certificate (usage extensions)" \
2876 -S "Processing of the Certificate handshake message failed"
2877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002878run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002879 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002880 "$O_CLI -key data_files/server5.key \
2881 -cert data_files/server5.ku-ka.crt" \
2882 0 \
2883 -s "bad certificate (usage extensions)" \
2884 -S "Processing of the Certificate handshake message failed"
2885
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002886# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002888run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002889 "$P_SRV key_file=data_files/server5.key \
2890 crt_file=data_files/server5.eku-srv.crt" \
2891 "$P_CLI" \
2892 0
2893
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002894run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002895 "$P_SRV key_file=data_files/server5.key \
2896 crt_file=data_files/server5.eku-srv.crt" \
2897 "$P_CLI" \
2898 0
2899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002900run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002901 "$P_SRV key_file=data_files/server5.key \
2902 crt_file=data_files/server5.eku-cs_any.crt" \
2903 "$P_CLI" \
2904 0
2905
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002906run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002907 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002908 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002909 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002910 1
2911
2912# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002914run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002915 "$O_SRV -key data_files/server5.key \
2916 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002917 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002918 0 \
2919 -C "bad certificate (usage extensions)" \
2920 -C "Processing of the Certificate handshake message failed" \
2921 -c "Ciphersuite is TLS-"
2922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002923run_test "extKeyUsage cli: serverAuth,clientAuth -> 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_cli.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: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002933 "$O_SRV -key data_files/server5.key \
2934 -cert data_files/server5.eku-cs_any.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 -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002942 "$O_SRV -key data_files/server5.key \
2943 -cert data_files/server5.eku-cs.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 1 \
2946 -c "bad certificate (usage extensions)" \
2947 -c "Processing of the Certificate handshake message failed" \
2948 -C "Ciphersuite is TLS-"
2949
2950# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002952run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002953 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002954 "$O_CLI -key data_files/server5.key \
2955 -cert data_files/server5.eku-cli.crt" \
2956 0 \
2957 -S "bad certificate (usage extensions)" \
2958 -S "Processing of the Certificate handshake message failed"
2959
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002960run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002961 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002962 "$O_CLI -key data_files/server5.key \
2963 -cert data_files/server5.eku-srv_cli.crt" \
2964 0 \
2965 -S "bad certificate (usage extensions)" \
2966 -S "Processing of the Certificate handshake message failed"
2967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002968run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002969 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002970 "$O_CLI -key data_files/server5.key \
2971 -cert data_files/server5.eku-cs_any.crt" \
2972 0 \
2973 -S "bad certificate (usage extensions)" \
2974 -S "Processing of the Certificate handshake message failed"
2975
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002976run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002977 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002978 "$O_CLI -key data_files/server5.key \
2979 -cert data_files/server5.eku-cs.crt" \
2980 0 \
2981 -s "bad certificate (usage extensions)" \
2982 -S "Processing of the Certificate handshake message failed"
2983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002984run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002985 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002986 "$O_CLI -key data_files/server5.key \
2987 -cert data_files/server5.eku-cs.crt" \
2988 1 \
2989 -s "bad certificate (usage extensions)" \
2990 -s "Processing of the Certificate handshake message failed"
2991
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002992# Tests for DHM parameters loading
2993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002994run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002995 "$P_SRV" \
2996 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2997 debug_level=3" \
2998 0 \
2999 -c "value of 'DHM: P ' (2048 bits)" \
3000 -c "value of 'DHM: G ' (2048 bits)"
3001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003002run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003003 "$P_SRV dhm_file=data_files/dhparams.pem" \
3004 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3005 debug_level=3" \
3006 0 \
3007 -c "value of 'DHM: P ' (1024 bits)" \
3008 -c "value of 'DHM: G ' (2 bits)"
3009
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003010# Tests for DHM client-side size checking
3011
3012run_test "DHM size: server default, client default, OK" \
3013 "$P_SRV" \
3014 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3015 debug_level=1" \
3016 0 \
3017 -C "DHM prime too short:"
3018
3019run_test "DHM size: server default, client 2048, OK" \
3020 "$P_SRV" \
3021 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3022 debug_level=1 dhmlen=2048" \
3023 0 \
3024 -C "DHM prime too short:"
3025
3026run_test "DHM size: server 1024, client default, OK" \
3027 "$P_SRV dhm_file=data_files/dhparams.pem" \
3028 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3029 debug_level=1" \
3030 0 \
3031 -C "DHM prime too short:"
3032
3033run_test "DHM size: server 1000, client default, rejected" \
3034 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3035 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3036 debug_level=1" \
3037 1 \
3038 -c "DHM prime too short:"
3039
3040run_test "DHM size: server default, client 2049, rejected" \
3041 "$P_SRV" \
3042 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3043 debug_level=1 dhmlen=2049" \
3044 1 \
3045 -c "DHM prime too short:"
3046
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003047# Tests for PSK callback
3048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003049run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003050 "$P_SRV psk=abc123 psk_identity=foo" \
3051 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3052 psk_identity=foo psk=abc123" \
3053 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003054 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003055 -S "SSL - Unknown identity received" \
3056 -S "SSL - Verification of the message MAC failed"
3057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003058run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003059 "$P_SRV" \
3060 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3061 psk_identity=foo psk=abc123" \
3062 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003063 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +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: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003068 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
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: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003077 "$P_SRV psk_list=abc,dead,def,beef" \
3078 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3079 psk_identity=abc psk=dead" \
3080 0 \
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: second 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=def psk=beef" \
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: no match" \
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=ghi psk=beef" \
3098 1 \
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: wrong key" \
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=abc 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"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003111
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003112# Tests for EC J-PAKE
3113
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003114requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003115run_test "ECJPAKE: client not configured" \
3116 "$P_SRV debug_level=3" \
3117 "$P_CLI debug_level=3" \
3118 0 \
3119 -C "add ciphersuite: c0ff" \
3120 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003121 -S "found ecjpake kkpp extension" \
3122 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003123 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003124 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003125 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003126 -S "None of the common ciphersuites is usable"
3127
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003128requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003129run_test "ECJPAKE: server not configured" \
3130 "$P_SRV debug_level=3" \
3131 "$P_CLI debug_level=3 ecjpake_pw=bla \
3132 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3133 1 \
3134 -c "add ciphersuite: c0ff" \
3135 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003136 -s "found ecjpake kkpp extension" \
3137 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003138 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003139 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003140 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003141 -s "None of the common ciphersuites is usable"
3142
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003143requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003144run_test "ECJPAKE: working, TLS" \
3145 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3146 "$P_CLI debug_level=3 ecjpake_pw=bla \
3147 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003148 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003149 -c "add ciphersuite: c0ff" \
3150 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003151 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003152 -s "found ecjpake kkpp extension" \
3153 -S "skip ecjpake kkpp extension" \
3154 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003155 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003156 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003157 -S "None of the common ciphersuites is usable" \
3158 -S "SSL - Verification of the message MAC failed"
3159
Janos Follath74537a62016-09-02 13:45:28 +01003160server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003161requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003162run_test "ECJPAKE: password mismatch, TLS" \
3163 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3164 "$P_CLI debug_level=3 ecjpake_pw=bad \
3165 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3166 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003167 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003168 -s "SSL - Verification of the message MAC failed"
3169
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: working, DTLS" \
3172 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3173 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3174 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3175 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003176 -c "re-using cached ecjpake parameters" \
3177 -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é-Gonnardd0d8cb32015-09-17 14:16:30 +02003180run_test "ECJPAKE: working, DTLS, no cookie" \
3181 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3182 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3183 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3184 0 \
3185 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003186 -S "SSL - Verification of the message MAC failed"
3187
Janos Follath74537a62016-09-02 13:45:28 +01003188server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003189requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003190run_test "ECJPAKE: password mismatch, DTLS" \
3191 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3192 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3193 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3194 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003195 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003196 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003197
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003198# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003199requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003200run_test "ECJPAKE: working, DTLS, nolog" \
3201 "$P_SRV dtls=1 ecjpake_pw=bla" \
3202 "$P_CLI dtls=1 ecjpake_pw=bla \
3203 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3204 0
3205
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003206# Tests for ciphersuites per version
3207
Janos Follathe2681a42016-03-07 15:57:05 +00003208requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003209run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003210 "$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 +02003211 "$P_CLI force_version=ssl3" \
3212 0 \
3213 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003215run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003216 "$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 +01003217 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003218 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003219 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003221run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003222 "$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 +02003223 "$P_CLI force_version=tls1_1" \
3224 0 \
3225 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003227run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003228 "$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 +02003229 "$P_CLI force_version=tls1_2" \
3230 0 \
3231 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3232
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003233# Test for ClientHello without extensions
3234
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003235requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003236run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003237 "$P_SRV debug_level=3" \
3238 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3239 0 \
3240 -s "dumping 'client hello extensions' (0 bytes)"
3241
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003242requires_gnutls
3243run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3244 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3245 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3246 0 \
3247 -s "dumping 'client hello extensions' (0 bytes)"
3248
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003249# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003250
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003251run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003252 "$P_SRV" \
3253 "$P_CLI request_size=100" \
3254 0 \
3255 -s "Read from client: 100 bytes read$"
3256
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003257run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003258 "$P_SRV" \
3259 "$P_CLI request_size=500" \
3260 0 \
3261 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003262
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003263# Tests for small packets
3264
Janos Follathe2681a42016-03-07 15:57:05 +00003265requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003266run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003267 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003268 "$P_CLI request_size=1 force_version=ssl3 \
3269 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3270 0 \
3271 -s "Read from client: 1 bytes read"
3272
Janos Follathe2681a42016-03-07 15:57:05 +00003273requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003274run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003275 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003276 "$P_CLI request_size=1 force_version=ssl3 \
3277 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3278 0 \
3279 -s "Read from client: 1 bytes read"
3280
3281run_test "Small packet TLS 1.0 BlockCipher" \
3282 "$P_SRV" \
3283 "$P_CLI request_size=1 force_version=tls1 \
3284 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3285 0 \
3286 -s "Read from client: 1 bytes read"
3287
Hanno Becker8501f982017-11-10 08:59:04 +00003288run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003289 "$P_SRV" \
3290 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3291 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3292 0 \
3293 -s "Read from client: 1 bytes read"
3294
Hanno Becker32c55012017-11-10 08:42:54 +00003295requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003296run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003297 "$P_SRV" \
3298 "$P_CLI request_size=1 force_version=tls1 \
3299 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3300 trunc_hmac=1" \
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, without EtM, truncated MAC" \
3306 "$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 etm=0" \
3311 0 \
3312 -s "Read from client: 1 bytes read"
3313
3314run_test "Small packet TLS 1.0 StreamCipher" \
3315 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3316 "$P_CLI request_size=1 force_version=tls1 \
3317 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3318 0 \
3319 -s "Read from client: 1 bytes read"
3320
3321run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3322 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3323 "$P_CLI request_size=1 force_version=tls1 \
3324 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3325 etm=0" \
3326 0 \
3327 -s "Read from client: 1 bytes read"
3328
3329requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3330run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003331 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003332 "$P_CLI request_size=1 force_version=tls1 \
3333 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3334 trunc_hmac=1" \
3335 0 \
3336 -s "Read from client: 1 bytes read"
3337
Hanno Becker8501f982017-11-10 08:59:04 +00003338requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3339run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
3340 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3341 "$P_CLI request_size=1 force_version=tls1 \
3342 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3343 trunc_hmac=1 \
3344 etm=0" \
3345 0 \
3346 -s "Read from client: 1 bytes read"
3347
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003348run_test "Small packet TLS 1.1 BlockCipher" \
3349 "$P_SRV" \
3350 "$P_CLI request_size=1 force_version=tls1_1 \
3351 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3352 0 \
3353 -s "Read from client: 1 bytes read"
3354
Hanno Becker8501f982017-11-10 08:59:04 +00003355run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003356 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003357 "$P_CLI request_size=1 force_version=tls1_1 \
3358 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA
3359 etm=0" \
3360 0 \
3361 -s "Read from client: 1 bytes read"
3362
3363requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3364run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
3365 "$P_SRV" \
3366 "$P_CLI request_size=1 force_version=tls1_1 \
3367 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3368 trunc_hmac=1" \
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, without EtM, 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 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003379 0 \
3380 -s "Read from client: 1 bytes read"
3381
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003382run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003383 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003384 "$P_CLI request_size=1 force_version=tls1_1 \
3385 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3386 0 \
3387 -s "Read from client: 1 bytes read"
3388
Hanno Becker8501f982017-11-10 08:59:04 +00003389run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3390 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003391 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003392 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3393 etm=0" \
3394 0 \
3395 -s "Read from client: 1 bytes read"
3396
3397requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3398run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
3399 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3400 "$P_CLI request_size=1 force_version=tls1_1 \
3401 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003402 trunc_hmac=1" \
3403 0 \
3404 -s "Read from client: 1 bytes read"
3405
Hanno Becker32c55012017-11-10 08:42:54 +00003406requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003407run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003408 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003409 "$P_CLI request_size=1 force_version=tls1_1 \
3410 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
Hanno Becker8501f982017-11-10 08:59:04 +00003411 trunc_hmac=1 \
3412 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003413 0 \
3414 -s "Read from client: 1 bytes read"
3415
3416run_test "Small packet TLS 1.2 BlockCipher" \
3417 "$P_SRV" \
3418 "$P_CLI request_size=1 force_version=tls1_2 \
3419 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3420 0 \
3421 -s "Read from client: 1 bytes read"
3422
Hanno Becker8501f982017-11-10 08:59:04 +00003423run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003424 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003425 "$P_CLI request_size=1 force_version=tls1_2 \
3426 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3427 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003428 0 \
3429 -s "Read from client: 1 bytes read"
3430
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003431run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3432 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003433 "$P_CLI request_size=1 force_version=tls1_2 \
3434 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003435 0 \
3436 -s "Read from client: 1 bytes read"
3437
Hanno Becker32c55012017-11-10 08:42:54 +00003438requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003439run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003440 "$P_SRV" \
3441 "$P_CLI request_size=1 force_version=tls1_2 \
3442 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3443 trunc_hmac=1" \
3444 0 \
3445 -s "Read from client: 1 bytes read"
3446
Hanno Becker8501f982017-11-10 08:59:04 +00003447requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3448run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
3449 "$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 etm=0" \
3454 0 \
3455 -s "Read from client: 1 bytes read"
3456
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003457run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003458 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003459 "$P_CLI request_size=1 force_version=tls1_2 \
3460 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3461 0 \
3462 -s "Read from client: 1 bytes read"
3463
Hanno Becker8501f982017-11-10 08:59:04 +00003464run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
3465 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3466 "$P_CLI request_size=1 force_version=tls1_2 \
3467 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3468 etm=0" \
3469 0 \
3470 -s "Read from client: 1 bytes read"
3471
Hanno Becker32c55012017-11-10 08:42:54 +00003472requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003473run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003474 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003475 "$P_CLI request_size=1 force_version=tls1_2 \
3476 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3477 trunc_hmac=1" \
3478 0 \
3479 -s "Read from client: 1 bytes read"
3480
Hanno Becker8501f982017-11-10 08:59:04 +00003481requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3482run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
3483 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3484 "$P_CLI request_size=1 force_version=tls1_2 \
3485 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3486 trunc_hmac=1 \
3487 etm=0" \
3488 0 \
3489 -s "Read from client: 1 bytes read"
3490
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003491run_test "Small packet TLS 1.2 AEAD" \
3492 "$P_SRV" \
3493 "$P_CLI request_size=1 force_version=tls1_2 \
3494 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3495 0 \
3496 -s "Read from client: 1 bytes read"
3497
3498run_test "Small packet TLS 1.2 AEAD shorter tag" \
3499 "$P_SRV" \
3500 "$P_CLI request_size=1 force_version=tls1_2 \
3501 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3502 0 \
3503 -s "Read from client: 1 bytes read"
3504
Hanno Beckere2148042017-11-10 08:59:18 +00003505# Tests for small packets in DTLS
3506
3507requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3508run_test "Small packet DTLS 1.0" \
3509 "$P_SRV dtls=1 force_version=dtls1" \
3510 "$P_CLI dtls=1 request_size=1 \
3511 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3512 0 \
3513 -s "Read from client: 1 bytes read"
3514
3515requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3516run_test "Small packet DTLS 1.0, without EtM" \
3517 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3518 "$P_CLI dtls=1 request_size=1 \
3519 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3520 0 \
3521 -s "Read from client: 1 bytes read"
3522
3523requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3524requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3525run_test "Small packet DTLS 1.0, truncated hmac" \
3526 "$P_SRV dtls=1 force_version=dtls1" \
3527 "$P_CLI dtls=1 request_size=1 trunc_hmac=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, without EtM, truncated MAC" \
3535 "$P_SRV dtls=1 force_version=dtls1 \
3536 etm=0" \
3537 "$P_CLI dtls=1 request_size=1 \
3538 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3539 trunc_hmac=1"\
3540 0 \
3541 -s "Read from client: 1 bytes read"
3542
3543requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3544run_test "Small packet DTLS 1.2" \
3545 "$P_SRV dtls=1 force_version=dtls1_2" \
3546 "$P_CLI dtls=1 request_size=1 \
3547 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3548 0 \
3549 -s "Read from client: 1 bytes read"
3550
3551requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3552run_test "Small packet DTLS 1.2, without EtM" \
3553 "$P_SRV dtls=1 force_version=dtls1_2 \
3554 etm=0" \
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
3561requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3562run_test "Small packet DTLS 1.2, truncated hmac" \
3563 "$P_SRV dtls=1 force_version=dtls1_2" \
3564 "$P_CLI dtls=1 request_size=1 \
3565 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3566 trunc_hmac=1" \
3567 0 \
3568 -s "Read from client: 1 bytes read"
3569
3570requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3571requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3572run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
3573 "$P_SRV dtls=1 force_version=dtls1_2 \
3574 etm=0" \
3575 "$P_CLI dtls=1 request_size=1 \
3576 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3577 trunc_hmac=1"\
3578 0 \
3579 -s "Read from client: 1 bytes read"
3580
Janos Follath00efff72016-05-06 13:48:23 +01003581# A test for extensions in SSLv3
3582
3583requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3584run_test "SSLv3 with extensions, server side" \
3585 "$P_SRV min_version=ssl3 debug_level=3" \
3586 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3587 0 \
3588 -S "dumping 'client hello extensions'" \
3589 -S "server hello, total extension length:"
3590
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003591# Test for large packets
3592
Janos Follathe2681a42016-03-07 15:57:05 +00003593requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003594run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003595 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003596 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003597 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3598 0 \
3599 -s "Read from client: 16384 bytes read"
3600
Janos Follathe2681a42016-03-07 15:57:05 +00003601requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003602run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003603 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003604 "$P_CLI request_size=16384 force_version=ssl3 \
3605 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3606 0 \
3607 -s "Read from client: 16384 bytes read"
3608
3609run_test "Large packet TLS 1.0 BlockCipher" \
3610 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003611 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003612 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3613 0 \
3614 -s "Read from client: 16384 bytes read"
3615
Hanno Becker278fc7a2017-11-10 09:16:28 +00003616run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
3617 "$P_SRV" \
3618 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3619 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3620 0 \
3621 -s "Read from client: 16384 bytes read"
3622
Hanno Becker32c55012017-11-10 08:42:54 +00003623requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003624run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003625 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003626 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003627 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3628 trunc_hmac=1" \
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, without EtM, truncated MAC" \
3634 "$P_SRV" \
3635 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3636 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3637 trunc_hmac=1" \
3638 0 \
3639 -s "Read from client: 16384 bytes read"
3640
3641run_test "Large packet TLS 1.0 StreamCipher" \
3642 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3643 "$P_CLI request_size=16384 force_version=tls1 \
3644 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3645 0 \
3646 -s "Read from client: 16384 bytes read"
3647
3648run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3649 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3650 "$P_CLI request_size=16384 force_version=tls1 \
3651 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3652 etm=0" \
3653 0 \
3654 -s "Read from client: 16384 bytes read"
3655
3656requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3657run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003658 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003659 "$P_CLI request_size=16384 force_version=tls1 \
3660 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3661 trunc_hmac=1" \
3662 0 \
3663 -s "Read from client: 16384 bytes read"
3664
Hanno Becker278fc7a2017-11-10 09:16:28 +00003665requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3666run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
3667 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3668 "$P_CLI request_size=16384 force_version=tls1 \
3669 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3670 trunc_hmac=1 etm=0" \
3671 0 \
3672 -s "Read from client: 16384 bytes read"
3673
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003674run_test "Large packet TLS 1.1 BlockCipher" \
3675 "$P_SRV" \
3676 "$P_CLI request_size=16384 force_version=tls1_1 \
3677 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3678 0 \
3679 -s "Read from client: 16384 bytes read"
3680
Hanno Becker278fc7a2017-11-10 09:16:28 +00003681run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3682 "$P_SRV" \
3683 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3684 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003685 0 \
3686 -s "Read from client: 16384 bytes read"
3687
Hanno Becker32c55012017-11-10 08:42:54 +00003688requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003689run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003690 "$P_SRV" \
3691 "$P_CLI request_size=16384 force_version=tls1_1 \
3692 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3693 trunc_hmac=1" \
3694 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, without EtM, truncated MAC" \
3699 "$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 etm=0" \
3703 0 \
3704 -s "Read from client: 16384 bytes read"
3705
3706run_test "Large packet TLS 1.1 StreamCipher" \
3707 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3708 "$P_CLI request_size=16384 force_version=tls1_1 \
3709 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3710 0 \
3711 -s "Read from client: 16384 bytes read"
3712
3713run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
3714 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3715 "$P_CLI request_size=16384 force_version=tls1_1 \
3716 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3717 etm=0" \
3718 0 \
3719 -s "Read from client: 16384 bytes read"
3720
3721requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3722run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003723 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003724 "$P_CLI request_size=16384 force_version=tls1_1 \
3725 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3726 trunc_hmac=1" \
3727 0 \
3728 -s "Read from client: 16384 bytes read"
3729
Hanno Becker278fc7a2017-11-10 09:16:28 +00003730requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3731run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
3732 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3733 "$P_CLI request_size=16384 force_version=tls1_1 \
3734 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3735 trunc_hmac=1 etm=0" \
3736 0 \
3737 -s "Read from client: 16384 bytes read"
3738
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003739run_test "Large packet TLS 1.2 BlockCipher" \
3740 "$P_SRV" \
3741 "$P_CLI request_size=16384 force_version=tls1_2 \
3742 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3743 0 \
3744 -s "Read from client: 16384 bytes read"
3745
Hanno Becker278fc7a2017-11-10 09:16:28 +00003746run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
3747 "$P_SRV" \
3748 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
3749 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3750 0 \
3751 -s "Read from client: 16384 bytes read"
3752
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003753run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3754 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003755 "$P_CLI request_size=16384 force_version=tls1_2 \
3756 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003757 0 \
3758 -s "Read from client: 16384 bytes read"
3759
Hanno Becker32c55012017-11-10 08:42:54 +00003760requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003761run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003762 "$P_SRV" \
3763 "$P_CLI request_size=16384 force_version=tls1_2 \
3764 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3765 trunc_hmac=1" \
3766 0 \
3767 -s "Read from client: 16384 bytes read"
3768
Hanno Becker278fc7a2017-11-10 09:16:28 +00003769requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3770run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
3771 "$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 etm=0" \
3775 0 \
3776 -s "Read from client: 16384 bytes read"
3777
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003778run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003779 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003780 "$P_CLI request_size=16384 force_version=tls1_2 \
3781 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3782 0 \
3783 -s "Read from client: 16384 bytes read"
3784
Hanno Becker278fc7a2017-11-10 09:16:28 +00003785run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
3786 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3787 "$P_CLI request_size=16384 force_version=tls1_2 \
3788 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
3789 0 \
3790 -s "Read from client: 16384 bytes read"
3791
Hanno Becker32c55012017-11-10 08:42:54 +00003792requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003793run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003794 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003795 "$P_CLI request_size=16384 force_version=tls1_2 \
3796 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3797 trunc_hmac=1" \
3798 0 \
3799 -s "Read from client: 16384 bytes read"
3800
Hanno Becker278fc7a2017-11-10 09:16:28 +00003801requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3802run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
3803 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3804 "$P_CLI request_size=16384 force_version=tls1_2 \
3805 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3806 trunc_hmac=1 etm=0" \
3807 0 \
3808 -s "Read from client: 16384 bytes read"
3809
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003810run_test "Large packet TLS 1.2 AEAD" \
3811 "$P_SRV" \
3812 "$P_CLI request_size=16384 force_version=tls1_2 \
3813 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3814 0 \
3815 -s "Read from client: 16384 bytes read"
3816
3817run_test "Large packet TLS 1.2 AEAD shorter tag" \
3818 "$P_SRV" \
3819 "$P_CLI request_size=16384 force_version=tls1_2 \
3820 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3821 0 \
3822 -s "Read from client: 16384 bytes read"
3823
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003824# Tests for DTLS HelloVerifyRequest
3825
3826run_test "DTLS cookie: enabled" \
3827 "$P_SRV dtls=1 debug_level=2" \
3828 "$P_CLI dtls=1 debug_level=2" \
3829 0 \
3830 -s "cookie verification failed" \
3831 -s "cookie verification passed" \
3832 -S "cookie verification skipped" \
3833 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003834 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003835 -S "SSL - The requested feature is not available"
3836
3837run_test "DTLS cookie: disabled" \
3838 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3839 "$P_CLI dtls=1 debug_level=2" \
3840 0 \
3841 -S "cookie verification failed" \
3842 -S "cookie verification passed" \
3843 -s "cookie verification skipped" \
3844 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003845 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003846 -S "SSL - The requested feature is not available"
3847
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003848run_test "DTLS cookie: default (failing)" \
3849 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3850 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3851 1 \
3852 -s "cookie verification failed" \
3853 -S "cookie verification passed" \
3854 -S "cookie verification skipped" \
3855 -C "received hello verify request" \
3856 -S "hello verification requested" \
3857 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003858
3859requires_ipv6
3860run_test "DTLS cookie: enabled, IPv6" \
3861 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3862 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3863 0 \
3864 -s "cookie verification failed" \
3865 -s "cookie verification passed" \
3866 -S "cookie verification skipped" \
3867 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003868 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003869 -S "SSL - The requested feature is not available"
3870
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003871run_test "DTLS cookie: enabled, nbio" \
3872 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3873 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3874 0 \
3875 -s "cookie verification failed" \
3876 -s "cookie verification passed" \
3877 -S "cookie verification skipped" \
3878 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003879 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003880 -S "SSL - The requested feature is not available"
3881
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003882# Tests for client reconnecting from the same port with DTLS
3883
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003884not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003885run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003886 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3887 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003888 0 \
3889 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003890 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003891 -S "Client initiated reconnection from same port"
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: reconnect" \
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 reconnect_hard=1" \
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
Paul Bakker362689d2016-05-13 10:33:25 +01003902not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3903run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003904 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
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 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003907 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003908 -s "Client initiated reconnection from same port"
3909
Paul Bakker362689d2016-05-13 10:33:25 +01003910only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3911run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3912 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3913 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3914 0 \
3915 -S "The operation timed out" \
3916 -s "Client initiated reconnection from same port"
3917
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003918run_test "DTLS client reconnect from same port: no cookies" \
3919 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003920 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3921 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003922 -s "The operation timed out" \
3923 -S "Client initiated reconnection from same port"
3924
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003925# Tests for various cases of client authentication with DTLS
3926# (focused on handshake flows and message parsing)
3927
3928run_test "DTLS client auth: required" \
3929 "$P_SRV dtls=1 auth_mode=required" \
3930 "$P_CLI dtls=1" \
3931 0 \
3932 -s "Verifying peer X.509 certificate... ok"
3933
3934run_test "DTLS client auth: optional, client has no cert" \
3935 "$P_SRV dtls=1 auth_mode=optional" \
3936 "$P_CLI dtls=1 crt_file=none key_file=none" \
3937 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003938 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003939
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003940run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003941 "$P_SRV dtls=1 auth_mode=none" \
3942 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3943 0 \
3944 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003945 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003946
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003947run_test "DTLS wrong PSK: badmac alert" \
3948 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3949 "$P_CLI dtls=1 psk=abc124" \
3950 1 \
3951 -s "SSL - Verification of the message MAC failed" \
3952 -c "SSL - A fatal alert message was received from our peer"
3953
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003954# Tests for receiving fragmented handshake messages with DTLS
3955
3956requires_gnutls
3957run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3958 "$G_SRV -u --mtu 2048 -a" \
3959 "$P_CLI dtls=1 debug_level=2" \
3960 0 \
3961 -C "found fragmented DTLS handshake message" \
3962 -C "error"
3963
3964requires_gnutls
3965run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3966 "$G_SRV -u --mtu 512" \
3967 "$P_CLI dtls=1 debug_level=2" \
3968 0 \
3969 -c "found fragmented DTLS handshake message" \
3970 -C "error"
3971
3972requires_gnutls
3973run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3974 "$G_SRV -u --mtu 128" \
3975 "$P_CLI dtls=1 debug_level=2" \
3976 0 \
3977 -c "found fragmented DTLS handshake message" \
3978 -C "error"
3979
3980requires_gnutls
3981run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3982 "$G_SRV -u --mtu 128" \
3983 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3984 0 \
3985 -c "found fragmented DTLS handshake message" \
3986 -C "error"
3987
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003988requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003989run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3990 "$G_SRV -u --mtu 256" \
3991 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3992 0 \
3993 -c "found fragmented DTLS handshake message" \
3994 -c "client hello, adding renegotiation extension" \
3995 -c "found renegotiation extension" \
3996 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003997 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003998 -C "error" \
3999 -s "Extra-header:"
4000
4001requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004002run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4003 "$G_SRV -u --mtu 256" \
4004 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4005 0 \
4006 -c "found fragmented DTLS handshake message" \
4007 -c "client hello, adding renegotiation extension" \
4008 -c "found renegotiation extension" \
4009 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004010 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004011 -C "error" \
4012 -s "Extra-header:"
4013
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004014run_test "DTLS reassembly: no fragmentation (openssl server)" \
4015 "$O_SRV -dtls1 -mtu 2048" \
4016 "$P_CLI dtls=1 debug_level=2" \
4017 0 \
4018 -C "found fragmented DTLS handshake message" \
4019 -C "error"
4020
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004021run_test "DTLS reassembly: some fragmentation (openssl server)" \
4022 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004023 "$P_CLI dtls=1 debug_level=2" \
4024 0 \
4025 -c "found fragmented DTLS handshake message" \
4026 -C "error"
4027
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004028run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004029 "$O_SRV -dtls1 -mtu 256" \
4030 "$P_CLI dtls=1 debug_level=2" \
4031 0 \
4032 -c "found fragmented DTLS handshake message" \
4033 -C "error"
4034
4035run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4036 "$O_SRV -dtls1 -mtu 256" \
4037 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4038 0 \
4039 -c "found fragmented DTLS handshake message" \
4040 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004041
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004042# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004043
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004044not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004045run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004046 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004047 "$P_SRV dtls=1 debug_level=2" \
4048 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004049 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004050 -C "replayed record" \
4051 -S "replayed record" \
4052 -C "record from another epoch" \
4053 -S "record from another epoch" \
4054 -C "discarding invalid record" \
4055 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004056 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004057 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004058 -c "HTTP/1.0 200 OK"
4059
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004060not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004061run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004062 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004063 "$P_SRV dtls=1 debug_level=2" \
4064 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004065 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004066 -c "replayed record" \
4067 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004068 -c "discarding invalid record" \
4069 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004070 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004071 -s "Extra-header:" \
4072 -c "HTTP/1.0 200 OK"
4073
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004074run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4075 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004076 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4077 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004078 0 \
4079 -c "replayed record" \
4080 -S "replayed record" \
4081 -c "discarding invalid record" \
4082 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004083 -c "resend" \
4084 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004085 -s "Extra-header:" \
4086 -c "HTTP/1.0 200 OK"
4087
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004088run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004089 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004090 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004091 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004092 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004093 -c "discarding invalid record (mac)" \
4094 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004095 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004096 -c "HTTP/1.0 200 OK" \
4097 -S "too many records with bad MAC" \
4098 -S "Verification of the message MAC failed"
4099
4100run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4101 -p "$P_PXY bad_ad=1" \
4102 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4103 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4104 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004105 -C "discarding invalid record (mac)" \
4106 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004107 -S "Extra-header:" \
4108 -C "HTTP/1.0 200 OK" \
4109 -s "too many records with bad MAC" \
4110 -s "Verification of the message MAC failed"
4111
4112run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4113 -p "$P_PXY bad_ad=1" \
4114 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4115 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4116 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004117 -c "discarding invalid record (mac)" \
4118 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004119 -s "Extra-header:" \
4120 -c "HTTP/1.0 200 OK" \
4121 -S "too many records with bad MAC" \
4122 -S "Verification of the message MAC failed"
4123
4124run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4125 -p "$P_PXY bad_ad=1" \
4126 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4127 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4128 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004129 -c "discarding invalid record (mac)" \
4130 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004131 -s "Extra-header:" \
4132 -c "HTTP/1.0 200 OK" \
4133 -s "too many records with bad MAC" \
4134 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004135
4136run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004137 -p "$P_PXY delay_ccs=1" \
4138 "$P_SRV dtls=1 debug_level=1" \
4139 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004140 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004141 -c "record from another epoch" \
4142 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004143 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004144 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004145 -s "Extra-header:" \
4146 -c "HTTP/1.0 200 OK"
4147
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004148# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004149
Janos Follath74537a62016-09-02 13:45:28 +01004150client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004151run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004152 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004153 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4154 psk=abc123" \
4155 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004156 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4157 0 \
4158 -s "Extra-header:" \
4159 -c "HTTP/1.0 200 OK"
4160
Janos Follath74537a62016-09-02 13:45:28 +01004161client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004162run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4163 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004164 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4165 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004166 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4167 0 \
4168 -s "Extra-header:" \
4169 -c "HTTP/1.0 200 OK"
4170
Janos Follath74537a62016-09-02 13:45:28 +01004171client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004172run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4173 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004174 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4175 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004176 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, FS, client auth" \
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=required" \
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, ticket" \
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=1 auth_mode=none" \
4193 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
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, max handshake (FS, ticket + client auth)" \
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=required" \
4202 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +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é-Gonnard6093d812014-09-29 17:52:57 +02004208run_test "DTLS proxy: 3d, max handshake, nbio" \
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 nbio=2 tickets=1 \
4211 auth_mode=required" \
4212 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004213 0 \
4214 -s "Extra-header:" \
4215 -c "HTTP/1.0 200 OK"
4216
Janos Follath74537a62016-09-02 13:45:28 +01004217client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004218run_test "DTLS proxy: 3d, min handshake, resumption" \
4219 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4220 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4221 psk=abc123 debug_level=3" \
4222 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4223 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4224 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4225 0 \
4226 -s "a session has been resumed" \
4227 -c "a session has been resumed" \
4228 -s "Extra-header:" \
4229 -c "HTTP/1.0 200 OK"
4230
Janos Follath74537a62016-09-02 13:45:28 +01004231client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004232run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4233 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4234 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4235 psk=abc123 debug_level=3 nbio=2" \
4236 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4237 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4238 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4239 0 \
4240 -s "a session has been resumed" \
4241 -c "a session has been resumed" \
4242 -s "Extra-header:" \
4243 -c "HTTP/1.0 200 OK"
4244
Janos Follath74537a62016-09-02 13:45:28 +01004245client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004246run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004247 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004248 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4249 psk=abc123 renegotiation=1 debug_level=2" \
4250 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4251 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004252 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4253 0 \
4254 -c "=> renegotiate" \
4255 -s "=> renegotiate" \
4256 -s "Extra-header:" \
4257 -c "HTTP/1.0 200 OK"
4258
Janos Follath74537a62016-09-02 13:45:28 +01004259client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004260run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4261 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004262 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4263 psk=abc123 renegotiation=1 debug_level=2" \
4264 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4265 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004266 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4267 0 \
4268 -c "=> renegotiate" \
4269 -s "=> renegotiate" \
4270 -s "Extra-header:" \
4271 -c "HTTP/1.0 200 OK"
4272
Janos Follath74537a62016-09-02 13:45:28 +01004273client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004274run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004275 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004276 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004277 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004278 debug_level=2" \
4279 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004280 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004281 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4282 0 \
4283 -c "=> renegotiate" \
4284 -s "=> renegotiate" \
4285 -s "Extra-header:" \
4286 -c "HTTP/1.0 200 OK"
4287
Janos Follath74537a62016-09-02 13:45:28 +01004288client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004289run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004290 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004291 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004292 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004293 debug_level=2 nbio=2" \
4294 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004295 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004296 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4297 0 \
4298 -c "=> renegotiate" \
4299 -s "=> renegotiate" \
4300 -s "Extra-header:" \
4301 -c "HTTP/1.0 200 OK"
4302
Janos Follath74537a62016-09-02 13:45:28 +01004303client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004304not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004305run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004306 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4307 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004308 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004309 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004310 -c "HTTP/1.0 200 OK"
4311
Janos Follath74537a62016-09-02 13:45:28 +01004312client_needs_more_time 8
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, fragmentation" \
4315 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4316 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004317 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004318 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +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é-Gonnard6093d812014-09-29 17:52:57 +02004323run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
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 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004327 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004328 -c "HTTP/1.0 200 OK"
4329
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004330requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004331client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004332not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004333run_test "DTLS proxy: 3d, gnutls server" \
4334 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4335 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004336 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004337 0 \
4338 -s "Extra-header:" \
4339 -c "Extra-header:"
4340
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004341requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004342client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004343not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004344run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4345 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4346 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004347 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004348 0 \
4349 -s "Extra-header:" \
4350 -c "Extra-header:"
4351
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004352requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004353client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004354not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004355run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4356 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4357 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004358 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004359 0 \
4360 -s "Extra-header:" \
4361 -c "Extra-header:"
4362
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004363# Final report
4364
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004365echo "------------------------------------------------------------------------"
4366
4367if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004368 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004369else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004370 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004371fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004372PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004373echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004374
4375exit $FAILS