blob: 50fb0f94b9535d8623e15407e2e704f79672c5d3 [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
Azim Khan19d13732018-03-29 11:04:20 +0100234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot -o "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200235 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
Gilles Peskine418b5362017-12-14 18:58:42 +0100289# Wait for process $2 to be listening on port $1
290if type lsof >/dev/null 2>/dev/null; then
291 wait_server_start() {
292 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200293 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100294 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200295 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100296 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200297 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100298 # Make a tight loop, server normally takes less than 1s to start.
299 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
300 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
301 echo "SERVERSTART TIMEOUT"
302 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
303 break
304 fi
305 # Linux and *BSD support decimal arguments to sleep. On other
306 # OSes this may be a tight loop.
307 sleep 0.1 2>/dev/null || true
308 done
309 }
310else
Gilles Peskine3c9e2b52018-01-08 12:38:15 +0100311 echo "Warning: lsof not available, wait_server_start = sleep $START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100312 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200313 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100314 }
315fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200316
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100317# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100318# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100319# acceptable bounds
320check_server_hello_time() {
321 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100322 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100323 # Get the Unix timestamp for now
324 CUR_TIME=$(date +'%s')
325 THRESHOLD_IN_SECS=300
326
327 # Check if the ServerHello time was printed
328 if [ -z "$SERVER_HELLO_TIME" ]; then
329 return 1
330 fi
331
332 # Check the time in ServerHello is within acceptable bounds
333 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
334 # The time in ServerHello is at least 5 minutes before now
335 return 1
336 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100337 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100338 return 1
339 else
340 return 0
341 fi
342}
343
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200344# wait for client to terminate and set CLI_EXIT
345# must be called right after starting the client
346wait_client_done() {
347 CLI_PID=$!
348
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200349 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
350 CLI_DELAY_FACTOR=1
351
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200352 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200353 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200354
355 wait $CLI_PID
356 CLI_EXIT=$?
357
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200358 kill $DOG_PID >/dev/null 2>&1
359 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200360
361 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100362
363 sleep $SRV_DELAY_SECONDS
364 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200365}
366
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200367# check if the given command uses dtls and sets global variable DTLS
368detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200369 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200370 DTLS=1
371 else
372 DTLS=0
373 fi
374}
375
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200376# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100377# Options: -s pattern pattern that must be present in server output
378# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100379# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100380# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100381# -S pattern pattern that must be absent in server output
382# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100383# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100384# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100385run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100386 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200387 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100388
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100389 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
390 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200391 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100392 return
393 fi
394
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100396
Paul Bakkerb7584a52016-05-10 10:50:43 +0100397 # Do we only run numbered tests?
398 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
399 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
400 else
401 SKIP_NEXT="YES"
402 fi
403
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200404 # should we skip?
405 if [ "X$SKIP_NEXT" = "XYES" ]; then
406 SKIP_NEXT="NO"
407 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200408 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200409 return
410 fi
411
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200412 # does this test use a proxy?
413 if [ "X$1" = "X-p" ]; then
414 PXY_CMD="$2"
415 shift 2
416 else
417 PXY_CMD=""
418 fi
419
420 # get commands and client output
421 SRV_CMD="$1"
422 CLI_CMD="$2"
423 CLI_EXPECT="$3"
424 shift 3
425
426 # fix client port
427 if [ -n "$PXY_CMD" ]; then
428 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
429 else
430 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
431 fi
432
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200433 # update DTLS variable
434 detect_dtls "$SRV_CMD"
435
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100436 # prepend valgrind to our commands if active
437 if [ "$MEMCHECK" -gt 0 ]; then
438 if is_polar "$SRV_CMD"; then
439 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
440 fi
441 if is_polar "$CLI_CMD"; then
442 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
443 fi
444 fi
445
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200446 TIMES_LEFT=2
447 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200448 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200449
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200450 # run the commands
451 if [ -n "$PXY_CMD" ]; then
452 echo "$PXY_CMD" > $PXY_OUT
453 $PXY_CMD >> $PXY_OUT 2>&1 &
454 PXY_PID=$!
455 # assume proxy starts faster than server
456 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200457
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200458 check_osrv_dtls
459 echo "$SRV_CMD" > $SRV_OUT
460 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
461 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100462 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200463
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200464 echo "$CLI_CMD" > $CLI_OUT
465 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
466 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100467
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100468 sleep 0.05
469
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200470 # terminate the server (and the proxy)
471 kill $SRV_PID
472 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100473
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200474 if [ -n "$PXY_CMD" ]; then
475 kill $PXY_PID >/dev/null 2>&1
476 wait $PXY_PID
477 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100478
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200479 # retry only on timeouts
480 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
481 printf "RETRY "
482 else
483 TIMES_LEFT=0
484 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200485 done
486
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100487 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200488 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100489 # expected client exit to incorrectly succeed in case of catastrophic
490 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100491 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200492 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100493 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100494 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100495 return
496 fi
497 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100498 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200499 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100500 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100501 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100502 return
503 fi
504 fi
505
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100506 # check server exit code
507 if [ $? != 0 ]; then
508 fail "server fail"
509 return
510 fi
511
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100512 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100513 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
514 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100515 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200516 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100517 return
518 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100519
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100520 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200521 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100522 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100523 while [ $# -gt 0 ]
524 do
525 case $1 in
526 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100527 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 +0100528 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100529 return
530 fi
531 ;;
532
533 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100534 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 +0100535 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100536 return
537 fi
538 ;;
539
540 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100541 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 +0100542 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100543 return
544 fi
545 ;;
546
547 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100548 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 +0100549 fail "pattern '$2' MUST NOT be present in the Client output"
550 return
551 fi
552 ;;
553
554 # The filtering in the following two options (-u and -U) do the following
555 # - ignore valgrind output
556 # - filter out everything but lines right after the pattern occurances
557 # - keep one of each non-unique line
558 # - count how many lines remain
559 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
560 # if there were no duplicates.
561 "-U")
562 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
563 fail "lines following pattern '$2' must be unique in Server output"
564 return
565 fi
566 ;;
567
568 "-u")
569 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
570 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100571 return
572 fi
573 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100574 "-F")
575 if ! $2 "$SRV_OUT"; then
576 fail "function call to '$2' failed on Server output"
577 return
578 fi
579 ;;
580 "-f")
581 if ! $2 "$CLI_OUT"; then
582 fail "function call to '$2' failed on Client output"
583 return
584 fi
585 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100586
587 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200588 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100589 exit 1
590 esac
591 shift 2
592 done
593
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100594 # check valgrind's results
595 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200596 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100597 fail "Server has memory errors"
598 return
599 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200600 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100601 fail "Client has memory errors"
602 return
603 fi
604 fi
605
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100606 # if we're here, everything is ok
607 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100608 if [ "$PRESERVE_LOGS" -gt 0 ]; then
609 mv $SRV_OUT o-srv-${TESTS}.log
610 mv $CLI_OUT o-cli-${TESTS}.log
611 fi
612
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200613 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100614}
615
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100616cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200618 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
619 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
620 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
621 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100622 exit 1
623}
624
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100625#
626# MAIN
627#
628
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000629if cd $( dirname $0 ); then :; else
630 echo "cd $( dirname $0 ) failed" >&2
631 exit 1
632fi
633
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100634get_options "$@"
635
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100636# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100637P_SRV_BIN="${P_SRV%%[ ]*}"
638P_CLI_BIN="${P_CLI%%[ ]*}"
639P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100640if [ ! -x "$P_SRV_BIN" ]; then
641 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100642 exit 1
643fi
Hanno Becker17c04932017-10-10 14:44:53 +0100644if [ ! -x "$P_CLI_BIN" ]; then
645 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100646 exit 1
647fi
Hanno Becker17c04932017-10-10 14:44:53 +0100648if [ ! -x "$P_PXY_BIN" ]; then
649 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200650 exit 1
651fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100652if [ "$MEMCHECK" -gt 0 ]; then
653 if which valgrind >/dev/null 2>&1; then :; else
654 echo "Memcheck not possible. Valgrind not found"
655 exit 1
656 fi
657fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100658if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
659 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100660 exit 1
661fi
662
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200663# used by watchdog
664MAIN_PID="$$"
665
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100666# We use somewhat arbitrary delays for tests:
667# - how long do we wait for the server to start (when lsof not available)?
668# - how long do we allow for the client to finish?
669# (not to check performance, just to avoid waiting indefinitely)
670# Things are slower with valgrind, so give extra time here.
671#
672# Note: without lsof, there is a trade-off between the running time of this
673# script and the risk of spurious errors because we didn't wait long enough.
674# The watchdog delay on the other hand doesn't affect normal running time of
675# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200676if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100677 START_DELAY=6
678 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200679else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100680 START_DELAY=2
681 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200682fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100683
684# some particular tests need more time:
685# - for the client, we multiply the usual watchdog limit by a factor
686# - for the server, we sleep for a number of seconds after the client exits
687# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200688CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100689SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200690
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200691# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000692# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200693P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
694P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100695P_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 +0200696O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200697O_CLI="$O_CLI -connect localhost:+SRV_PORT"
698G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000699G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200700
Gilles Peskine62469d92017-05-10 10:13:59 +0200701# Allow SHA-1, because many of our test certificates use it
702P_SRV="$P_SRV allow_sha1=1"
703P_CLI="$P_CLI allow_sha1=1"
704
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200705# Also pick a unique name for intermediate files
706SRV_OUT="srv_out.$$"
707CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200708PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200709SESSION="session.$$"
710
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200711SKIP_NEXT="NO"
712
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100713trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100714
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200715# Basic test
716
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200717# Checks that:
718# - things work with all ciphersuites active (used with config-full in all.sh)
719# - the expected (highest security) parameters are selected
720# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200721run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200722 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200723 "$P_CLI" \
724 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200725 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200726 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200727 -s "client hello v3, signature_algorithm ext: 6" \
728 -s "ECDHE curve: secp521r1" \
729 -S "error" \
730 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200731
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000732run_test "Default, DTLS" \
733 "$P_SRV dtls=1" \
734 "$P_CLI dtls=1" \
735 0 \
736 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200737 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000738
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100739# Test current time in ServerHello
740requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200741run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100742 "$P_SRV debug_level=3" \
743 "$P_CLI debug_level=3" \
744 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100745 -f "check_server_hello_time" \
746 -F "check_server_hello_time"
747
Simon Butcher8e004102016-10-14 00:48:33 +0100748# Test for uniqueness of IVs in AEAD ciphersuites
749run_test "Unique IV in GCM" \
750 "$P_SRV exchanges=20 debug_level=4" \
751 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
752 0 \
753 -u "IV used" \
754 -U "IV used"
755
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100756# Tests for rc4 option
757
Simon Butchera410af52016-05-19 22:12:18 +0100758requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100759run_test "RC4: server disabled, client enabled" \
760 "$P_SRV" \
761 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
762 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100763 -s "SSL - The server has no ciphersuites in common"
764
Simon Butchera410af52016-05-19 22:12:18 +0100765requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100766run_test "RC4: server half, client enabled" \
767 "$P_SRV arc4=1" \
768 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
769 1 \
770 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100771
772run_test "RC4: server enabled, client disabled" \
773 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
774 "$P_CLI" \
775 1 \
776 -s "SSL - The server has no ciphersuites in common"
777
778run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100779 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100780 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
781 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100782 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100783 -S "SSL - The server has no ciphersuites in common"
784
Gilles Peskinebc70a182017-05-09 15:59:24 +0200785# Tests for SHA-1 support
786
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200787requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200788run_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 1 \
792 -c "The certificate is signed with an unacceptable hash"
793
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200794requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
795run_test "SHA-1 forbidden by default in server certificate" \
796 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
797 "$P_CLI debug_level=2 allow_sha1=0" \
798 0
799
Gilles Peskinebc70a182017-05-09 15:59:24 +0200800run_test "SHA-1 explicitly allowed in server certificate" \
801 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
802 "$P_CLI allow_sha1=1" \
803 0
804
805run_test "SHA-256 allowed by default in server certificate" \
806 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
807 "$P_CLI allow_sha1=0" \
808 0
809
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200810requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200811run_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 1 \
815 -s "The certificate is signed with an unacceptable hash"
816
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200817requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
818run_test "SHA-1 forbidden by default in client certificate" \
819 "$P_SRV auth_mode=required allow_sha1=0" \
820 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
821 0
822
Gilles Peskinebc70a182017-05-09 15:59:24 +0200823run_test "SHA-1 explicitly allowed in client certificate" \
824 "$P_SRV auth_mode=required allow_sha1=1" \
825 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
826 0
827
828run_test "SHA-256 allowed by default in client certificate" \
829 "$P_SRV auth_mode=required allow_sha1=0" \
830 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
831 0
832
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100833# Tests for Truncated HMAC extension
834
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100835run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200836 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100837 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100838 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000839 -s "dumping 'expected mac' (20 bytes)" \
840 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100841
Hanno Becker32c55012017-11-10 08:42:54 +0000842requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100843run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200844 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000845 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100846 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000847 -s "dumping 'expected mac' (20 bytes)" \
848 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100849
Hanno Becker32c55012017-11-10 08:42:54 +0000850requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100851run_test "Truncated HMAC: client enabled, server default" \
852 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000853 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100854 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000855 -s "dumping 'expected mac' (20 bytes)" \
856 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100857
Hanno Becker32c55012017-11-10 08:42:54 +0000858requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100859run_test "Truncated HMAC: client enabled, server disabled" \
860 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000861 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100862 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000863 -s "dumping 'expected mac' (20 bytes)" \
864 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100865
Hanno Becker32c55012017-11-10 08:42:54 +0000866requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000867run_test "Truncated HMAC: client disabled, server enabled" \
868 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000869 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000870 0 \
871 -s "dumping 'expected mac' (20 bytes)" \
872 -S "dumping 'expected mac' (10 bytes)"
873
874requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100875run_test "Truncated HMAC: client enabled, server enabled" \
876 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000877 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100878 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000879 -S "dumping 'expected mac' (20 bytes)" \
880 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100881
Hanno Becker4c4f4102017-11-10 09:16:05 +0000882run_test "Truncated HMAC, DTLS: client default, server default" \
883 "$P_SRV dtls=1 debug_level=4" \
884 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
885 0 \
886 -s "dumping 'expected mac' (20 bytes)" \
887 -S "dumping 'expected mac' (10 bytes)"
888
889requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
890run_test "Truncated HMAC, DTLS: client disabled, server default" \
891 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000892 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000893 0 \
894 -s "dumping 'expected mac' (20 bytes)" \
895 -S "dumping 'expected mac' (10 bytes)"
896
897requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
898run_test "Truncated HMAC, DTLS: client enabled, server default" \
899 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000900 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000901 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" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000908 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000909 0 \
910 -s "dumping 'expected mac' (20 bytes)" \
911 -S "dumping 'expected mac' (10 bytes)"
912
913requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
914run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
915 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000916 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000917 0 \
918 -s "dumping 'expected mac' (20 bytes)" \
919 -S "dumping 'expected mac' (10 bytes)"
920
921requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
922run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
923 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000924 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100925 0 \
926 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100927 -s "dumping 'expected mac' (10 bytes)"
928
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100929# Tests for Encrypt-then-MAC extension
930
931run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100932 "$P_SRV debug_level=3 \
933 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100934 "$P_CLI debug_level=3" \
935 0 \
936 -c "client hello, adding encrypt_then_mac extension" \
937 -s "found encrypt then mac extension" \
938 -s "server hello, adding encrypt then mac extension" \
939 -c "found encrypt_then_mac extension" \
940 -c "using encrypt then mac" \
941 -s "using encrypt then mac"
942
943run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100944 "$P_SRV debug_level=3 etm=0 \
945 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100946 "$P_CLI debug_level=3 etm=1" \
947 0 \
948 -c "client hello, adding encrypt_then_mac extension" \
949 -s "found encrypt then mac extension" \
950 -S "server hello, adding encrypt then mac extension" \
951 -C "found encrypt_then_mac extension" \
952 -C "using encrypt then mac" \
953 -S "using encrypt then mac"
954
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100955run_test "Encrypt then MAC: client enabled, aead cipher" \
956 "$P_SRV debug_level=3 etm=1 \
957 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
958 "$P_CLI debug_level=3 etm=1" \
959 0 \
960 -c "client hello, adding encrypt_then_mac extension" \
961 -s "found encrypt then mac extension" \
962 -S "server hello, adding encrypt then mac extension" \
963 -C "found encrypt_then_mac extension" \
964 -C "using encrypt then mac" \
965 -S "using encrypt then mac"
966
967run_test "Encrypt then MAC: client enabled, stream cipher" \
968 "$P_SRV debug_level=3 etm=1 \
969 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100970 "$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 +0100971 0 \
972 -c "client hello, adding encrypt_then_mac extension" \
973 -s "found encrypt then mac extension" \
974 -S "server hello, adding encrypt then mac extension" \
975 -C "found encrypt_then_mac extension" \
976 -C "using encrypt then mac" \
977 -S "using encrypt then mac"
978
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100979run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100980 "$P_SRV debug_level=3 etm=1 \
981 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100982 "$P_CLI debug_level=3 etm=0" \
983 0 \
984 -C "client hello, adding encrypt_then_mac extension" \
985 -S "found encrypt then mac extension" \
986 -S "server hello, adding encrypt then mac extension" \
987 -C "found encrypt_then_mac extension" \
988 -C "using encrypt then mac" \
989 -S "using encrypt then mac"
990
Janos Follathe2681a42016-03-07 15:57:05 +0000991requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100992run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100993 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100994 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100995 "$P_CLI debug_level=3 force_version=ssl3" \
996 0 \
997 -C "client hello, adding encrypt_then_mac extension" \
998 -S "found encrypt then mac extension" \
999 -S "server hello, adding encrypt then mac extension" \
1000 -C "found encrypt_then_mac extension" \
1001 -C "using encrypt then mac" \
1002 -S "using encrypt then mac"
1003
Janos Follathe2681a42016-03-07 15:57:05 +00001004requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001005run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001006 "$P_SRV debug_level=3 force_version=ssl3 \
1007 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001008 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001009 0 \
1010 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001011 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001012 -S "server hello, adding encrypt then mac extension" \
1013 -C "found encrypt_then_mac extension" \
1014 -C "using encrypt then mac" \
1015 -S "using encrypt then mac"
1016
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001017# Tests for Extended Master Secret extension
1018
1019run_test "Extended Master Secret: default" \
1020 "$P_SRV debug_level=3" \
1021 "$P_CLI debug_level=3" \
1022 0 \
1023 -c "client hello, adding extended_master_secret extension" \
1024 -s "found extended master secret extension" \
1025 -s "server hello, adding extended master secret extension" \
1026 -c "found extended_master_secret extension" \
1027 -c "using extended master secret" \
1028 -s "using extended master secret"
1029
1030run_test "Extended Master Secret: client enabled, server disabled" \
1031 "$P_SRV debug_level=3 extended_ms=0" \
1032 "$P_CLI debug_level=3 extended_ms=1" \
1033 0 \
1034 -c "client hello, adding extended_master_secret extension" \
1035 -s "found extended master secret extension" \
1036 -S "server hello, adding extended master secret extension" \
1037 -C "found extended_master_secret extension" \
1038 -C "using extended master secret" \
1039 -S "using extended master secret"
1040
1041run_test "Extended Master Secret: client disabled, server enabled" \
1042 "$P_SRV debug_level=3 extended_ms=1" \
1043 "$P_CLI debug_level=3 extended_ms=0" \
1044 0 \
1045 -C "client hello, adding extended_master_secret extension" \
1046 -S "found extended master secret extension" \
1047 -S "server hello, adding extended master secret extension" \
1048 -C "found extended_master_secret extension" \
1049 -C "using extended master secret" \
1050 -S "using extended master secret"
1051
Janos Follathe2681a42016-03-07 15:57:05 +00001052requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001053run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001054 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001055 "$P_CLI debug_level=3 force_version=ssl3" \
1056 0 \
1057 -C "client hello, adding extended_master_secret extension" \
1058 -S "found extended master secret extension" \
1059 -S "server hello, adding extended master secret extension" \
1060 -C "found extended_master_secret extension" \
1061 -C "using extended master secret" \
1062 -S "using extended master secret"
1063
Janos Follathe2681a42016-03-07 15:57:05 +00001064requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001065run_test "Extended Master Secret: client enabled, server SSLv3" \
1066 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001067 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001068 0 \
1069 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001070 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001071 -S "server hello, adding extended master secret extension" \
1072 -C "found extended_master_secret extension" \
1073 -C "using extended master secret" \
1074 -S "using extended master secret"
1075
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001076# Tests for FALLBACK_SCSV
1077
1078run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001079 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001080 "$P_CLI debug_level=3 force_version=tls1_1" \
1081 0 \
1082 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001083 -S "received FALLBACK_SCSV" \
1084 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001085 -C "is a fatal alert message (msg 86)"
1086
1087run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001088 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001089 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1090 0 \
1091 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001092 -S "received FALLBACK_SCSV" \
1093 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001094 -C "is a fatal alert message (msg 86)"
1095
1096run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001097 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001098 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001099 1 \
1100 -c "adding FALLBACK_SCSV" \
1101 -s "received FALLBACK_SCSV" \
1102 -s "inapropriate fallback" \
1103 -c "is a fatal alert message (msg 86)"
1104
1105run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001106 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001107 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001108 0 \
1109 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001110 -s "received FALLBACK_SCSV" \
1111 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001112 -C "is a fatal alert message (msg 86)"
1113
1114requires_openssl_with_fallback_scsv
1115run_test "Fallback SCSV: default, openssl server" \
1116 "$O_SRV" \
1117 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1118 0 \
1119 -C "adding FALLBACK_SCSV" \
1120 -C "is a fatal alert message (msg 86)"
1121
1122requires_openssl_with_fallback_scsv
1123run_test "Fallback SCSV: enabled, openssl server" \
1124 "$O_SRV" \
1125 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1126 1 \
1127 -c "adding FALLBACK_SCSV" \
1128 -c "is a fatal alert message (msg 86)"
1129
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001130requires_openssl_with_fallback_scsv
1131run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001132 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001133 "$O_CLI -tls1_1" \
1134 0 \
1135 -S "received FALLBACK_SCSV" \
1136 -S "inapropriate fallback"
1137
1138requires_openssl_with_fallback_scsv
1139run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001140 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001141 "$O_CLI -tls1_1 -fallback_scsv" \
1142 1 \
1143 -s "received FALLBACK_SCSV" \
1144 -s "inapropriate fallback"
1145
1146requires_openssl_with_fallback_scsv
1147run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001148 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001149 "$O_CLI -fallback_scsv" \
1150 0 \
1151 -s "received FALLBACK_SCSV" \
1152 -S "inapropriate fallback"
1153
Gilles Peskined50177f2017-05-16 17:53:03 +02001154## ClientHello generated with
1155## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1156## then manually twiddling the ciphersuite list.
1157## The ClientHello content is spelled out below as a hex string as
1158## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1159## The expected response is an inappropriate_fallback alert.
1160requires_openssl_with_fallback_scsv
1161run_test "Fallback SCSV: beginning of list" \
1162 "$P_SRV debug_level=2" \
1163 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1164 0 \
1165 -s "received FALLBACK_SCSV" \
1166 -s "inapropriate fallback"
1167
1168requires_openssl_with_fallback_scsv
1169run_test "Fallback SCSV: end of list" \
1170 "$P_SRV debug_level=2" \
1171 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1172 0 \
1173 -s "received FALLBACK_SCSV" \
1174 -s "inapropriate fallback"
1175
1176## Here the expected response is a valid ServerHello prefix, up to the random.
1177requires_openssl_with_fallback_scsv
1178run_test "Fallback SCSV: not in list" \
1179 "$P_SRV debug_level=2" \
1180 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1181 0 \
1182 -S "received FALLBACK_SCSV" \
1183 -S "inapropriate fallback"
1184
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001185# Tests for CBC 1/n-1 record splitting
1186
1187run_test "CBC Record splitting: TLS 1.2, no splitting" \
1188 "$P_SRV" \
1189 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1190 request_size=123 force_version=tls1_2" \
1191 0 \
1192 -s "Read from client: 123 bytes read" \
1193 -S "Read from client: 1 bytes read" \
1194 -S "122 bytes read"
1195
1196run_test "CBC Record splitting: TLS 1.1, no splitting" \
1197 "$P_SRV" \
1198 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1199 request_size=123 force_version=tls1_1" \
1200 0 \
1201 -s "Read from client: 123 bytes read" \
1202 -S "Read from client: 1 bytes read" \
1203 -S "122 bytes read"
1204
1205run_test "CBC Record splitting: TLS 1.0, splitting" \
1206 "$P_SRV" \
1207 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1208 request_size=123 force_version=tls1" \
1209 0 \
1210 -S "Read from client: 123 bytes read" \
1211 -s "Read from client: 1 bytes read" \
1212 -s "122 bytes read"
1213
Janos Follathe2681a42016-03-07 15:57:05 +00001214requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001215run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001216 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001217 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1218 request_size=123 force_version=ssl3" \
1219 0 \
1220 -S "Read from client: 123 bytes read" \
1221 -s "Read from client: 1 bytes read" \
1222 -s "122 bytes read"
1223
1224run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001225 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001226 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1227 request_size=123 force_version=tls1" \
1228 0 \
1229 -s "Read from client: 123 bytes read" \
1230 -S "Read from client: 1 bytes read" \
1231 -S "122 bytes read"
1232
1233run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1234 "$P_SRV" \
1235 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1236 request_size=123 force_version=tls1 recsplit=0" \
1237 0 \
1238 -s "Read from client: 123 bytes read" \
1239 -S "Read from client: 1 bytes read" \
1240 -S "122 bytes read"
1241
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001242run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1243 "$P_SRV nbio=2" \
1244 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1245 request_size=123 force_version=tls1" \
1246 0 \
1247 -S "Read from client: 123 bytes read" \
1248 -s "Read from client: 1 bytes read" \
1249 -s "122 bytes read"
1250
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001251# Tests for Session Tickets
1252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001253run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001254 "$P_SRV debug_level=3 tickets=1" \
1255 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001256 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001257 -c "client hello, adding session ticket extension" \
1258 -s "found session ticket extension" \
1259 -s "server hello, adding session ticket extension" \
1260 -c "found session_ticket extension" \
1261 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001262 -S "session successfully restored from cache" \
1263 -s "session successfully restored from ticket" \
1264 -s "a session has been resumed" \
1265 -c "a session has been resumed"
1266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001267run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001268 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1269 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001270 0 \
1271 -c "client hello, adding session ticket extension" \
1272 -s "found session ticket extension" \
1273 -s "server hello, adding session ticket extension" \
1274 -c "found session_ticket extension" \
1275 -c "parse new session ticket" \
1276 -S "session successfully restored from cache" \
1277 -s "session successfully restored from ticket" \
1278 -s "a session has been resumed" \
1279 -c "a session has been resumed"
1280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001281run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001282 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1283 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001284 0 \
1285 -c "client hello, adding session ticket extension" \
1286 -s "found session ticket extension" \
1287 -s "server hello, adding session ticket extension" \
1288 -c "found session_ticket extension" \
1289 -c "parse new session ticket" \
1290 -S "session successfully restored from cache" \
1291 -S "session successfully restored from ticket" \
1292 -S "a session has been resumed" \
1293 -C "a session has been resumed"
1294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001295run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001296 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001297 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001298 0 \
1299 -c "client hello, adding session ticket extension" \
1300 -c "found session_ticket extension" \
1301 -c "parse new session ticket" \
1302 -c "a session has been resumed"
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001305 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001306 "( $O_CLI -sess_out $SESSION; \
1307 $O_CLI -sess_in $SESSION; \
1308 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001309 0 \
1310 -s "found session ticket extension" \
1311 -s "server hello, adding session ticket extension" \
1312 -S "session successfully restored from cache" \
1313 -s "session successfully restored from ticket" \
1314 -s "a session has been resumed"
1315
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001316# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001318run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001319 "$P_SRV debug_level=3 tickets=0" \
1320 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001321 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001322 -c "client hello, adding session ticket extension" \
1323 -s "found session ticket extension" \
1324 -S "server hello, adding session ticket extension" \
1325 -C "found session_ticket extension" \
1326 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001327 -s "session successfully restored from cache" \
1328 -S "session successfully restored from ticket" \
1329 -s "a session has been resumed" \
1330 -c "a session has been resumed"
1331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001332run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_SRV debug_level=3 tickets=1" \
1334 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001335 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001336 -C "client hello, adding session ticket extension" \
1337 -S "found session ticket extension" \
1338 -S "server hello, adding session ticket extension" \
1339 -C "found session_ticket extension" \
1340 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001341 -s "session successfully restored from cache" \
1342 -S "session successfully restored from ticket" \
1343 -s "a session has been resumed" \
1344 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1348 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001349 0 \
1350 -S "session successfully restored from cache" \
1351 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001352 -S "a session has been resumed" \
1353 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001355run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001356 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1357 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001358 0 \
1359 -s "session successfully restored from cache" \
1360 -S "session successfully restored from ticket" \
1361 -s "a session has been resumed" \
1362 -c "a session has been resumed"
1363
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001364run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001365 "$P_SRV debug_level=3 tickets=0" \
1366 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001367 0 \
1368 -s "session successfully restored from cache" \
1369 -S "session successfully restored from ticket" \
1370 -s "a session has been resumed" \
1371 -c "a session has been resumed"
1372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001373run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001374 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1375 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001376 0 \
1377 -S "session successfully restored from cache" \
1378 -S "session successfully restored from ticket" \
1379 -S "a session has been resumed" \
1380 -C "a session has been resumed"
1381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001382run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001383 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1384 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001385 0 \
1386 -s "session successfully restored from cache" \
1387 -S "session successfully restored from ticket" \
1388 -s "a session has been resumed" \
1389 -c "a session has been resumed"
1390
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001391run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001392 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001393 "( $O_CLI -sess_out $SESSION; \
1394 $O_CLI -sess_in $SESSION; \
1395 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001396 0 \
1397 -s "found session ticket extension" \
1398 -S "server hello, adding session ticket extension" \
1399 -s "session successfully restored from cache" \
1400 -S "session successfully restored from ticket" \
1401 -s "a session has been resumed"
1402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001403run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001404 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001405 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001406 0 \
1407 -C "found session_ticket extension" \
1408 -C "parse new session ticket" \
1409 -c "a session has been resumed"
1410
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001411# Tests for Max Fragment Length extension
1412
Hanno Becker6428f8d2017-09-22 16:58:50 +01001413MAX_CONTENT_LEN_EXPECT='16384'
1414MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1415
1416if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1417 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1418 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1419 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1420 printf "\n"
1421 printf "The tests assume this value and if it changes, the tests in this\n"
1422 printf "script should also be adjusted.\n"
1423 printf "\n"
1424
1425 exit 1
1426fi
1427
Hanno Becker4aed27e2017-09-18 15:00:34 +01001428requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001429run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001430 "$P_SRV debug_level=3" \
1431 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001432 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001433 -c "Maximum fragment length is 16384" \
1434 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001435 -C "client hello, adding max_fragment_length extension" \
1436 -S "found max fragment length extension" \
1437 -S "server hello, max_fragment_length extension" \
1438 -C "found max_fragment_length extension"
1439
Hanno Becker4aed27e2017-09-18 15:00:34 +01001440requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001441run_test "Max fragment length: enabled, default, larger message" \
1442 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001443 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001444 0 \
1445 -c "Maximum fragment length is 16384" \
1446 -s "Maximum fragment length is 16384" \
1447 -C "client hello, adding max_fragment_length extension" \
1448 -S "found max fragment length extension" \
1449 -S "server hello, max_fragment_length extension" \
1450 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001451 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001452 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001453 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001454
1455requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1456run_test "Max fragment length, DTLS: enabled, default, larger message" \
1457 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001458 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001459 1 \
1460 -c "Maximum fragment length is 16384" \
1461 -s "Maximum fragment length is 16384" \
1462 -C "client hello, adding max_fragment_length extension" \
1463 -S "found max fragment length extension" \
1464 -S "server hello, max_fragment_length extension" \
1465 -C "found max_fragment_length extension" \
1466 -c "fragment larger than.*maximum "
1467
1468requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1469run_test "Max fragment length: disabled, larger message" \
1470 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001471 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001472 0 \
1473 -C "Maximum fragment length is 16384" \
1474 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001475 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001476 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001477 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001478
1479requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1480run_test "Max fragment length DTLS: disabled, larger message" \
1481 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001482 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001483 1 \
1484 -C "Maximum fragment length is 16384" \
1485 -S "Maximum fragment length is 16384" \
1486 -c "fragment larger than.*maximum "
1487
1488requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001489run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001490 "$P_SRV debug_level=3" \
1491 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001492 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001493 -c "Maximum fragment length is 4096" \
1494 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001495 -c "client hello, adding max_fragment_length extension" \
1496 -s "found max fragment length extension" \
1497 -s "server hello, max_fragment_length extension" \
1498 -c "found max_fragment_length extension"
1499
Hanno Becker4aed27e2017-09-18 15:00:34 +01001500requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001501run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001502 "$P_SRV debug_level=3 max_frag_len=4096" \
1503 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001504 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001505 -c "Maximum fragment length is 16384" \
1506 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001507 -C "client hello, adding max_fragment_length extension" \
1508 -S "found max fragment length extension" \
1509 -S "server hello, max_fragment_length extension" \
1510 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001511
Hanno Becker4aed27e2017-09-18 15:00:34 +01001512requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001513requires_gnutls
1514run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001515 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001516 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001517 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001518 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001519 -c "client hello, adding max_fragment_length extension" \
1520 -c "found max_fragment_length extension"
1521
Hanno Becker4aed27e2017-09-18 15:00:34 +01001522requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001523run_test "Max fragment length: client, message just fits" \
1524 "$P_SRV debug_level=3" \
1525 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1526 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001527 -c "Maximum fragment length is 2048" \
1528 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001529 -c "client hello, adding max_fragment_length extension" \
1530 -s "found max fragment length extension" \
1531 -s "server hello, max_fragment_length extension" \
1532 -c "found max_fragment_length extension" \
1533 -c "2048 bytes written in 1 fragments" \
1534 -s "2048 bytes read"
1535
Hanno Becker4aed27e2017-09-18 15:00:34 +01001536requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001537run_test "Max fragment length: client, larger message" \
1538 "$P_SRV debug_level=3" \
1539 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1540 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001541 -c "Maximum fragment length is 2048" \
1542 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001543 -c "client hello, adding max_fragment_length extension" \
1544 -s "found max fragment length extension" \
1545 -s "server hello, max_fragment_length extension" \
1546 -c "found max_fragment_length extension" \
1547 -c "2345 bytes written in 2 fragments" \
1548 -s "2048 bytes read" \
1549 -s "297 bytes read"
1550
Hanno Becker4aed27e2017-09-18 15:00:34 +01001551requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001552run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001553 "$P_SRV debug_level=3 dtls=1" \
1554 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1555 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001556 -c "Maximum fragment length is 2048" \
1557 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001558 -c "client hello, adding max_fragment_length extension" \
1559 -s "found max fragment length extension" \
1560 -s "server hello, max_fragment_length extension" \
1561 -c "found max_fragment_length extension" \
1562 -c "fragment larger than.*maximum"
1563
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001564# Tests for renegotiation
1565
Hanno Becker6a243642017-10-12 15:18:45 +01001566# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001567run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001568 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001569 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001570 0 \
1571 -C "client hello, adding renegotiation extension" \
1572 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1573 -S "found renegotiation extension" \
1574 -s "server hello, secure renegotiation extension" \
1575 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001576 -C "=> renegotiate" \
1577 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001578 -S "write hello request"
1579
Hanno Becker6a243642017-10-12 15:18:45 +01001580requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001581run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001582 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001583 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001584 0 \
1585 -c "client hello, adding renegotiation extension" \
1586 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1587 -s "found renegotiation extension" \
1588 -s "server hello, secure renegotiation extension" \
1589 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001590 -c "=> renegotiate" \
1591 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001592 -S "write hello request"
1593
Hanno Becker6a243642017-10-12 15:18:45 +01001594requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001595run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001596 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001597 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001598 0 \
1599 -c "client hello, adding renegotiation extension" \
1600 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1601 -s "found renegotiation extension" \
1602 -s "server hello, secure renegotiation extension" \
1603 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001604 -c "=> renegotiate" \
1605 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001606 -s "write hello request"
1607
Janos Follathb0f148c2017-10-05 12:29:42 +01001608# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1609# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1610# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001611requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001612run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1613 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1614 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1615 0 \
1616 -c "client hello, adding renegotiation extension" \
1617 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1618 -s "found renegotiation extension" \
1619 -s "server hello, secure renegotiation extension" \
1620 -c "found renegotiation extension" \
1621 -c "=> renegotiate" \
1622 -s "=> renegotiate" \
1623 -S "write hello request" \
1624 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1625
1626# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1627# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1628# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001629requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001630run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1631 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1632 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1633 0 \
1634 -c "client hello, adding renegotiation extension" \
1635 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1636 -s "found renegotiation extension" \
1637 -s "server hello, secure renegotiation extension" \
1638 -c "found renegotiation extension" \
1639 -c "=> renegotiate" \
1640 -s "=> renegotiate" \
1641 -s "write hello request" \
1642 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1643
Hanno Becker6a243642017-10-12 15:18:45 +01001644requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001645run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001646 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001647 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001648 0 \
1649 -c "client hello, adding renegotiation extension" \
1650 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1651 -s "found renegotiation extension" \
1652 -s "server hello, secure renegotiation extension" \
1653 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001654 -c "=> renegotiate" \
1655 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001656 -s "write hello request"
1657
Hanno Becker6a243642017-10-12 15:18:45 +01001658requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001659run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001660 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001661 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001662 1 \
1663 -c "client hello, adding renegotiation extension" \
1664 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1665 -S "found renegotiation extension" \
1666 -s "server hello, secure renegotiation extension" \
1667 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001668 -c "=> renegotiate" \
1669 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001670 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001671 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001672 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001673
Hanno Becker6a243642017-10-12 15:18:45 +01001674requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001675run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001676 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001677 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001678 0 \
1679 -C "client hello, adding renegotiation extension" \
1680 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1681 -S "found renegotiation extension" \
1682 -s "server hello, secure renegotiation extension" \
1683 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001684 -C "=> renegotiate" \
1685 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001686 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001687 -S "SSL - An unexpected message was received from our peer" \
1688 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001689
Hanno Becker6a243642017-10-12 15:18:45 +01001690requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001691run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001692 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001693 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001694 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001695 0 \
1696 -C "client hello, adding renegotiation extension" \
1697 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1698 -S "found renegotiation extension" \
1699 -s "server hello, secure renegotiation extension" \
1700 -c "found renegotiation extension" \
1701 -C "=> renegotiate" \
1702 -S "=> renegotiate" \
1703 -s "write hello request" \
1704 -S "SSL - An unexpected message was received from our peer" \
1705 -S "failed"
1706
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001707# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001708requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001709run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001710 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001711 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001712 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001713 0 \
1714 -C "client hello, adding renegotiation extension" \
1715 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1716 -S "found renegotiation extension" \
1717 -s "server hello, secure renegotiation extension" \
1718 -c "found renegotiation extension" \
1719 -C "=> renegotiate" \
1720 -S "=> renegotiate" \
1721 -s "write hello request" \
1722 -S "SSL - An unexpected message was received from our peer" \
1723 -S "failed"
1724
Hanno Becker6a243642017-10-12 15:18:45 +01001725requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001727 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001728 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001729 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001730 0 \
1731 -C "client hello, adding renegotiation extension" \
1732 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1733 -S "found renegotiation extension" \
1734 -s "server hello, secure renegotiation extension" \
1735 -c "found renegotiation extension" \
1736 -C "=> renegotiate" \
1737 -S "=> renegotiate" \
1738 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001739 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001740
Hanno Becker6a243642017-10-12 15:18:45 +01001741requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001742run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001743 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001744 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001745 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001746 0 \
1747 -c "client hello, adding renegotiation extension" \
1748 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1749 -s "found renegotiation extension" \
1750 -s "server hello, secure renegotiation extension" \
1751 -c "found renegotiation extension" \
1752 -c "=> renegotiate" \
1753 -s "=> renegotiate" \
1754 -s "write hello request" \
1755 -S "SSL - An unexpected message was received from our peer" \
1756 -S "failed"
1757
Hanno Becker6a243642017-10-12 15:18:45 +01001758requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001759run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001760 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001761 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1762 0 \
1763 -C "client hello, adding renegotiation extension" \
1764 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1765 -S "found renegotiation extension" \
1766 -s "server hello, secure renegotiation extension" \
1767 -c "found renegotiation extension" \
1768 -S "record counter limit reached: renegotiate" \
1769 -C "=> renegotiate" \
1770 -S "=> renegotiate" \
1771 -S "write hello request" \
1772 -S "SSL - An unexpected message was received from our peer" \
1773 -S "failed"
1774
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001775# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001776requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001777run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001778 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001779 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001780 0 \
1781 -c "client hello, adding renegotiation extension" \
1782 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1783 -s "found renegotiation extension" \
1784 -s "server hello, secure renegotiation extension" \
1785 -c "found renegotiation extension" \
1786 -s "record counter limit reached: renegotiate" \
1787 -c "=> renegotiate" \
1788 -s "=> renegotiate" \
1789 -s "write hello request" \
1790 -S "SSL - An unexpected message was received from our peer" \
1791 -S "failed"
1792
Hanno Becker6a243642017-10-12 15:18:45 +01001793requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001794run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001795 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001796 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001797 0 \
1798 -c "client hello, adding renegotiation extension" \
1799 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1800 -s "found renegotiation extension" \
1801 -s "server hello, secure renegotiation extension" \
1802 -c "found renegotiation extension" \
1803 -s "record counter limit reached: renegotiate" \
1804 -c "=> renegotiate" \
1805 -s "=> renegotiate" \
1806 -s "write hello request" \
1807 -S "SSL - An unexpected message was received from our peer" \
1808 -S "failed"
1809
Hanno Becker6a243642017-10-12 15:18:45 +01001810requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001811run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001812 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001813 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1814 0 \
1815 -C "client hello, adding renegotiation extension" \
1816 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1817 -S "found renegotiation extension" \
1818 -s "server hello, secure renegotiation extension" \
1819 -c "found renegotiation extension" \
1820 -S "record counter limit reached: renegotiate" \
1821 -C "=> renegotiate" \
1822 -S "=> renegotiate" \
1823 -S "write hello request" \
1824 -S "SSL - An unexpected message was received from our peer" \
1825 -S "failed"
1826
Hanno Becker6a243642017-10-12 15:18:45 +01001827requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001828run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001829 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001830 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001831 0 \
1832 -c "client hello, adding renegotiation extension" \
1833 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1834 -s "found renegotiation extension" \
1835 -s "server hello, secure renegotiation extension" \
1836 -c "found renegotiation extension" \
1837 -c "=> renegotiate" \
1838 -s "=> renegotiate" \
1839 -S "write hello request"
1840
Hanno Becker6a243642017-10-12 15:18:45 +01001841requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001842run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001843 "$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 +02001844 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001845 0 \
1846 -c "client hello, adding renegotiation extension" \
1847 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1848 -s "found renegotiation extension" \
1849 -s "server hello, secure renegotiation extension" \
1850 -c "found renegotiation extension" \
1851 -c "=> renegotiate" \
1852 -s "=> renegotiate" \
1853 -s "write hello request"
1854
Hanno Becker6a243642017-10-12 15:18:45 +01001855requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001856run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001857 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001859 0 \
1860 -c "client hello, adding renegotiation extension" \
1861 -c "found renegotiation extension" \
1862 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001863 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001864 -C "error" \
1865 -c "HTTP/1.0 200 [Oo][Kk]"
1866
Paul Bakker539d9722015-02-08 16:18:35 +01001867requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001868requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001869run_test "Renegotiation: gnutls server strict, client-initiated" \
1870 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001871 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001872 0 \
1873 -c "client hello, adding renegotiation extension" \
1874 -c "found renegotiation extension" \
1875 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001876 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001877 -C "error" \
1878 -c "HTTP/1.0 200 [Oo][Kk]"
1879
Paul Bakker539d9722015-02-08 16:18:35 +01001880requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001881requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001882run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1883 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1884 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1885 1 \
1886 -c "client hello, adding renegotiation extension" \
1887 -C "found renegotiation extension" \
1888 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001889 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001890 -c "error" \
1891 -C "HTTP/1.0 200 [Oo][Kk]"
1892
Paul Bakker539d9722015-02-08 16:18:35 +01001893requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001894requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001895run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1896 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1897 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1898 allow_legacy=0" \
1899 1 \
1900 -c "client hello, adding renegotiation extension" \
1901 -C "found renegotiation extension" \
1902 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001903 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001904 -c "error" \
1905 -C "HTTP/1.0 200 [Oo][Kk]"
1906
Paul Bakker539d9722015-02-08 16:18:35 +01001907requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001908requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001909run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1910 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1911 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1912 allow_legacy=1" \
1913 0 \
1914 -c "client hello, adding renegotiation extension" \
1915 -C "found renegotiation extension" \
1916 -c "=> renegotiate" \
1917 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001918 -C "error" \
1919 -c "HTTP/1.0 200 [Oo][Kk]"
1920
Hanno Becker6a243642017-10-12 15:18:45 +01001921requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001922run_test "Renegotiation: DTLS, client-initiated" \
1923 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1924 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1925 0 \
1926 -c "client hello, adding renegotiation extension" \
1927 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1928 -s "found renegotiation extension" \
1929 -s "server hello, secure renegotiation extension" \
1930 -c "found renegotiation extension" \
1931 -c "=> renegotiate" \
1932 -s "=> renegotiate" \
1933 -S "write hello request"
1934
Hanno Becker6a243642017-10-12 15:18:45 +01001935requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001936run_test "Renegotiation: DTLS, server-initiated" \
1937 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001938 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1939 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001940 0 \
1941 -c "client hello, adding renegotiation extension" \
1942 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1943 -s "found renegotiation extension" \
1944 -s "server hello, secure renegotiation extension" \
1945 -c "found renegotiation extension" \
1946 -c "=> renegotiate" \
1947 -s "=> renegotiate" \
1948 -s "write hello request"
1949
Hanno Becker6a243642017-10-12 15:18:45 +01001950requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00001951run_test "Renegotiation: DTLS, renego_period overflow" \
1952 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1953 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1954 0 \
1955 -c "client hello, adding renegotiation extension" \
1956 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1957 -s "found renegotiation extension" \
1958 -s "server hello, secure renegotiation extension" \
1959 -s "record counter limit reached: renegotiate" \
1960 -c "=> renegotiate" \
1961 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01001962 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00001963
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001964requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001965requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001966run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1967 "$G_SRV -u --mtu 4096" \
1968 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1969 0 \
1970 -c "client hello, adding renegotiation extension" \
1971 -c "found renegotiation extension" \
1972 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001973 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001974 -C "error" \
1975 -s "Extra-header:"
1976
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001977# Test for the "secure renegotation" extension only (no actual renegotiation)
1978
Paul Bakker539d9722015-02-08 16:18:35 +01001979requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001980run_test "Renego ext: gnutls server strict, client default" \
1981 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1982 "$P_CLI debug_level=3" \
1983 0 \
1984 -c "found renegotiation extension" \
1985 -C "error" \
1986 -c "HTTP/1.0 200 [Oo][Kk]"
1987
Paul Bakker539d9722015-02-08 16:18:35 +01001988requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001989run_test "Renego ext: gnutls server unsafe, client default" \
1990 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1991 "$P_CLI debug_level=3" \
1992 0 \
1993 -C "found renegotiation extension" \
1994 -C "error" \
1995 -c "HTTP/1.0 200 [Oo][Kk]"
1996
Paul Bakker539d9722015-02-08 16:18:35 +01001997requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001998run_test "Renego ext: gnutls server unsafe, client break legacy" \
1999 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2000 "$P_CLI debug_level=3 allow_legacy=-1" \
2001 1 \
2002 -C "found renegotiation extension" \
2003 -c "error" \
2004 -C "HTTP/1.0 200 [Oo][Kk]"
2005
Paul Bakker539d9722015-02-08 16:18:35 +01002006requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002007run_test "Renego ext: gnutls client strict, server default" \
2008 "$P_SRV debug_level=3" \
2009 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2010 0 \
2011 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2012 -s "server hello, secure renegotiation extension"
2013
Paul Bakker539d9722015-02-08 16:18:35 +01002014requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002015run_test "Renego ext: gnutls client unsafe, server default" \
2016 "$P_SRV debug_level=3" \
2017 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2018 0 \
2019 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2020 -S "server hello, secure renegotiation extension"
2021
Paul Bakker539d9722015-02-08 16:18:35 +01002022requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002023run_test "Renego ext: gnutls client unsafe, server break legacy" \
2024 "$P_SRV debug_level=3 allow_legacy=-1" \
2025 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2026 1 \
2027 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2028 -S "server hello, secure renegotiation extension"
2029
Janos Follath0b242342016-02-17 10:11:21 +00002030# Tests for silently dropping trailing extra bytes in .der certificates
2031
2032requires_gnutls
2033run_test "DER format: no trailing bytes" \
2034 "$P_SRV crt_file=data_files/server5-der0.crt \
2035 key_file=data_files/server5.key" \
2036 "$G_CLI " \
2037 0 \
2038 -c "Handshake was completed" \
2039
2040requires_gnutls
2041run_test "DER format: with a trailing zero byte" \
2042 "$P_SRV crt_file=data_files/server5-der1a.crt \
2043 key_file=data_files/server5.key" \
2044 "$G_CLI " \
2045 0 \
2046 -c "Handshake was completed" \
2047
2048requires_gnutls
2049run_test "DER format: with a trailing random byte" \
2050 "$P_SRV crt_file=data_files/server5-der1b.crt \
2051 key_file=data_files/server5.key" \
2052 "$G_CLI " \
2053 0 \
2054 -c "Handshake was completed" \
2055
2056requires_gnutls
2057run_test "DER format: with 2 trailing random bytes" \
2058 "$P_SRV crt_file=data_files/server5-der2.crt \
2059 key_file=data_files/server5.key" \
2060 "$G_CLI " \
2061 0 \
2062 -c "Handshake was completed" \
2063
2064requires_gnutls
2065run_test "DER format: with 4 trailing random bytes" \
2066 "$P_SRV crt_file=data_files/server5-der4.crt \
2067 key_file=data_files/server5.key" \
2068 "$G_CLI " \
2069 0 \
2070 -c "Handshake was completed" \
2071
2072requires_gnutls
2073run_test "DER format: with 8 trailing random bytes" \
2074 "$P_SRV crt_file=data_files/server5-der8.crt \
2075 key_file=data_files/server5.key" \
2076 "$G_CLI " \
2077 0 \
2078 -c "Handshake was completed" \
2079
2080requires_gnutls
2081run_test "DER format: with 9 trailing random bytes" \
2082 "$P_SRV crt_file=data_files/server5-der9.crt \
2083 key_file=data_files/server5.key" \
2084 "$G_CLI " \
2085 0 \
2086 -c "Handshake was completed" \
2087
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002088# Tests for auth_mode
2089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002090run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002091 "$P_SRV crt_file=data_files/server5-badsign.crt \
2092 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002093 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002094 1 \
2095 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002096 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002097 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002098 -c "X509 - Certificate verification failed"
2099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002100run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002101 "$P_SRV crt_file=data_files/server5-badsign.crt \
2102 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002103 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002104 0 \
2105 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002106 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002107 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002108 -C "X509 - Certificate verification failed"
2109
Hanno Beckere6706e62017-05-15 16:05:15 +01002110run_test "Authentication: server goodcert, client optional, no trusted CA" \
2111 "$P_SRV" \
2112 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2113 0 \
2114 -c "x509_verify_cert() returned" \
2115 -c "! The certificate is not correctly signed by the trusted CA" \
2116 -c "! Certificate verification flags"\
2117 -C "! mbedtls_ssl_handshake returned" \
2118 -C "X509 - Certificate verification failed" \
2119 -C "SSL - No CA Chain is set, but required to operate"
2120
2121run_test "Authentication: server goodcert, client required, no trusted CA" \
2122 "$P_SRV" \
2123 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2124 1 \
2125 -c "x509_verify_cert() returned" \
2126 -c "! The certificate is not correctly signed by the trusted CA" \
2127 -c "! Certificate verification flags"\
2128 -c "! mbedtls_ssl_handshake returned" \
2129 -c "SSL - No CA Chain is set, but required to operate"
2130
2131# The purpose of the next two tests is to test the client's behaviour when receiving a server
2132# certificate with an unsupported elliptic curve. This should usually not happen because
2133# the client informs the server about the supported curves - it does, though, in the
2134# corner case of a static ECDH suite, because the server doesn't check the curve on that
2135# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2136# different means to have the server ignoring the client's supported curve list.
2137
2138requires_config_enabled MBEDTLS_ECP_C
2139run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2140 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2141 crt_file=data_files/server5.ku-ka.crt" \
2142 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2143 1 \
2144 -c "bad certificate (EC key curve)"\
2145 -c "! Certificate verification flags"\
2146 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2147
2148requires_config_enabled MBEDTLS_ECP_C
2149run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2150 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2151 crt_file=data_files/server5.ku-ka.crt" \
2152 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2153 1 \
2154 -c "bad certificate (EC key curve)"\
2155 -c "! Certificate verification flags"\
2156 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002158run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002159 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002160 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002161 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002162 0 \
2163 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002164 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002165 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002166 -C "X509 - Certificate verification failed"
2167
Simon Butcher99000142016-10-13 17:21:01 +01002168run_test "Authentication: client SHA256, server required" \
2169 "$P_SRV auth_mode=required" \
2170 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2171 key_file=data_files/server6.key \
2172 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2173 0 \
2174 -c "Supported Signature Algorithm found: 4," \
2175 -c "Supported Signature Algorithm found: 5,"
2176
2177run_test "Authentication: client SHA384, server required" \
2178 "$P_SRV auth_mode=required" \
2179 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2180 key_file=data_files/server6.key \
2181 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2182 0 \
2183 -c "Supported Signature Algorithm found: 4," \
2184 -c "Supported Signature Algorithm found: 5,"
2185
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002186requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2187run_test "Authentication: client has no cert, server required (SSLv3)" \
2188 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2189 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2190 key_file=data_files/server5.key" \
2191 1 \
2192 -S "skip write certificate request" \
2193 -C "skip parse certificate request" \
2194 -c "got a certificate request" \
2195 -c "got no certificate to send" \
2196 -S "x509_verify_cert() returned" \
2197 -s "client has no certificate" \
2198 -s "! mbedtls_ssl_handshake returned" \
2199 -c "! mbedtls_ssl_handshake returned" \
2200 -s "No client certification received from the client, but required by the authentication mode"
2201
2202run_test "Authentication: client has no cert, server required (TLS)" \
2203 "$P_SRV debug_level=3 auth_mode=required" \
2204 "$P_CLI debug_level=3 crt_file=none \
2205 key_file=data_files/server5.key" \
2206 1 \
2207 -S "skip write certificate request" \
2208 -C "skip parse certificate request" \
2209 -c "got a certificate request" \
2210 -c "= write certificate$" \
2211 -C "skip write certificate$" \
2212 -S "x509_verify_cert() returned" \
2213 -s "client has no certificate" \
2214 -s "! mbedtls_ssl_handshake returned" \
2215 -c "! mbedtls_ssl_handshake returned" \
2216 -s "No client certification received from the client, but required by the authentication mode"
2217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002218run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002219 "$P_SRV debug_level=3 auth_mode=required" \
2220 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002221 key_file=data_files/server5.key" \
2222 1 \
2223 -S "skip write certificate request" \
2224 -C "skip parse certificate request" \
2225 -c "got a certificate request" \
2226 -C "skip write certificate" \
2227 -C "skip write certificate verify" \
2228 -S "skip parse certificate verify" \
2229 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002230 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002231 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002232 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002233 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002234 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002235# We don't check that the client receives the alert because it might
2236# detect that its write end of the connection is closed and abort
2237# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002238
Janos Follath89baba22017-04-10 14:34:35 +01002239run_test "Authentication: client cert not trusted, server required" \
2240 "$P_SRV debug_level=3 auth_mode=required" \
2241 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2242 key_file=data_files/server5.key" \
2243 1 \
2244 -S "skip write certificate request" \
2245 -C "skip parse certificate request" \
2246 -c "got a certificate request" \
2247 -C "skip write certificate" \
2248 -C "skip write certificate verify" \
2249 -S "skip parse certificate verify" \
2250 -s "x509_verify_cert() returned" \
2251 -s "! The certificate is not correctly signed by the trusted CA" \
2252 -s "! mbedtls_ssl_handshake returned" \
2253 -c "! mbedtls_ssl_handshake returned" \
2254 -s "X509 - Certificate verification failed"
2255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002256run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002257 "$P_SRV debug_level=3 auth_mode=optional" \
2258 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002259 key_file=data_files/server5.key" \
2260 0 \
2261 -S "skip write certificate request" \
2262 -C "skip parse certificate request" \
2263 -c "got a certificate request" \
2264 -C "skip write certificate" \
2265 -C "skip write certificate verify" \
2266 -S "skip parse certificate verify" \
2267 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002268 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002269 -S "! mbedtls_ssl_handshake returned" \
2270 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002271 -S "X509 - Certificate verification failed"
2272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002273run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002274 "$P_SRV debug_level=3 auth_mode=none" \
2275 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002276 key_file=data_files/server5.key" \
2277 0 \
2278 -s "skip write certificate request" \
2279 -C "skip parse certificate request" \
2280 -c "got no certificate request" \
2281 -c "skip write certificate" \
2282 -c "skip write certificate verify" \
2283 -s "skip parse certificate verify" \
2284 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002285 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002286 -S "! mbedtls_ssl_handshake returned" \
2287 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002288 -S "X509 - Certificate verification failed"
2289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002290run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002291 "$P_SRV debug_level=3 auth_mode=optional" \
2292 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002293 0 \
2294 -S "skip write certificate request" \
2295 -C "skip parse certificate request" \
2296 -c "got a certificate request" \
2297 -C "skip write certificate$" \
2298 -C "got no certificate to send" \
2299 -S "SSLv3 client has no certificate" \
2300 -c "skip write certificate verify" \
2301 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002302 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002303 -S "! mbedtls_ssl_handshake returned" \
2304 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002305 -S "X509 - Certificate verification failed"
2306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002307run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002308 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002309 "$O_CLI" \
2310 0 \
2311 -S "skip write certificate request" \
2312 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002313 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002314 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002315 -S "X509 - Certificate verification failed"
2316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002317run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002318 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002319 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002320 0 \
2321 -C "skip parse certificate request" \
2322 -c "got a certificate request" \
2323 -C "skip write certificate$" \
2324 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002325 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002326
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002327run_test "Authentication: client no cert, openssl server required" \
2328 "$O_SRV -Verify 10" \
2329 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2330 1 \
2331 -C "skip parse certificate request" \
2332 -c "got a certificate request" \
2333 -C "skip write certificate$" \
2334 -c "skip write certificate verify" \
2335 -c "! mbedtls_ssl_handshake returned"
2336
Janos Follathe2681a42016-03-07 15:57:05 +00002337requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002338run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002339 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002340 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002341 0 \
2342 -S "skip write certificate request" \
2343 -C "skip parse certificate request" \
2344 -c "got a certificate request" \
2345 -C "skip write certificate$" \
2346 -c "skip write certificate verify" \
2347 -c "got no certificate to send" \
2348 -s "SSLv3 client has no certificate" \
2349 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002350 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002351 -S "! mbedtls_ssl_handshake returned" \
2352 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002353 -S "X509 - Certificate verification failed"
2354
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002355# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2356# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002357
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002358MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002359MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002360
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002361if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002362 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002363 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002364 printf "test value of ${MAX_IM_CA}. \n"
2365 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002366 printf "The tests assume this value and if it changes, the tests in this\n"
2367 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002368 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002369
2370 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002371fi
2372
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002373run_test "Authentication: server max_int chain, client default" \
2374 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2375 key_file=data_files/dir-maxpath/09.key" \
2376 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2377 0 \
2378 -C "X509 - A fatal error occured"
2379
2380run_test "Authentication: server max_int+1 chain, client default" \
2381 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2382 key_file=data_files/dir-maxpath/10.key" \
2383 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2384 1 \
2385 -c "X509 - A fatal error occured"
2386
2387run_test "Authentication: server max_int+1 chain, client optional" \
2388 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2389 key_file=data_files/dir-maxpath/10.key" \
2390 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2391 auth_mode=optional" \
2392 1 \
2393 -c "X509 - A fatal error occured"
2394
2395run_test "Authentication: server max_int+1 chain, client none" \
2396 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2397 key_file=data_files/dir-maxpath/10.key" \
2398 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2399 auth_mode=none" \
2400 0 \
2401 -C "X509 - A fatal error occured"
2402
2403run_test "Authentication: client max_int+1 chain, server default" \
2404 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2405 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2406 key_file=data_files/dir-maxpath/10.key" \
2407 0 \
2408 -S "X509 - A fatal error occured"
2409
2410run_test "Authentication: client max_int+1 chain, server optional" \
2411 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2412 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2413 key_file=data_files/dir-maxpath/10.key" \
2414 1 \
2415 -s "X509 - A fatal error occured"
2416
2417run_test "Authentication: client max_int+1 chain, server required" \
2418 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2419 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2420 key_file=data_files/dir-maxpath/10.key" \
2421 1 \
2422 -s "X509 - A fatal error occured"
2423
2424run_test "Authentication: client max_int chain, server required" \
2425 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2426 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2427 key_file=data_files/dir-maxpath/09.key" \
2428 0 \
2429 -S "X509 - A fatal error occured"
2430
Janos Follath89baba22017-04-10 14:34:35 +01002431# Tests for CA list in CertificateRequest messages
2432
2433run_test "Authentication: send CA list in CertificateRequest (default)" \
2434 "$P_SRV debug_level=3 auth_mode=required" \
2435 "$P_CLI crt_file=data_files/server6.crt \
2436 key_file=data_files/server6.key" \
2437 0 \
2438 -s "requested DN"
2439
2440run_test "Authentication: do not send CA list in CertificateRequest" \
2441 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2442 "$P_CLI crt_file=data_files/server6.crt \
2443 key_file=data_files/server6.key" \
2444 0 \
2445 -S "requested DN"
2446
2447run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2448 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2449 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2450 key_file=data_files/server5.key" \
2451 1 \
2452 -S "requested DN" \
2453 -s "x509_verify_cert() returned" \
2454 -s "! The certificate is not correctly signed by the trusted CA" \
2455 -s "! mbedtls_ssl_handshake returned" \
2456 -c "! mbedtls_ssl_handshake returned" \
2457 -s "X509 - Certificate verification failed"
2458
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002459# Tests for certificate selection based on SHA verson
2460
2461run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2462 "$P_SRV crt_file=data_files/server5.crt \
2463 key_file=data_files/server5.key \
2464 crt_file2=data_files/server5-sha1.crt \
2465 key_file2=data_files/server5.key" \
2466 "$P_CLI force_version=tls1_2" \
2467 0 \
2468 -c "signed using.*ECDSA with SHA256" \
2469 -C "signed using.*ECDSA with SHA1"
2470
2471run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2472 "$P_SRV crt_file=data_files/server5.crt \
2473 key_file=data_files/server5.key \
2474 crt_file2=data_files/server5-sha1.crt \
2475 key_file2=data_files/server5.key" \
2476 "$P_CLI force_version=tls1_1" \
2477 0 \
2478 -C "signed using.*ECDSA with SHA256" \
2479 -c "signed using.*ECDSA with SHA1"
2480
2481run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2482 "$P_SRV crt_file=data_files/server5.crt \
2483 key_file=data_files/server5.key \
2484 crt_file2=data_files/server5-sha1.crt \
2485 key_file2=data_files/server5.key" \
2486 "$P_CLI force_version=tls1" \
2487 0 \
2488 -C "signed using.*ECDSA with SHA256" \
2489 -c "signed using.*ECDSA with SHA1"
2490
2491run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2492 "$P_SRV crt_file=data_files/server5.crt \
2493 key_file=data_files/server5.key \
2494 crt_file2=data_files/server6.crt \
2495 key_file2=data_files/server6.key" \
2496 "$P_CLI force_version=tls1_1" \
2497 0 \
2498 -c "serial number.*09" \
2499 -c "signed using.*ECDSA with SHA256" \
2500 -C "signed using.*ECDSA with SHA1"
2501
2502run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2503 "$P_SRV crt_file=data_files/server6.crt \
2504 key_file=data_files/server6.key \
2505 crt_file2=data_files/server5.crt \
2506 key_file2=data_files/server5.key" \
2507 "$P_CLI force_version=tls1_1" \
2508 0 \
2509 -c "serial number.*0A" \
2510 -c "signed using.*ECDSA with SHA256" \
2511 -C "signed using.*ECDSA with SHA1"
2512
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002513# tests for SNI
2514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002515run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002516 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002517 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002518 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002519 0 \
2520 -S "parse ServerName extension" \
2521 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2522 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002524run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002525 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002526 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002527 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 +02002528 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002529 0 \
2530 -s "parse ServerName extension" \
2531 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2532 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002534run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002535 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002536 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002537 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 +02002538 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002539 0 \
2540 -s "parse ServerName extension" \
2541 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2542 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002544run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002545 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002546 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002547 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 +02002548 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002549 1 \
2550 -s "parse ServerName extension" \
2551 -s "ssl_sni_wrapper() returned" \
2552 -s "mbedtls_ssl_handshake returned" \
2553 -c "mbedtls_ssl_handshake returned" \
2554 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002555
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002556run_test "SNI: client auth no override: optional" \
2557 "$P_SRV debug_level=3 auth_mode=optional \
2558 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2559 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2560 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002561 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002562 -S "skip write certificate request" \
2563 -C "skip parse certificate request" \
2564 -c "got a certificate request" \
2565 -C "skip write certificate" \
2566 -C "skip write certificate verify" \
2567 -S "skip parse certificate verify"
2568
2569run_test "SNI: client auth override: none -> optional" \
2570 "$P_SRV debug_level=3 auth_mode=none \
2571 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2572 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2573 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002574 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002575 -S "skip write certificate request" \
2576 -C "skip parse certificate request" \
2577 -c "got a certificate request" \
2578 -C "skip write certificate" \
2579 -C "skip write certificate verify" \
2580 -S "skip parse certificate verify"
2581
2582run_test "SNI: client auth override: optional -> none" \
2583 "$P_SRV debug_level=3 auth_mode=optional \
2584 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2585 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2586 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002587 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002588 -s "skip write certificate request" \
2589 -C "skip parse certificate request" \
2590 -c "got no certificate request" \
2591 -c "skip write certificate" \
2592 -c "skip write certificate verify" \
2593 -s "skip parse certificate verify"
2594
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002595run_test "SNI: CA no override" \
2596 "$P_SRV debug_level=3 auth_mode=optional \
2597 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2598 ca_file=data_files/test-ca.crt \
2599 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2600 "$P_CLI debug_level=3 server_name=localhost \
2601 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2602 1 \
2603 -S "skip write certificate request" \
2604 -C "skip parse certificate request" \
2605 -c "got a certificate request" \
2606 -C "skip write certificate" \
2607 -C "skip write certificate verify" \
2608 -S "skip parse certificate verify" \
2609 -s "x509_verify_cert() returned" \
2610 -s "! The certificate is not correctly signed by the trusted CA" \
2611 -S "The certificate has been revoked (is on a CRL)"
2612
2613run_test "SNI: CA override" \
2614 "$P_SRV debug_level=3 auth_mode=optional \
2615 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2616 ca_file=data_files/test-ca.crt \
2617 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2618 "$P_CLI debug_level=3 server_name=localhost \
2619 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2620 0 \
2621 -S "skip write certificate request" \
2622 -C "skip parse certificate request" \
2623 -c "got a certificate request" \
2624 -C "skip write certificate" \
2625 -C "skip write certificate verify" \
2626 -S "skip parse certificate verify" \
2627 -S "x509_verify_cert() returned" \
2628 -S "! The certificate is not correctly signed by the trusted CA" \
2629 -S "The certificate has been revoked (is on a CRL)"
2630
2631run_test "SNI: CA override with CRL" \
2632 "$P_SRV debug_level=3 auth_mode=optional \
2633 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2634 ca_file=data_files/test-ca.crt \
2635 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2636 "$P_CLI debug_level=3 server_name=localhost \
2637 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2638 1 \
2639 -S "skip write certificate request" \
2640 -C "skip parse certificate request" \
2641 -c "got a certificate request" \
2642 -C "skip write certificate" \
2643 -C "skip write certificate verify" \
2644 -S "skip parse certificate verify" \
2645 -s "x509_verify_cert() returned" \
2646 -S "! The certificate is not correctly signed by the trusted CA" \
2647 -s "The certificate has been revoked (is on a CRL)"
2648
Andres AG1a834452016-12-07 10:01:30 +00002649# Tests for SNI and DTLS
2650
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002651run_test "SNI: DTLS, no SNI callback" \
2652 "$P_SRV debug_level=3 dtls=1 \
2653 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2654 "$P_CLI server_name=localhost dtls=1" \
2655 0 \
2656 -S "parse ServerName extension" \
2657 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2658 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2659
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002660run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00002661 "$P_SRV debug_level=3 dtls=1 \
2662 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2663 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2664 "$P_CLI server_name=localhost dtls=1" \
2665 0 \
2666 -s "parse ServerName extension" \
2667 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2668 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2669
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002670run_test "SNI: DTLS, matching cert 2" \
2671 "$P_SRV debug_level=3 dtls=1 \
2672 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2673 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2674 "$P_CLI server_name=polarssl.example dtls=1" \
2675 0 \
2676 -s "parse ServerName extension" \
2677 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2678 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2679
2680run_test "SNI: DTLS, no matching cert" \
2681 "$P_SRV debug_level=3 dtls=1 \
2682 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2683 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2684 "$P_CLI server_name=nonesuch.example dtls=1" \
2685 1 \
2686 -s "parse ServerName extension" \
2687 -s "ssl_sni_wrapper() returned" \
2688 -s "mbedtls_ssl_handshake returned" \
2689 -c "mbedtls_ssl_handshake returned" \
2690 -c "SSL - A fatal alert message was received from our peer"
2691
2692run_test "SNI: DTLS, client auth no override: optional" \
2693 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2694 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2695 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2696 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2697 0 \
2698 -S "skip write certificate request" \
2699 -C "skip parse certificate request" \
2700 -c "got a certificate request" \
2701 -C "skip write certificate" \
2702 -C "skip write certificate verify" \
2703 -S "skip parse certificate verify"
2704
2705run_test "SNI: DTLS, client auth override: none -> optional" \
2706 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2707 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2708 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2709 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2710 0 \
2711 -S "skip write certificate request" \
2712 -C "skip parse certificate request" \
2713 -c "got a certificate request" \
2714 -C "skip write certificate" \
2715 -C "skip write certificate verify" \
2716 -S "skip parse certificate verify"
2717
2718run_test "SNI: DTLS, client auth override: optional -> none" \
2719 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2720 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2721 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2722 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2723 0 \
2724 -s "skip write certificate request" \
2725 -C "skip parse certificate request" \
2726 -c "got no certificate request" \
2727 -c "skip write certificate" \
2728 -c "skip write certificate verify" \
2729 -s "skip parse certificate verify"
2730
2731run_test "SNI: DTLS, CA no override" \
2732 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2733 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2734 ca_file=data_files/test-ca.crt \
2735 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2736 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2737 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2738 1 \
2739 -S "skip write certificate request" \
2740 -C "skip parse certificate request" \
2741 -c "got a certificate request" \
2742 -C "skip write certificate" \
2743 -C "skip write certificate verify" \
2744 -S "skip parse certificate verify" \
2745 -s "x509_verify_cert() returned" \
2746 -s "! The certificate is not correctly signed by the trusted CA" \
2747 -S "The certificate has been revoked (is on a CRL)"
2748
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002749run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00002750 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2751 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2752 ca_file=data_files/test-ca.crt \
2753 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2754 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2755 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2756 0 \
2757 -S "skip write certificate request" \
2758 -C "skip parse certificate request" \
2759 -c "got a certificate request" \
2760 -C "skip write certificate" \
2761 -C "skip write certificate verify" \
2762 -S "skip parse certificate verify" \
2763 -S "x509_verify_cert() returned" \
2764 -S "! The certificate is not correctly signed by the trusted CA" \
2765 -S "The certificate has been revoked (is on a CRL)"
2766
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002767run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00002768 "$P_SRV debug_level=3 auth_mode=optional \
2769 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2770 ca_file=data_files/test-ca.crt \
2771 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2772 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2773 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2774 1 \
2775 -S "skip write certificate request" \
2776 -C "skip parse certificate request" \
2777 -c "got a certificate request" \
2778 -C "skip write certificate" \
2779 -C "skip write certificate verify" \
2780 -S "skip parse certificate verify" \
2781 -s "x509_verify_cert() returned" \
2782 -S "! The certificate is not correctly signed by the trusted CA" \
2783 -s "The certificate has been revoked (is on a CRL)"
2784
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002785# Tests for non-blocking I/O: exercise a variety of handshake flows
2786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002787run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002788 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2789 "$P_CLI nbio=2 tickets=0" \
2790 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002791 -S "mbedtls_ssl_handshake returned" \
2792 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002793 -c "Read from server: .* bytes read"
2794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002795run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002796 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2797 "$P_CLI nbio=2 tickets=0" \
2798 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002799 -S "mbedtls_ssl_handshake returned" \
2800 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002801 -c "Read from server: .* bytes read"
2802
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002803run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002804 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2805 "$P_CLI nbio=2 tickets=1" \
2806 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002807 -S "mbedtls_ssl_handshake returned" \
2808 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002809 -c "Read from server: .* bytes read"
2810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002811run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002812 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2813 "$P_CLI nbio=2 tickets=1" \
2814 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002815 -S "mbedtls_ssl_handshake returned" \
2816 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002817 -c "Read from server: .* bytes read"
2818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002819run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002820 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2821 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2822 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002823 -S "mbedtls_ssl_handshake returned" \
2824 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002825 -c "Read from server: .* bytes read"
2826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002827run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002828 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2829 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2830 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002831 -S "mbedtls_ssl_handshake returned" \
2832 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002833 -c "Read from server: .* bytes read"
2834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002835run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002836 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2837 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2838 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002839 -S "mbedtls_ssl_handshake returned" \
2840 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002841 -c "Read from server: .* bytes read"
2842
Hanno Becker00076712017-11-15 16:39:08 +00002843# Tests for event-driven I/O: exercise a variety of handshake flows
2844
2845run_test "Event-driven I/O: basic handshake" \
2846 "$P_SRV event=1 tickets=0 auth_mode=none" \
2847 "$P_CLI event=1 tickets=0" \
2848 0 \
2849 -S "mbedtls_ssl_handshake returned" \
2850 -C "mbedtls_ssl_handshake returned" \
2851 -c "Read from server: .* bytes read"
2852
2853run_test "Event-driven I/O: client auth" \
2854 "$P_SRV event=1 tickets=0 auth_mode=required" \
2855 "$P_CLI event=1 tickets=0" \
2856 0 \
2857 -S "mbedtls_ssl_handshake returned" \
2858 -C "mbedtls_ssl_handshake returned" \
2859 -c "Read from server: .* bytes read"
2860
2861run_test "Event-driven I/O: ticket" \
2862 "$P_SRV event=1 tickets=1 auth_mode=none" \
2863 "$P_CLI event=1 tickets=1" \
2864 0 \
2865 -S "mbedtls_ssl_handshake returned" \
2866 -C "mbedtls_ssl_handshake returned" \
2867 -c "Read from server: .* bytes read"
2868
2869run_test "Event-driven I/O: ticket + client auth" \
2870 "$P_SRV event=1 tickets=1 auth_mode=required" \
2871 "$P_CLI event=1 tickets=1" \
2872 0 \
2873 -S "mbedtls_ssl_handshake returned" \
2874 -C "mbedtls_ssl_handshake returned" \
2875 -c "Read from server: .* bytes read"
2876
2877run_test "Event-driven I/O: ticket + client auth + resume" \
2878 "$P_SRV event=1 tickets=1 auth_mode=required" \
2879 "$P_CLI event=1 tickets=1 reconnect=1" \
2880 0 \
2881 -S "mbedtls_ssl_handshake returned" \
2882 -C "mbedtls_ssl_handshake returned" \
2883 -c "Read from server: .* bytes read"
2884
2885run_test "Event-driven I/O: ticket + resume" \
2886 "$P_SRV event=1 tickets=1 auth_mode=none" \
2887 "$P_CLI event=1 tickets=1 reconnect=1" \
2888 0 \
2889 -S "mbedtls_ssl_handshake returned" \
2890 -C "mbedtls_ssl_handshake returned" \
2891 -c "Read from server: .* bytes read"
2892
2893run_test "Event-driven I/O: session-id resume" \
2894 "$P_SRV event=1 tickets=0 auth_mode=none" \
2895 "$P_CLI event=1 tickets=0 reconnect=1" \
2896 0 \
2897 -S "mbedtls_ssl_handshake returned" \
2898 -C "mbedtls_ssl_handshake returned" \
2899 -c "Read from server: .* bytes read"
2900
Hanno Becker6a33f592018-03-13 11:38:46 +00002901run_test "Event-driven I/O, DTLS: basic handshake" \
2902 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2903 "$P_CLI dtls=1 event=1 tickets=0" \
2904 0 \
2905 -c "Read from server: .* bytes read"
2906
2907run_test "Event-driven I/O, DTLS: client auth" \
2908 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
2909 "$P_CLI dtls=1 event=1 tickets=0" \
2910 0 \
2911 -c "Read from server: .* bytes read"
2912
2913run_test "Event-driven I/O, DTLS: ticket" \
2914 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2915 "$P_CLI dtls=1 event=1 tickets=1" \
2916 0 \
2917 -c "Read from server: .* bytes read"
2918
2919run_test "Event-driven I/O, DTLS: ticket + client auth" \
2920 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2921 "$P_CLI dtls=1 event=1 tickets=1" \
2922 0 \
2923 -c "Read from server: .* bytes read"
2924
2925run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
2926 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2927 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2928 0 \
2929 -c "Read from server: .* bytes read"
2930
2931run_test "Event-driven I/O, DTLS: ticket + resume" \
2932 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2933 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2934 0 \
2935 -c "Read from server: .* bytes read"
2936
2937run_test "Event-driven I/O, DTLS: session-id resume" \
2938 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2939 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
2940 0 \
2941 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00002942
2943# This test demonstrates the need for the mbedtls_ssl_check_pending function.
2944# During session resumption, the client will send its ApplicationData record
2945# within the same datagram as the Finished messages. In this situation, the
2946# server MUST NOT idle on the underlying transport after handshake completion,
2947# because the ApplicationData request has already been queued internally.
2948run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00002949 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00002950 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
2951 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
2952 0 \
2953 -c "Read from server: .* bytes read"
2954
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002955# Tests for version negotiation
2956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002957run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002958 "$P_SRV" \
2959 "$P_CLI" \
2960 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002961 -S "mbedtls_ssl_handshake returned" \
2962 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002963 -s "Protocol is TLSv1.2" \
2964 -c "Protocol is TLSv1.2"
2965
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002966run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002967 "$P_SRV" \
2968 "$P_CLI max_version=tls1_1" \
2969 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002970 -S "mbedtls_ssl_handshake returned" \
2971 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002972 -s "Protocol is TLSv1.1" \
2973 -c "Protocol is TLSv1.1"
2974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002975run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002976 "$P_SRV max_version=tls1_1" \
2977 "$P_CLI" \
2978 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002979 -S "mbedtls_ssl_handshake returned" \
2980 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002981 -s "Protocol is TLSv1.1" \
2982 -c "Protocol is TLSv1.1"
2983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002984run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002985 "$P_SRV max_version=tls1_1" \
2986 "$P_CLI max_version=tls1_1" \
2987 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002988 -S "mbedtls_ssl_handshake returned" \
2989 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002990 -s "Protocol is TLSv1.1" \
2991 -c "Protocol is TLSv1.1"
2992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002993run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002994 "$P_SRV min_version=tls1_1" \
2995 "$P_CLI max_version=tls1_1" \
2996 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002997 -S "mbedtls_ssl_handshake returned" \
2998 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002999 -s "Protocol is TLSv1.1" \
3000 -c "Protocol is TLSv1.1"
3001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003002run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003003 "$P_SRV max_version=tls1_1" \
3004 "$P_CLI min_version=tls1_1" \
3005 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003006 -S "mbedtls_ssl_handshake returned" \
3007 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003008 -s "Protocol is TLSv1.1" \
3009 -c "Protocol is TLSv1.1"
3010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003011run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003012 "$P_SRV max_version=tls1_1" \
3013 "$P_CLI min_version=tls1_2" \
3014 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003015 -s "mbedtls_ssl_handshake returned" \
3016 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003017 -c "SSL - Handshake protocol not within min/max boundaries"
3018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003019run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003020 "$P_SRV min_version=tls1_2" \
3021 "$P_CLI max_version=tls1_1" \
3022 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003023 -s "mbedtls_ssl_handshake returned" \
3024 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003025 -s "SSL - Handshake protocol not within min/max boundaries"
3026
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003027# Tests for ALPN extension
3028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003029run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003030 "$P_SRV debug_level=3" \
3031 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003032 0 \
3033 -C "client hello, adding alpn extension" \
3034 -S "found alpn extension" \
3035 -C "got an alert message, type: \\[2:120]" \
3036 -S "server hello, adding alpn extension" \
3037 -C "found alpn extension " \
3038 -C "Application Layer Protocol is" \
3039 -S "Application Layer Protocol is"
3040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003041run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003042 "$P_SRV debug_level=3" \
3043 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003044 0 \
3045 -c "client hello, adding alpn extension" \
3046 -s "found alpn extension" \
3047 -C "got an alert message, type: \\[2:120]" \
3048 -S "server hello, adding alpn extension" \
3049 -C "found alpn extension " \
3050 -c "Application Layer Protocol is (none)" \
3051 -S "Application Layer Protocol is"
3052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003053run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003054 "$P_SRV debug_level=3 alpn=abc,1234" \
3055 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003056 0 \
3057 -C "client hello, adding alpn extension" \
3058 -S "found alpn extension" \
3059 -C "got an alert message, type: \\[2:120]" \
3060 -S "server hello, adding alpn extension" \
3061 -C "found alpn extension " \
3062 -C "Application Layer Protocol is" \
3063 -s "Application Layer Protocol is (none)"
3064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003065run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003066 "$P_SRV debug_level=3 alpn=abc,1234" \
3067 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003068 0 \
3069 -c "client hello, adding alpn extension" \
3070 -s "found alpn extension" \
3071 -C "got an alert message, type: \\[2:120]" \
3072 -s "server hello, adding alpn extension" \
3073 -c "found alpn extension" \
3074 -c "Application Layer Protocol is abc" \
3075 -s "Application Layer Protocol is abc"
3076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003077run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003078 "$P_SRV debug_level=3 alpn=abc,1234" \
3079 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003080 0 \
3081 -c "client hello, adding alpn extension" \
3082 -s "found alpn extension" \
3083 -C "got an alert message, type: \\[2:120]" \
3084 -s "server hello, adding alpn extension" \
3085 -c "found alpn extension" \
3086 -c "Application Layer Protocol is abc" \
3087 -s "Application Layer Protocol is abc"
3088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003089run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003090 "$P_SRV debug_level=3 alpn=abc,1234" \
3091 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003092 0 \
3093 -c "client hello, adding alpn extension" \
3094 -s "found alpn extension" \
3095 -C "got an alert message, type: \\[2:120]" \
3096 -s "server hello, adding alpn extension" \
3097 -c "found alpn extension" \
3098 -c "Application Layer Protocol is 1234" \
3099 -s "Application Layer Protocol is 1234"
3100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003101run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003102 "$P_SRV debug_level=3 alpn=abc,123" \
3103 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003104 1 \
3105 -c "client hello, adding alpn extension" \
3106 -s "found alpn extension" \
3107 -c "got an alert message, type: \\[2:120]" \
3108 -S "server hello, adding alpn extension" \
3109 -C "found alpn extension" \
3110 -C "Application Layer Protocol is 1234" \
3111 -S "Application Layer Protocol is 1234"
3112
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003113
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003114# Tests for keyUsage in leaf certificates, part 1:
3115# server-side certificate/suite selection
3116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003117run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003118 "$P_SRV key_file=data_files/server2.key \
3119 crt_file=data_files/server2.ku-ds.crt" \
3120 "$P_CLI" \
3121 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003122 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003123
3124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003125run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003126 "$P_SRV key_file=data_files/server2.key \
3127 crt_file=data_files/server2.ku-ke.crt" \
3128 "$P_CLI" \
3129 0 \
3130 -c "Ciphersuite is TLS-RSA-WITH-"
3131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003132run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003133 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003134 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003135 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003136 1 \
3137 -C "Ciphersuite is "
3138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003139run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003140 "$P_SRV key_file=data_files/server5.key \
3141 crt_file=data_files/server5.ku-ds.crt" \
3142 "$P_CLI" \
3143 0 \
3144 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3145
3146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003147run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003148 "$P_SRV key_file=data_files/server5.key \
3149 crt_file=data_files/server5.ku-ka.crt" \
3150 "$P_CLI" \
3151 0 \
3152 -c "Ciphersuite is TLS-ECDH-"
3153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003154run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003155 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003156 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003157 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003158 1 \
3159 -C "Ciphersuite is "
3160
3161# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003162# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003164run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003165 "$O_SRV -key data_files/server2.key \
3166 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003167 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003168 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3169 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003170 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003171 -C "Processing of the Certificate handshake message failed" \
3172 -c "Ciphersuite is TLS-"
3173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003174run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003175 "$O_SRV -key data_files/server2.key \
3176 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003177 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003178 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3179 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003180 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003181 -C "Processing of the Certificate handshake message failed" \
3182 -c "Ciphersuite is TLS-"
3183
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003184run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003185 "$O_SRV -key data_files/server2.key \
3186 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003187 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003188 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3189 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003190 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003191 -C "Processing of the Certificate handshake message failed" \
3192 -c "Ciphersuite is TLS-"
3193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003194run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003195 "$O_SRV -key data_files/server2.key \
3196 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003197 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003198 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3199 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003200 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003201 -c "Processing of the Certificate handshake message failed" \
3202 -C "Ciphersuite is TLS-"
3203
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003204run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3205 "$O_SRV -key data_files/server2.key \
3206 -cert data_files/server2.ku-ke.crt" \
3207 "$P_CLI debug_level=1 auth_mode=optional \
3208 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3209 0 \
3210 -c "bad certificate (usage extensions)" \
3211 -C "Processing of the Certificate handshake message failed" \
3212 -c "Ciphersuite is TLS-" \
3213 -c "! Usage does not match the keyUsage extension"
3214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003215run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003216 "$O_SRV -key data_files/server2.key \
3217 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003218 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003219 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3220 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003221 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003222 -C "Processing of the Certificate handshake message failed" \
3223 -c "Ciphersuite is TLS-"
3224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003225run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003226 "$O_SRV -key data_files/server2.key \
3227 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003228 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003229 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3230 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003231 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003232 -c "Processing of the Certificate handshake message failed" \
3233 -C "Ciphersuite is TLS-"
3234
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003235run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3236 "$O_SRV -key data_files/server2.key \
3237 -cert data_files/server2.ku-ds.crt" \
3238 "$P_CLI debug_level=1 auth_mode=optional \
3239 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3240 0 \
3241 -c "bad certificate (usage extensions)" \
3242 -C "Processing of the Certificate handshake message failed" \
3243 -c "Ciphersuite is TLS-" \
3244 -c "! Usage does not match the keyUsage extension"
3245
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003246# Tests for keyUsage in leaf certificates, part 3:
3247# server-side checking of client cert
3248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003249run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003250 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003251 "$O_CLI -key data_files/server2.key \
3252 -cert data_files/server2.ku-ds.crt" \
3253 0 \
3254 -S "bad certificate (usage extensions)" \
3255 -S "Processing of the Certificate handshake message failed"
3256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003257run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003258 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003259 "$O_CLI -key data_files/server2.key \
3260 -cert data_files/server2.ku-ke.crt" \
3261 0 \
3262 -s "bad certificate (usage extensions)" \
3263 -S "Processing of the Certificate handshake message failed"
3264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003265run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003266 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003267 "$O_CLI -key data_files/server2.key \
3268 -cert data_files/server2.ku-ke.crt" \
3269 1 \
3270 -s "bad certificate (usage extensions)" \
3271 -s "Processing of the Certificate handshake message failed"
3272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003273run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003274 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003275 "$O_CLI -key data_files/server5.key \
3276 -cert data_files/server5.ku-ds.crt" \
3277 0 \
3278 -S "bad certificate (usage extensions)" \
3279 -S "Processing of the Certificate handshake message failed"
3280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003281run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003282 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003283 "$O_CLI -key data_files/server5.key \
3284 -cert data_files/server5.ku-ka.crt" \
3285 0 \
3286 -s "bad certificate (usage extensions)" \
3287 -S "Processing of the Certificate handshake message failed"
3288
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003289# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003291run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003292 "$P_SRV key_file=data_files/server5.key \
3293 crt_file=data_files/server5.eku-srv.crt" \
3294 "$P_CLI" \
3295 0
3296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003297run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003298 "$P_SRV key_file=data_files/server5.key \
3299 crt_file=data_files/server5.eku-srv.crt" \
3300 "$P_CLI" \
3301 0
3302
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003303run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003304 "$P_SRV key_file=data_files/server5.key \
3305 crt_file=data_files/server5.eku-cs_any.crt" \
3306 "$P_CLI" \
3307 0
3308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003309run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003310 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003311 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003312 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003313 1
3314
3315# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003317run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003318 "$O_SRV -key data_files/server5.key \
3319 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003320 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003321 0 \
3322 -C "bad certificate (usage extensions)" \
3323 -C "Processing of the Certificate handshake message failed" \
3324 -c "Ciphersuite is TLS-"
3325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003326run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003327 "$O_SRV -key data_files/server5.key \
3328 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003329 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003330 0 \
3331 -C "bad certificate (usage extensions)" \
3332 -C "Processing of the Certificate handshake message failed" \
3333 -c "Ciphersuite is TLS-"
3334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003335run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003336 "$O_SRV -key data_files/server5.key \
3337 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003338 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003339 0 \
3340 -C "bad certificate (usage extensions)" \
3341 -C "Processing of the Certificate handshake message failed" \
3342 -c "Ciphersuite is TLS-"
3343
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003344run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003345 "$O_SRV -key data_files/server5.key \
3346 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003347 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003348 1 \
3349 -c "bad certificate (usage extensions)" \
3350 -c "Processing of the Certificate handshake message failed" \
3351 -C "Ciphersuite is TLS-"
3352
3353# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003355run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003356 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003357 "$O_CLI -key data_files/server5.key \
3358 -cert data_files/server5.eku-cli.crt" \
3359 0 \
3360 -S "bad certificate (usage extensions)" \
3361 -S "Processing of the Certificate handshake message failed"
3362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003363run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003364 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003365 "$O_CLI -key data_files/server5.key \
3366 -cert data_files/server5.eku-srv_cli.crt" \
3367 0 \
3368 -S "bad certificate (usage extensions)" \
3369 -S "Processing of the Certificate handshake message failed"
3370
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003371run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003372 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003373 "$O_CLI -key data_files/server5.key \
3374 -cert data_files/server5.eku-cs_any.crt" \
3375 0 \
3376 -S "bad certificate (usage extensions)" \
3377 -S "Processing of the Certificate handshake message failed"
3378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003379run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003380 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003381 "$O_CLI -key data_files/server5.key \
3382 -cert data_files/server5.eku-cs.crt" \
3383 0 \
3384 -s "bad certificate (usage extensions)" \
3385 -S "Processing of the Certificate handshake message failed"
3386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003387run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003388 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003389 "$O_CLI -key data_files/server5.key \
3390 -cert data_files/server5.eku-cs.crt" \
3391 1 \
3392 -s "bad certificate (usage extensions)" \
3393 -s "Processing of the Certificate handshake message failed"
3394
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003395# Tests for DHM parameters loading
3396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003397run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003398 "$P_SRV" \
3399 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3400 debug_level=3" \
3401 0 \
3402 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003403 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003405run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003406 "$P_SRV dhm_file=data_files/dhparams.pem" \
3407 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3408 debug_level=3" \
3409 0 \
3410 -c "value of 'DHM: P ' (1024 bits)" \
3411 -c "value of 'DHM: G ' (2 bits)"
3412
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003413# Tests for DHM client-side size checking
3414
3415run_test "DHM size: server default, client default, OK" \
3416 "$P_SRV" \
3417 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3418 debug_level=1" \
3419 0 \
3420 -C "DHM prime too short:"
3421
3422run_test "DHM size: server default, client 2048, OK" \
3423 "$P_SRV" \
3424 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3425 debug_level=1 dhmlen=2048" \
3426 0 \
3427 -C "DHM prime too short:"
3428
3429run_test "DHM size: server 1024, client default, OK" \
3430 "$P_SRV dhm_file=data_files/dhparams.pem" \
3431 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3432 debug_level=1" \
3433 0 \
3434 -C "DHM prime too short:"
3435
3436run_test "DHM size: server 1000, client default, rejected" \
3437 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3438 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3439 debug_level=1" \
3440 1 \
3441 -c "DHM prime too short:"
3442
3443run_test "DHM size: server default, client 2049, rejected" \
3444 "$P_SRV" \
3445 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3446 debug_level=1 dhmlen=2049" \
3447 1 \
3448 -c "DHM prime too short:"
3449
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003450# Tests for PSK callback
3451
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003452run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003453 "$P_SRV psk=abc123 psk_identity=foo" \
3454 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3455 psk_identity=foo psk=abc123" \
3456 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003457 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003458 -S "SSL - Unknown identity received" \
3459 -S "SSL - Verification of the message MAC failed"
3460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003461run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003462 "$P_SRV" \
3463 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3464 psk_identity=foo psk=abc123" \
3465 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003466 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003467 -S "SSL - Unknown identity received" \
3468 -S "SSL - Verification of the message MAC failed"
3469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003470run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003471 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3472 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3473 psk_identity=foo psk=abc123" \
3474 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003475 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003476 -s "SSL - Unknown identity received" \
3477 -S "SSL - Verification of the message MAC failed"
3478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003479run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003480 "$P_SRV psk_list=abc,dead,def,beef" \
3481 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3482 psk_identity=abc psk=dead" \
3483 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003484 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003485 -S "SSL - Unknown identity received" \
3486 -S "SSL - Verification of the message MAC failed"
3487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003488run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003489 "$P_SRV psk_list=abc,dead,def,beef" \
3490 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3491 psk_identity=def psk=beef" \
3492 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003493 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003494 -S "SSL - Unknown identity received" \
3495 -S "SSL - Verification of the message MAC failed"
3496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003497run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003498 "$P_SRV psk_list=abc,dead,def,beef" \
3499 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3500 psk_identity=ghi psk=beef" \
3501 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003502 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003503 -s "SSL - Unknown identity received" \
3504 -S "SSL - Verification of the message MAC failed"
3505
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003506run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003507 "$P_SRV psk_list=abc,dead,def,beef" \
3508 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3509 psk_identity=abc psk=beef" \
3510 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003511 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003512 -S "SSL - Unknown identity received" \
3513 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003514
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003515# Tests for EC J-PAKE
3516
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003517requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003518run_test "ECJPAKE: client not configured" \
3519 "$P_SRV debug_level=3" \
3520 "$P_CLI debug_level=3" \
3521 0 \
3522 -C "add ciphersuite: c0ff" \
3523 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003524 -S "found ecjpake kkpp extension" \
3525 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003526 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003527 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003528 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003529 -S "None of the common ciphersuites is usable"
3530
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003531requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003532run_test "ECJPAKE: server not configured" \
3533 "$P_SRV debug_level=3" \
3534 "$P_CLI debug_level=3 ecjpake_pw=bla \
3535 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3536 1 \
3537 -c "add ciphersuite: c0ff" \
3538 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003539 -s "found ecjpake kkpp extension" \
3540 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003541 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003542 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003543 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003544 -s "None of the common ciphersuites is usable"
3545
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003546requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003547run_test "ECJPAKE: working, TLS" \
3548 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3549 "$P_CLI debug_level=3 ecjpake_pw=bla \
3550 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003551 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003552 -c "add ciphersuite: c0ff" \
3553 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003554 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003555 -s "found ecjpake kkpp extension" \
3556 -S "skip ecjpake kkpp extension" \
3557 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003558 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003559 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003560 -S "None of the common ciphersuites is usable" \
3561 -S "SSL - Verification of the message MAC failed"
3562
Janos Follath74537a62016-09-02 13:45:28 +01003563server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003564requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003565run_test "ECJPAKE: password mismatch, TLS" \
3566 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3567 "$P_CLI debug_level=3 ecjpake_pw=bad \
3568 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3569 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003570 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003571 -s "SSL - Verification of the message MAC failed"
3572
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003573requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003574run_test "ECJPAKE: working, DTLS" \
3575 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3576 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3577 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3578 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003579 -c "re-using cached ecjpake parameters" \
3580 -S "SSL - Verification of the message MAC failed"
3581
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003582requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003583run_test "ECJPAKE: working, DTLS, no cookie" \
3584 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3585 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3586 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3587 0 \
3588 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003589 -S "SSL - Verification of the message MAC failed"
3590
Janos Follath74537a62016-09-02 13:45:28 +01003591server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003592requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003593run_test "ECJPAKE: password mismatch, DTLS" \
3594 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3595 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3596 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3597 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003598 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003599 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003600
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003601# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003602requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003603run_test "ECJPAKE: working, DTLS, nolog" \
3604 "$P_SRV dtls=1 ecjpake_pw=bla" \
3605 "$P_CLI dtls=1 ecjpake_pw=bla \
3606 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3607 0
3608
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003609# Tests for ciphersuites per version
3610
Janos Follathe2681a42016-03-07 15:57:05 +00003611requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003612run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003613 "$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 +02003614 "$P_CLI force_version=ssl3" \
3615 0 \
3616 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003618run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003619 "$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 +01003620 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003621 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003622 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003624run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003625 "$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 +02003626 "$P_CLI force_version=tls1_1" \
3627 0 \
3628 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3629
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003630run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003631 "$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 +02003632 "$P_CLI force_version=tls1_2" \
3633 0 \
3634 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3635
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003636# Test for ClientHello without extensions
3637
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003638requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003639run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003640 "$P_SRV debug_level=3" \
3641 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3642 0 \
3643 -s "dumping 'client hello extensions' (0 bytes)"
3644
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003645requires_gnutls
3646run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3647 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3648 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3649 0 \
3650 -s "dumping 'client hello extensions' (0 bytes)"
3651
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003652# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003653
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003654run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003655 "$P_SRV" \
3656 "$P_CLI request_size=100" \
3657 0 \
3658 -s "Read from client: 100 bytes read$"
3659
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003660run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003661 "$P_SRV" \
3662 "$P_CLI request_size=500" \
3663 0 \
3664 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003665
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003666# Tests for small packets
3667
Janos Follathe2681a42016-03-07 15:57:05 +00003668requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003669run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003670 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003671 "$P_CLI request_size=1 force_version=ssl3 \
3672 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3673 0 \
3674 -s "Read from client: 1 bytes read"
3675
Janos Follathe2681a42016-03-07 15:57:05 +00003676requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003677run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003678 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003679 "$P_CLI request_size=1 force_version=ssl3 \
3680 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3681 0 \
3682 -s "Read from client: 1 bytes read"
3683
3684run_test "Small packet TLS 1.0 BlockCipher" \
3685 "$P_SRV" \
3686 "$P_CLI request_size=1 force_version=tls1 \
3687 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3688 0 \
3689 -s "Read from client: 1 bytes read"
3690
Hanno Becker8501f982017-11-10 08:59:04 +00003691run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003692 "$P_SRV" \
3693 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3694 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3695 0 \
3696 -s "Read from client: 1 bytes read"
3697
Hanno Becker32c55012017-11-10 08:42:54 +00003698requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003699run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003700 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003701 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003702 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003703 0 \
3704 -s "Read from client: 1 bytes read"
3705
Hanno Becker32c55012017-11-10 08:42:54 +00003706requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003707run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003708 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003709 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003710 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003711 0 \
3712 -s "Read from client: 1 bytes read"
3713
3714run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003715 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003716 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003717 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3718 0 \
3719 -s "Read from client: 1 bytes read"
3720
3721run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3722 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3723 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003724 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003725 0 \
3726 -s "Read from client: 1 bytes read"
3727
3728requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3729run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003730 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003731 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003732 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003733 0 \
3734 -s "Read from client: 1 bytes read"
3735
Hanno Becker8501f982017-11-10 08:59:04 +00003736requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3737run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003738 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3739 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3740 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003741 0 \
3742 -s "Read from client: 1 bytes read"
3743
3744run_test "Small packet TLS 1.1 BlockCipher" \
3745 "$P_SRV" \
3746 "$P_CLI request_size=1 force_version=tls1_1 \
3747 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3748 0 \
3749 -s "Read from client: 1 bytes read"
3750
Hanno Becker8501f982017-11-10 08:59:04 +00003751run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003752 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003753 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003754 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003755 0 \
3756 -s "Read from client: 1 bytes read"
3757
3758requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3759run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003760 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003761 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003762 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003763 0 \
3764 -s "Read from client: 1 bytes read"
3765
3766requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3767run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003768 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003769 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003770 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003771 0 \
3772 -s "Read from client: 1 bytes read"
3773
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003774run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003775 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003776 "$P_CLI request_size=1 force_version=tls1_1 \
3777 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3778 0 \
3779 -s "Read from client: 1 bytes read"
3780
Hanno Becker8501f982017-11-10 08:59:04 +00003781run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3782 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003783 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003784 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003785 0 \
3786 -s "Read from client: 1 bytes read"
3787
Hanno Becker8501f982017-11-10 08:59:04 +00003788requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3789run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003790 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003791 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003792 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003793 0 \
3794 -s "Read from client: 1 bytes read"
3795
Hanno Becker32c55012017-11-10 08:42:54 +00003796requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003797run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003798 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003799 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003800 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003801 0 \
3802 -s "Read from client: 1 bytes read"
3803
3804run_test "Small packet TLS 1.2 BlockCipher" \
3805 "$P_SRV" \
3806 "$P_CLI request_size=1 force_version=tls1_2 \
3807 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3808 0 \
3809 -s "Read from client: 1 bytes read"
3810
Hanno Becker8501f982017-11-10 08:59:04 +00003811run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003812 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003813 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003814 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003815 0 \
3816 -s "Read from client: 1 bytes read"
3817
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003818run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3819 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003820 "$P_CLI request_size=1 force_version=tls1_2 \
3821 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003822 0 \
3823 -s "Read from client: 1 bytes read"
3824
Hanno Becker32c55012017-11-10 08:42:54 +00003825requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003826run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003827 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003828 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003829 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003830 0 \
3831 -s "Read from client: 1 bytes read"
3832
Hanno Becker8501f982017-11-10 08:59:04 +00003833requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3834run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003835 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003836 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003838 0 \
3839 -s "Read from client: 1 bytes read"
3840
3841run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003842 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003843 "$P_CLI request_size=1 force_version=tls1_2 \
3844 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3845 0 \
3846 -s "Read from client: 1 bytes read"
3847
Hanno Becker8501f982017-11-10 08:59:04 +00003848run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003849 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003850 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003851 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003852 0 \
3853 -s "Read from client: 1 bytes read"
3854
Hanno Becker32c55012017-11-10 08:42:54 +00003855requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003856run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003857 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003858 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003859 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003860 0 \
3861 -s "Read from client: 1 bytes read"
3862
Hanno Becker8501f982017-11-10 08:59:04 +00003863requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3864run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003865 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003866 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003867 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003868 0 \
3869 -s "Read from client: 1 bytes read"
3870
3871run_test "Small packet TLS 1.2 AEAD" \
3872 "$P_SRV" \
3873 "$P_CLI request_size=1 force_version=tls1_2 \
3874 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3875 0 \
3876 -s "Read from client: 1 bytes read"
3877
3878run_test "Small packet TLS 1.2 AEAD shorter tag" \
3879 "$P_SRV" \
3880 "$P_CLI request_size=1 force_version=tls1_2 \
3881 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3882 0 \
3883 -s "Read from client: 1 bytes read"
3884
Hanno Beckere2148042017-11-10 08:59:18 +00003885# Tests for small packets in DTLS
3886
3887requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3888run_test "Small packet DTLS 1.0" \
3889 "$P_SRV dtls=1 force_version=dtls1" \
3890 "$P_CLI dtls=1 request_size=1 \
3891 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3892 0 \
3893 -s "Read from client: 1 bytes read"
3894
3895requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3896run_test "Small packet DTLS 1.0, without EtM" \
3897 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3898 "$P_CLI dtls=1 request_size=1 \
3899 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3900 0 \
3901 -s "Read from client: 1 bytes read"
3902
3903requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3904requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3905run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003906 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3907 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003908 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3909 0 \
3910 -s "Read from client: 1 bytes read"
3911
3912requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3913requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3914run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003915 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003916 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003917 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003918 0 \
3919 -s "Read from client: 1 bytes read"
3920
3921requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3922run_test "Small packet DTLS 1.2" \
3923 "$P_SRV dtls=1 force_version=dtls1_2" \
3924 "$P_CLI dtls=1 request_size=1 \
3925 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3926 0 \
3927 -s "Read from client: 1 bytes read"
3928
3929requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3930run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003931 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003932 "$P_CLI dtls=1 request_size=1 \
3933 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3934 0 \
3935 -s "Read from client: 1 bytes read"
3936
3937requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3938requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3939run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003940 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003941 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003942 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003943 0 \
3944 -s "Read from client: 1 bytes read"
3945
3946requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3947requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3948run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003949 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003950 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003951 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003952 0 \
3953 -s "Read from client: 1 bytes read"
3954
Janos Follath00efff72016-05-06 13:48:23 +01003955# A test for extensions in SSLv3
3956
3957requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3958run_test "SSLv3 with extensions, server side" \
3959 "$P_SRV min_version=ssl3 debug_level=3" \
3960 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3961 0 \
3962 -S "dumping 'client hello extensions'" \
3963 -S "server hello, total extension length:"
3964
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003965# Test for large packets
3966
Janos Follathe2681a42016-03-07 15:57:05 +00003967requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003968run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003969 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003970 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003971 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3972 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003973 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003974 -s "Read from client: 16384 bytes read"
3975
Janos Follathe2681a42016-03-07 15:57:05 +00003976requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003977run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003978 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003979 "$P_CLI request_size=16384 force_version=ssl3 \
3980 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3981 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003982 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003983 -s "Read from client: 16384 bytes read"
3984
3985run_test "Large packet TLS 1.0 BlockCipher" \
3986 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003987 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003988 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3989 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003990 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003991 -s "Read from client: 16384 bytes read"
3992
Hanno Becker278fc7a2017-11-10 09:16:28 +00003993run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003994 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003995 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3996 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3997 0 \
3998 -s "Read from client: 16384 bytes read"
3999
Hanno Becker32c55012017-11-10 08:42:54 +00004000requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004001run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004002 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004003 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004004 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004005 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004006 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004007 -s "Read from client: 16384 bytes read"
4008
Hanno Becker32c55012017-11-10 08:42:54 +00004009requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004010run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004011 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004012 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004013 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004014 0 \
4015 -s "Read from client: 16384 bytes read"
4016
4017run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004018 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004019 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004020 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4021 0 \
4022 -s "Read from client: 16384 bytes read"
4023
4024run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
4025 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4026 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004027 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004028 0 \
4029 -s "Read from client: 16384 bytes read"
4030
4031requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4032run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004033 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004034 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004035 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004036 0 \
4037 -s "Read from client: 16384 bytes read"
4038
Hanno Becker278fc7a2017-11-10 09:16:28 +00004039requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4040run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004041 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004042 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004043 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004044 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004045 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004046 -s "Read from client: 16384 bytes read"
4047
4048run_test "Large packet TLS 1.1 BlockCipher" \
4049 "$P_SRV" \
4050 "$P_CLI request_size=16384 force_version=tls1_1 \
4051 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4052 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004053 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004054 -s "Read from client: 16384 bytes read"
4055
Hanno Becker278fc7a2017-11-10 09:16:28 +00004056run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
4057 "$P_SRV" \
4058 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4059 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004060 0 \
4061 -s "Read from client: 16384 bytes read"
4062
Hanno Becker32c55012017-11-10 08:42:54 +00004063requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004064run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004065 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004066 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004067 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004068 0 \
4069 -s "Read from client: 16384 bytes read"
4070
Hanno Becker32c55012017-11-10 08:42:54 +00004071requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004072run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004073 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004074 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004075 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004076 0 \
4077 -s "Read from client: 16384 bytes read"
4078
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004079run_test "Large packet TLS 1.1 StreamCipher" \
4080 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4081 "$P_CLI request_size=16384 force_version=tls1_1 \
4082 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4083 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004084 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004085 -s "Read from client: 16384 bytes read"
4086
Hanno Becker278fc7a2017-11-10 09:16:28 +00004087run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
4088 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004089 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004090 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004091 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004092 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004093 -s "Read from client: 16384 bytes read"
4094
Hanno Becker278fc7a2017-11-10 09:16:28 +00004095requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4096run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004097 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004098 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004099 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004100 0 \
4101 -s "Read from client: 16384 bytes read"
4102
Hanno Becker278fc7a2017-11-10 09:16:28 +00004103requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4104run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004105 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004106 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004107 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004108 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004109 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004110 -s "Read from client: 16384 bytes read"
4111
4112run_test "Large packet TLS 1.2 BlockCipher" \
4113 "$P_SRV" \
4114 "$P_CLI request_size=16384 force_version=tls1_2 \
4115 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4116 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004117 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004118 -s "Read from client: 16384 bytes read"
4119
Hanno Becker278fc7a2017-11-10 09:16:28 +00004120run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
4121 "$P_SRV" \
4122 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4123 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4124 0 \
4125 -s "Read from client: 16384 bytes read"
4126
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004127run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
4128 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004129 "$P_CLI request_size=16384 force_version=tls1_2 \
4130 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004131 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004132 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004133 -s "Read from client: 16384 bytes read"
4134
Hanno Becker32c55012017-11-10 08:42:54 +00004135requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004136run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004137 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004138 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004139 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004140 0 \
4141 -s "Read from client: 16384 bytes read"
4142
Hanno Becker278fc7a2017-11-10 09:16:28 +00004143requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4144run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004145 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004146 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004147 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004148 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004149 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004150 -s "Read from client: 16384 bytes read"
4151
4152run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004153 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004154 "$P_CLI request_size=16384 force_version=tls1_2 \
4155 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4156 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004157 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004158 -s "Read from client: 16384 bytes read"
4159
Hanno Becker278fc7a2017-11-10 09:16:28 +00004160run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004161 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004162 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004163 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4164 0 \
4165 -s "Read from client: 16384 bytes read"
4166
Hanno Becker32c55012017-11-10 08:42:54 +00004167requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004168run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004169 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004170 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004171 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004172 0 \
4173 -s "Read from client: 16384 bytes read"
4174
Hanno Becker278fc7a2017-11-10 09:16:28 +00004175requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4176run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004177 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004178 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004179 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004180 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004181 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004182 -s "Read from client: 16384 bytes read"
4183
4184run_test "Large packet TLS 1.2 AEAD" \
4185 "$P_SRV" \
4186 "$P_CLI request_size=16384 force_version=tls1_2 \
4187 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4188 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004189 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004190 -s "Read from client: 16384 bytes read"
4191
4192run_test "Large packet TLS 1.2 AEAD shorter tag" \
4193 "$P_SRV" \
4194 "$P_CLI request_size=16384 force_version=tls1_2 \
4195 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4196 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004197 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004198 -s "Read from client: 16384 bytes read"
4199
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004200# Tests of asynchronous private key support in SSL
4201
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004202requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004203run_test "SSL async private: sign, delay=0" \
4204 "$P_SRV \
4205 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004206 "$P_CLI" \
4207 0 \
4208 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004209 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004210
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004211requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004212run_test "SSL async private: sign, delay=1" \
4213 "$P_SRV \
4214 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004215 "$P_CLI" \
4216 0 \
4217 -s "Async sign callback: using key slot " \
4218 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004219 -s "Async resume (slot [0-9]): sign done, status=0"
4220
Gilles Peskine12d0cc12018-04-26 15:06:56 +02004221requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4222run_test "SSL async private: sign, delay=2" \
4223 "$P_SRV \
4224 async_operations=s async_private_delay1=2 async_private_delay2=2" \
4225 "$P_CLI" \
4226 0 \
4227 -s "Async sign callback: using key slot " \
4228 -U "Async sign callback: using key slot " \
4229 -s "Async resume (slot [0-9]): call 1 more times." \
4230 -s "Async resume (slot [0-9]): call 0 more times." \
4231 -s "Async resume (slot [0-9]): sign done, status=0"
4232
Gilles Peskined3268832018-04-26 06:23:59 +02004233# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
4234# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
4235requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4236requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4237run_test "SSL async private: sign, RSA, TLS 1.1" \
4238 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
4239 async_operations=s async_private_delay1=0 async_private_delay2=0" \
4240 "$P_CLI force_version=tls1_1" \
4241 0 \
4242 -s "Async sign callback: using key slot " \
4243 -s "Async resume (slot [0-9]): sign done, status=0"
4244
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004245requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02004246run_test "SSL async private: sign, SNI" \
4247 "$P_SRV debug_level=3 \
4248 async_operations=s async_private_delay1=0 async_private_delay2=0 \
4249 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4250 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4251 "$P_CLI server_name=polarssl.example" \
4252 0 \
4253 -s "Async sign callback: using key slot " \
4254 -s "Async resume (slot [0-9]): sign done, status=0" \
4255 -s "parse ServerName extension" \
4256 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4257 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4258
4259requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004260run_test "SSL async private: decrypt, delay=0" \
4261 "$P_SRV \
4262 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4263 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4264 0 \
4265 -s "Async decrypt callback: using key slot " \
4266 -s "Async resume (slot [0-9]): decrypt done, status=0"
4267
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004268requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004269run_test "SSL async private: decrypt, delay=1" \
4270 "$P_SRV \
4271 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4272 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4273 0 \
4274 -s "Async decrypt callback: using key slot " \
4275 -s "Async resume (slot [0-9]): call 0 more times." \
4276 -s "Async resume (slot [0-9]): decrypt done, status=0"
4277
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004278requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004279run_test "SSL async private: decrypt RSA-PSK, delay=0" \
4280 "$P_SRV psk=abc123 \
4281 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4282 "$P_CLI psk=abc123 \
4283 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4284 0 \
4285 -s "Async decrypt callback: using key slot " \
4286 -s "Async resume (slot [0-9]): decrypt done, status=0"
4287
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004288requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004289run_test "SSL async private: decrypt RSA-PSK, delay=1" \
4290 "$P_SRV psk=abc123 \
4291 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4292 "$P_CLI psk=abc123 \
4293 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4294 0 \
4295 -s "Async decrypt callback: using key slot " \
4296 -s "Async resume (slot [0-9]): call 0 more times." \
4297 -s "Async resume (slot [0-9]): decrypt done, status=0"
4298
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004299requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004300run_test "SSL async private: sign callback not present" \
4301 "$P_SRV \
4302 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4303 "$P_CLI; [ \$? -eq 1 ] &&
4304 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4305 0 \
4306 -S "Async sign callback" \
4307 -s "! mbedtls_ssl_handshake returned" \
4308 -s "The own private key or pre-shared key is not set, but needed" \
4309 -s "Async resume (slot [0-9]): decrypt done, status=0" \
4310 -s "Successful connection"
4311
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004312requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004313run_test "SSL async private: decrypt callback not present" \
4314 "$P_SRV debug_level=1 \
4315 async_operations=s async_private_delay1=1 async_private_delay2=1" \
4316 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
4317 [ \$? -eq 1 ] && $P_CLI" \
4318 0 \
4319 -S "Async decrypt callback" \
4320 -s "! mbedtls_ssl_handshake returned" \
4321 -s "got no RSA private key" \
4322 -s "Async resume (slot [0-9]): sign done, status=0" \
4323 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004324
4325# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004326requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004327run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004328 "$P_SRV \
4329 async_operations=s async_private_delay1=1 \
4330 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4331 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004332 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4333 0 \
4334 -s "Async sign callback: using key slot 0," \
4335 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004336 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004337
4338# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004339requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004340run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004341 "$P_SRV \
4342 async_operations=s async_private_delay2=1 \
4343 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4344 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004345 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4346 0 \
4347 -s "Async sign callback: using key slot 0," \
4348 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004349 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004350
4351# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004352requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02004353run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004354 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02004355 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004356 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4357 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004358 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4359 0 \
4360 -s "Async sign callback: using key slot 1," \
4361 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004362 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004363
4364# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004365requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004366run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004367 "$P_SRV \
4368 async_operations=s async_private_delay1=1 \
4369 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4370 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004371 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4372 0 \
4373 -s "Async sign callback: no key matches this certificate."
4374
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004375requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004376run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004377 "$P_SRV \
4378 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4379 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004380 "$P_CLI" \
4381 1 \
4382 -s "Async sign callback: injected error" \
4383 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004384 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004385 -s "! mbedtls_ssl_handshake returned"
4386
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004387requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004388run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004389 "$P_SRV \
4390 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4391 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004392 "$P_CLI" \
4393 1 \
4394 -s "Async sign callback: using key slot " \
4395 -S "Async resume" \
4396 -s "Async cancel"
4397
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004398requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004399run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004400 "$P_SRV \
4401 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4402 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004403 "$P_CLI" \
4404 1 \
4405 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004406 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004407 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004408 -s "! mbedtls_ssl_handshake returned"
4409
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004410requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004411run_test "SSL async private: decrypt, error in start" \
4412 "$P_SRV \
4413 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4414 async_private_error=1" \
4415 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4416 1 \
4417 -s "Async decrypt callback: injected error" \
4418 -S "Async resume" \
4419 -S "Async cancel" \
4420 -s "! mbedtls_ssl_handshake returned"
4421
4422requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4423run_test "SSL async private: decrypt, cancel after start" \
4424 "$P_SRV \
4425 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4426 async_private_error=2" \
4427 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4428 1 \
4429 -s "Async decrypt callback: using key slot " \
4430 -S "Async resume" \
4431 -s "Async cancel"
4432
4433requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4434run_test "SSL async private: decrypt, error in resume" \
4435 "$P_SRV \
4436 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4437 async_private_error=3" \
4438 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4439 1 \
4440 -s "Async decrypt callback: using key slot " \
4441 -s "Async resume callback: decrypt done but injected error" \
4442 -S "Async cancel" \
4443 -s "! mbedtls_ssl_handshake returned"
4444
4445requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004446run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004447 "$P_SRV \
4448 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4449 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004450 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4451 0 \
4452 -s "Async cancel" \
4453 -s "! mbedtls_ssl_handshake returned" \
4454 -s "Async resume" \
4455 -s "Successful connection"
4456
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004457requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004458run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004459 "$P_SRV \
4460 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4461 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004462 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4463 0 \
4464 -s "! mbedtls_ssl_handshake returned" \
4465 -s "Async resume" \
4466 -s "Successful connection"
4467
4468# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004469requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004470run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004471 "$P_SRV \
4472 async_operations=s async_private_delay1=1 async_private_error=-2 \
4473 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4474 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004475 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4476 [ \$? -eq 1 ] &&
4477 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4478 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02004479 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004480 -S "Async resume" \
4481 -s "Async cancel" \
4482 -s "! mbedtls_ssl_handshake returned" \
4483 -s "Async sign callback: no key matches this certificate." \
4484 -s "Successful connection"
4485
4486# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004487requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004488run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004489 "$P_SRV \
4490 async_operations=s async_private_delay1=1 async_private_error=-3 \
4491 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4492 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004493 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4494 [ \$? -eq 1 ] &&
4495 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4496 0 \
4497 -s "Async resume" \
4498 -s "! mbedtls_ssl_handshake returned" \
4499 -s "Async sign callback: no key matches this certificate." \
4500 -s "Successful connection"
4501
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004502requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004503requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004504run_test "SSL async private: renegotiation: client-initiated; sign" \
4505 "$P_SRV \
4506 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004507 exchanges=2 renegotiation=1" \
4508 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
4509 0 \
4510 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004511 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004512
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004513requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004514requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004515run_test "SSL async private: renegotiation: server-initiated; sign" \
4516 "$P_SRV \
4517 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004518 exchanges=2 renegotiation=1 renegotiate=1" \
4519 "$P_CLI exchanges=2 renegotiation=1" \
4520 0 \
4521 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004522 -s "Async resume (slot [0-9]): sign done, status=0"
4523
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004524requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004525requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4526run_test "SSL async private: renegotiation: client-initiated; decrypt" \
4527 "$P_SRV \
4528 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4529 exchanges=2 renegotiation=1" \
4530 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
4531 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4532 0 \
4533 -s "Async decrypt callback: using key slot " \
4534 -s "Async resume (slot [0-9]): decrypt done, status=0"
4535
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004536requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004537requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4538run_test "SSL async private: renegotiation: server-initiated; decrypt" \
4539 "$P_SRV \
4540 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4541 exchanges=2 renegotiation=1 renegotiate=1" \
4542 "$P_CLI exchanges=2 renegotiation=1 \
4543 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4544 0 \
4545 -s "Async decrypt callback: using key slot " \
4546 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004547
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004548# Tests for DTLS HelloVerifyRequest
4549
4550run_test "DTLS cookie: enabled" \
4551 "$P_SRV dtls=1 debug_level=2" \
4552 "$P_CLI dtls=1 debug_level=2" \
4553 0 \
4554 -s "cookie verification failed" \
4555 -s "cookie verification passed" \
4556 -S "cookie verification skipped" \
4557 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004558 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004559 -S "SSL - The requested feature is not available"
4560
4561run_test "DTLS cookie: disabled" \
4562 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4563 "$P_CLI dtls=1 debug_level=2" \
4564 0 \
4565 -S "cookie verification failed" \
4566 -S "cookie verification passed" \
4567 -s "cookie verification skipped" \
4568 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004569 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004570 -S "SSL - The requested feature is not available"
4571
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004572run_test "DTLS cookie: default (failing)" \
4573 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4574 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4575 1 \
4576 -s "cookie verification failed" \
4577 -S "cookie verification passed" \
4578 -S "cookie verification skipped" \
4579 -C "received hello verify request" \
4580 -S "hello verification requested" \
4581 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004582
4583requires_ipv6
4584run_test "DTLS cookie: enabled, IPv6" \
4585 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4586 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4587 0 \
4588 -s "cookie verification failed" \
4589 -s "cookie verification passed" \
4590 -S "cookie verification skipped" \
4591 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004592 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004593 -S "SSL - The requested feature is not available"
4594
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004595run_test "DTLS cookie: enabled, nbio" \
4596 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4597 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4598 0 \
4599 -s "cookie verification failed" \
4600 -s "cookie verification passed" \
4601 -S "cookie verification skipped" \
4602 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004603 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004604 -S "SSL - The requested feature is not available"
4605
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004606# Tests for client reconnecting from the same port with DTLS
4607
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004608not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004609run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004610 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4611 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004612 0 \
4613 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004614 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004615 -S "Client initiated reconnection from same port"
4616
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004617not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004618run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004619 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4620 "$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 +02004621 0 \
4622 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004623 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004624 -s "Client initiated reconnection from same port"
4625
Paul Bakker362689d2016-05-13 10:33:25 +01004626not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4627run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004628 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4629 "$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 +02004630 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004631 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004632 -s "Client initiated reconnection from same port"
4633
Paul Bakker362689d2016-05-13 10:33:25 +01004634only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4635run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4636 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4637 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4638 0 \
4639 -S "The operation timed out" \
4640 -s "Client initiated reconnection from same port"
4641
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004642run_test "DTLS client reconnect from same port: no cookies" \
4643 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004644 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4645 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004646 -s "The operation timed out" \
4647 -S "Client initiated reconnection from same port"
4648
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004649# Tests for various cases of client authentication with DTLS
4650# (focused on handshake flows and message parsing)
4651
4652run_test "DTLS client auth: required" \
4653 "$P_SRV dtls=1 auth_mode=required" \
4654 "$P_CLI dtls=1" \
4655 0 \
4656 -s "Verifying peer X.509 certificate... ok"
4657
4658run_test "DTLS client auth: optional, client has no cert" \
4659 "$P_SRV dtls=1 auth_mode=optional" \
4660 "$P_CLI dtls=1 crt_file=none key_file=none" \
4661 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004662 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004663
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004664run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004665 "$P_SRV dtls=1 auth_mode=none" \
4666 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
4667 0 \
4668 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004669 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004670
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02004671run_test "DTLS wrong PSK: badmac alert" \
4672 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
4673 "$P_CLI dtls=1 psk=abc124" \
4674 1 \
4675 -s "SSL - Verification of the message MAC failed" \
4676 -c "SSL - A fatal alert message was received from our peer"
4677
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02004678# Tests for receiving fragmented handshake messages with DTLS
4679
4680requires_gnutls
4681run_test "DTLS reassembly: no fragmentation (gnutls server)" \
4682 "$G_SRV -u --mtu 2048 -a" \
4683 "$P_CLI dtls=1 debug_level=2" \
4684 0 \
4685 -C "found fragmented DTLS handshake message" \
4686 -C "error"
4687
4688requires_gnutls
4689run_test "DTLS reassembly: some fragmentation (gnutls server)" \
4690 "$G_SRV -u --mtu 512" \
4691 "$P_CLI dtls=1 debug_level=2" \
4692 0 \
4693 -c "found fragmented DTLS handshake message" \
4694 -C "error"
4695
4696requires_gnutls
4697run_test "DTLS reassembly: more fragmentation (gnutls server)" \
4698 "$G_SRV -u --mtu 128" \
4699 "$P_CLI dtls=1 debug_level=2" \
4700 0 \
4701 -c "found fragmented DTLS handshake message" \
4702 -C "error"
4703
4704requires_gnutls
4705run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
4706 "$G_SRV -u --mtu 128" \
4707 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4708 0 \
4709 -c "found fragmented DTLS handshake message" \
4710 -C "error"
4711
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004712requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004713requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004714run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4715 "$G_SRV -u --mtu 256" \
4716 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4717 0 \
4718 -c "found fragmented DTLS handshake message" \
4719 -c "client hello, adding renegotiation extension" \
4720 -c "found renegotiation extension" \
4721 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004722 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004723 -C "error" \
4724 -s "Extra-header:"
4725
4726requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004727requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004728run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4729 "$G_SRV -u --mtu 256" \
4730 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4731 0 \
4732 -c "found fragmented DTLS handshake message" \
4733 -c "client hello, adding renegotiation extension" \
4734 -c "found renegotiation extension" \
4735 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004736 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004737 -C "error" \
4738 -s "Extra-header:"
4739
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004740run_test "DTLS reassembly: no fragmentation (openssl server)" \
4741 "$O_SRV -dtls1 -mtu 2048" \
4742 "$P_CLI dtls=1 debug_level=2" \
4743 0 \
4744 -C "found fragmented DTLS handshake message" \
4745 -C "error"
4746
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004747run_test "DTLS reassembly: some fragmentation (openssl server)" \
4748 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004749 "$P_CLI dtls=1 debug_level=2" \
4750 0 \
4751 -c "found fragmented DTLS handshake message" \
4752 -C "error"
4753
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004754run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004755 "$O_SRV -dtls1 -mtu 256" \
4756 "$P_CLI dtls=1 debug_level=2" \
4757 0 \
4758 -c "found fragmented DTLS handshake message" \
4759 -C "error"
4760
4761run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4762 "$O_SRV -dtls1 -mtu 256" \
4763 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4764 0 \
4765 -c "found fragmented DTLS handshake message" \
4766 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004767
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004768# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004769
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004770not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004771run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004772 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004773 "$P_SRV dtls=1 debug_level=2" \
4774 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004775 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004776 -C "replayed record" \
4777 -S "replayed record" \
4778 -C "record from another epoch" \
4779 -S "record from another epoch" \
4780 -C "discarding invalid record" \
4781 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004782 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004783 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004784 -c "HTTP/1.0 200 OK"
4785
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004786not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004787run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004788 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004789 "$P_SRV dtls=1 debug_level=2" \
4790 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004791 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004792 -c "replayed record" \
4793 -s "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004794 -c "record from another epoch" \
4795 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004796 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004797 -s "Extra-header:" \
4798 -c "HTTP/1.0 200 OK"
4799
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004800run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4801 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004802 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4803 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004804 0 \
4805 -c "replayed record" \
4806 -S "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004807 -c "record from another epoch" \
4808 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004809 -c "resend" \
4810 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004811 -s "Extra-header:" \
4812 -c "HTTP/1.0 200 OK"
4813
Hanno Becker72a4f032017-11-15 16:39:20 +00004814run_test "DTLS proxy: multiple records in same datagram" \
Hanno Becker8d832182018-03-15 10:14:19 +00004815 -p "$P_PXY pack=50" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004816 "$P_SRV dtls=1 debug_level=2" \
4817 "$P_CLI dtls=1 debug_level=2" \
4818 0 \
4819 -c "next record in same datagram" \
4820 -s "next record in same datagram"
4821
4822run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
Hanno Becker8d832182018-03-15 10:14:19 +00004823 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004824 "$P_SRV dtls=1 debug_level=2" \
4825 "$P_CLI dtls=1 debug_level=2" \
4826 0 \
4827 -c "next record in same datagram" \
4828 -s "next record in same datagram"
4829
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004830run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004831 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004832 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004833 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004834 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004835 -c "discarding invalid record (mac)" \
4836 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004837 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004838 -c "HTTP/1.0 200 OK" \
4839 -S "too many records with bad MAC" \
4840 -S "Verification of the message MAC failed"
4841
4842run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4843 -p "$P_PXY bad_ad=1" \
4844 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4845 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4846 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004847 -C "discarding invalid record (mac)" \
4848 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004849 -S "Extra-header:" \
4850 -C "HTTP/1.0 200 OK" \
4851 -s "too many records with bad MAC" \
4852 -s "Verification of the message MAC failed"
4853
4854run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4855 -p "$P_PXY bad_ad=1" \
4856 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4857 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4858 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004859 -c "discarding invalid record (mac)" \
4860 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004861 -s "Extra-header:" \
4862 -c "HTTP/1.0 200 OK" \
4863 -S "too many records with bad MAC" \
4864 -S "Verification of the message MAC failed"
4865
4866run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4867 -p "$P_PXY bad_ad=1" \
4868 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4869 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4870 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004871 -c "discarding invalid record (mac)" \
4872 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004873 -s "Extra-header:" \
4874 -c "HTTP/1.0 200 OK" \
4875 -s "too many records with bad MAC" \
4876 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004877
4878run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004879 -p "$P_PXY delay_ccs=1" \
4880 "$P_SRV dtls=1 debug_level=1" \
4881 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004882 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004883 -c "record from another epoch" \
4884 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004885 -s "Extra-header:" \
4886 -c "HTTP/1.0 200 OK"
4887
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004888# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004889
Janos Follath74537a62016-09-02 13:45:28 +01004890client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004891run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004892 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004893 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4894 psk=abc123" \
4895 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004896 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4897 0 \
4898 -s "Extra-header:" \
4899 -c "HTTP/1.0 200 OK"
4900
Janos Follath74537a62016-09-02 13:45:28 +01004901client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004902run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4903 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004904 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4905 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004906 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4907 0 \
4908 -s "Extra-header:" \
4909 -c "HTTP/1.0 200 OK"
4910
Janos Follath74537a62016-09-02 13:45:28 +01004911client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004912run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4913 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004914 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4915 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004916 0 \
4917 -s "Extra-header:" \
4918 -c "HTTP/1.0 200 OK"
4919
Janos Follath74537a62016-09-02 13:45:28 +01004920client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004921run_test "DTLS proxy: 3d, FS, client auth" \
4922 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004923 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4924 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004925 0 \
4926 -s "Extra-header:" \
4927 -c "HTTP/1.0 200 OK"
4928
Janos Follath74537a62016-09-02 13:45:28 +01004929client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004930run_test "DTLS proxy: 3d, FS, ticket" \
4931 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004932 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4933 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004934 0 \
4935 -s "Extra-header:" \
4936 -c "HTTP/1.0 200 OK"
4937
Janos Follath74537a62016-09-02 13:45:28 +01004938client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004939run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4940 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004941 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4942 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004943 0 \
4944 -s "Extra-header:" \
4945 -c "HTTP/1.0 200 OK"
4946
Janos Follath74537a62016-09-02 13:45:28 +01004947client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004948run_test "DTLS proxy: 3d, max handshake, nbio" \
4949 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004950 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4951 auth_mode=required" \
4952 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004953 0 \
4954 -s "Extra-header:" \
4955 -c "HTTP/1.0 200 OK"
4956
Janos Follath74537a62016-09-02 13:45:28 +01004957client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004958run_test "DTLS proxy: 3d, min handshake, resumption" \
4959 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4960 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4961 psk=abc123 debug_level=3" \
4962 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4963 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4964 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4965 0 \
4966 -s "a session has been resumed" \
4967 -c "a session has been resumed" \
4968 -s "Extra-header:" \
4969 -c "HTTP/1.0 200 OK"
4970
Janos Follath74537a62016-09-02 13:45:28 +01004971client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004972run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4973 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4974 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4975 psk=abc123 debug_level=3 nbio=2" \
4976 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4977 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4978 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4979 0 \
4980 -s "a session has been resumed" \
4981 -c "a session has been resumed" \
4982 -s "Extra-header:" \
4983 -c "HTTP/1.0 200 OK"
4984
Janos Follath74537a62016-09-02 13:45:28 +01004985client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004986requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004987run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004988 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004989 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4990 psk=abc123 renegotiation=1 debug_level=2" \
4991 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4992 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004993 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4994 0 \
4995 -c "=> renegotiate" \
4996 -s "=> renegotiate" \
4997 -s "Extra-header:" \
4998 -c "HTTP/1.0 200 OK"
4999
Janos Follath74537a62016-09-02 13:45:28 +01005000client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005001requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005002run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
5003 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005004 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5005 psk=abc123 renegotiation=1 debug_level=2" \
5006 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5007 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005008 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5009 0 \
5010 -c "=> renegotiate" \
5011 -s "=> renegotiate" \
5012 -s "Extra-header:" \
5013 -c "HTTP/1.0 200 OK"
5014
Janos Follath74537a62016-09-02 13:45:28 +01005015client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005016requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005017run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005018 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005019 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005020 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005021 debug_level=2" \
5022 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005023 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005024 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5025 0 \
5026 -c "=> renegotiate" \
5027 -s "=> renegotiate" \
5028 -s "Extra-header:" \
5029 -c "HTTP/1.0 200 OK"
5030
Janos Follath74537a62016-09-02 13:45:28 +01005031client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005032requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005033run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005034 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005035 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005036 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005037 debug_level=2 nbio=2" \
5038 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005039 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005040 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5041 0 \
5042 -c "=> renegotiate" \
5043 -s "=> renegotiate" \
5044 -s "Extra-header:" \
5045 -c "HTTP/1.0 200 OK"
5046
Janos Follath74537a62016-09-02 13:45:28 +01005047client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005048not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005049run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005050 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5051 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005052 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005053 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005054 -c "HTTP/1.0 200 OK"
5055
Janos Follath74537a62016-09-02 13:45:28 +01005056client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005057not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005058run_test "DTLS proxy: 3d, openssl server, fragmentation" \
5059 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5060 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005061 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005062 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005063 -c "HTTP/1.0 200 OK"
5064
Janos Follath74537a62016-09-02 13:45:28 +01005065client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005066not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005067run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
5068 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5069 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005070 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005071 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005072 -c "HTTP/1.0 200 OK"
5073
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005074requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005075client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005076not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005077run_test "DTLS proxy: 3d, gnutls server" \
5078 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5079 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005080 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005081 0 \
5082 -s "Extra-header:" \
5083 -c "Extra-header:"
5084
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005085requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005086client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005087not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005088run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
5089 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5090 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005091 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005092 0 \
5093 -s "Extra-header:" \
5094 -c "Extra-header:"
5095
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005096requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005097client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005098not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005099run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
5100 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5101 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005102 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005103 0 \
5104 -s "Extra-header:" \
5105 -c "Extra-header:"
5106
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01005107# Final report
5108
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005109echo "------------------------------------------------------------------------"
5110
5111if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005112 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005113else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005114 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005115fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02005116PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02005117echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005118
5119exit $FAILS