blob: 46c267dd4bf823b3b612a66693b9662807c9cda9 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200125# skip next test if the flag is enabled in config.h
126requires_config_disabled() {
127 if grep "^#define $1" $CONFIG_H > /dev/null; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200132# skip next test if OpenSSL doesn't support FALLBACK_SCSV
133requires_openssl_with_fallback_scsv() {
134 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
135 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
136 then
137 OPENSSL_HAS_FBSCSV="YES"
138 else
139 OPENSSL_HAS_FBSCSV="NO"
140 fi
141 fi
142 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
143 SKIP_NEXT="YES"
144 fi
145}
146
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200147# skip next test if GnuTLS isn't available
148requires_gnutls() {
149 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200150 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151 GNUTLS_AVAILABLE="YES"
152 else
153 GNUTLS_AVAILABLE="NO"
154 fi
155 fi
156 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200161# skip next test if IPv6 isn't available on this host
162requires_ipv6() {
163 if [ -z "${HAS_IPV6:-}" ]; then
164 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
165 SRV_PID=$!
166 sleep 1
167 kill $SRV_PID >/dev/null 2>&1
168 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
169 HAS_IPV6="NO"
170 else
171 HAS_IPV6="YES"
172 fi
173 rm -r $SRV_OUT
174 fi
175
176 if [ "$HAS_IPV6" = "NO" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200181# skip the next test if valgrind is in use
182not_with_valgrind() {
183 if [ "$MEMCHECK" -gt 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Paul Bakker362689d2016-05-13 10:33:25 +0100188# skip the next test if valgrind is NOT in use
189only_with_valgrind() {
190 if [ "$MEMCHECK" -eq 0 ]; then
191 SKIP_NEXT="YES"
192 fi
193}
194
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200195# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100196client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200197 CLI_DELAY_FACTOR=$1
198}
199
Janos Follath74537a62016-09-02 13:45:28 +0100200# wait for the given seconds after the client finished in the next test
201server_needs_more_time() {
202 SRV_DELAY_SECONDS=$1
203}
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205# print_name <name>
206print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100207 TESTS=$(( $TESTS + 1 ))
208 LINE=""
209
210 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
211 LINE="$TESTS "
212 fi
213
214 LINE="$LINE$1"
215 printf "$LINE "
216 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100217 for i in `seq 1 $LEN`; do printf '.'; done
218 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100220}
221
222# fail <message>
223fail() {
224 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100225 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200227 mv $SRV_OUT o-srv-${TESTS}.log
228 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if [ -n "$PXY_CMD" ]; then
230 mv $PXY_OUT o-pxy-${TESTS}.log
231 fi
232 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100233
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
235 echo " ! server output:"
236 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200237 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200238 echo " ! client output:"
239 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200240 if [ -n "$PXY_CMD" ]; then
241 echo " ! ========================================================"
242 echo " ! proxy output:"
243 cat o-pxy-${TESTS}.log
244 fi
245 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200246 fi
247
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200248 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249}
250
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251# is_polar <cmd_line>
252is_polar() {
253 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
254}
255
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200256# openssl s_server doesn't have -www with DTLS
257check_osrv_dtls() {
258 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
259 NEEDS_INPUT=1
260 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
261 else
262 NEEDS_INPUT=0
263 fi
264}
265
266# provide input to commands that need it
267provide_input() {
268 if [ $NEEDS_INPUT -eq 0 ]; then
269 return
270 fi
271
272 while true; do
273 echo "HTTP/1.0 200 OK"
274 sleep 1
275 done
276}
277
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100278# has_mem_err <log_file_name>
279has_mem_err() {
280 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
281 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
282 then
283 return 1 # false: does not have errors
284 else
285 return 0 # true: has errors
286 fi
287}
288
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200289# wait for server to start: two versions depending on lsof availability
290wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200291 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200292 START_TIME=$( date +%s )
293 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200294
295 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200296 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200297 while [ $DONE -eq 0 ]; do
298 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
299 then
300 DONE=1
301 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
302 echo "SERVERSTART TIMEOUT"
303 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
304 DONE=1
305 fi
306 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200307 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200308 while [ $DONE -eq 0 ]; do
309 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
310 then
311 DONE=1
312 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
313 echo "SERVERSTART TIMEOUT"
314 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
315 DONE=1
316 fi
317 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200318 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200319 else
320 sleep "$START_DELAY"
321 fi
322}
323
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100324# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100325# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100326# acceptable bounds
327check_server_hello_time() {
328 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100329 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100330 # Get the Unix timestamp for now
331 CUR_TIME=$(date +'%s')
332 THRESHOLD_IN_SECS=300
333
334 # Check if the ServerHello time was printed
335 if [ -z "$SERVER_HELLO_TIME" ]; then
336 return 1
337 fi
338
339 # Check the time in ServerHello is within acceptable bounds
340 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
341 # The time in ServerHello is at least 5 minutes before now
342 return 1
343 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100344 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100345 return 1
346 else
347 return 0
348 fi
349}
350
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200351# wait for client to terminate and set CLI_EXIT
352# must be called right after starting the client
353wait_client_done() {
354 CLI_PID=$!
355
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200356 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
357 CLI_DELAY_FACTOR=1
358
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200359 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200360 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200361
362 wait $CLI_PID
363 CLI_EXIT=$?
364
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200365 kill $DOG_PID >/dev/null 2>&1
366 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200367
368 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100369
370 sleep $SRV_DELAY_SECONDS
371 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200372}
373
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200374# check if the given command uses dtls and sets global variable DTLS
375detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200376 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200377 DTLS=1
378 else
379 DTLS=0
380 fi
381}
382
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200383# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100384# Options: -s pattern pattern that must be present in server output
385# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100386# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100387# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100388# -S pattern pattern that must be absent in server output
389# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100390# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100391# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100392run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100393 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200394 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100396 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
397 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200398 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100399 return
400 fi
401
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100403
Paul Bakkerb7584a52016-05-10 10:50:43 +0100404 # Do we only run numbered tests?
405 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
406 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
407 else
408 SKIP_NEXT="YES"
409 fi
410
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200411 # should we skip?
412 if [ "X$SKIP_NEXT" = "XYES" ]; then
413 SKIP_NEXT="NO"
414 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200415 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200416 return
417 fi
418
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200419 # does this test use a proxy?
420 if [ "X$1" = "X-p" ]; then
421 PXY_CMD="$2"
422 shift 2
423 else
424 PXY_CMD=""
425 fi
426
427 # get commands and client output
428 SRV_CMD="$1"
429 CLI_CMD="$2"
430 CLI_EXPECT="$3"
431 shift 3
432
433 # fix client port
434 if [ -n "$PXY_CMD" ]; then
435 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
436 else
437 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
438 fi
439
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200440 # update DTLS variable
441 detect_dtls "$SRV_CMD"
442
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100443 # prepend valgrind to our commands if active
444 if [ "$MEMCHECK" -gt 0 ]; then
445 if is_polar "$SRV_CMD"; then
446 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
447 fi
448 if is_polar "$CLI_CMD"; then
449 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
450 fi
451 fi
452
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200453 TIMES_LEFT=2
454 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200455 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200456
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200457 # run the commands
458 if [ -n "$PXY_CMD" ]; then
459 echo "$PXY_CMD" > $PXY_OUT
460 $PXY_CMD >> $PXY_OUT 2>&1 &
461 PXY_PID=$!
462 # assume proxy starts faster than server
463 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200464
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200465 check_osrv_dtls
466 echo "$SRV_CMD" > $SRV_OUT
467 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
468 SRV_PID=$!
469 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200470
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200471 echo "$CLI_CMD" > $CLI_OUT
472 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
473 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100474
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200475 # terminate the server (and the proxy)
476 kill $SRV_PID
477 wait $SRV_PID
478 if [ -n "$PXY_CMD" ]; then
479 kill $PXY_PID >/dev/null 2>&1
480 wait $PXY_PID
481 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100482
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200483 # retry only on timeouts
484 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
485 printf "RETRY "
486 else
487 TIMES_LEFT=0
488 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200489 done
490
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100491 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200492 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100493 # expected client exit to incorrectly succeed in case of catastrophic
494 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100495 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200496 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100497 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100498 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100499 return
500 fi
501 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100502 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200503 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100504 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100505 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100506 return
507 fi
508 fi
509
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100510 # check server exit code
511 if [ $? != 0 ]; then
512 fail "server fail"
513 return
514 fi
515
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100516 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100517 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
518 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100519 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200520 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100521 return
522 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100523
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100524 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200525 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100526 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100527 while [ $# -gt 0 ]
528 do
529 case $1 in
530 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100531 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100532 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100533 return
534 fi
535 ;;
536
537 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100538 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100539 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100540 return
541 fi
542 ;;
543
544 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100545 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100546 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100547 return
548 fi
549 ;;
550
551 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100552 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100553 fail "pattern '$2' MUST NOT be present in the Client output"
554 return
555 fi
556 ;;
557
558 # The filtering in the following two options (-u and -U) do the following
559 # - ignore valgrind output
560 # - filter out everything but lines right after the pattern occurances
561 # - keep one of each non-unique line
562 # - count how many lines remain
563 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
564 # if there were no duplicates.
565 "-U")
566 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
567 fail "lines following pattern '$2' must be unique in Server output"
568 return
569 fi
570 ;;
571
572 "-u")
573 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
574 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100575 return
576 fi
577 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100578 "-F")
579 if ! $2 "$SRV_OUT"; then
580 fail "function call to '$2' failed on Server output"
581 return
582 fi
583 ;;
584 "-f")
585 if ! $2 "$CLI_OUT"; then
586 fail "function call to '$2' failed on Client output"
587 return
588 fi
589 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100590
591 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200592 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100593 exit 1
594 esac
595 shift 2
596 done
597
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100598 # check valgrind's results
599 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200600 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100601 fail "Server has memory errors"
602 return
603 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200604 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100605 fail "Client has memory errors"
606 return
607 fi
608 fi
609
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100610 # if we're here, everything is ok
611 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100612 if [ "$PRESERVE_LOGS" -gt 0 ]; then
613 mv $SRV_OUT o-srv-${TESTS}.log
614 mv $CLI_OUT o-cli-${TESTS}.log
615 fi
616
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100618}
619
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100620cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200621 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200622 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
623 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
624 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
625 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100626 exit 1
627}
628
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100629#
630# MAIN
631#
632
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000633if cd $( dirname $0 ); then :; else
634 echo "cd $( dirname $0 ) failed" >&2
635 exit 1
636fi
637
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100638get_options "$@"
639
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100640# sanity checks, avoid an avalanche of errors
641if [ ! -x "$P_SRV" ]; then
642 echo "Command '$P_SRV' is not an executable file"
643 exit 1
644fi
645if [ ! -x "$P_CLI" ]; then
646 echo "Command '$P_CLI' is not an executable file"
647 exit 1
648fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200649if [ ! -x "$P_PXY" ]; then
650 echo "Command '$P_PXY' is not an executable file"
651 exit 1
652fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100653if [ "$MEMCHECK" -gt 0 ]; then
654 if which valgrind >/dev/null 2>&1; then :; else
655 echo "Memcheck not possible. Valgrind not found"
656 exit 1
657 fi
658fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100659if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
660 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100661 exit 1
662fi
663
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200664# used by watchdog
665MAIN_PID="$$"
666
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200667# be more patient with valgrind
668if [ "$MEMCHECK" -gt 0 ]; then
669 START_DELAY=3
670 DOG_DELAY=30
671else
672 START_DELAY=1
673 DOG_DELAY=10
674fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200675CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100676SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200677
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200678# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000679# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200680P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
681P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100682P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200683O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200684O_CLI="$O_CLI -connect localhost:+SRV_PORT"
685G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000686G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200687
Gilles Peskine62469d92017-05-10 10:13:59 +0200688# Allow SHA-1, because many of our test certificates use it
689P_SRV="$P_SRV allow_sha1=1"
690P_CLI="$P_CLI allow_sha1=1"
691
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200692# Also pick a unique name for intermediate files
693SRV_OUT="srv_out.$$"
694CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200695PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200696SESSION="session.$$"
697
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200698SKIP_NEXT="NO"
699
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100700trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100701
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200702# Basic test
703
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200704# Checks that:
705# - things work with all ciphersuites active (used with config-full in all.sh)
706# - the expected (highest security) parameters are selected
707# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200708run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200709 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200710 "$P_CLI" \
711 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200712 -s "Protocol is TLSv1.2" \
713 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
714 -s "client hello v3, signature_algorithm ext: 6" \
715 -s "ECDHE curve: secp521r1" \
716 -S "error" \
717 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200718
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000719run_test "Default, DTLS" \
720 "$P_SRV dtls=1" \
721 "$P_CLI dtls=1" \
722 0 \
723 -s "Protocol is DTLSv1.2" \
724 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
725
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100726# Test current time in ServerHello
727requires_config_enabled MBEDTLS_HAVE_TIME
728run_test "Default, ServerHello contains gmt_unix_time" \
729 "$P_SRV debug_level=3" \
730 "$P_CLI debug_level=3" \
731 0 \
732 -s "Protocol is TLSv1.2" \
733 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
734 -s "client hello v3, signature_algorithm ext: 6" \
735 -s "ECDHE curve: secp521r1" \
736 -S "error" \
737 -C "error" \
738 -f "check_server_hello_time" \
739 -F "check_server_hello_time"
740
Simon Butcher8e004102016-10-14 00:48:33 +0100741# Test for uniqueness of IVs in AEAD ciphersuites
742run_test "Unique IV in GCM" \
743 "$P_SRV exchanges=20 debug_level=4" \
744 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
745 0 \
746 -u "IV used" \
747 -U "IV used"
748
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100749# Tests for rc4 option
750
Simon Butchera410af52016-05-19 22:12:18 +0100751requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100752run_test "RC4: server disabled, client enabled" \
753 "$P_SRV" \
754 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
755 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100756 -s "SSL - The server has no ciphersuites in common"
757
Simon Butchera410af52016-05-19 22:12:18 +0100758requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100759run_test "RC4: server half, client enabled" \
760 "$P_SRV arc4=1" \
761 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
762 1 \
763 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100764
765run_test "RC4: server enabled, client disabled" \
766 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
767 "$P_CLI" \
768 1 \
769 -s "SSL - The server has no ciphersuites in common"
770
771run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100772 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100773 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
774 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100775 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100776 -S "SSL - The server has no ciphersuites in common"
777
Gilles Peskinebc70a182017-05-09 15:59:24 +0200778# Tests for SHA-1 support
779
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200780requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200781run_test "SHA-1 forbidden by default in server certificate" \
782 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
783 "$P_CLI debug_level=2 allow_sha1=0" \
784 1 \
785 -c "The certificate is signed with an unacceptable hash"
786
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200787requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
788run_test "SHA-1 forbidden by default in server certificate" \
789 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
790 "$P_CLI debug_level=2 allow_sha1=0" \
791 0
792
Gilles Peskinebc70a182017-05-09 15:59:24 +0200793run_test "SHA-1 explicitly allowed in server certificate" \
794 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
795 "$P_CLI allow_sha1=1" \
796 0
797
798run_test "SHA-256 allowed by default in server certificate" \
799 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
800 "$P_CLI allow_sha1=0" \
801 0
802
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200803requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200804run_test "SHA-1 forbidden by default in client certificate" \
805 "$P_SRV auth_mode=required allow_sha1=0" \
806 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
807 1 \
808 -s "The certificate is signed with an unacceptable hash"
809
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200810requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
811run_test "SHA-1 forbidden by default in client certificate" \
812 "$P_SRV auth_mode=required allow_sha1=0" \
813 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
814 0
815
Gilles Peskinebc70a182017-05-09 15:59:24 +0200816run_test "SHA-1 explicitly allowed in client certificate" \
817 "$P_SRV auth_mode=required allow_sha1=1" \
818 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
819 0
820
821run_test "SHA-256 allowed by default in client certificate" \
822 "$P_SRV auth_mode=required allow_sha1=0" \
823 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
824 0
825
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100826# Tests for Truncated HMAC extension
827
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100828run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200829 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100830 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100831 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000832 -s "dumping 'expected mac' (20 bytes)" \
833 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100834
Hanno Becker32c55012017-11-10 08:42:54 +0000835requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100836run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200837 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100838 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
839 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100840 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000841 -s "dumping 'expected mac' (20 bytes)" \
842 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100843
Hanno Becker32c55012017-11-10 08:42:54 +0000844requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100845run_test "Truncated HMAC: client enabled, server default" \
846 "$P_SRV debug_level=4" \
847 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
848 trunc_hmac=1" \
849 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000850 -s "dumping 'expected mac' (20 bytes)" \
851 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100852
Hanno Becker32c55012017-11-10 08:42:54 +0000853requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100854run_test "Truncated HMAC: client enabled, server disabled" \
855 "$P_SRV debug_level=4 trunc_hmac=0" \
856 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
857 trunc_hmac=1" \
858 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000859 -s "dumping 'expected mac' (20 bytes)" \
860 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100861
Hanno Becker32c55012017-11-10 08:42:54 +0000862requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000863run_test "Truncated HMAC: client disabled, server enabled" \
864 "$P_SRV debug_level=4 trunc_hmac=1" \
865 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
866 trunc_hmac=0" \
867 0 \
868 -s "dumping 'expected mac' (20 bytes)" \
869 -S "dumping 'expected mac' (10 bytes)"
870
871requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100872run_test "Truncated HMAC: client enabled, server enabled" \
873 "$P_SRV debug_level=4 trunc_hmac=1" \
874 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
875 trunc_hmac=1" \
876 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000877 -S "dumping 'expected mac' (20 bytes)" \
878 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100879
Hanno Becker4c4f4102017-11-10 09:16:05 +0000880run_test "Truncated HMAC, DTLS: client default, server default" \
881 "$P_SRV dtls=1 debug_level=4" \
882 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
883 0 \
884 -s "dumping 'expected mac' (20 bytes)" \
885 -S "dumping 'expected mac' (10 bytes)"
886
887requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
888run_test "Truncated HMAC, DTLS: client disabled, server default" \
889 "$P_SRV dtls=1 debug_level=4" \
890 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
891 trunc_hmac=0" \
892 0 \
893 -s "dumping 'expected mac' (20 bytes)" \
894 -S "dumping 'expected mac' (10 bytes)"
895
896requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
897run_test "Truncated HMAC, DTLS: client enabled, server default" \
898 "$P_SRV dtls=1 debug_level=4" \
899 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
900 trunc_hmac=1" \
901 0 \
902 -s "dumping 'expected mac' (20 bytes)" \
903 -S "dumping 'expected mac' (10 bytes)"
904
905requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
906run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
907 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
908 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
909 trunc_hmac=1" \
910 0 \
911 -s "dumping 'expected mac' (20 bytes)" \
912 -S "dumping 'expected mac' (10 bytes)"
913
914requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
915run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
916 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
917 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
918 trunc_hmac=0" \
919 0 \
920 -s "dumping 'expected mac' (20 bytes)" \
921 -S "dumping 'expected mac' (10 bytes)"
922
923requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
924run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
925 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
926 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
927 trunc_hmac=1" \
928 0 \
929 -S "dumping 'expected mac' (20 bytes)" \
930 -s "dumping 'expected mac' (10 bytes)"
931
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100932# Tests for Encrypt-then-MAC extension
933
934run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100935 "$P_SRV debug_level=3 \
936 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100937 "$P_CLI debug_level=3" \
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
946run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100947 "$P_SRV debug_level=3 etm=0 \
948 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100949 "$P_CLI debug_level=3 etm=1" \
950 0 \
951 -c "client hello, adding encrypt_then_mac extension" \
952 -s "found encrypt then mac extension" \
953 -S "server hello, adding encrypt then mac extension" \
954 -C "found encrypt_then_mac extension" \
955 -C "using encrypt then mac" \
956 -S "using encrypt then mac"
957
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100958run_test "Encrypt then MAC: client enabled, aead cipher" \
959 "$P_SRV debug_level=3 etm=1 \
960 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
961 "$P_CLI debug_level=3 etm=1" \
962 0 \
963 -c "client hello, adding encrypt_then_mac extension" \
964 -s "found encrypt then mac extension" \
965 -S "server hello, adding encrypt then mac extension" \
966 -C "found encrypt_then_mac extension" \
967 -C "using encrypt then mac" \
968 -S "using encrypt then mac"
969
970run_test "Encrypt then MAC: client enabled, stream cipher" \
971 "$P_SRV debug_level=3 etm=1 \
972 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100973 "$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 +0100974 0 \
975 -c "client hello, adding encrypt_then_mac extension" \
976 -s "found encrypt then mac extension" \
977 -S "server hello, adding encrypt then mac extension" \
978 -C "found encrypt_then_mac extension" \
979 -C "using encrypt then mac" \
980 -S "using encrypt then mac"
981
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100982run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100983 "$P_SRV debug_level=3 etm=1 \
984 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100985 "$P_CLI debug_level=3 etm=0" \
986 0 \
987 -C "client hello, adding encrypt_then_mac extension" \
988 -S "found encrypt then mac extension" \
989 -S "server hello, adding encrypt then mac extension" \
990 -C "found encrypt_then_mac extension" \
991 -C "using encrypt then mac" \
992 -S "using encrypt then mac"
993
Janos Follathe2681a42016-03-07 15:57:05 +0000994requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100995run_test "Encrypt then MAC: 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é-Gonnard0098e7d2014-10-28 13:08:59 +0100997 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100998 "$P_CLI debug_level=3 force_version=ssl3" \
999 0 \
1000 -C "client hello, adding encrypt_then_mac extension" \
1001 -S "found encrypt then mac extension" \
1002 -S "server hello, adding encrypt then mac extension" \
1003 -C "found encrypt_then_mac extension" \
1004 -C "using encrypt then mac" \
1005 -S "using encrypt then mac"
1006
Janos Follathe2681a42016-03-07 15:57:05 +00001007requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001008run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001009 "$P_SRV debug_level=3 force_version=ssl3 \
1010 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001011 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001012 0 \
1013 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001014 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001015 -S "server hello, adding encrypt then mac extension" \
1016 -C "found encrypt_then_mac extension" \
1017 -C "using encrypt then mac" \
1018 -S "using encrypt then mac"
1019
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001020# Tests for Extended Master Secret extension
1021
1022run_test "Extended Master Secret: default" \
1023 "$P_SRV debug_level=3" \
1024 "$P_CLI debug_level=3" \
1025 0 \
1026 -c "client hello, adding extended_master_secret extension" \
1027 -s "found extended master secret extension" \
1028 -s "server hello, adding extended master secret extension" \
1029 -c "found extended_master_secret extension" \
1030 -c "using extended master secret" \
1031 -s "using extended master secret"
1032
1033run_test "Extended Master Secret: client enabled, server disabled" \
1034 "$P_SRV debug_level=3 extended_ms=0" \
1035 "$P_CLI debug_level=3 extended_ms=1" \
1036 0 \
1037 -c "client hello, adding extended_master_secret extension" \
1038 -s "found extended master secret extension" \
1039 -S "server hello, adding extended master secret extension" \
1040 -C "found extended_master_secret extension" \
1041 -C "using extended master secret" \
1042 -S "using extended master secret"
1043
1044run_test "Extended Master Secret: client disabled, server enabled" \
1045 "$P_SRV debug_level=3 extended_ms=1" \
1046 "$P_CLI debug_level=3 extended_ms=0" \
1047 0 \
1048 -C "client hello, adding extended_master_secret extension" \
1049 -S "found extended master secret extension" \
1050 -S "server hello, adding extended master secret extension" \
1051 -C "found extended_master_secret extension" \
1052 -C "using extended master secret" \
1053 -S "using extended master secret"
1054
Janos Follathe2681a42016-03-07 15:57:05 +00001055requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001056run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001057 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001058 "$P_CLI debug_level=3 force_version=ssl3" \
1059 0 \
1060 -C "client hello, adding extended_master_secret extension" \
1061 -S "found extended master secret extension" \
1062 -S "server hello, adding extended master secret extension" \
1063 -C "found extended_master_secret extension" \
1064 -C "using extended master secret" \
1065 -S "using extended master secret"
1066
Janos Follathe2681a42016-03-07 15:57:05 +00001067requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001068run_test "Extended Master Secret: client enabled, server SSLv3" \
1069 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001070 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001071 0 \
1072 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001073 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001074 -S "server hello, adding extended master secret extension" \
1075 -C "found extended_master_secret extension" \
1076 -C "using extended master secret" \
1077 -S "using extended master secret"
1078
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001079# Tests for FALLBACK_SCSV
1080
1081run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001082 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001083 "$P_CLI debug_level=3 force_version=tls1_1" \
1084 0 \
1085 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001086 -S "received FALLBACK_SCSV" \
1087 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001088 -C "is a fatal alert message (msg 86)"
1089
1090run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001091 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001092 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1093 0 \
1094 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001095 -S "received FALLBACK_SCSV" \
1096 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001097 -C "is a fatal alert message (msg 86)"
1098
1099run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001100 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001101 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001102 1 \
1103 -c "adding FALLBACK_SCSV" \
1104 -s "received FALLBACK_SCSV" \
1105 -s "inapropriate fallback" \
1106 -c "is a fatal alert message (msg 86)"
1107
1108run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001109 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001110 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001111 0 \
1112 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001113 -s "received FALLBACK_SCSV" \
1114 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001115 -C "is a fatal alert message (msg 86)"
1116
1117requires_openssl_with_fallback_scsv
1118run_test "Fallback SCSV: default, openssl server" \
1119 "$O_SRV" \
1120 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1121 0 \
1122 -C "adding FALLBACK_SCSV" \
1123 -C "is a fatal alert message (msg 86)"
1124
1125requires_openssl_with_fallback_scsv
1126run_test "Fallback SCSV: enabled, openssl server" \
1127 "$O_SRV" \
1128 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1129 1 \
1130 -c "adding FALLBACK_SCSV" \
1131 -c "is a fatal alert message (msg 86)"
1132
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001133requires_openssl_with_fallback_scsv
1134run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001135 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001136 "$O_CLI -tls1_1" \
1137 0 \
1138 -S "received FALLBACK_SCSV" \
1139 -S "inapropriate fallback"
1140
1141requires_openssl_with_fallback_scsv
1142run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001143 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001144 "$O_CLI -tls1_1 -fallback_scsv" \
1145 1 \
1146 -s "received FALLBACK_SCSV" \
1147 -s "inapropriate fallback"
1148
1149requires_openssl_with_fallback_scsv
1150run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001151 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001152 "$O_CLI -fallback_scsv" \
1153 0 \
1154 -s "received FALLBACK_SCSV" \
1155 -S "inapropriate fallback"
1156
Gilles Peskined50177f2017-05-16 17:53:03 +02001157## ClientHello generated with
1158## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1159## then manually twiddling the ciphersuite list.
1160## The ClientHello content is spelled out below as a hex string as
1161## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1162## The expected response is an inappropriate_fallback alert.
1163requires_openssl_with_fallback_scsv
1164run_test "Fallback SCSV: beginning of list" \
1165 "$P_SRV debug_level=2" \
1166 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1167 0 \
1168 -s "received FALLBACK_SCSV" \
1169 -s "inapropriate fallback"
1170
1171requires_openssl_with_fallback_scsv
1172run_test "Fallback SCSV: end of list" \
1173 "$P_SRV debug_level=2" \
1174 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1175 0 \
1176 -s "received FALLBACK_SCSV" \
1177 -s "inapropriate fallback"
1178
1179## Here the expected response is a valid ServerHello prefix, up to the random.
1180requires_openssl_with_fallback_scsv
1181run_test "Fallback SCSV: not in list" \
1182 "$P_SRV debug_level=2" \
1183 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1184 0 \
1185 -S "received FALLBACK_SCSV" \
1186 -S "inapropriate fallback"
1187
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001188# Tests for CBC 1/n-1 record splitting
1189
1190run_test "CBC Record splitting: TLS 1.2, no splitting" \
1191 "$P_SRV" \
1192 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1193 request_size=123 force_version=tls1_2" \
1194 0 \
1195 -s "Read from client: 123 bytes read" \
1196 -S "Read from client: 1 bytes read" \
1197 -S "122 bytes read"
1198
1199run_test "CBC Record splitting: TLS 1.1, no splitting" \
1200 "$P_SRV" \
1201 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1202 request_size=123 force_version=tls1_1" \
1203 0 \
1204 -s "Read from client: 123 bytes read" \
1205 -S "Read from client: 1 bytes read" \
1206 -S "122 bytes read"
1207
1208run_test "CBC Record splitting: TLS 1.0, splitting" \
1209 "$P_SRV" \
1210 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1211 request_size=123 force_version=tls1" \
1212 0 \
1213 -S "Read from client: 123 bytes read" \
1214 -s "Read from client: 1 bytes read" \
1215 -s "122 bytes read"
1216
Janos Follathe2681a42016-03-07 15:57:05 +00001217requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001218run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001219 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001220 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1221 request_size=123 force_version=ssl3" \
1222 0 \
1223 -S "Read from client: 123 bytes read" \
1224 -s "Read from client: 1 bytes read" \
1225 -s "122 bytes read"
1226
1227run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001228 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001229 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1230 request_size=123 force_version=tls1" \
1231 0 \
1232 -s "Read from client: 123 bytes read" \
1233 -S "Read from client: 1 bytes read" \
1234 -S "122 bytes read"
1235
1236run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1237 "$P_SRV" \
1238 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1239 request_size=123 force_version=tls1 recsplit=0" \
1240 0 \
1241 -s "Read from client: 123 bytes read" \
1242 -S "Read from client: 1 bytes read" \
1243 -S "122 bytes read"
1244
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001245run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1246 "$P_SRV nbio=2" \
1247 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1248 request_size=123 force_version=tls1" \
1249 0 \
1250 -S "Read from client: 123 bytes read" \
1251 -s "Read from client: 1 bytes read" \
1252 -s "122 bytes read"
1253
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001254# Tests for Session Tickets
1255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_SRV debug_level=3 tickets=1" \
1258 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001259 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001260 -c "client hello, adding session ticket extension" \
1261 -s "found session ticket extension" \
1262 -s "server hello, adding session ticket extension" \
1263 -c "found session_ticket extension" \
1264 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001265 -S "session successfully restored from cache" \
1266 -s "session successfully restored from ticket" \
1267 -s "a session has been resumed" \
1268 -c "a session has been resumed"
1269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001270run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001271 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1272 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001273 0 \
1274 -c "client hello, adding session ticket extension" \
1275 -s "found session ticket extension" \
1276 -s "server hello, adding session ticket extension" \
1277 -c "found session_ticket extension" \
1278 -c "parse new session ticket" \
1279 -S "session successfully restored from cache" \
1280 -s "session successfully restored from ticket" \
1281 -s "a session has been resumed" \
1282 -c "a session has been resumed"
1283
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001284run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001285 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1286 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001287 0 \
1288 -c "client hello, adding session ticket extension" \
1289 -s "found session ticket extension" \
1290 -s "server hello, adding session ticket extension" \
1291 -c "found session_ticket extension" \
1292 -c "parse new session ticket" \
1293 -S "session successfully restored from cache" \
1294 -S "session successfully restored from ticket" \
1295 -S "a session has been resumed" \
1296 -C "a session has been resumed"
1297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001298run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001299 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001300 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001301 0 \
1302 -c "client hello, adding session ticket extension" \
1303 -c "found session_ticket extension" \
1304 -c "parse new session ticket" \
1305 -c "a session has been resumed"
1306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001307run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001308 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001309 "( $O_CLI -sess_out $SESSION; \
1310 $O_CLI -sess_in $SESSION; \
1311 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001312 0 \
1313 -s "found session ticket extension" \
1314 -s "server hello, adding session ticket extension" \
1315 -S "session successfully restored from cache" \
1316 -s "session successfully restored from ticket" \
1317 -s "a session has been resumed"
1318
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001319# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001321run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001322 "$P_SRV debug_level=3 tickets=0" \
1323 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001324 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001325 -c "client hello, adding session ticket extension" \
1326 -s "found session ticket extension" \
1327 -S "server hello, adding session ticket extension" \
1328 -C "found session_ticket extension" \
1329 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001330 -s "session successfully restored from cache" \
1331 -S "session successfully restored from ticket" \
1332 -s "a session has been resumed" \
1333 -c "a session has been resumed"
1334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001335run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001336 "$P_SRV debug_level=3 tickets=1" \
1337 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001338 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001339 -C "client hello, adding session ticket extension" \
1340 -S "found session ticket extension" \
1341 -S "server hello, adding session ticket extension" \
1342 -C "found session_ticket extension" \
1343 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001344 -s "session successfully restored from cache" \
1345 -S "session successfully restored from ticket" \
1346 -s "a session has been resumed" \
1347 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001349run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001350 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1351 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001352 0 \
1353 -S "session successfully restored from cache" \
1354 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001355 -S "a session has been resumed" \
1356 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001358run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001359 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1360 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001361 0 \
1362 -s "session successfully restored from cache" \
1363 -S "session successfully restored from ticket" \
1364 -s "a session has been resumed" \
1365 -c "a session has been resumed"
1366
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001367run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001368 "$P_SRV debug_level=3 tickets=0" \
1369 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001370 0 \
1371 -s "session successfully restored from cache" \
1372 -S "session successfully restored from ticket" \
1373 -s "a session has been resumed" \
1374 -c "a session has been resumed"
1375
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001376run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001377 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1378 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001379 0 \
1380 -S "session successfully restored from cache" \
1381 -S "session successfully restored from ticket" \
1382 -S "a session has been resumed" \
1383 -C "a session has been resumed"
1384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001385run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001386 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1387 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001388 0 \
1389 -s "session successfully restored from cache" \
1390 -S "session successfully restored from ticket" \
1391 -s "a session has been resumed" \
1392 -c "a session has been resumed"
1393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001394run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001395 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001396 "( $O_CLI -sess_out $SESSION; \
1397 $O_CLI -sess_in $SESSION; \
1398 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001399 0 \
1400 -s "found session ticket extension" \
1401 -S "server hello, adding session ticket extension" \
1402 -s "session successfully restored from cache" \
1403 -S "session successfully restored from ticket" \
1404 -s "a session has been resumed"
1405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001406run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001407 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001408 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001409 0 \
1410 -C "found session_ticket extension" \
1411 -C "parse new session ticket" \
1412 -c "a session has been resumed"
1413
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001414# Tests for Max Fragment Length extension
1415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001416run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001417 "$P_SRV debug_level=3" \
1418 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001419 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001420 -c "Maximum fragment length is 16384" \
1421 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001422 -C "client hello, adding max_fragment_length extension" \
1423 -S "found max fragment length extension" \
1424 -S "server hello, max_fragment_length extension" \
1425 -C "found max_fragment_length extension"
1426
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001427run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001428 "$P_SRV debug_level=3" \
1429 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001430 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001431 -c "Maximum fragment length is 4096" \
1432 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001433 -c "client hello, adding max_fragment_length extension" \
1434 -s "found max fragment length extension" \
1435 -s "server hello, max_fragment_length extension" \
1436 -c "found max_fragment_length extension"
1437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001438run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001439 "$P_SRV debug_level=3 max_frag_len=4096" \
1440 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001441 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001442 -c "Maximum fragment length is 16384" \
1443 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001444 -C "client hello, adding max_fragment_length extension" \
1445 -S "found max fragment length extension" \
1446 -S "server hello, max_fragment_length extension" \
1447 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001449requires_gnutls
1450run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001451 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001452 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001453 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001454 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001455 -c "client hello, adding max_fragment_length extension" \
1456 -c "found max_fragment_length extension"
1457
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001458run_test "Max fragment length: client, message just fits" \
1459 "$P_SRV debug_level=3" \
1460 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1461 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001462 -c "Maximum fragment length is 2048" \
1463 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001464 -c "client hello, adding max_fragment_length extension" \
1465 -s "found max fragment length extension" \
1466 -s "server hello, max_fragment_length extension" \
1467 -c "found max_fragment_length extension" \
1468 -c "2048 bytes written in 1 fragments" \
1469 -s "2048 bytes read"
1470
1471run_test "Max fragment length: client, larger message" \
1472 "$P_SRV debug_level=3" \
1473 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1474 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001475 -c "Maximum fragment length is 2048" \
1476 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001477 -c "client hello, adding max_fragment_length extension" \
1478 -s "found max fragment length extension" \
1479 -s "server hello, max_fragment_length extension" \
1480 -c "found max_fragment_length extension" \
1481 -c "2345 bytes written in 2 fragments" \
1482 -s "2048 bytes read" \
1483 -s "297 bytes read"
1484
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001485run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001486 "$P_SRV debug_level=3 dtls=1" \
1487 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1488 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001489 -c "Maximum fragment length is 2048" \
1490 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001491 -c "client hello, adding max_fragment_length extension" \
1492 -s "found max fragment length extension" \
1493 -s "server hello, max_fragment_length extension" \
1494 -c "found max_fragment_length extension" \
1495 -c "fragment larger than.*maximum"
1496
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001497# Tests for renegotiation
1498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001499run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001500 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001501 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001502 0 \
1503 -C "client hello, adding renegotiation extension" \
1504 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1505 -S "found renegotiation extension" \
1506 -s "server hello, secure renegotiation extension" \
1507 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001508 -C "=> renegotiate" \
1509 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001510 -S "write hello request"
1511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001512run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001513 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001514 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001515 0 \
1516 -c "client hello, adding renegotiation extension" \
1517 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1518 -s "found renegotiation extension" \
1519 -s "server hello, secure renegotiation extension" \
1520 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001521 -c "=> renegotiate" \
1522 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001523 -S "write hello request"
1524
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001525run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001526 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001527 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001528 0 \
1529 -c "client hello, adding renegotiation extension" \
1530 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1531 -s "found renegotiation extension" \
1532 -s "server hello, secure renegotiation extension" \
1533 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001534 -c "=> renegotiate" \
1535 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001536 -s "write hello request"
1537
Janos Follathb0f148c2017-10-05 12:29:42 +01001538# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1539# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1540# algorithm stronger than SHA-1 is enabled in config.h
1541run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1542 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1543 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1544 0 \
1545 -c "client hello, adding renegotiation extension" \
1546 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1547 -s "found renegotiation extension" \
1548 -s "server hello, secure renegotiation extension" \
1549 -c "found renegotiation extension" \
1550 -c "=> renegotiate" \
1551 -s "=> renegotiate" \
1552 -S "write hello request" \
1553 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1554
1555# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1556# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1557# algorithm stronger than SHA-1 is enabled in config.h
1558run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1559 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1560 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1561 0 \
1562 -c "client hello, adding renegotiation extension" \
1563 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1564 -s "found renegotiation extension" \
1565 -s "server hello, secure renegotiation extension" \
1566 -c "found renegotiation extension" \
1567 -c "=> renegotiate" \
1568 -s "=> renegotiate" \
1569 -s "write hello request" \
1570 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1571
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001572run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001573 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001574 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001575 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" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001581 -c "=> renegotiate" \
1582 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001583 -s "write hello request"
1584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001585run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001586 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001587 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001588 1 \
1589 -c "client hello, adding renegotiation extension" \
1590 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1591 -S "found renegotiation extension" \
1592 -s "server hello, secure renegotiation extension" \
1593 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001594 -c "=> renegotiate" \
1595 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001596 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001597 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001598 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001600run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001601 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001602 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001603 0 \
1604 -C "client hello, adding renegotiation extension" \
1605 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1606 -S "found renegotiation extension" \
1607 -s "server hello, secure renegotiation extension" \
1608 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001609 -C "=> renegotiate" \
1610 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001611 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001612 -S "SSL - An unexpected message was received from our peer" \
1613 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001615run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001616 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001617 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001618 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001619 0 \
1620 -C "client hello, adding renegotiation extension" \
1621 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1622 -S "found renegotiation extension" \
1623 -s "server hello, secure renegotiation extension" \
1624 -c "found renegotiation extension" \
1625 -C "=> renegotiate" \
1626 -S "=> renegotiate" \
1627 -s "write hello request" \
1628 -S "SSL - An unexpected message was received from our peer" \
1629 -S "failed"
1630
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001631# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001632run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001633 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001634 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001635 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001636 0 \
1637 -C "client hello, adding renegotiation extension" \
1638 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1639 -S "found renegotiation extension" \
1640 -s "server hello, secure renegotiation extension" \
1641 -c "found renegotiation extension" \
1642 -C "=> renegotiate" \
1643 -S "=> renegotiate" \
1644 -s "write hello request" \
1645 -S "SSL - An unexpected message was received from our peer" \
1646 -S "failed"
1647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001648run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001649 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001650 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001651 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001652 0 \
1653 -C "client hello, adding renegotiation extension" \
1654 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1655 -S "found renegotiation extension" \
1656 -s "server hello, secure renegotiation extension" \
1657 -c "found renegotiation extension" \
1658 -C "=> renegotiate" \
1659 -S "=> renegotiate" \
1660 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001661 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001663run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001664 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001665 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001666 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001667 0 \
1668 -c "client hello, adding renegotiation extension" \
1669 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1670 -s "found renegotiation extension" \
1671 -s "server hello, secure renegotiation extension" \
1672 -c "found renegotiation extension" \
1673 -c "=> renegotiate" \
1674 -s "=> renegotiate" \
1675 -s "write hello request" \
1676 -S "SSL - An unexpected message was received from our peer" \
1677 -S "failed"
1678
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001679run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001680 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001681 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1682 0 \
1683 -C "client hello, adding renegotiation extension" \
1684 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1685 -S "found renegotiation extension" \
1686 -s "server hello, secure renegotiation extension" \
1687 -c "found renegotiation extension" \
1688 -S "record counter limit reached: renegotiate" \
1689 -C "=> renegotiate" \
1690 -S "=> renegotiate" \
1691 -S "write hello request" \
1692 -S "SSL - An unexpected message was received from our peer" \
1693 -S "failed"
1694
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001695# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001696run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001697 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001698 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001699 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 -s "record counter limit reached: renegotiate" \
1706 -c "=> renegotiate" \
1707 -s "=> renegotiate" \
1708 -s "write hello request" \
1709 -S "SSL - An unexpected message was received from our peer" \
1710 -S "failed"
1711
1712run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001713 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001714 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001715 0 \
1716 -c "client hello, adding renegotiation extension" \
1717 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1718 -s "found renegotiation extension" \
1719 -s "server hello, secure renegotiation extension" \
1720 -c "found renegotiation extension" \
1721 -s "record counter limit reached: renegotiate" \
1722 -c "=> renegotiate" \
1723 -s "=> renegotiate" \
1724 -s "write hello request" \
1725 -S "SSL - An unexpected message was received from our peer" \
1726 -S "failed"
1727
1728run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001729 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001730 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1731 0 \
1732 -C "client hello, adding renegotiation extension" \
1733 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1734 -S "found renegotiation extension" \
1735 -s "server hello, secure renegotiation extension" \
1736 -c "found renegotiation extension" \
1737 -S "record counter limit reached: renegotiate" \
1738 -C "=> renegotiate" \
1739 -S "=> renegotiate" \
1740 -S "write hello request" \
1741 -S "SSL - An unexpected message was received from our peer" \
1742 -S "failed"
1743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001744run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001745 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001746 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001747 0 \
1748 -c "client hello, adding renegotiation extension" \
1749 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1750 -s "found renegotiation extension" \
1751 -s "server hello, secure renegotiation extension" \
1752 -c "found renegotiation extension" \
1753 -c "=> renegotiate" \
1754 -s "=> renegotiate" \
1755 -S "write hello request"
1756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001757run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001758 "$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 +02001759 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001760 0 \
1761 -c "client hello, adding renegotiation extension" \
1762 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1763 -s "found renegotiation extension" \
1764 -s "server hello, secure renegotiation extension" \
1765 -c "found renegotiation extension" \
1766 -c "=> renegotiate" \
1767 -s "=> renegotiate" \
1768 -s "write hello request"
1769
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001770run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001771 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001772 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001773 0 \
1774 -c "client hello, adding renegotiation extension" \
1775 -c "found renegotiation extension" \
1776 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001777 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001778 -C "error" \
1779 -c "HTTP/1.0 200 [Oo][Kk]"
1780
Paul Bakker539d9722015-02-08 16:18:35 +01001781requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001782run_test "Renegotiation: gnutls server strict, client-initiated" \
1783 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001784 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001785 0 \
1786 -c "client hello, adding renegotiation extension" \
1787 -c "found renegotiation extension" \
1788 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001789 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001790 -C "error" \
1791 -c "HTTP/1.0 200 [Oo][Kk]"
1792
Paul Bakker539d9722015-02-08 16:18:35 +01001793requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001794run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1795 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1796 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1797 1 \
1798 -c "client hello, adding renegotiation extension" \
1799 -C "found renegotiation extension" \
1800 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001801 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001802 -c "error" \
1803 -C "HTTP/1.0 200 [Oo][Kk]"
1804
Paul Bakker539d9722015-02-08 16:18:35 +01001805requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001806run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1807 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1808 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1809 allow_legacy=0" \
1810 1 \
1811 -c "client hello, adding renegotiation extension" \
1812 -C "found renegotiation extension" \
1813 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001814 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001815 -c "error" \
1816 -C "HTTP/1.0 200 [Oo][Kk]"
1817
Paul Bakker539d9722015-02-08 16:18:35 +01001818requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001819run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1820 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1821 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1822 allow_legacy=1" \
1823 0 \
1824 -c "client hello, adding renegotiation extension" \
1825 -C "found renegotiation extension" \
1826 -c "=> renegotiate" \
1827 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001828 -C "error" \
1829 -c "HTTP/1.0 200 [Oo][Kk]"
1830
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001831run_test "Renegotiation: DTLS, client-initiated" \
1832 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1833 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1834 0 \
1835 -c "client hello, adding renegotiation extension" \
1836 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1837 -s "found renegotiation extension" \
1838 -s "server hello, secure renegotiation extension" \
1839 -c "found renegotiation extension" \
1840 -c "=> renegotiate" \
1841 -s "=> renegotiate" \
1842 -S "write hello request"
1843
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001844run_test "Renegotiation: DTLS, server-initiated" \
1845 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001846 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1847 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001848 0 \
1849 -c "client hello, adding renegotiation extension" \
1850 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1851 -s "found renegotiation extension" \
1852 -s "server hello, secure renegotiation extension" \
1853 -c "found renegotiation extension" \
1854 -c "=> renegotiate" \
1855 -s "=> renegotiate" \
1856 -s "write hello request"
1857
Andres AG692ad842017-01-19 16:30:57 +00001858run_test "Renegotiation: DTLS, renego_period overflow" \
1859 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1860 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1861 0 \
1862 -c "client hello, adding renegotiation extension" \
1863 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1864 -s "found renegotiation extension" \
1865 -s "server hello, secure renegotiation extension" \
1866 -s "record counter limit reached: renegotiate" \
1867 -c "=> renegotiate" \
1868 -s "=> renegotiate" \
1869 -s "write hello request" \
1870
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001871requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001872run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1873 "$G_SRV -u --mtu 4096" \
1874 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1875 0 \
1876 -c "client hello, adding renegotiation extension" \
1877 -c "found renegotiation extension" \
1878 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001879 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001880 -C "error" \
1881 -s "Extra-header:"
1882
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001883# Test for the "secure renegotation" extension only (no actual renegotiation)
1884
Paul Bakker539d9722015-02-08 16:18:35 +01001885requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001886run_test "Renego ext: gnutls server strict, client default" \
1887 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1888 "$P_CLI debug_level=3" \
1889 0 \
1890 -c "found renegotiation extension" \
1891 -C "error" \
1892 -c "HTTP/1.0 200 [Oo][Kk]"
1893
Paul Bakker539d9722015-02-08 16:18:35 +01001894requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001895run_test "Renego ext: gnutls server unsafe, client default" \
1896 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1897 "$P_CLI debug_level=3" \
1898 0 \
1899 -C "found renegotiation extension" \
1900 -C "error" \
1901 -c "HTTP/1.0 200 [Oo][Kk]"
1902
Paul Bakker539d9722015-02-08 16:18:35 +01001903requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001904run_test "Renego ext: gnutls server unsafe, client break legacy" \
1905 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1906 "$P_CLI debug_level=3 allow_legacy=-1" \
1907 1 \
1908 -C "found renegotiation extension" \
1909 -c "error" \
1910 -C "HTTP/1.0 200 [Oo][Kk]"
1911
Paul Bakker539d9722015-02-08 16:18:35 +01001912requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001913run_test "Renego ext: gnutls client strict, server default" \
1914 "$P_SRV debug_level=3" \
1915 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1916 0 \
1917 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1918 -s "server hello, secure renegotiation extension"
1919
Paul Bakker539d9722015-02-08 16:18:35 +01001920requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001921run_test "Renego ext: gnutls client unsafe, server default" \
1922 "$P_SRV debug_level=3" \
1923 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1924 0 \
1925 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1926 -S "server hello, secure renegotiation extension"
1927
Paul Bakker539d9722015-02-08 16:18:35 +01001928requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001929run_test "Renego ext: gnutls client unsafe, server break legacy" \
1930 "$P_SRV debug_level=3 allow_legacy=-1" \
1931 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1932 1 \
1933 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1934 -S "server hello, secure renegotiation extension"
1935
Janos Follath0b242342016-02-17 10:11:21 +00001936# Tests for silently dropping trailing extra bytes in .der certificates
1937
1938requires_gnutls
1939run_test "DER format: no trailing bytes" \
1940 "$P_SRV crt_file=data_files/server5-der0.crt \
1941 key_file=data_files/server5.key" \
1942 "$G_CLI " \
1943 0 \
1944 -c "Handshake was completed" \
1945
1946requires_gnutls
1947run_test "DER format: with a trailing zero byte" \
1948 "$P_SRV crt_file=data_files/server5-der1a.crt \
1949 key_file=data_files/server5.key" \
1950 "$G_CLI " \
1951 0 \
1952 -c "Handshake was completed" \
1953
1954requires_gnutls
1955run_test "DER format: with a trailing random byte" \
1956 "$P_SRV crt_file=data_files/server5-der1b.crt \
1957 key_file=data_files/server5.key" \
1958 "$G_CLI " \
1959 0 \
1960 -c "Handshake was completed" \
1961
1962requires_gnutls
1963run_test "DER format: with 2 trailing random bytes" \
1964 "$P_SRV crt_file=data_files/server5-der2.crt \
1965 key_file=data_files/server5.key" \
1966 "$G_CLI " \
1967 0 \
1968 -c "Handshake was completed" \
1969
1970requires_gnutls
1971run_test "DER format: with 4 trailing random bytes" \
1972 "$P_SRV crt_file=data_files/server5-der4.crt \
1973 key_file=data_files/server5.key" \
1974 "$G_CLI " \
1975 0 \
1976 -c "Handshake was completed" \
1977
1978requires_gnutls
1979run_test "DER format: with 8 trailing random bytes" \
1980 "$P_SRV crt_file=data_files/server5-der8.crt \
1981 key_file=data_files/server5.key" \
1982 "$G_CLI " \
1983 0 \
1984 -c "Handshake was completed" \
1985
1986requires_gnutls
1987run_test "DER format: with 9 trailing random bytes" \
1988 "$P_SRV crt_file=data_files/server5-der9.crt \
1989 key_file=data_files/server5.key" \
1990 "$G_CLI " \
1991 0 \
1992 -c "Handshake was completed" \
1993
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001994# Tests for auth_mode
1995
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001996run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001997 "$P_SRV crt_file=data_files/server5-badsign.crt \
1998 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001999 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002000 1 \
2001 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002002 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002003 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002004 -c "X509 - Certificate verification failed"
2005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002006run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002007 "$P_SRV crt_file=data_files/server5-badsign.crt \
2008 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002009 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002010 0 \
2011 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002012 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002013 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002014 -C "X509 - Certificate verification failed"
2015
Hanno Beckere6706e62017-05-15 16:05:15 +01002016run_test "Authentication: server goodcert, client optional, no trusted CA" \
2017 "$P_SRV" \
2018 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2019 0 \
2020 -c "x509_verify_cert() returned" \
2021 -c "! The certificate is not correctly signed by the trusted CA" \
2022 -c "! Certificate verification flags"\
2023 -C "! mbedtls_ssl_handshake returned" \
2024 -C "X509 - Certificate verification failed" \
2025 -C "SSL - No CA Chain is set, but required to operate"
2026
2027run_test "Authentication: server goodcert, client required, no trusted CA" \
2028 "$P_SRV" \
2029 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2030 1 \
2031 -c "x509_verify_cert() returned" \
2032 -c "! The certificate is not correctly signed by the trusted CA" \
2033 -c "! Certificate verification flags"\
2034 -c "! mbedtls_ssl_handshake returned" \
2035 -c "SSL - No CA Chain is set, but required to operate"
2036
2037# The purpose of the next two tests is to test the client's behaviour when receiving a server
2038# certificate with an unsupported elliptic curve. This should usually not happen because
2039# the client informs the server about the supported curves - it does, though, in the
2040# corner case of a static ECDH suite, because the server doesn't check the curve on that
2041# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2042# different means to have the server ignoring the client's supported curve list.
2043
2044requires_config_enabled MBEDTLS_ECP_C
2045run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2046 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2047 crt_file=data_files/server5.ku-ka.crt" \
2048 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2049 1 \
2050 -c "bad certificate (EC key curve)"\
2051 -c "! Certificate verification flags"\
2052 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2053
2054requires_config_enabled MBEDTLS_ECP_C
2055run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2056 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2057 crt_file=data_files/server5.ku-ka.crt" \
2058 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2059 1 \
2060 -c "bad certificate (EC key curve)"\
2061 -c "! Certificate verification flags"\
2062 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002064run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002065 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002066 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002067 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002068 0 \
2069 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002070 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002071 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002072 -C "X509 - Certificate verification failed"
2073
Simon Butcher99000142016-10-13 17:21:01 +01002074run_test "Authentication: client SHA256, server required" \
2075 "$P_SRV auth_mode=required" \
2076 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2077 key_file=data_files/server6.key \
2078 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2079 0 \
2080 -c "Supported Signature Algorithm found: 4," \
2081 -c "Supported Signature Algorithm found: 5,"
2082
2083run_test "Authentication: client SHA384, server required" \
2084 "$P_SRV auth_mode=required" \
2085 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2086 key_file=data_files/server6.key \
2087 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2088 0 \
2089 -c "Supported Signature Algorithm found: 4," \
2090 -c "Supported Signature Algorithm found: 5,"
2091
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002092requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2093run_test "Authentication: client has no cert, server required (SSLv3)" \
2094 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2095 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2096 key_file=data_files/server5.key" \
2097 1 \
2098 -S "skip write certificate request" \
2099 -C "skip parse certificate request" \
2100 -c "got a certificate request" \
2101 -c "got no certificate to send" \
2102 -S "x509_verify_cert() returned" \
2103 -s "client has no certificate" \
2104 -s "! mbedtls_ssl_handshake returned" \
2105 -c "! mbedtls_ssl_handshake returned" \
2106 -s "No client certification received from the client, but required by the authentication mode"
2107
2108run_test "Authentication: client has no cert, server required (TLS)" \
2109 "$P_SRV debug_level=3 auth_mode=required" \
2110 "$P_CLI debug_level=3 crt_file=none \
2111 key_file=data_files/server5.key" \
2112 1 \
2113 -S "skip write certificate request" \
2114 -C "skip parse certificate request" \
2115 -c "got a certificate request" \
2116 -c "= write certificate$" \
2117 -C "skip write certificate$" \
2118 -S "x509_verify_cert() returned" \
2119 -s "client has no certificate" \
2120 -s "! mbedtls_ssl_handshake returned" \
2121 -c "! mbedtls_ssl_handshake returned" \
2122 -s "No client certification received from the client, but required by the authentication mode"
2123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002124run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002125 "$P_SRV debug_level=3 auth_mode=required" \
2126 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002127 key_file=data_files/server5.key" \
2128 1 \
2129 -S "skip write certificate request" \
2130 -C "skip parse certificate request" \
2131 -c "got a certificate request" \
2132 -C "skip write certificate" \
2133 -C "skip write certificate verify" \
2134 -S "skip parse certificate verify" \
2135 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002136 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002137 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002138 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002139 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002140 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002141# We don't check that the client receives the alert because it might
2142# detect that its write end of the connection is closed and abort
2143# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002144
Janos Follath89baba22017-04-10 14:34:35 +01002145run_test "Authentication: client cert not trusted, server required" \
2146 "$P_SRV debug_level=3 auth_mode=required" \
2147 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2148 key_file=data_files/server5.key" \
2149 1 \
2150 -S "skip write certificate request" \
2151 -C "skip parse certificate request" \
2152 -c "got a certificate request" \
2153 -C "skip write certificate" \
2154 -C "skip write certificate verify" \
2155 -S "skip parse certificate verify" \
2156 -s "x509_verify_cert() returned" \
2157 -s "! The certificate is not correctly signed by the trusted CA" \
2158 -s "! mbedtls_ssl_handshake returned" \
2159 -c "! mbedtls_ssl_handshake returned" \
2160 -s "X509 - Certificate verification failed"
2161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002162run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002163 "$P_SRV debug_level=3 auth_mode=optional" \
2164 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002165 key_file=data_files/server5.key" \
2166 0 \
2167 -S "skip write certificate request" \
2168 -C "skip parse certificate request" \
2169 -c "got a certificate request" \
2170 -C "skip write certificate" \
2171 -C "skip write certificate verify" \
2172 -S "skip parse certificate verify" \
2173 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002174 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002175 -S "! mbedtls_ssl_handshake returned" \
2176 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002177 -S "X509 - Certificate verification failed"
2178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002179run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002180 "$P_SRV debug_level=3 auth_mode=none" \
2181 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002182 key_file=data_files/server5.key" \
2183 0 \
2184 -s "skip write certificate request" \
2185 -C "skip parse certificate request" \
2186 -c "got no certificate request" \
2187 -c "skip write certificate" \
2188 -c "skip write certificate verify" \
2189 -s "skip parse certificate verify" \
2190 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002191 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002192 -S "! mbedtls_ssl_handshake returned" \
2193 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002194 -S "X509 - Certificate verification failed"
2195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002196run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002197 "$P_SRV debug_level=3 auth_mode=optional" \
2198 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002199 0 \
2200 -S "skip write certificate request" \
2201 -C "skip parse certificate request" \
2202 -c "got a certificate request" \
2203 -C "skip write certificate$" \
2204 -C "got no certificate to send" \
2205 -S "SSLv3 client has no certificate" \
2206 -c "skip write certificate verify" \
2207 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002208 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002209 -S "! mbedtls_ssl_handshake returned" \
2210 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002211 -S "X509 - Certificate verification failed"
2212
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002213run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002214 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002215 "$O_CLI" \
2216 0 \
2217 -S "skip write certificate request" \
2218 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002219 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002220 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002221 -S "X509 - Certificate verification failed"
2222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002223run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002224 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002225 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002226 0 \
2227 -C "skip parse certificate request" \
2228 -c "got a certificate request" \
2229 -C "skip write certificate$" \
2230 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002231 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002232
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002233run_test "Authentication: client no cert, openssl server required" \
2234 "$O_SRV -Verify 10" \
2235 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2236 1 \
2237 -C "skip parse certificate request" \
2238 -c "got a certificate request" \
2239 -C "skip write certificate$" \
2240 -c "skip write certificate verify" \
2241 -c "! mbedtls_ssl_handshake returned"
2242
Janos Follathe2681a42016-03-07 15:57:05 +00002243requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002244run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002245 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002246 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002247 0 \
2248 -S "skip write certificate request" \
2249 -C "skip parse certificate request" \
2250 -c "got a certificate request" \
2251 -C "skip write certificate$" \
2252 -c "skip write certificate verify" \
2253 -c "got no certificate to send" \
2254 -s "SSLv3 client has no certificate" \
2255 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002256 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002257 -S "! mbedtls_ssl_handshake returned" \
2258 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002259 -S "X509 - Certificate verification failed"
2260
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002261# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2262# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002263
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002264MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002265MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002266
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002267if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002268 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002269 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002270 printf "test value of ${MAX_IM_CA}. \n"
2271 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002272 printf "The tests assume this value and if it changes, the tests in this\n"
2273 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002274 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002275
2276 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002277fi
2278
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002279run_test "Authentication: server max_int chain, client default" \
2280 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2281 key_file=data_files/dir-maxpath/09.key" \
2282 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2283 0 \
2284 -C "X509 - A fatal error occured"
2285
2286run_test "Authentication: server max_int+1 chain, client default" \
2287 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2288 key_file=data_files/dir-maxpath/10.key" \
2289 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2290 1 \
2291 -c "X509 - A fatal error occured"
2292
2293run_test "Authentication: server max_int+1 chain, client optional" \
2294 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2295 key_file=data_files/dir-maxpath/10.key" \
2296 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2297 auth_mode=optional" \
2298 1 \
2299 -c "X509 - A fatal error occured"
2300
2301run_test "Authentication: server max_int+1 chain, client none" \
2302 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2303 key_file=data_files/dir-maxpath/10.key" \
2304 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2305 auth_mode=none" \
2306 0 \
2307 -C "X509 - A fatal error occured"
2308
2309run_test "Authentication: client max_int+1 chain, server default" \
2310 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2311 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2312 key_file=data_files/dir-maxpath/10.key" \
2313 0 \
2314 -S "X509 - A fatal error occured"
2315
2316run_test "Authentication: client max_int+1 chain, server optional" \
2317 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2318 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2319 key_file=data_files/dir-maxpath/10.key" \
2320 1 \
2321 -s "X509 - A fatal error occured"
2322
2323run_test "Authentication: client max_int+1 chain, server required" \
2324 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2325 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2326 key_file=data_files/dir-maxpath/10.key" \
2327 1 \
2328 -s "X509 - A fatal error occured"
2329
2330run_test "Authentication: client max_int chain, server required" \
2331 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2332 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2333 key_file=data_files/dir-maxpath/09.key" \
2334 0 \
2335 -S "X509 - A fatal error occured"
2336
Janos Follath89baba22017-04-10 14:34:35 +01002337# Tests for CA list in CertificateRequest messages
2338
2339run_test "Authentication: send CA list in CertificateRequest (default)" \
2340 "$P_SRV debug_level=3 auth_mode=required" \
2341 "$P_CLI crt_file=data_files/server6.crt \
2342 key_file=data_files/server6.key" \
2343 0 \
2344 -s "requested DN"
2345
2346run_test "Authentication: do not send CA list in CertificateRequest" \
2347 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2348 "$P_CLI crt_file=data_files/server6.crt \
2349 key_file=data_files/server6.key" \
2350 0 \
2351 -S "requested DN"
2352
2353run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2354 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2355 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2356 key_file=data_files/server5.key" \
2357 1 \
2358 -S "requested DN" \
2359 -s "x509_verify_cert() returned" \
2360 -s "! The certificate is not correctly signed by the trusted CA" \
2361 -s "! mbedtls_ssl_handshake returned" \
2362 -c "! mbedtls_ssl_handshake returned" \
2363 -s "X509 - Certificate verification failed"
2364
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002365# Tests for certificate selection based on SHA verson
2366
2367run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2368 "$P_SRV crt_file=data_files/server5.crt \
2369 key_file=data_files/server5.key \
2370 crt_file2=data_files/server5-sha1.crt \
2371 key_file2=data_files/server5.key" \
2372 "$P_CLI force_version=tls1_2" \
2373 0 \
2374 -c "signed using.*ECDSA with SHA256" \
2375 -C "signed using.*ECDSA with SHA1"
2376
2377run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2378 "$P_SRV crt_file=data_files/server5.crt \
2379 key_file=data_files/server5.key \
2380 crt_file2=data_files/server5-sha1.crt \
2381 key_file2=data_files/server5.key" \
2382 "$P_CLI force_version=tls1_1" \
2383 0 \
2384 -C "signed using.*ECDSA with SHA256" \
2385 -c "signed using.*ECDSA with SHA1"
2386
2387run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2388 "$P_SRV crt_file=data_files/server5.crt \
2389 key_file=data_files/server5.key \
2390 crt_file2=data_files/server5-sha1.crt \
2391 key_file2=data_files/server5.key" \
2392 "$P_CLI force_version=tls1" \
2393 0 \
2394 -C "signed using.*ECDSA with SHA256" \
2395 -c "signed using.*ECDSA with SHA1"
2396
2397run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2398 "$P_SRV crt_file=data_files/server5.crt \
2399 key_file=data_files/server5.key \
2400 crt_file2=data_files/server6.crt \
2401 key_file2=data_files/server6.key" \
2402 "$P_CLI force_version=tls1_1" \
2403 0 \
2404 -c "serial number.*09" \
2405 -c "signed using.*ECDSA with SHA256" \
2406 -C "signed using.*ECDSA with SHA1"
2407
2408run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2409 "$P_SRV crt_file=data_files/server6.crt \
2410 key_file=data_files/server6.key \
2411 crt_file2=data_files/server5.crt \
2412 key_file2=data_files/server5.key" \
2413 "$P_CLI force_version=tls1_1" \
2414 0 \
2415 -c "serial number.*0A" \
2416 -c "signed using.*ECDSA with SHA256" \
2417 -C "signed using.*ECDSA with SHA1"
2418
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002419# tests for SNI
2420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002421run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002422 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002423 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002424 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002425 0 \
2426 -S "parse ServerName extension" \
2427 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2428 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002430run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002431 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002432 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002433 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002434 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002435 0 \
2436 -s "parse ServerName extension" \
2437 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2438 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002440run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002441 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002442 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002443 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002444 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002445 0 \
2446 -s "parse ServerName extension" \
2447 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2448 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002449
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002450run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002451 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002452 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002453 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 +02002454 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002455 1 \
2456 -s "parse ServerName extension" \
2457 -s "ssl_sni_wrapper() returned" \
2458 -s "mbedtls_ssl_handshake returned" \
2459 -c "mbedtls_ssl_handshake returned" \
2460 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002461
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002462run_test "SNI: client auth no override: optional" \
2463 "$P_SRV debug_level=3 auth_mode=optional \
2464 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2465 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2466 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002467 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002468 -S "skip write certificate request" \
2469 -C "skip parse certificate request" \
2470 -c "got a certificate request" \
2471 -C "skip write certificate" \
2472 -C "skip write certificate verify" \
2473 -S "skip parse certificate verify"
2474
2475run_test "SNI: client auth override: none -> optional" \
2476 "$P_SRV debug_level=3 auth_mode=none \
2477 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2478 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2479 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002480 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002481 -S "skip write certificate request" \
2482 -C "skip parse certificate request" \
2483 -c "got a certificate request" \
2484 -C "skip write certificate" \
2485 -C "skip write certificate verify" \
2486 -S "skip parse certificate verify"
2487
2488run_test "SNI: client auth override: optional -> none" \
2489 "$P_SRV debug_level=3 auth_mode=optional \
2490 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2491 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2492 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002493 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002494 -s "skip write certificate request" \
2495 -C "skip parse certificate request" \
2496 -c "got no certificate request" \
2497 -c "skip write certificate" \
2498 -c "skip write certificate verify" \
2499 -s "skip parse certificate verify"
2500
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002501run_test "SNI: CA no override" \
2502 "$P_SRV debug_level=3 auth_mode=optional \
2503 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2504 ca_file=data_files/test-ca.crt \
2505 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2506 "$P_CLI debug_level=3 server_name=localhost \
2507 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2508 1 \
2509 -S "skip write certificate request" \
2510 -C "skip parse certificate request" \
2511 -c "got a certificate request" \
2512 -C "skip write certificate" \
2513 -C "skip write certificate verify" \
2514 -S "skip parse certificate verify" \
2515 -s "x509_verify_cert() returned" \
2516 -s "! The certificate is not correctly signed by the trusted CA" \
2517 -S "The certificate has been revoked (is on a CRL)"
2518
2519run_test "SNI: CA override" \
2520 "$P_SRV debug_level=3 auth_mode=optional \
2521 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2522 ca_file=data_files/test-ca.crt \
2523 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2524 "$P_CLI debug_level=3 server_name=localhost \
2525 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2526 0 \
2527 -S "skip write certificate request" \
2528 -C "skip parse certificate request" \
2529 -c "got a certificate request" \
2530 -C "skip write certificate" \
2531 -C "skip write certificate verify" \
2532 -S "skip parse certificate verify" \
2533 -S "x509_verify_cert() returned" \
2534 -S "! The certificate is not correctly signed by the trusted CA" \
2535 -S "The certificate has been revoked (is on a CRL)"
2536
2537run_test "SNI: CA override with CRL" \
2538 "$P_SRV debug_level=3 auth_mode=optional \
2539 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2540 ca_file=data_files/test-ca.crt \
2541 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2542 "$P_CLI debug_level=3 server_name=localhost \
2543 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2544 1 \
2545 -S "skip write certificate request" \
2546 -C "skip parse certificate request" \
2547 -c "got a certificate request" \
2548 -C "skip write certificate" \
2549 -C "skip write certificate verify" \
2550 -S "skip parse certificate verify" \
2551 -s "x509_verify_cert() returned" \
2552 -S "! The certificate is not correctly signed by the trusted CA" \
2553 -s "The certificate has been revoked (is on a CRL)"
2554
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002555# Tests for non-blocking I/O: exercise a variety of handshake flows
2556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002557run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002558 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2559 "$P_CLI nbio=2 tickets=0" \
2560 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002561 -S "mbedtls_ssl_handshake returned" \
2562 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002563 -c "Read from server: .* bytes read"
2564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002565run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002566 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2567 "$P_CLI nbio=2 tickets=0" \
2568 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002569 -S "mbedtls_ssl_handshake returned" \
2570 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002571 -c "Read from server: .* bytes read"
2572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002573run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002574 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2575 "$P_CLI nbio=2 tickets=1" \
2576 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002577 -S "mbedtls_ssl_handshake returned" \
2578 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002579 -c "Read from server: .* bytes read"
2580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002581run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002582 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2583 "$P_CLI nbio=2 tickets=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é-Gonnard0b6609b2014-02-26 14:45:12 +01002587 -c "Read from server: .* bytes read"
2588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002589run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002590 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2591 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2592 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002593 -S "mbedtls_ssl_handshake returned" \
2594 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002595 -c "Read from server: .* bytes read"
2596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002597run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002598 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2599 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2600 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002601 -S "mbedtls_ssl_handshake returned" \
2602 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002603 -c "Read from server: .* bytes read"
2604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002605run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002606 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2607 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2608 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002609 -S "mbedtls_ssl_handshake returned" \
2610 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002611 -c "Read from server: .* bytes read"
2612
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002613# Tests for version negotiation
2614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002615run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002616 "$P_SRV" \
2617 "$P_CLI" \
2618 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002619 -S "mbedtls_ssl_handshake returned" \
2620 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002621 -s "Protocol is TLSv1.2" \
2622 -c "Protocol is TLSv1.2"
2623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002624run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002625 "$P_SRV" \
2626 "$P_CLI max_version=tls1_1" \
2627 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002628 -S "mbedtls_ssl_handshake returned" \
2629 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002630 -s "Protocol is TLSv1.1" \
2631 -c "Protocol is TLSv1.1"
2632
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002633run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002634 "$P_SRV max_version=tls1_1" \
2635 "$P_CLI" \
2636 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002637 -S "mbedtls_ssl_handshake returned" \
2638 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002639 -s "Protocol is TLSv1.1" \
2640 -c "Protocol is TLSv1.1"
2641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002642run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002643 "$P_SRV max_version=tls1_1" \
2644 "$P_CLI max_version=tls1_1" \
2645 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002646 -S "mbedtls_ssl_handshake returned" \
2647 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002648 -s "Protocol is TLSv1.1" \
2649 -c "Protocol is TLSv1.1"
2650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002651run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002652 "$P_SRV min_version=tls1_1" \
2653 "$P_CLI max_version=tls1_1" \
2654 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002655 -S "mbedtls_ssl_handshake returned" \
2656 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002657 -s "Protocol is TLSv1.1" \
2658 -c "Protocol is TLSv1.1"
2659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002660run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002661 "$P_SRV max_version=tls1_1" \
2662 "$P_CLI min_version=tls1_1" \
2663 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002664 -S "mbedtls_ssl_handshake returned" \
2665 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002666 -s "Protocol is TLSv1.1" \
2667 -c "Protocol is TLSv1.1"
2668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002669run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002670 "$P_SRV max_version=tls1_1" \
2671 "$P_CLI min_version=tls1_2" \
2672 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002673 -s "mbedtls_ssl_handshake returned" \
2674 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002675 -c "SSL - Handshake protocol not within min/max boundaries"
2676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002677run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002678 "$P_SRV min_version=tls1_2" \
2679 "$P_CLI max_version=tls1_1" \
2680 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002681 -s "mbedtls_ssl_handshake returned" \
2682 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002683 -s "SSL - Handshake protocol not within min/max boundaries"
2684
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002685# Tests for ALPN extension
2686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002687run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002688 "$P_SRV debug_level=3" \
2689 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002690 0 \
2691 -C "client hello, adding alpn extension" \
2692 -S "found alpn extension" \
2693 -C "got an alert message, type: \\[2:120]" \
2694 -S "server hello, adding alpn extension" \
2695 -C "found alpn extension " \
2696 -C "Application Layer Protocol is" \
2697 -S "Application Layer Protocol is"
2698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002699run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002700 "$P_SRV debug_level=3" \
2701 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002702 0 \
2703 -c "client hello, adding alpn extension" \
2704 -s "found alpn extension" \
2705 -C "got an alert message, type: \\[2:120]" \
2706 -S "server hello, adding alpn extension" \
2707 -C "found alpn extension " \
2708 -c "Application Layer Protocol is (none)" \
2709 -S "Application Layer Protocol is"
2710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002711run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002712 "$P_SRV debug_level=3 alpn=abc,1234" \
2713 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002714 0 \
2715 -C "client hello, adding alpn extension" \
2716 -S "found alpn extension" \
2717 -C "got an alert message, type: \\[2:120]" \
2718 -S "server hello, adding alpn extension" \
2719 -C "found alpn extension " \
2720 -C "Application Layer Protocol is" \
2721 -s "Application Layer Protocol is (none)"
2722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002723run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002724 "$P_SRV debug_level=3 alpn=abc,1234" \
2725 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002726 0 \
2727 -c "client hello, adding alpn extension" \
2728 -s "found alpn extension" \
2729 -C "got an alert message, type: \\[2:120]" \
2730 -s "server hello, adding alpn extension" \
2731 -c "found alpn extension" \
2732 -c "Application Layer Protocol is abc" \
2733 -s "Application Layer Protocol is abc"
2734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002735run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002736 "$P_SRV debug_level=3 alpn=abc,1234" \
2737 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002738 0 \
2739 -c "client hello, adding alpn extension" \
2740 -s "found alpn extension" \
2741 -C "got an alert message, type: \\[2:120]" \
2742 -s "server hello, adding alpn extension" \
2743 -c "found alpn extension" \
2744 -c "Application Layer Protocol is abc" \
2745 -s "Application Layer Protocol is abc"
2746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002747run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002748 "$P_SRV debug_level=3 alpn=abc,1234" \
2749 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002750 0 \
2751 -c "client hello, adding alpn extension" \
2752 -s "found alpn extension" \
2753 -C "got an alert message, type: \\[2:120]" \
2754 -s "server hello, adding alpn extension" \
2755 -c "found alpn extension" \
2756 -c "Application Layer Protocol is 1234" \
2757 -s "Application Layer Protocol is 1234"
2758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002759run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002760 "$P_SRV debug_level=3 alpn=abc,123" \
2761 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002762 1 \
2763 -c "client hello, adding alpn extension" \
2764 -s "found alpn extension" \
2765 -c "got an alert message, type: \\[2:120]" \
2766 -S "server hello, adding alpn extension" \
2767 -C "found alpn extension" \
2768 -C "Application Layer Protocol is 1234" \
2769 -S "Application Layer Protocol is 1234"
2770
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002771
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002772# Tests for keyUsage in leaf certificates, part 1:
2773# server-side certificate/suite selection
2774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002775run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002776 "$P_SRV key_file=data_files/server2.key \
2777 crt_file=data_files/server2.ku-ds.crt" \
2778 "$P_CLI" \
2779 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002780 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002781
2782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002783run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002784 "$P_SRV key_file=data_files/server2.key \
2785 crt_file=data_files/server2.ku-ke.crt" \
2786 "$P_CLI" \
2787 0 \
2788 -c "Ciphersuite is TLS-RSA-WITH-"
2789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002790run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002791 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002792 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002793 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002794 1 \
2795 -C "Ciphersuite is "
2796
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002797run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002798 "$P_SRV key_file=data_files/server5.key \
2799 crt_file=data_files/server5.ku-ds.crt" \
2800 "$P_CLI" \
2801 0 \
2802 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2803
2804
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002805run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002806 "$P_SRV key_file=data_files/server5.key \
2807 crt_file=data_files/server5.ku-ka.crt" \
2808 "$P_CLI" \
2809 0 \
2810 -c "Ciphersuite is TLS-ECDH-"
2811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002812run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002813 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002814 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002815 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002816 1 \
2817 -C "Ciphersuite is "
2818
2819# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002820# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002821
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002822run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002823 "$O_SRV -key data_files/server2.key \
2824 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002825 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002826 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2827 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002828 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002829 -C "Processing of the Certificate handshake message failed" \
2830 -c "Ciphersuite is TLS-"
2831
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002832run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002833 "$O_SRV -key data_files/server2.key \
2834 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002835 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002836 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2837 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002838 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002839 -C "Processing of the Certificate handshake message failed" \
2840 -c "Ciphersuite is TLS-"
2841
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002842run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002843 "$O_SRV -key data_files/server2.key \
2844 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002845 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002846 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2847 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002848 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002849 -C "Processing of the Certificate handshake message failed" \
2850 -c "Ciphersuite is TLS-"
2851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002852run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002853 "$O_SRV -key data_files/server2.key \
2854 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002855 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002856 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2857 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002858 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002859 -c "Processing of the Certificate handshake message failed" \
2860 -C "Ciphersuite is TLS-"
2861
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002862run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2863 "$O_SRV -key data_files/server2.key \
2864 -cert data_files/server2.ku-ke.crt" \
2865 "$P_CLI debug_level=1 auth_mode=optional \
2866 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2867 0 \
2868 -c "bad certificate (usage extensions)" \
2869 -C "Processing of the Certificate handshake message failed" \
2870 -c "Ciphersuite is TLS-" \
2871 -c "! Usage does not match the keyUsage extension"
2872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002873run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002874 "$O_SRV -key data_files/server2.key \
2875 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002876 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002877 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2878 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002879 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002880 -C "Processing of the Certificate handshake message failed" \
2881 -c "Ciphersuite is TLS-"
2882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002883run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002884 "$O_SRV -key data_files/server2.key \
2885 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002886 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002887 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2888 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002889 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002890 -c "Processing of the Certificate handshake message failed" \
2891 -C "Ciphersuite is TLS-"
2892
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002893run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2894 "$O_SRV -key data_files/server2.key \
2895 -cert data_files/server2.ku-ds.crt" \
2896 "$P_CLI debug_level=1 auth_mode=optional \
2897 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2898 0 \
2899 -c "bad certificate (usage extensions)" \
2900 -C "Processing of the Certificate handshake message failed" \
2901 -c "Ciphersuite is TLS-" \
2902 -c "! Usage does not match the keyUsage extension"
2903
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002904# Tests for keyUsage in leaf certificates, part 3:
2905# server-side checking of client cert
2906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002907run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002908 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002909 "$O_CLI -key data_files/server2.key \
2910 -cert data_files/server2.ku-ds.crt" \
2911 0 \
2912 -S "bad certificate (usage extensions)" \
2913 -S "Processing of the Certificate handshake message failed"
2914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002915run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002916 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002917 "$O_CLI -key data_files/server2.key \
2918 -cert data_files/server2.ku-ke.crt" \
2919 0 \
2920 -s "bad certificate (usage extensions)" \
2921 -S "Processing of the Certificate handshake message failed"
2922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002923run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002924 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002925 "$O_CLI -key data_files/server2.key \
2926 -cert data_files/server2.ku-ke.crt" \
2927 1 \
2928 -s "bad certificate (usage extensions)" \
2929 -s "Processing of the Certificate handshake message failed"
2930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002931run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002932 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002933 "$O_CLI -key data_files/server5.key \
2934 -cert data_files/server5.ku-ds.crt" \
2935 0 \
2936 -S "bad certificate (usage extensions)" \
2937 -S "Processing of the Certificate handshake message failed"
2938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002939run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002940 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002941 "$O_CLI -key data_files/server5.key \
2942 -cert data_files/server5.ku-ka.crt" \
2943 0 \
2944 -s "bad certificate (usage extensions)" \
2945 -S "Processing of the Certificate handshake message failed"
2946
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002947# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002949run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002950 "$P_SRV key_file=data_files/server5.key \
2951 crt_file=data_files/server5.eku-srv.crt" \
2952 "$P_CLI" \
2953 0
2954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002955run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002956 "$P_SRV key_file=data_files/server5.key \
2957 crt_file=data_files/server5.eku-srv.crt" \
2958 "$P_CLI" \
2959 0
2960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002961run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002962 "$P_SRV key_file=data_files/server5.key \
2963 crt_file=data_files/server5.eku-cs_any.crt" \
2964 "$P_CLI" \
2965 0
2966
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002967run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002968 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002969 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002970 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002971 1
2972
2973# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002975run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002976 "$O_SRV -key data_files/server5.key \
2977 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002978 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002979 0 \
2980 -C "bad certificate (usage extensions)" \
2981 -C "Processing of the Certificate handshake message failed" \
2982 -c "Ciphersuite is TLS-"
2983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002984run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002985 "$O_SRV -key data_files/server5.key \
2986 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002987 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002988 0 \
2989 -C "bad certificate (usage extensions)" \
2990 -C "Processing of the Certificate handshake message failed" \
2991 -c "Ciphersuite is TLS-"
2992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002993run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002994 "$O_SRV -key data_files/server5.key \
2995 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002996 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002997 0 \
2998 -C "bad certificate (usage extensions)" \
2999 -C "Processing of the Certificate handshake message failed" \
3000 -c "Ciphersuite is TLS-"
3001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003002run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003003 "$O_SRV -key data_files/server5.key \
3004 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003005 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003006 1 \
3007 -c "bad certificate (usage extensions)" \
3008 -c "Processing of the Certificate handshake message failed" \
3009 -C "Ciphersuite is TLS-"
3010
3011# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3012
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003013run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003014 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003015 "$O_CLI -key data_files/server5.key \
3016 -cert data_files/server5.eku-cli.crt" \
3017 0 \
3018 -S "bad certificate (usage extensions)" \
3019 -S "Processing of the Certificate handshake message failed"
3020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003021run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003022 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003023 "$O_CLI -key data_files/server5.key \
3024 -cert data_files/server5.eku-srv_cli.crt" \
3025 0 \
3026 -S "bad certificate (usage extensions)" \
3027 -S "Processing of the Certificate handshake message failed"
3028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003029run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003030 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003031 "$O_CLI -key data_files/server5.key \
3032 -cert data_files/server5.eku-cs_any.crt" \
3033 0 \
3034 -S "bad certificate (usage extensions)" \
3035 -S "Processing of the Certificate handshake message failed"
3036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003037run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003038 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003039 "$O_CLI -key data_files/server5.key \
3040 -cert data_files/server5.eku-cs.crt" \
3041 0 \
3042 -s "bad certificate (usage extensions)" \
3043 -S "Processing of the Certificate handshake message failed"
3044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003045run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003046 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003047 "$O_CLI -key data_files/server5.key \
3048 -cert data_files/server5.eku-cs.crt" \
3049 1 \
3050 -s "bad certificate (usage extensions)" \
3051 -s "Processing of the Certificate handshake message failed"
3052
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003053# Tests for DHM parameters loading
3054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003055run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003056 "$P_SRV" \
3057 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3058 debug_level=3" \
3059 0 \
3060 -c "value of 'DHM: P ' (2048 bits)" \
3061 -c "value of 'DHM: G ' (2048 bits)"
3062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003063run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003064 "$P_SRV dhm_file=data_files/dhparams.pem" \
3065 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3066 debug_level=3" \
3067 0 \
3068 -c "value of 'DHM: P ' (1024 bits)" \
3069 -c "value of 'DHM: G ' (2 bits)"
3070
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003071# Tests for DHM client-side size checking
3072
3073run_test "DHM size: server default, client default, OK" \
3074 "$P_SRV" \
3075 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3076 debug_level=1" \
3077 0 \
3078 -C "DHM prime too short:"
3079
3080run_test "DHM size: server default, client 2048, OK" \
3081 "$P_SRV" \
3082 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3083 debug_level=1 dhmlen=2048" \
3084 0 \
3085 -C "DHM prime too short:"
3086
3087run_test "DHM size: server 1024, client default, OK" \
3088 "$P_SRV dhm_file=data_files/dhparams.pem" \
3089 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3090 debug_level=1" \
3091 0 \
3092 -C "DHM prime too short:"
3093
3094run_test "DHM size: server 1000, client default, rejected" \
3095 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3096 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3097 debug_level=1" \
3098 1 \
3099 -c "DHM prime too short:"
3100
3101run_test "DHM size: server default, client 2049, rejected" \
3102 "$P_SRV" \
3103 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3104 debug_level=1 dhmlen=2049" \
3105 1 \
3106 -c "DHM prime too short:"
3107
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003108# Tests for PSK callback
3109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003110run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003111 "$P_SRV psk=abc123 psk_identity=foo" \
3112 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3113 psk_identity=foo psk=abc123" \
3114 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003115 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003116 -S "SSL - Unknown identity received" \
3117 -S "SSL - Verification of the message MAC failed"
3118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003119run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003120 "$P_SRV" \
3121 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3122 psk_identity=foo psk=abc123" \
3123 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003124 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003125 -S "SSL - Unknown identity received" \
3126 -S "SSL - Verification of the message MAC failed"
3127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003128run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003129 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3130 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3131 psk_identity=foo psk=abc123" \
3132 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003133 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003134 -s "SSL - Unknown identity received" \
3135 -S "SSL - Verification of the message MAC failed"
3136
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003137run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003138 "$P_SRV psk_list=abc,dead,def,beef" \
3139 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3140 psk_identity=abc psk=dead" \
3141 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003142 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003143 -S "SSL - Unknown identity received" \
3144 -S "SSL - Verification of the message MAC failed"
3145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003146run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003147 "$P_SRV psk_list=abc,dead,def,beef" \
3148 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3149 psk_identity=def psk=beef" \
3150 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003151 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003152 -S "SSL - Unknown identity received" \
3153 -S "SSL - Verification of the message MAC failed"
3154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003155run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003156 "$P_SRV psk_list=abc,dead,def,beef" \
3157 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3158 psk_identity=ghi psk=beef" \
3159 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003160 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003161 -s "SSL - Unknown identity received" \
3162 -S "SSL - Verification of the message MAC failed"
3163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003164run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003165 "$P_SRV psk_list=abc,dead,def,beef" \
3166 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3167 psk_identity=abc psk=beef" \
3168 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003169 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003170 -S "SSL - Unknown identity received" \
3171 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003172
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003173# Tests for EC J-PAKE
3174
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003175requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003176run_test "ECJPAKE: client not configured" \
3177 "$P_SRV debug_level=3" \
3178 "$P_CLI debug_level=3" \
3179 0 \
3180 -C "add ciphersuite: c0ff" \
3181 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003182 -S "found ecjpake kkpp extension" \
3183 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003184 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003185 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003186 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003187 -S "None of the common ciphersuites is usable"
3188
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003189requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003190run_test "ECJPAKE: server not configured" \
3191 "$P_SRV debug_level=3" \
3192 "$P_CLI debug_level=3 ecjpake_pw=bla \
3193 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3194 1 \
3195 -c "add ciphersuite: c0ff" \
3196 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003197 -s "found ecjpake kkpp extension" \
3198 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003199 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003200 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003201 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003202 -s "None of the common ciphersuites is usable"
3203
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003204requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003205run_test "ECJPAKE: working, TLS" \
3206 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3207 "$P_CLI debug_level=3 ecjpake_pw=bla \
3208 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003209 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003210 -c "add ciphersuite: c0ff" \
3211 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003212 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003213 -s "found ecjpake kkpp extension" \
3214 -S "skip ecjpake kkpp extension" \
3215 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003216 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003217 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003218 -S "None of the common ciphersuites is usable" \
3219 -S "SSL - Verification of the message MAC failed"
3220
Janos Follath74537a62016-09-02 13:45:28 +01003221server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003222requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003223run_test "ECJPAKE: password mismatch, TLS" \
3224 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3225 "$P_CLI debug_level=3 ecjpake_pw=bad \
3226 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3227 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003228 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003229 -s "SSL - Verification of the message MAC failed"
3230
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003231requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003232run_test "ECJPAKE: working, DTLS" \
3233 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3234 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3235 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3236 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003237 -c "re-using cached ecjpake parameters" \
3238 -S "SSL - Verification of the message MAC failed"
3239
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003240requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003241run_test "ECJPAKE: working, DTLS, no cookie" \
3242 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3243 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3244 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3245 0 \
3246 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003247 -S "SSL - Verification of the message MAC failed"
3248
Janos Follath74537a62016-09-02 13:45:28 +01003249server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003250requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003251run_test "ECJPAKE: password mismatch, DTLS" \
3252 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3253 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3254 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3255 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003256 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003257 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003258
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003259# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003260requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003261run_test "ECJPAKE: working, DTLS, nolog" \
3262 "$P_SRV dtls=1 ecjpake_pw=bla" \
3263 "$P_CLI dtls=1 ecjpake_pw=bla \
3264 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3265 0
3266
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003267# Tests for ciphersuites per version
3268
Janos Follathe2681a42016-03-07 15:57:05 +00003269requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003270run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003271 "$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 +02003272 "$P_CLI force_version=ssl3" \
3273 0 \
3274 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003276run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003277 "$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 +01003278 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003279 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003280 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003281
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003282run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003283 "$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 +02003284 "$P_CLI force_version=tls1_1" \
3285 0 \
3286 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003288run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003289 "$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 +02003290 "$P_CLI force_version=tls1_2" \
3291 0 \
3292 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3293
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003294# Test for ClientHello without extensions
3295
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003296requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003297run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003298 "$P_SRV debug_level=3" \
3299 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3300 0 \
3301 -s "dumping 'client hello extensions' (0 bytes)"
3302
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003303requires_gnutls
3304run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3305 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3306 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3307 0 \
3308 -s "dumping 'client hello extensions' (0 bytes)"
3309
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003310# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003311
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003312run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003313 "$P_SRV" \
3314 "$P_CLI request_size=100" \
3315 0 \
3316 -s "Read from client: 100 bytes read$"
3317
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003318run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003319 "$P_SRV" \
3320 "$P_CLI request_size=500" \
3321 0 \
3322 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003323
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003324# Tests for small packets
3325
Janos Follathe2681a42016-03-07 15:57:05 +00003326requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003327run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003328 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003329 "$P_CLI request_size=1 force_version=ssl3 \
3330 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3331 0 \
3332 -s "Read from client: 1 bytes read"
3333
Janos Follathe2681a42016-03-07 15:57:05 +00003334requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003335run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003336 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003337 "$P_CLI request_size=1 force_version=ssl3 \
3338 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3339 0 \
3340 -s "Read from client: 1 bytes read"
3341
3342run_test "Small packet TLS 1.0 BlockCipher" \
3343 "$P_SRV" \
3344 "$P_CLI request_size=1 force_version=tls1 \
3345 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3346 0 \
3347 -s "Read from client: 1 bytes read"
3348
Hanno Becker8501f982017-11-10 08:59:04 +00003349run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003350 "$P_SRV" \
3351 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3352 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3353 0 \
3354 -s "Read from client: 1 bytes read"
3355
Hanno Becker32c55012017-11-10 08:42:54 +00003356requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003357run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003358 "$P_SRV" \
3359 "$P_CLI request_size=1 force_version=tls1 \
3360 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3361 trunc_hmac=1" \
3362 0 \
3363 -s "Read from client: 1 bytes read"
3364
Hanno Becker32c55012017-11-10 08:42:54 +00003365requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003366run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
3367 "$P_SRV" \
3368 "$P_CLI request_size=1 force_version=tls1 \
3369 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3370 trunc_hmac=1 \
3371 etm=0" \
3372 0 \
3373 -s "Read from client: 1 bytes read"
3374
3375run_test "Small packet TLS 1.0 StreamCipher" \
3376 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3377 "$P_CLI request_size=1 force_version=tls1 \
3378 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3379 0 \
3380 -s "Read from client: 1 bytes read"
3381
3382run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3383 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3384 "$P_CLI request_size=1 force_version=tls1 \
3385 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3386 etm=0" \
3387 0 \
3388 -s "Read from client: 1 bytes read"
3389
3390requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3391run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003392 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003393 "$P_CLI request_size=1 force_version=tls1 \
3394 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3395 trunc_hmac=1" \
3396 0 \
3397 -s "Read from client: 1 bytes read"
3398
Hanno Becker8501f982017-11-10 08:59:04 +00003399requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3400run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
3401 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3402 "$P_CLI request_size=1 force_version=tls1 \
3403 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3404 trunc_hmac=1 \
3405 etm=0" \
3406 0 \
3407 -s "Read from client: 1 bytes read"
3408
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003409run_test "Small packet TLS 1.1 BlockCipher" \
3410 "$P_SRV" \
3411 "$P_CLI request_size=1 force_version=tls1_1 \
3412 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3413 0 \
3414 -s "Read from client: 1 bytes read"
3415
Hanno Becker8501f982017-11-10 08:59:04 +00003416run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003417 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003418 "$P_CLI request_size=1 force_version=tls1_1 \
3419 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA
3420 etm=0" \
3421 0 \
3422 -s "Read from client: 1 bytes read"
3423
3424requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3425run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
3426 "$P_SRV" \
3427 "$P_CLI request_size=1 force_version=tls1_1 \
3428 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3429 trunc_hmac=1" \
3430 0 \
3431 -s "Read from client: 1 bytes read"
3432
3433requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3434run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
3435 "$P_SRV" \
3436 "$P_CLI request_size=1 force_version=tls1_1 \
3437 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3438 trunc_hmac=1 \
3439 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003440 0 \
3441 -s "Read from client: 1 bytes read"
3442
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003443run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003444 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003445 "$P_CLI request_size=1 force_version=tls1_1 \
3446 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3447 0 \
3448 -s "Read from client: 1 bytes read"
3449
Hanno Becker8501f982017-11-10 08:59:04 +00003450run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3451 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003452 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003453 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3454 etm=0" \
3455 0 \
3456 -s "Read from client: 1 bytes read"
3457
3458requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3459run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
3460 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3461 "$P_CLI request_size=1 force_version=tls1_1 \
3462 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003463 trunc_hmac=1" \
3464 0 \
3465 -s "Read from client: 1 bytes read"
3466
Hanno Becker32c55012017-11-10 08:42:54 +00003467requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003468run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003469 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003470 "$P_CLI request_size=1 force_version=tls1_1 \
3471 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
Hanno Becker8501f982017-11-10 08:59:04 +00003472 trunc_hmac=1 \
3473 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003474 0 \
3475 -s "Read from client: 1 bytes read"
3476
3477run_test "Small packet TLS 1.2 BlockCipher" \
3478 "$P_SRV" \
3479 "$P_CLI request_size=1 force_version=tls1_2 \
3480 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3481 0 \
3482 -s "Read from client: 1 bytes read"
3483
Hanno Becker8501f982017-11-10 08:59:04 +00003484run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003485 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003486 "$P_CLI request_size=1 force_version=tls1_2 \
3487 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3488 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003489 0 \
3490 -s "Read from client: 1 bytes read"
3491
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003492run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3493 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003494 "$P_CLI request_size=1 force_version=tls1_2 \
3495 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003496 0 \
3497 -s "Read from client: 1 bytes read"
3498
Hanno Becker32c55012017-11-10 08:42:54 +00003499requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003500run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003501 "$P_SRV" \
3502 "$P_CLI request_size=1 force_version=tls1_2 \
3503 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3504 trunc_hmac=1" \
3505 0 \
3506 -s "Read from client: 1 bytes read"
3507
Hanno Becker8501f982017-11-10 08:59:04 +00003508requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3509run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
3510 "$P_SRV" \
3511 "$P_CLI request_size=1 force_version=tls1_2 \
3512 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3513 trunc_hmac=1 \
3514 etm=0" \
3515 0 \
3516 -s "Read from client: 1 bytes read"
3517
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003518run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003519 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003520 "$P_CLI request_size=1 force_version=tls1_2 \
3521 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3522 0 \
3523 -s "Read from client: 1 bytes read"
3524
Hanno Becker8501f982017-11-10 08:59:04 +00003525run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
3526 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3527 "$P_CLI request_size=1 force_version=tls1_2 \
3528 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3529 etm=0" \
3530 0 \
3531 -s "Read from client: 1 bytes read"
3532
Hanno Becker32c55012017-11-10 08:42:54 +00003533requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003534run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003535 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003536 "$P_CLI request_size=1 force_version=tls1_2 \
3537 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3538 trunc_hmac=1" \
3539 0 \
3540 -s "Read from client: 1 bytes read"
3541
Hanno Becker8501f982017-11-10 08:59:04 +00003542requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3543run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
3544 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3545 "$P_CLI request_size=1 force_version=tls1_2 \
3546 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3547 trunc_hmac=1 \
3548 etm=0" \
3549 0 \
3550 -s "Read from client: 1 bytes read"
3551
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003552run_test "Small packet TLS 1.2 AEAD" \
3553 "$P_SRV" \
3554 "$P_CLI request_size=1 force_version=tls1_2 \
3555 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3556 0 \
3557 -s "Read from client: 1 bytes read"
3558
3559run_test "Small packet TLS 1.2 AEAD shorter tag" \
3560 "$P_SRV" \
3561 "$P_CLI request_size=1 force_version=tls1_2 \
3562 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3563 0 \
3564 -s "Read from client: 1 bytes read"
3565
Hanno Beckere2148042017-11-10 08:59:18 +00003566# Tests for small packets in DTLS
3567
3568requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3569run_test "Small packet DTLS 1.0" \
3570 "$P_SRV dtls=1 force_version=dtls1" \
3571 "$P_CLI dtls=1 request_size=1 \
3572 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3573 0 \
3574 -s "Read from client: 1 bytes read"
3575
3576requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3577run_test "Small packet DTLS 1.0, without EtM" \
3578 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3579 "$P_CLI dtls=1 request_size=1 \
3580 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3581 0 \
3582 -s "Read from client: 1 bytes read"
3583
3584requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3585requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3586run_test "Small packet DTLS 1.0, truncated hmac" \
3587 "$P_SRV dtls=1 force_version=dtls1" \
3588 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
3589 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3590 0 \
3591 -s "Read from client: 1 bytes read"
3592
3593requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3594requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3595run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
3596 "$P_SRV dtls=1 force_version=dtls1 \
3597 etm=0" \
3598 "$P_CLI dtls=1 request_size=1 \
3599 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3600 trunc_hmac=1"\
3601 0 \
3602 -s "Read from client: 1 bytes read"
3603
3604requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3605run_test "Small packet DTLS 1.2" \
3606 "$P_SRV dtls=1 force_version=dtls1_2" \
3607 "$P_CLI dtls=1 request_size=1 \
3608 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3609 0 \
3610 -s "Read from client: 1 bytes read"
3611
3612requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3613run_test "Small packet DTLS 1.2, without EtM" \
3614 "$P_SRV dtls=1 force_version=dtls1_2 \
3615 etm=0" \
3616 "$P_CLI dtls=1 request_size=1 \
3617 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3618 0 \
3619 -s "Read from client: 1 bytes read"
3620
3621requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3622requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3623run_test "Small packet DTLS 1.2, truncated hmac" \
3624 "$P_SRV dtls=1 force_version=dtls1_2" \
3625 "$P_CLI dtls=1 request_size=1 \
3626 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3627 trunc_hmac=1" \
3628 0 \
3629 -s "Read from client: 1 bytes read"
3630
3631requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3632requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3633run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
3634 "$P_SRV dtls=1 force_version=dtls1_2 \
3635 etm=0" \
3636 "$P_CLI dtls=1 request_size=1 \
3637 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3638 trunc_hmac=1"\
3639 0 \
3640 -s "Read from client: 1 bytes read"
3641
Janos Follath00efff72016-05-06 13:48:23 +01003642# A test for extensions in SSLv3
3643
3644requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3645run_test "SSLv3 with extensions, server side" \
3646 "$P_SRV min_version=ssl3 debug_level=3" \
3647 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3648 0 \
3649 -S "dumping 'client hello extensions'" \
3650 -S "server hello, total extension length:"
3651
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003652# Test for large packets
3653
Janos Follathe2681a42016-03-07 15:57:05 +00003654requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003655run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003656 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003657 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003658 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3659 0 \
3660 -s "Read from client: 16384 bytes read"
3661
Janos Follathe2681a42016-03-07 15:57:05 +00003662requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003663run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003664 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003665 "$P_CLI request_size=16384 force_version=ssl3 \
3666 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3667 0 \
3668 -s "Read from client: 16384 bytes read"
3669
3670run_test "Large packet TLS 1.0 BlockCipher" \
3671 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003672 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003673 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3674 0 \
3675 -s "Read from client: 16384 bytes read"
3676
Hanno Becker278fc7a2017-11-10 09:16:28 +00003677run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
3678 "$P_SRV" \
3679 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3680 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3681 0 \
3682 -s "Read from client: 16384 bytes read"
3683
Hanno Becker32c55012017-11-10 08:42:54 +00003684requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003685run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003686 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003687 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003688 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3689 trunc_hmac=1" \
3690 0 \
3691 -s "Read from client: 16384 bytes read"
3692
Hanno Becker32c55012017-11-10 08:42:54 +00003693requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003694run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
3695 "$P_SRV" \
3696 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3697 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3698 trunc_hmac=1" \
3699 0 \
3700 -s "Read from client: 16384 bytes read"
3701
3702run_test "Large packet TLS 1.0 StreamCipher" \
3703 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3704 "$P_CLI request_size=16384 force_version=tls1 \
3705 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3706 0 \
3707 -s "Read from client: 16384 bytes read"
3708
3709run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3710 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3711 "$P_CLI request_size=16384 force_version=tls1 \
3712 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3713 etm=0" \
3714 0 \
3715 -s "Read from client: 16384 bytes read"
3716
3717requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3718run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003719 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003720 "$P_CLI request_size=16384 force_version=tls1 \
3721 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3722 trunc_hmac=1" \
3723 0 \
3724 -s "Read from client: 16384 bytes read"
3725
Hanno Becker278fc7a2017-11-10 09:16:28 +00003726requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3727run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
3728 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3729 "$P_CLI request_size=16384 force_version=tls1 \
3730 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3731 trunc_hmac=1 etm=0" \
3732 0 \
3733 -s "Read from client: 16384 bytes read"
3734
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003735run_test "Large packet TLS 1.1 BlockCipher" \
3736 "$P_SRV" \
3737 "$P_CLI request_size=16384 force_version=tls1_1 \
3738 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3739 0 \
3740 -s "Read from client: 16384 bytes read"
3741
Hanno Becker278fc7a2017-11-10 09:16:28 +00003742run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3743 "$P_SRV" \
3744 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3745 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003746 0 \
3747 -s "Read from client: 16384 bytes read"
3748
Hanno Becker32c55012017-11-10 08:42:54 +00003749requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003750run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003751 "$P_SRV" \
3752 "$P_CLI request_size=16384 force_version=tls1_1 \
3753 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3754 trunc_hmac=1" \
3755 0 \
3756 -s "Read from client: 16384 bytes read"
3757
Hanno Becker32c55012017-11-10 08:42:54 +00003758requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003759run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
3760 "$P_SRV" \
3761 "$P_CLI request_size=16384 force_version=tls1_1 \
3762 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3763 trunc_hmac=1 etm=0" \
3764 0 \
3765 -s "Read from client: 16384 bytes read"
3766
3767run_test "Large packet TLS 1.1 StreamCipher" \
3768 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3769 "$P_CLI request_size=16384 force_version=tls1_1 \
3770 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3771 0 \
3772 -s "Read from client: 16384 bytes read"
3773
3774run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
3775 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3776 "$P_CLI request_size=16384 force_version=tls1_1 \
3777 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3778 etm=0" \
3779 0 \
3780 -s "Read from client: 16384 bytes read"
3781
3782requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3783run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003784 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003785 "$P_CLI request_size=16384 force_version=tls1_1 \
3786 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3787 trunc_hmac=1" \
3788 0 \
3789 -s "Read from client: 16384 bytes read"
3790
Hanno Becker278fc7a2017-11-10 09:16:28 +00003791requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3792run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
3793 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3794 "$P_CLI request_size=16384 force_version=tls1_1 \
3795 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3796 trunc_hmac=1 etm=0" \
3797 0 \
3798 -s "Read from client: 16384 bytes read"
3799
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003800run_test "Large packet TLS 1.2 BlockCipher" \
3801 "$P_SRV" \
3802 "$P_CLI request_size=16384 force_version=tls1_2 \
3803 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3804 0 \
3805 -s "Read from client: 16384 bytes read"
3806
Hanno Becker278fc7a2017-11-10 09:16:28 +00003807run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
3808 "$P_SRV" \
3809 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
3810 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3811 0 \
3812 -s "Read from client: 16384 bytes read"
3813
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003814run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3815 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003816 "$P_CLI request_size=16384 force_version=tls1_2 \
3817 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003818 0 \
3819 -s "Read from client: 16384 bytes read"
3820
Hanno Becker32c55012017-11-10 08:42:54 +00003821requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003822run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003823 "$P_SRV" \
3824 "$P_CLI request_size=16384 force_version=tls1_2 \
3825 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3826 trunc_hmac=1" \
3827 0 \
3828 -s "Read from client: 16384 bytes read"
3829
Hanno Becker278fc7a2017-11-10 09:16:28 +00003830requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3831run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
3832 "$P_SRV" \
3833 "$P_CLI request_size=16384 force_version=tls1_2 \
3834 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3835 trunc_hmac=1 etm=0" \
3836 0 \
3837 -s "Read from client: 16384 bytes read"
3838
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003839run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003840 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003841 "$P_CLI request_size=16384 force_version=tls1_2 \
3842 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3843 0 \
3844 -s "Read from client: 16384 bytes read"
3845
Hanno Becker278fc7a2017-11-10 09:16:28 +00003846run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
3847 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3848 "$P_CLI request_size=16384 force_version=tls1_2 \
3849 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
3850 0 \
3851 -s "Read from client: 16384 bytes read"
3852
Hanno Becker32c55012017-11-10 08:42:54 +00003853requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003854run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003855 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003856 "$P_CLI request_size=16384 force_version=tls1_2 \
3857 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3858 trunc_hmac=1" \
3859 0 \
3860 -s "Read from client: 16384 bytes read"
3861
Hanno Becker278fc7a2017-11-10 09:16:28 +00003862requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3863run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
3864 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3865 "$P_CLI request_size=16384 force_version=tls1_2 \
3866 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3867 trunc_hmac=1 etm=0" \
3868 0 \
3869 -s "Read from client: 16384 bytes read"
3870
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003871run_test "Large packet TLS 1.2 AEAD" \
3872 "$P_SRV" \
3873 "$P_CLI request_size=16384 force_version=tls1_2 \
3874 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3875 0 \
3876 -s "Read from client: 16384 bytes read"
3877
3878run_test "Large packet TLS 1.2 AEAD shorter tag" \
3879 "$P_SRV" \
3880 "$P_CLI request_size=16384 force_version=tls1_2 \
3881 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3882 0 \
3883 -s "Read from client: 16384 bytes read"
3884
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003885# Tests for DTLS HelloVerifyRequest
3886
3887run_test "DTLS cookie: enabled" \
3888 "$P_SRV dtls=1 debug_level=2" \
3889 "$P_CLI dtls=1 debug_level=2" \
3890 0 \
3891 -s "cookie verification failed" \
3892 -s "cookie verification passed" \
3893 -S "cookie verification skipped" \
3894 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003895 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003896 -S "SSL - The requested feature is not available"
3897
3898run_test "DTLS cookie: disabled" \
3899 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3900 "$P_CLI dtls=1 debug_level=2" \
3901 0 \
3902 -S "cookie verification failed" \
3903 -S "cookie verification passed" \
3904 -s "cookie verification skipped" \
3905 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003906 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003907 -S "SSL - The requested feature is not available"
3908
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003909run_test "DTLS cookie: default (failing)" \
3910 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3911 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3912 1 \
3913 -s "cookie verification failed" \
3914 -S "cookie verification passed" \
3915 -S "cookie verification skipped" \
3916 -C "received hello verify request" \
3917 -S "hello verification requested" \
3918 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003919
3920requires_ipv6
3921run_test "DTLS cookie: enabled, IPv6" \
3922 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3923 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3924 0 \
3925 -s "cookie verification failed" \
3926 -s "cookie verification passed" \
3927 -S "cookie verification skipped" \
3928 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003929 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003930 -S "SSL - The requested feature is not available"
3931
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003932run_test "DTLS cookie: enabled, nbio" \
3933 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3934 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3935 0 \
3936 -s "cookie verification failed" \
3937 -s "cookie verification passed" \
3938 -S "cookie verification skipped" \
3939 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003940 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003941 -S "SSL - The requested feature is not available"
3942
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003943# Tests for client reconnecting from the same port with DTLS
3944
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003945not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003946run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003947 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3948 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003949 0 \
3950 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003951 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003952 -S "Client initiated reconnection from same port"
3953
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003954not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003955run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003956 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3957 "$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 +02003958 0 \
3959 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003960 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003961 -s "Client initiated reconnection from same port"
3962
Paul Bakker362689d2016-05-13 10:33:25 +01003963not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3964run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003965 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3966 "$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 +02003967 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003968 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003969 -s "Client initiated reconnection from same port"
3970
Paul Bakker362689d2016-05-13 10:33:25 +01003971only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3972run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3973 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3974 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3975 0 \
3976 -S "The operation timed out" \
3977 -s "Client initiated reconnection from same port"
3978
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003979run_test "DTLS client reconnect from same port: no cookies" \
3980 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003981 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3982 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003983 -s "The operation timed out" \
3984 -S "Client initiated reconnection from same port"
3985
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003986# Tests for various cases of client authentication with DTLS
3987# (focused on handshake flows and message parsing)
3988
3989run_test "DTLS client auth: required" \
3990 "$P_SRV dtls=1 auth_mode=required" \
3991 "$P_CLI dtls=1" \
3992 0 \
3993 -s "Verifying peer X.509 certificate... ok"
3994
3995run_test "DTLS client auth: optional, client has no cert" \
3996 "$P_SRV dtls=1 auth_mode=optional" \
3997 "$P_CLI dtls=1 crt_file=none key_file=none" \
3998 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003999 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004000
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004001run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004002 "$P_SRV dtls=1 auth_mode=none" \
4003 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
4004 0 \
4005 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004006 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004007
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02004008run_test "DTLS wrong PSK: badmac alert" \
4009 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
4010 "$P_CLI dtls=1 psk=abc124" \
4011 1 \
4012 -s "SSL - Verification of the message MAC failed" \
4013 -c "SSL - A fatal alert message was received from our peer"
4014
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02004015# Tests for receiving fragmented handshake messages with DTLS
4016
4017requires_gnutls
4018run_test "DTLS reassembly: no fragmentation (gnutls server)" \
4019 "$G_SRV -u --mtu 2048 -a" \
4020 "$P_CLI dtls=1 debug_level=2" \
4021 0 \
4022 -C "found fragmented DTLS handshake message" \
4023 -C "error"
4024
4025requires_gnutls
4026run_test "DTLS reassembly: some fragmentation (gnutls server)" \
4027 "$G_SRV -u --mtu 512" \
4028 "$P_CLI dtls=1 debug_level=2" \
4029 0 \
4030 -c "found fragmented DTLS handshake message" \
4031 -C "error"
4032
4033requires_gnutls
4034run_test "DTLS reassembly: more fragmentation (gnutls server)" \
4035 "$G_SRV -u --mtu 128" \
4036 "$P_CLI dtls=1 debug_level=2" \
4037 0 \
4038 -c "found fragmented DTLS handshake message" \
4039 -C "error"
4040
4041requires_gnutls
4042run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
4043 "$G_SRV -u --mtu 128" \
4044 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4045 0 \
4046 -c "found fragmented DTLS handshake message" \
4047 -C "error"
4048
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004049requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004050run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4051 "$G_SRV -u --mtu 256" \
4052 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4053 0 \
4054 -c "found fragmented DTLS handshake message" \
4055 -c "client hello, adding renegotiation extension" \
4056 -c "found renegotiation extension" \
4057 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004058 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004059 -C "error" \
4060 -s "Extra-header:"
4061
4062requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004063run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4064 "$G_SRV -u --mtu 256" \
4065 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4066 0 \
4067 -c "found fragmented DTLS handshake message" \
4068 -c "client hello, adding renegotiation extension" \
4069 -c "found renegotiation extension" \
4070 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004071 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004072 -C "error" \
4073 -s "Extra-header:"
4074
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004075run_test "DTLS reassembly: no fragmentation (openssl server)" \
4076 "$O_SRV -dtls1 -mtu 2048" \
4077 "$P_CLI dtls=1 debug_level=2" \
4078 0 \
4079 -C "found fragmented DTLS handshake message" \
4080 -C "error"
4081
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004082run_test "DTLS reassembly: some fragmentation (openssl server)" \
4083 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004084 "$P_CLI dtls=1 debug_level=2" \
4085 0 \
4086 -c "found fragmented DTLS handshake message" \
4087 -C "error"
4088
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004089run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004090 "$O_SRV -dtls1 -mtu 256" \
4091 "$P_CLI dtls=1 debug_level=2" \
4092 0 \
4093 -c "found fragmented DTLS handshake message" \
4094 -C "error"
4095
4096run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4097 "$O_SRV -dtls1 -mtu 256" \
4098 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4099 0 \
4100 -c "found fragmented DTLS handshake message" \
4101 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004102
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004103# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004104
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004105not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004106run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004107 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004108 "$P_SRV dtls=1 debug_level=2" \
4109 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004110 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004111 -C "replayed record" \
4112 -S "replayed record" \
4113 -C "record from another epoch" \
4114 -S "record from another epoch" \
4115 -C "discarding invalid record" \
4116 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004117 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004118 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004119 -c "HTTP/1.0 200 OK"
4120
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004121not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004122run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004123 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004124 "$P_SRV dtls=1 debug_level=2" \
4125 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004126 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004127 -c "replayed record" \
4128 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004129 -c "discarding invalid record" \
4130 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004131 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004132 -s "Extra-header:" \
4133 -c "HTTP/1.0 200 OK"
4134
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004135run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4136 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004137 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4138 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004139 0 \
4140 -c "replayed record" \
4141 -S "replayed record" \
4142 -c "discarding invalid record" \
4143 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004144 -c "resend" \
4145 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004146 -s "Extra-header:" \
4147 -c "HTTP/1.0 200 OK"
4148
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004149run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004150 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004151 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004152 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004153 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004154 -c "discarding invalid record (mac)" \
4155 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004156 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004157 -c "HTTP/1.0 200 OK" \
4158 -S "too many records with bad MAC" \
4159 -S "Verification of the message MAC failed"
4160
4161run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4162 -p "$P_PXY bad_ad=1" \
4163 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4164 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4165 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004166 -C "discarding invalid record (mac)" \
4167 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004168 -S "Extra-header:" \
4169 -C "HTTP/1.0 200 OK" \
4170 -s "too many records with bad MAC" \
4171 -s "Verification of the message MAC failed"
4172
4173run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4174 -p "$P_PXY bad_ad=1" \
4175 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4176 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4177 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004178 -c "discarding invalid record (mac)" \
4179 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004180 -s "Extra-header:" \
4181 -c "HTTP/1.0 200 OK" \
4182 -S "too many records with bad MAC" \
4183 -S "Verification of the message MAC failed"
4184
4185run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4186 -p "$P_PXY bad_ad=1" \
4187 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4188 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4189 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004190 -c "discarding invalid record (mac)" \
4191 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004192 -s "Extra-header:" \
4193 -c "HTTP/1.0 200 OK" \
4194 -s "too many records with bad MAC" \
4195 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004196
4197run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004198 -p "$P_PXY delay_ccs=1" \
4199 "$P_SRV dtls=1 debug_level=1" \
4200 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004201 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004202 -c "record from another epoch" \
4203 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004204 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004205 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004206 -s "Extra-header:" \
4207 -c "HTTP/1.0 200 OK"
4208
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004209# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004210
Janos Follath74537a62016-09-02 13:45:28 +01004211client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004212run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004213 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004214 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4215 psk=abc123" \
4216 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004217 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4218 0 \
4219 -s "Extra-header:" \
4220 -c "HTTP/1.0 200 OK"
4221
Janos Follath74537a62016-09-02 13:45:28 +01004222client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004223run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4224 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004225 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4226 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004227 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4228 0 \
4229 -s "Extra-header:" \
4230 -c "HTTP/1.0 200 OK"
4231
Janos Follath74537a62016-09-02 13:45:28 +01004232client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004233run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4234 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004235 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4236 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004237 0 \
4238 -s "Extra-header:" \
4239 -c "HTTP/1.0 200 OK"
4240
Janos Follath74537a62016-09-02 13:45:28 +01004241client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004242run_test "DTLS proxy: 3d, FS, client auth" \
4243 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004244 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4245 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004246 0 \
4247 -s "Extra-header:" \
4248 -c "HTTP/1.0 200 OK"
4249
Janos Follath74537a62016-09-02 13:45:28 +01004250client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004251run_test "DTLS proxy: 3d, FS, ticket" \
4252 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004253 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4254 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004255 0 \
4256 -s "Extra-header:" \
4257 -c "HTTP/1.0 200 OK"
4258
Janos Follath74537a62016-09-02 13:45:28 +01004259client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004260run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
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=1 auth_mode=required" \
4263 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004264 0 \
4265 -s "Extra-header:" \
4266 -c "HTTP/1.0 200 OK"
4267
Janos Follath74537a62016-09-02 13:45:28 +01004268client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004269run_test "DTLS proxy: 3d, max handshake, nbio" \
4270 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004271 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4272 auth_mode=required" \
4273 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004274 0 \
4275 -s "Extra-header:" \
4276 -c "HTTP/1.0 200 OK"
4277
Janos Follath74537a62016-09-02 13:45:28 +01004278client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004279run_test "DTLS proxy: 3d, min handshake, resumption" \
4280 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4281 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4282 psk=abc123 debug_level=3" \
4283 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4284 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4285 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4286 0 \
4287 -s "a session has been resumed" \
4288 -c "a session has been resumed" \
4289 -s "Extra-header:" \
4290 -c "HTTP/1.0 200 OK"
4291
Janos Follath74537a62016-09-02 13:45:28 +01004292client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004293run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4294 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4295 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4296 psk=abc123 debug_level=3 nbio=2" \
4297 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4298 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4299 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4300 0 \
4301 -s "a session has been resumed" \
4302 -c "a session has been resumed" \
4303 -s "Extra-header:" \
4304 -c "HTTP/1.0 200 OK"
4305
Janos Follath74537a62016-09-02 13:45:28 +01004306client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004307run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004308 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004309 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4310 psk=abc123 renegotiation=1 debug_level=2" \
4311 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4312 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004313 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4314 0 \
4315 -c "=> renegotiate" \
4316 -s "=> renegotiate" \
4317 -s "Extra-header:" \
4318 -c "HTTP/1.0 200 OK"
4319
Janos Follath74537a62016-09-02 13:45:28 +01004320client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004321run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4322 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004323 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4324 psk=abc123 renegotiation=1 debug_level=2" \
4325 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4326 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004327 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4328 0 \
4329 -c "=> renegotiate" \
4330 -s "=> renegotiate" \
4331 -s "Extra-header:" \
4332 -c "HTTP/1.0 200 OK"
4333
Janos Follath74537a62016-09-02 13:45:28 +01004334client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004335run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004336 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004337 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004338 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004339 debug_level=2" \
4340 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004341 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004342 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4343 0 \
4344 -c "=> renegotiate" \
4345 -s "=> renegotiate" \
4346 -s "Extra-header:" \
4347 -c "HTTP/1.0 200 OK"
4348
Janos Follath74537a62016-09-02 13:45:28 +01004349client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004350run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004351 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004352 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004353 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004354 debug_level=2 nbio=2" \
4355 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004356 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004357 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4358 0 \
4359 -c "=> renegotiate" \
4360 -s "=> renegotiate" \
4361 -s "Extra-header:" \
4362 -c "HTTP/1.0 200 OK"
4363
Janos Follath74537a62016-09-02 13:45:28 +01004364client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004365not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004366run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004367 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4368 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004369 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004370 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004371 -c "HTTP/1.0 200 OK"
4372
Janos Follath74537a62016-09-02 13:45:28 +01004373client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004374not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004375run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4376 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4377 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004378 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004379 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004380 -c "HTTP/1.0 200 OK"
4381
Janos Follath74537a62016-09-02 13:45:28 +01004382client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004383not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004384run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4385 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4386 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004387 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004388 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004389 -c "HTTP/1.0 200 OK"
4390
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004391requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004392client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004393not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004394run_test "DTLS proxy: 3d, gnutls server" \
4395 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4396 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004397 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004398 0 \
4399 -s "Extra-header:" \
4400 -c "Extra-header:"
4401
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004402requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004403client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004404not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004405run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4406 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4407 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004408 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004409 0 \
4410 -s "Extra-header:" \
4411 -c "Extra-header:"
4412
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004413requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004414client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004415not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004416run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4417 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4418 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004419 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004420 0 \
4421 -s "Extra-header:" \
4422 -c "Extra-header:"
4423
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004424# Final report
4425
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004426echo "------------------------------------------------------------------------"
4427
4428if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004429 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004430else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004431 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004432fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004433PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004434echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004435
4436exit $FAILS