blob: 4a93a1772b390839840ad34f816c5a18f87608dc [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
Angus Grattonc4dd0732018-04-11 16:28:39 +100024if cd $( dirname $0 ); then :; else
25 echo "cd $( dirname $0 ) failed" >&2
26 exit 1
27fi
28
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010029# default values, can be overriden by the environment
30: ${P_SRV:=../programs/ssl/ssl_server2}
31: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020032: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010033: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020034: ${GNUTLS_CLI:=gnutls-cli}
35: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020036: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010037
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020038O_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 +010039O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020040G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010041G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020042TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010043
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010044TESTS=0
45FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020046SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010047
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000048CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020049
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010050MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010051FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020052EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053
Paul Bakkere20310a2016-05-10 11:18:17 +010054SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010055RUN_TEST_NUMBER=''
56
Paul Bakkeracaac852016-05-10 11:47:13 +010057PRESERVE_LOGS=0
58
Gilles Peskinef93c7d32017-04-14 17:55:28 +020059# Pick a "unique" server port in the range 10000-19999, and a proxy
60# port which is this plus 10000. Each port number may be independently
61# overridden by a command line option.
62SRV_PORT=$(($$ % 10000 + 10000))
63PXY_PORT=$((SRV_PORT + 10000))
64
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010065print_usage() {
66 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010067 printf " -h|--help\tPrint this help.\n"
68 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
70 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010071 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010072 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010073 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020074 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
75 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010076 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010077}
78
79get_options() {
80 while [ $# -gt 0 ]; do
81 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010082 -f|--filter)
83 shift; FILTER=$1
84 ;;
85 -e|--exclude)
86 shift; EXCLUDE=$1
87 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010088 -m|--memcheck)
89 MEMCHECK=1
90 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010091 -n|--number)
92 shift; RUN_TEST_NUMBER=$1
93 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010094 -s|--show-numbers)
95 SHOW_TEST_NUMBER=1
96 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010097 -p|--preserve-logs)
98 PRESERVE_LOGS=1
99 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200100 --port)
101 shift; SRV_PORT=$1
102 ;;
103 --proxy-port)
104 shift; PXY_PORT=$1
105 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100106 --seed)
107 shift; SEED="$1"
108 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100109 -h|--help)
110 print_usage
111 exit 0
112 ;;
113 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200114 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100115 print_usage
116 exit 1
117 ;;
118 esac
119 shift
120 done
121}
122
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100123# skip next test if the flag is not enabled in config.h
124requires_config_enabled() {
125 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
126 SKIP_NEXT="YES"
127 fi
128}
129
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200130# skip next test if the flag is enabled in config.h
131requires_config_disabled() {
132 if grep "^#define $1" $CONFIG_H > /dev/null; then
133 SKIP_NEXT="YES"
134 fi
135}
136
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200137# skip next test if OpenSSL doesn't support FALLBACK_SCSV
138requires_openssl_with_fallback_scsv() {
139 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
140 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
141 then
142 OPENSSL_HAS_FBSCSV="YES"
143 else
144 OPENSSL_HAS_FBSCSV="NO"
145 fi
146 fi
147 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
148 SKIP_NEXT="YES"
149 fi
150}
151
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200152# skip next test if GnuTLS isn't available
153requires_gnutls() {
154 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200155 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200156 GNUTLS_AVAILABLE="YES"
157 else
158 GNUTLS_AVAILABLE="NO"
159 fi
160 fi
161 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
162 SKIP_NEXT="YES"
163 fi
164}
165
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200166# skip next test if IPv6 isn't available on this host
167requires_ipv6() {
168 if [ -z "${HAS_IPV6:-}" ]; then
169 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
170 SRV_PID=$!
171 sleep 1
172 kill $SRV_PID >/dev/null 2>&1
173 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
174 HAS_IPV6="NO"
175 else
176 HAS_IPV6="YES"
177 fi
178 rm -r $SRV_OUT
179 fi
180
181 if [ "$HAS_IPV6" = "NO" ]; then
182 SKIP_NEXT="YES"
183 fi
184}
185
Angus Grattonc4dd0732018-04-11 16:28:39 +1000186# Calculate the input & output maximum content lengths set in the config
187MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
188MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
189MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
190
191if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
192 MAX_CONTENT_LEN="$MAX_IN_LEN"
193fi
194if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
195 MAX_CONTENT_LEN="$MAX_OUT_LEN"
196fi
197
198# skip the next test if the SSL output buffer is less than 16KB
199requires_full_size_output_buffer() {
200 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
201 SKIP_NEXT="YES"
202 fi
203}
204
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200205# skip the next test if valgrind is in use
206not_with_valgrind() {
207 if [ "$MEMCHECK" -gt 0 ]; then
208 SKIP_NEXT="YES"
209 fi
210}
211
Paul Bakker362689d2016-05-13 10:33:25 +0100212# skip the next test if valgrind is NOT in use
213only_with_valgrind() {
214 if [ "$MEMCHECK" -eq 0 ]; then
215 SKIP_NEXT="YES"
216 fi
217}
218
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200219# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100220client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200221 CLI_DELAY_FACTOR=$1
222}
223
Janos Follath74537a62016-09-02 13:45:28 +0100224# wait for the given seconds after the client finished in the next test
225server_needs_more_time() {
226 SRV_DELAY_SECONDS=$1
227}
228
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100229# print_name <name>
230print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100231 TESTS=$(( $TESTS + 1 ))
232 LINE=""
233
234 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
235 LINE="$TESTS "
236 fi
237
238 LINE="$LINE$1"
239 printf "$LINE "
240 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100241 for i in `seq 1 $LEN`; do printf '.'; done
242 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100243
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100244}
245
246# fail <message>
247fail() {
248 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100249 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100250
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200251 mv $SRV_OUT o-srv-${TESTS}.log
252 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200253 if [ -n "$PXY_CMD" ]; then
254 mv $PXY_OUT o-pxy-${TESTS}.log
255 fi
256 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100257
Azim Khan19d13732018-03-29 11:04:20 +0100258 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 +0200259 echo " ! server output:"
260 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200261 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200262 echo " ! client output:"
263 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200264 if [ -n "$PXY_CMD" ]; then
265 echo " ! ========================================================"
266 echo " ! proxy output:"
267 cat o-pxy-${TESTS}.log
268 fi
269 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200270 fi
271
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200272 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100273}
274
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100275# is_polar <cmd_line>
276is_polar() {
277 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
278}
279
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200280# openssl s_server doesn't have -www with DTLS
281check_osrv_dtls() {
282 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
283 NEEDS_INPUT=1
284 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
285 else
286 NEEDS_INPUT=0
287 fi
288}
289
290# provide input to commands that need it
291provide_input() {
292 if [ $NEEDS_INPUT -eq 0 ]; then
293 return
294 fi
295
296 while true; do
297 echo "HTTP/1.0 200 OK"
298 sleep 1
299 done
300}
301
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100302# has_mem_err <log_file_name>
303has_mem_err() {
304 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
305 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
306 then
307 return 1 # false: does not have errors
308 else
309 return 0 # true: has errors
310 fi
311}
312
Gilles Peskine418b5362017-12-14 18:58:42 +0100313# Wait for process $2 to be listening on port $1
314if type lsof >/dev/null 2>/dev/null; then
315 wait_server_start() {
316 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200317 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100318 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200319 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100320 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200321 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100322 # Make a tight loop, server normally takes less than 1s to start.
323 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
324 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
325 echo "SERVERSTART TIMEOUT"
326 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
327 break
328 fi
329 # Linux and *BSD support decimal arguments to sleep. On other
330 # OSes this may be a tight loop.
331 sleep 0.1 2>/dev/null || true
332 done
333 }
334else
Gilles Peskinea9312652018-06-29 15:48:13 +0200335 echo "Warning: lsof not available, wait_server_start = sleep"
Gilles Peskine418b5362017-12-14 18:58:42 +0100336 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200337 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100338 }
339fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200340
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100341# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100342# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100343# acceptable bounds
344check_server_hello_time() {
345 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100346 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100347 # Get the Unix timestamp for now
348 CUR_TIME=$(date +'%s')
349 THRESHOLD_IN_SECS=300
350
351 # Check if the ServerHello time was printed
352 if [ -z "$SERVER_HELLO_TIME" ]; then
353 return 1
354 fi
355
356 # Check the time in ServerHello is within acceptable bounds
357 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
358 # The time in ServerHello is at least 5 minutes before now
359 return 1
360 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100361 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100362 return 1
363 else
364 return 0
365 fi
366}
367
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200368# wait for client to terminate and set CLI_EXIT
369# must be called right after starting the client
370wait_client_done() {
371 CLI_PID=$!
372
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200373 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
374 CLI_DELAY_FACTOR=1
375
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200376 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200377 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200378
379 wait $CLI_PID
380 CLI_EXIT=$?
381
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200382 kill $DOG_PID >/dev/null 2>&1
383 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200384
385 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100386
387 sleep $SRV_DELAY_SECONDS
388 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200389}
390
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200391# check if the given command uses dtls and sets global variable DTLS
392detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200393 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200394 DTLS=1
395 else
396 DTLS=0
397 fi
398}
399
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200400# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100401# Options: -s pattern pattern that must be present in server output
402# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100403# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100404# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100405# -S pattern pattern that must be absent in server output
406# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100407# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100408# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100409run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100410 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200411 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100412
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100413 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
414 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200415 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100416 return
417 fi
418
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100419 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100420
Paul Bakkerb7584a52016-05-10 10:50:43 +0100421 # Do we only run numbered tests?
422 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
423 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
424 else
425 SKIP_NEXT="YES"
426 fi
427
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200428 # should we skip?
429 if [ "X$SKIP_NEXT" = "XYES" ]; then
430 SKIP_NEXT="NO"
431 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200432 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200433 return
434 fi
435
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200436 # does this test use a proxy?
437 if [ "X$1" = "X-p" ]; then
438 PXY_CMD="$2"
439 shift 2
440 else
441 PXY_CMD=""
442 fi
443
444 # get commands and client output
445 SRV_CMD="$1"
446 CLI_CMD="$2"
447 CLI_EXPECT="$3"
448 shift 3
449
450 # fix client port
451 if [ -n "$PXY_CMD" ]; then
452 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
453 else
454 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
455 fi
456
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200457 # update DTLS variable
458 detect_dtls "$SRV_CMD"
459
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100460 # prepend valgrind to our commands if active
461 if [ "$MEMCHECK" -gt 0 ]; then
462 if is_polar "$SRV_CMD"; then
463 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
464 fi
465 if is_polar "$CLI_CMD"; then
466 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
467 fi
468 fi
469
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200470 TIMES_LEFT=2
471 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200472 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200473
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200474 # run the commands
475 if [ -n "$PXY_CMD" ]; then
476 echo "$PXY_CMD" > $PXY_OUT
477 $PXY_CMD >> $PXY_OUT 2>&1 &
478 PXY_PID=$!
479 # assume proxy starts faster than server
480 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200481
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200482 check_osrv_dtls
483 echo "$SRV_CMD" > $SRV_OUT
484 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
485 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100486 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200487
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200488 echo "$CLI_CMD" > $CLI_OUT
489 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
490 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100491
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100492 sleep 0.05
493
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200494 # terminate the server (and the proxy)
495 kill $SRV_PID
496 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100497
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200498 if [ -n "$PXY_CMD" ]; then
499 kill $PXY_PID >/dev/null 2>&1
500 wait $PXY_PID
501 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100502
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200503 # retry only on timeouts
504 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
505 printf "RETRY "
506 else
507 TIMES_LEFT=0
508 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200509 done
510
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100511 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200512 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100513 # expected client exit to incorrectly succeed in case of catastrophic
514 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100515 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200516 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100517 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100518 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100519 return
520 fi
521 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100522 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200523 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100524 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100525 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100526 return
527 fi
528 fi
529
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100530 # check server exit code
531 if [ $? != 0 ]; then
532 fail "server fail"
533 return
534 fi
535
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100536 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100537 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
538 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100539 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200540 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100541 return
542 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100543
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100544 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200545 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100546 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100547 while [ $# -gt 0 ]
548 do
549 case $1 in
550 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100551 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 +0100552 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100553 return
554 fi
555 ;;
556
557 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100558 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 +0100559 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100560 return
561 fi
562 ;;
563
564 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100565 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 +0100566 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100567 return
568 fi
569 ;;
570
571 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100572 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 +0100573 fail "pattern '$2' MUST NOT be present in the Client output"
574 return
575 fi
576 ;;
577
578 # The filtering in the following two options (-u and -U) do the following
579 # - ignore valgrind output
580 # - filter out everything but lines right after the pattern occurances
581 # - keep one of each non-unique line
582 # - count how many lines remain
583 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
584 # if there were no duplicates.
585 "-U")
586 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
587 fail "lines following pattern '$2' must be unique in Server output"
588 return
589 fi
590 ;;
591
592 "-u")
593 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
594 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100595 return
596 fi
597 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100598 "-F")
599 if ! $2 "$SRV_OUT"; then
600 fail "function call to '$2' failed on Server output"
601 return
602 fi
603 ;;
604 "-f")
605 if ! $2 "$CLI_OUT"; then
606 fail "function call to '$2' failed on Client output"
607 return
608 fi
609 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100610
611 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200612 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100613 exit 1
614 esac
615 shift 2
616 done
617
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100618 # check valgrind's results
619 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200620 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100621 fail "Server has memory errors"
622 return
623 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200624 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100625 fail "Client has memory errors"
626 return
627 fi
628 fi
629
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100630 # if we're here, everything is ok
631 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100632 if [ "$PRESERVE_LOGS" -gt 0 ]; then
633 mv $SRV_OUT o-srv-${TESTS}.log
634 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100635 if [ -n "$PXY_CMD" ]; then
636 mv $PXY_OUT o-pxy-${TESTS}.log
637 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100638 fi
639
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200640 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100641}
642
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100643cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200644 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200645 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
646 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
647 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
648 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100649 exit 1
650}
651
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100652#
653# MAIN
654#
655
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100656get_options "$@"
657
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100658# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100659P_SRV_BIN="${P_SRV%%[ ]*}"
660P_CLI_BIN="${P_CLI%%[ ]*}"
661P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100662if [ ! -x "$P_SRV_BIN" ]; then
663 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100664 exit 1
665fi
Hanno Becker17c04932017-10-10 14:44:53 +0100666if [ ! -x "$P_CLI_BIN" ]; then
667 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100668 exit 1
669fi
Hanno Becker17c04932017-10-10 14:44:53 +0100670if [ ! -x "$P_PXY_BIN" ]; then
671 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200672 exit 1
673fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100674if [ "$MEMCHECK" -gt 0 ]; then
675 if which valgrind >/dev/null 2>&1; then :; else
676 echo "Memcheck not possible. Valgrind not found"
677 exit 1
678 fi
679fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100680if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
681 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100682 exit 1
683fi
684
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200685# used by watchdog
686MAIN_PID="$$"
687
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100688# We use somewhat arbitrary delays for tests:
689# - how long do we wait for the server to start (when lsof not available)?
690# - how long do we allow for the client to finish?
691# (not to check performance, just to avoid waiting indefinitely)
692# Things are slower with valgrind, so give extra time here.
693#
694# Note: without lsof, there is a trade-off between the running time of this
695# script and the risk of spurious errors because we didn't wait long enough.
696# The watchdog delay on the other hand doesn't affect normal running time of
697# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200698if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100699 START_DELAY=6
700 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200701else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100702 START_DELAY=2
703 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200704fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100705
706# some particular tests need more time:
707# - for the client, we multiply the usual watchdog limit by a factor
708# - for the server, we sleep for a number of seconds after the client exits
709# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200710CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100711SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200712
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200713# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000714# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200715P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
716P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100717P_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 +0200718O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200719O_CLI="$O_CLI -connect localhost:+SRV_PORT"
720G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000721G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200722
Gilles Peskine62469d92017-05-10 10:13:59 +0200723# Allow SHA-1, because many of our test certificates use it
724P_SRV="$P_SRV allow_sha1=1"
725P_CLI="$P_CLI allow_sha1=1"
726
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200727# Also pick a unique name for intermediate files
728SRV_OUT="srv_out.$$"
729CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200730PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200731SESSION="session.$$"
732
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200733SKIP_NEXT="NO"
734
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100735trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100736
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200737# Basic test
738
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200739# Checks that:
740# - things work with all ciphersuites active (used with config-full in all.sh)
741# - the expected (highest security) parameters are selected
742# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200743run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200744 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200745 "$P_CLI" \
746 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200747 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200748 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200749 -s "client hello v3, signature_algorithm ext: 6" \
750 -s "ECDHE curve: secp521r1" \
751 -S "error" \
752 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200753
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000754run_test "Default, DTLS" \
755 "$P_SRV dtls=1" \
756 "$P_CLI dtls=1" \
757 0 \
758 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200759 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000760
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100761# Test current time in ServerHello
762requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200763run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100764 "$P_SRV debug_level=3" \
765 "$P_CLI debug_level=3" \
766 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100767 -f "check_server_hello_time" \
768 -F "check_server_hello_time"
769
Simon Butcher8e004102016-10-14 00:48:33 +0100770# Test for uniqueness of IVs in AEAD ciphersuites
771run_test "Unique IV in GCM" \
772 "$P_SRV exchanges=20 debug_level=4" \
773 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
774 0 \
775 -u "IV used" \
776 -U "IV used"
777
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100778# Tests for rc4 option
779
Simon Butchera410af52016-05-19 22:12:18 +0100780requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100781run_test "RC4: server disabled, client enabled" \
782 "$P_SRV" \
783 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
784 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100785 -s "SSL - The server has no ciphersuites in common"
786
Simon Butchera410af52016-05-19 22:12:18 +0100787requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100788run_test "RC4: server half, client enabled" \
789 "$P_SRV arc4=1" \
790 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
791 1 \
792 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100793
794run_test "RC4: server enabled, client disabled" \
795 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
796 "$P_CLI" \
797 1 \
798 -s "SSL - The server has no ciphersuites in common"
799
800run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100801 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100802 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
803 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100804 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100805 -S "SSL - The server has no ciphersuites in common"
806
Gilles Peskinebc70a182017-05-09 15:59:24 +0200807# Tests for SHA-1 support
808
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200809requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200810run_test "SHA-1 forbidden by default in server certificate" \
811 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
812 "$P_CLI debug_level=2 allow_sha1=0" \
813 1 \
814 -c "The certificate is signed with an unacceptable hash"
815
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200816requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
817run_test "SHA-1 forbidden by default in server certificate" \
818 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
819 "$P_CLI debug_level=2 allow_sha1=0" \
820 0
821
Gilles Peskinebc70a182017-05-09 15:59:24 +0200822run_test "SHA-1 explicitly allowed in server certificate" \
823 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
824 "$P_CLI allow_sha1=1" \
825 0
826
827run_test "SHA-256 allowed by default in server certificate" \
828 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
829 "$P_CLI allow_sha1=0" \
830 0
831
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200832requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200833run_test "SHA-1 forbidden by default in client certificate" \
834 "$P_SRV auth_mode=required allow_sha1=0" \
835 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
836 1 \
837 -s "The certificate is signed with an unacceptable hash"
838
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200839requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
840run_test "SHA-1 forbidden by default in client certificate" \
841 "$P_SRV auth_mode=required allow_sha1=0" \
842 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
843 0
844
Gilles Peskinebc70a182017-05-09 15:59:24 +0200845run_test "SHA-1 explicitly allowed in client certificate" \
846 "$P_SRV auth_mode=required allow_sha1=1" \
847 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
848 0
849
850run_test "SHA-256 allowed by default in client certificate" \
851 "$P_SRV auth_mode=required allow_sha1=0" \
852 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
853 0
854
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100855# Tests for Truncated HMAC extension
856
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100857run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200858 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100859 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100860 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000861 -s "dumping 'expected mac' (20 bytes)" \
862 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100863
Hanno Becker32c55012017-11-10 08:42:54 +0000864requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100865run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200866 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000867 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100868 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000869 -s "dumping 'expected mac' (20 bytes)" \
870 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100871
Hanno Becker32c55012017-11-10 08:42:54 +0000872requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100873run_test "Truncated HMAC: client enabled, server default" \
874 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000875 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100876 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000877 -s "dumping 'expected mac' (20 bytes)" \
878 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100879
Hanno Becker32c55012017-11-10 08:42:54 +0000880requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100881run_test "Truncated HMAC: client enabled, server disabled" \
882 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000883 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100884 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000885 -s "dumping 'expected mac' (20 bytes)" \
886 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100887
Hanno Becker32c55012017-11-10 08:42:54 +0000888requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000889run_test "Truncated HMAC: client disabled, server enabled" \
890 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000891 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000892 0 \
893 -s "dumping 'expected mac' (20 bytes)" \
894 -S "dumping 'expected mac' (10 bytes)"
895
896requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100897run_test "Truncated HMAC: client enabled, server enabled" \
898 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000899 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100900 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000901 -S "dumping 'expected mac' (20 bytes)" \
902 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100903
Hanno Becker4c4f4102017-11-10 09:16:05 +0000904run_test "Truncated HMAC, DTLS: client default, server default" \
905 "$P_SRV dtls=1 debug_level=4" \
906 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
907 0 \
908 -s "dumping 'expected mac' (20 bytes)" \
909 -S "dumping 'expected mac' (10 bytes)"
910
911requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
912run_test "Truncated HMAC, DTLS: client disabled, server default" \
913 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000914 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000915 0 \
916 -s "dumping 'expected mac' (20 bytes)" \
917 -S "dumping 'expected mac' (10 bytes)"
918
919requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
920run_test "Truncated HMAC, DTLS: client enabled, server default" \
921 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000922 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000923 0 \
924 -s "dumping 'expected mac' (20 bytes)" \
925 -S "dumping 'expected mac' (10 bytes)"
926
927requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
928run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
929 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000930 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000931 0 \
932 -s "dumping 'expected mac' (20 bytes)" \
933 -S "dumping 'expected mac' (10 bytes)"
934
935requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
936run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
937 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000938 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000939 0 \
940 -s "dumping 'expected mac' (20 bytes)" \
941 -S "dumping 'expected mac' (10 bytes)"
942
943requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
944run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
945 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000946 "$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 +0100947 0 \
948 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100949 -s "dumping 'expected mac' (10 bytes)"
950
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100951# Tests for Encrypt-then-MAC extension
952
953run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100954 "$P_SRV debug_level=3 \
955 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100956 "$P_CLI debug_level=3" \
957 0 \
958 -c "client hello, adding encrypt_then_mac extension" \
959 -s "found encrypt then mac extension" \
960 -s "server hello, adding encrypt then mac extension" \
961 -c "found encrypt_then_mac extension" \
962 -c "using encrypt then mac" \
963 -s "using encrypt then mac"
964
965run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100966 "$P_SRV debug_level=3 etm=0 \
967 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100968 "$P_CLI debug_level=3 etm=1" \
969 0 \
970 -c "client hello, adding encrypt_then_mac extension" \
971 -s "found encrypt then mac extension" \
972 -S "server hello, adding encrypt then mac extension" \
973 -C "found encrypt_then_mac extension" \
974 -C "using encrypt then mac" \
975 -S "using encrypt then mac"
976
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100977run_test "Encrypt then MAC: client enabled, aead cipher" \
978 "$P_SRV debug_level=3 etm=1 \
979 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
980 "$P_CLI debug_level=3 etm=1" \
981 0 \
982 -c "client hello, adding encrypt_then_mac extension" \
983 -s "found encrypt then mac extension" \
984 -S "server hello, adding encrypt then mac extension" \
985 -C "found encrypt_then_mac extension" \
986 -C "using encrypt then mac" \
987 -S "using encrypt then mac"
988
989run_test "Encrypt then MAC: client enabled, stream cipher" \
990 "$P_SRV debug_level=3 etm=1 \
991 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100992 "$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 +0100993 0 \
994 -c "client hello, adding encrypt_then_mac extension" \
995 -s "found encrypt then mac extension" \
996 -S "server hello, adding encrypt then mac extension" \
997 -C "found encrypt_then_mac extension" \
998 -C "using encrypt then mac" \
999 -S "using encrypt then mac"
1000
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001001run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001002 "$P_SRV debug_level=3 etm=1 \
1003 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001004 "$P_CLI debug_level=3 etm=0" \
1005 0 \
1006 -C "client hello, adding encrypt_then_mac extension" \
1007 -S "found encrypt then mac extension" \
1008 -S "server hello, adding encrypt then mac extension" \
1009 -C "found encrypt_then_mac extension" \
1010 -C "using encrypt then mac" \
1011 -S "using encrypt then mac"
1012
Janos Follathe2681a42016-03-07 15:57:05 +00001013requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001014run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001015 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001016 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001017 "$P_CLI debug_level=3 force_version=ssl3" \
1018 0 \
1019 -C "client hello, adding encrypt_then_mac extension" \
1020 -S "found encrypt then mac extension" \
1021 -S "server hello, adding encrypt then mac extension" \
1022 -C "found encrypt_then_mac extension" \
1023 -C "using encrypt then mac" \
1024 -S "using encrypt then mac"
1025
Janos Follathe2681a42016-03-07 15:57:05 +00001026requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001027run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001028 "$P_SRV debug_level=3 force_version=ssl3 \
1029 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001030 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001031 0 \
1032 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001033 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001034 -S "server hello, adding encrypt then mac extension" \
1035 -C "found encrypt_then_mac extension" \
1036 -C "using encrypt then mac" \
1037 -S "using encrypt then mac"
1038
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001039# Tests for Extended Master Secret extension
1040
1041run_test "Extended Master Secret: default" \
1042 "$P_SRV debug_level=3" \
1043 "$P_CLI debug_level=3" \
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
1052run_test "Extended Master Secret: client enabled, server disabled" \
1053 "$P_SRV debug_level=3 extended_ms=0" \
1054 "$P_CLI debug_level=3 extended_ms=1" \
1055 0 \
1056 -c "client hello, adding extended_master_secret extension" \
1057 -s "found extended master secret extension" \
1058 -S "server hello, adding extended master secret extension" \
1059 -C "found extended_master_secret extension" \
1060 -C "using extended master secret" \
1061 -S "using extended master secret"
1062
1063run_test "Extended Master Secret: client disabled, server enabled" \
1064 "$P_SRV debug_level=3 extended_ms=1" \
1065 "$P_CLI debug_level=3 extended_ms=0" \
1066 0 \
1067 -C "client hello, adding extended_master_secret extension" \
1068 -S "found extended master secret extension" \
1069 -S "server hello, adding extended master secret extension" \
1070 -C "found extended_master_secret extension" \
1071 -C "using extended master secret" \
1072 -S "using extended master secret"
1073
Janos Follathe2681a42016-03-07 15:57:05 +00001074requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001075run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001076 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001077 "$P_CLI debug_level=3 force_version=ssl3" \
1078 0 \
1079 -C "client hello, adding extended_master_secret extension" \
1080 -S "found extended master secret extension" \
1081 -S "server hello, adding extended master secret extension" \
1082 -C "found extended_master_secret extension" \
1083 -C "using extended master secret" \
1084 -S "using extended master secret"
1085
Janos Follathe2681a42016-03-07 15:57:05 +00001086requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001087run_test "Extended Master Secret: client enabled, server SSLv3" \
1088 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001089 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001090 0 \
1091 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001092 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001093 -S "server hello, adding extended master secret extension" \
1094 -C "found extended_master_secret extension" \
1095 -C "using extended master secret" \
1096 -S "using extended master secret"
1097
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001098# Tests for FALLBACK_SCSV
1099
1100run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001101 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001102 "$P_CLI debug_level=3 force_version=tls1_1" \
1103 0 \
1104 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001105 -S "received FALLBACK_SCSV" \
1106 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001107 -C "is a fatal alert message (msg 86)"
1108
1109run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001110 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001111 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1112 0 \
1113 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001114 -S "received FALLBACK_SCSV" \
1115 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001116 -C "is a fatal alert message (msg 86)"
1117
1118run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001119 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001120 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001121 1 \
1122 -c "adding FALLBACK_SCSV" \
1123 -s "received FALLBACK_SCSV" \
1124 -s "inapropriate fallback" \
1125 -c "is a fatal alert message (msg 86)"
1126
1127run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001128 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001129 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001130 0 \
1131 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001132 -s "received FALLBACK_SCSV" \
1133 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001134 -C "is a fatal alert message (msg 86)"
1135
1136requires_openssl_with_fallback_scsv
1137run_test "Fallback SCSV: default, openssl server" \
1138 "$O_SRV" \
1139 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1140 0 \
1141 -C "adding FALLBACK_SCSV" \
1142 -C "is a fatal alert message (msg 86)"
1143
1144requires_openssl_with_fallback_scsv
1145run_test "Fallback SCSV: enabled, openssl server" \
1146 "$O_SRV" \
1147 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1148 1 \
1149 -c "adding FALLBACK_SCSV" \
1150 -c "is a fatal alert message (msg 86)"
1151
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001152requires_openssl_with_fallback_scsv
1153run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001154 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001155 "$O_CLI -tls1_1" \
1156 0 \
1157 -S "received FALLBACK_SCSV" \
1158 -S "inapropriate fallback"
1159
1160requires_openssl_with_fallback_scsv
1161run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001162 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001163 "$O_CLI -tls1_1 -fallback_scsv" \
1164 1 \
1165 -s "received FALLBACK_SCSV" \
1166 -s "inapropriate fallback"
1167
1168requires_openssl_with_fallback_scsv
1169run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001170 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001171 "$O_CLI -fallback_scsv" \
1172 0 \
1173 -s "received FALLBACK_SCSV" \
1174 -S "inapropriate fallback"
1175
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001176# Test sending and receiving empty application data records
1177
1178run_test "Encrypt then MAC: empty application data record" \
1179 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1180 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1181 0 \
1182 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1183 -s "dumping 'input payload after decrypt' (0 bytes)" \
1184 -c "0 bytes written in 1 fragments"
1185
1186run_test "Default, no Encrypt then MAC: empty application data record" \
1187 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1188 "$P_CLI auth_mode=none etm=0 request_size=0" \
1189 0 \
1190 -s "dumping 'input payload after decrypt' (0 bytes)" \
1191 -c "0 bytes written in 1 fragments"
1192
1193run_test "Encrypt then MAC, DTLS: empty application data record" \
1194 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1195 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1196 0 \
1197 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1198 -s "dumping 'input payload after decrypt' (0 bytes)" \
1199 -c "0 bytes written in 1 fragments"
1200
1201run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
1202 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1203 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1204 0 \
1205 -s "dumping 'input payload after decrypt' (0 bytes)" \
1206 -c "0 bytes written in 1 fragments"
1207
Gilles Peskined50177f2017-05-16 17:53:03 +02001208## ClientHello generated with
1209## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1210## then manually twiddling the ciphersuite list.
1211## The ClientHello content is spelled out below as a hex string as
1212## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1213## The expected response is an inappropriate_fallback alert.
1214requires_openssl_with_fallback_scsv
1215run_test "Fallback SCSV: beginning of list" \
1216 "$P_SRV debug_level=2" \
1217 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1218 0 \
1219 -s "received FALLBACK_SCSV" \
1220 -s "inapropriate fallback"
1221
1222requires_openssl_with_fallback_scsv
1223run_test "Fallback SCSV: end of list" \
1224 "$P_SRV debug_level=2" \
1225 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1226 0 \
1227 -s "received FALLBACK_SCSV" \
1228 -s "inapropriate fallback"
1229
1230## Here the expected response is a valid ServerHello prefix, up to the random.
1231requires_openssl_with_fallback_scsv
1232run_test "Fallback SCSV: not in list" \
1233 "$P_SRV debug_level=2" \
1234 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1235 0 \
1236 -S "received FALLBACK_SCSV" \
1237 -S "inapropriate fallback"
1238
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001239# Tests for CBC 1/n-1 record splitting
1240
1241run_test "CBC Record splitting: TLS 1.2, no splitting" \
1242 "$P_SRV" \
1243 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1244 request_size=123 force_version=tls1_2" \
1245 0 \
1246 -s "Read from client: 123 bytes read" \
1247 -S "Read from client: 1 bytes read" \
1248 -S "122 bytes read"
1249
1250run_test "CBC Record splitting: TLS 1.1, no splitting" \
1251 "$P_SRV" \
1252 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1253 request_size=123 force_version=tls1_1" \
1254 0 \
1255 -s "Read from client: 123 bytes read" \
1256 -S "Read from client: 1 bytes read" \
1257 -S "122 bytes read"
1258
1259run_test "CBC Record splitting: TLS 1.0, splitting" \
1260 "$P_SRV" \
1261 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1262 request_size=123 force_version=tls1" \
1263 0 \
1264 -S "Read from client: 123 bytes read" \
1265 -s "Read from client: 1 bytes read" \
1266 -s "122 bytes read"
1267
Janos Follathe2681a42016-03-07 15:57:05 +00001268requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001269run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001270 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001271 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1272 request_size=123 force_version=ssl3" \
1273 0 \
1274 -S "Read from client: 123 bytes read" \
1275 -s "Read from client: 1 bytes read" \
1276 -s "122 bytes read"
1277
1278run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001279 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001280 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1281 request_size=123 force_version=tls1" \
1282 0 \
1283 -s "Read from client: 123 bytes read" \
1284 -S "Read from client: 1 bytes read" \
1285 -S "122 bytes read"
1286
1287run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1288 "$P_SRV" \
1289 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1290 request_size=123 force_version=tls1 recsplit=0" \
1291 0 \
1292 -s "Read from client: 123 bytes read" \
1293 -S "Read from client: 1 bytes read" \
1294 -S "122 bytes read"
1295
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001296run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1297 "$P_SRV nbio=2" \
1298 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1299 request_size=123 force_version=tls1" \
1300 0 \
1301 -S "Read from client: 123 bytes read" \
1302 -s "Read from client: 1 bytes read" \
1303 -s "122 bytes read"
1304
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001305# Tests for Session Tickets
1306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001307run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001308 "$P_SRV debug_level=3 tickets=1" \
1309 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001310 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001311 -c "client hello, adding session ticket extension" \
1312 -s "found session ticket extension" \
1313 -s "server hello, adding session ticket extension" \
1314 -c "found session_ticket extension" \
1315 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001316 -S "session successfully restored from cache" \
1317 -s "session successfully restored from ticket" \
1318 -s "a session has been resumed" \
1319 -c "a session has been resumed"
1320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001321run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001322 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1323 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001324 0 \
1325 -c "client hello, adding session ticket extension" \
1326 -s "found session ticket extension" \
1327 -s "server hello, adding session ticket extension" \
1328 -c "found session_ticket extension" \
1329 -c "parse new session ticket" \
1330 -S "session successfully restored from cache" \
1331 -s "session successfully restored from ticket" \
1332 -s "a session has been resumed" \
1333 -c "a session has been resumed"
1334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001335run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001336 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1337 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001338 0 \
1339 -c "client hello, adding session ticket extension" \
1340 -s "found session ticket extension" \
1341 -s "server hello, adding session ticket extension" \
1342 -c "found session_ticket extension" \
1343 -c "parse new session ticket" \
1344 -S "session successfully restored from cache" \
1345 -S "session successfully restored from ticket" \
1346 -S "a session has been resumed" \
1347 -C "a session has been resumed"
1348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001349run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001350 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001351 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001352 0 \
1353 -c "client hello, adding session ticket extension" \
1354 -c "found session_ticket extension" \
1355 -c "parse new session ticket" \
1356 -c "a session has been resumed"
1357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001358run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001359 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001360 "( $O_CLI -sess_out $SESSION; \
1361 $O_CLI -sess_in $SESSION; \
1362 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001363 0 \
1364 -s "found session ticket extension" \
1365 -s "server hello, adding session ticket extension" \
1366 -S "session successfully restored from cache" \
1367 -s "session successfully restored from ticket" \
1368 -s "a session has been resumed"
1369
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001370# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001372run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001373 "$P_SRV debug_level=3 tickets=0" \
1374 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001375 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001376 -c "client hello, adding session ticket extension" \
1377 -s "found session ticket extension" \
1378 -S "server hello, adding session ticket extension" \
1379 -C "found session_ticket extension" \
1380 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001381 -s "session successfully restored from cache" \
1382 -S "session successfully restored from ticket" \
1383 -s "a session has been resumed" \
1384 -c "a session has been resumed"
1385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001386run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001387 "$P_SRV debug_level=3 tickets=1" \
1388 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001389 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001390 -C "client hello, adding session ticket extension" \
1391 -S "found session ticket extension" \
1392 -S "server hello, adding session ticket extension" \
1393 -C "found session_ticket extension" \
1394 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001395 -s "session successfully restored from cache" \
1396 -S "session successfully restored from ticket" \
1397 -s "a session has been resumed" \
1398 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001400run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001401 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1402 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001403 0 \
1404 -S "session successfully restored from cache" \
1405 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001406 -S "a session has been resumed" \
1407 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001410 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1411 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001412 0 \
1413 -s "session successfully restored from cache" \
1414 -S "session successfully restored from ticket" \
1415 -s "a session has been resumed" \
1416 -c "a session has been resumed"
1417
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001418run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001419 "$P_SRV debug_level=3 tickets=0" \
1420 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001421 0 \
1422 -s "session successfully restored from cache" \
1423 -S "session successfully restored from ticket" \
1424 -s "a session has been resumed" \
1425 -c "a session has been resumed"
1426
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001427run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001428 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1429 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001430 0 \
1431 -S "session successfully restored from cache" \
1432 -S "session successfully restored from ticket" \
1433 -S "a session has been resumed" \
1434 -C "a session has been resumed"
1435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001436run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001437 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1438 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001439 0 \
1440 -s "session successfully restored from cache" \
1441 -S "session successfully restored from ticket" \
1442 -s "a session has been resumed" \
1443 -c "a session has been resumed"
1444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001445run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001446 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001447 "( $O_CLI -sess_out $SESSION; \
1448 $O_CLI -sess_in $SESSION; \
1449 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001450 0 \
1451 -s "found session ticket extension" \
1452 -S "server hello, adding session ticket extension" \
1453 -s "session successfully restored from cache" \
1454 -S "session successfully restored from ticket" \
1455 -s "a session has been resumed"
1456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001457run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001458 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001459 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001460 0 \
1461 -C "found session_ticket extension" \
1462 -C "parse new session ticket" \
1463 -c "a session has been resumed"
1464
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001465# Tests for Max Fragment Length extension
1466
Angus Grattonc4dd0732018-04-11 16:28:39 +10001467if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
1468 printf "${CONFIG_H} defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n"
Hanno Becker6428f8d2017-09-22 16:58:50 +01001469 exit 1
1470fi
1471
Angus Grattonc4dd0732018-04-11 16:28:39 +10001472if [ $MAX_CONTENT_LEN -ne 16384 ]; then
1473 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
1474fi
1475
Hanno Becker4aed27e2017-09-18 15:00:34 +01001476requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001477run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001478 "$P_SRV debug_level=3" \
1479 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001480 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001481 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1482 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001483 -C "client hello, adding max_fragment_length extension" \
1484 -S "found max fragment length extension" \
1485 -S "server hello, max_fragment_length extension" \
1486 -C "found max_fragment_length extension"
1487
Hanno Becker4aed27e2017-09-18 15:00:34 +01001488requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001489run_test "Max fragment length: enabled, default, larger message" \
1490 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001491 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001492 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001493 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1494 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +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" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001499 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1500 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001501 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001502
1503requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1504run_test "Max fragment length, DTLS: enabled, default, larger message" \
1505 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001506 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001507 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001508 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1509 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001510 -C "client hello, adding max_fragment_length extension" \
1511 -S "found max fragment length extension" \
1512 -S "server hello, max_fragment_length extension" \
1513 -C "found max_fragment_length extension" \
1514 -c "fragment larger than.*maximum "
1515
Angus Grattonc4dd0732018-04-11 16:28:39 +10001516# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1517# (session fragment length will be 16384 regardless of mbedtls
1518# content length configuration.)
1519
Hanno Beckerc5266962017-09-18 15:01:50 +01001520requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1521run_test "Max fragment length: disabled, larger message" \
1522 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001523 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001524 0 \
1525 -C "Maximum fragment length is 16384" \
1526 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001527 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1528 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001529 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001530
1531requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1532run_test "Max fragment length DTLS: disabled, larger message" \
1533 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001534 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001535 1 \
1536 -C "Maximum fragment length is 16384" \
1537 -S "Maximum fragment length is 16384" \
1538 -c "fragment larger than.*maximum "
1539
1540requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001541run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001542 "$P_SRV debug_level=3" \
1543 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001544 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001545 -c "Maximum fragment length is 4096" \
1546 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001547 -c "client hello, adding max_fragment_length extension" \
1548 -s "found max fragment length extension" \
1549 -s "server hello, max_fragment_length extension" \
1550 -c "found max_fragment_length extension"
1551
Hanno Becker4aed27e2017-09-18 15:00:34 +01001552requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001553run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001554 "$P_SRV debug_level=3 max_frag_len=4096" \
1555 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001556 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001557 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001558 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001559 -C "client hello, adding max_fragment_length extension" \
1560 -S "found max fragment length extension" \
1561 -S "server hello, max_fragment_length extension" \
1562 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001563
Hanno Becker4aed27e2017-09-18 15:00:34 +01001564requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001565requires_gnutls
1566run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001567 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001568 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001569 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001570 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001571 -c "client hello, adding max_fragment_length extension" \
1572 -c "found max_fragment_length extension"
1573
Hanno Becker4aed27e2017-09-18 15:00:34 +01001574requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001575run_test "Max fragment length: client, message just fits" \
1576 "$P_SRV debug_level=3" \
1577 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1578 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001579 -c "Maximum fragment length is 2048" \
1580 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001581 -c "client hello, adding max_fragment_length extension" \
1582 -s "found max fragment length extension" \
1583 -s "server hello, max_fragment_length extension" \
1584 -c "found max_fragment_length extension" \
1585 -c "2048 bytes written in 1 fragments" \
1586 -s "2048 bytes read"
1587
Hanno Becker4aed27e2017-09-18 15:00:34 +01001588requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001589run_test "Max fragment length: client, larger message" \
1590 "$P_SRV debug_level=3" \
1591 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1592 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001593 -c "Maximum fragment length is 2048" \
1594 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001595 -c "client hello, adding max_fragment_length extension" \
1596 -s "found max fragment length extension" \
1597 -s "server hello, max_fragment_length extension" \
1598 -c "found max_fragment_length extension" \
1599 -c "2345 bytes written in 2 fragments" \
1600 -s "2048 bytes read" \
1601 -s "297 bytes read"
1602
Hanno Becker4aed27e2017-09-18 15:00:34 +01001603requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001604run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001605 "$P_SRV debug_level=3 dtls=1" \
1606 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1607 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001608 -c "Maximum fragment length is 2048" \
1609 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001610 -c "client hello, adding max_fragment_length extension" \
1611 -s "found max fragment length extension" \
1612 -s "server hello, max_fragment_length extension" \
1613 -c "found max_fragment_length extension" \
1614 -c "fragment larger than.*maximum"
1615
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001616# Tests for renegotiation
1617
Hanno Becker6a243642017-10-12 15:18:45 +01001618# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001619run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001620 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001621 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001622 0 \
1623 -C "client hello, adding renegotiation extension" \
1624 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1625 -S "found renegotiation extension" \
1626 -s "server hello, secure renegotiation extension" \
1627 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001628 -C "=> renegotiate" \
1629 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001630 -S "write hello request"
1631
Hanno Becker6a243642017-10-12 15:18:45 +01001632requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001633run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001634 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001635 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001636 0 \
1637 -c "client hello, adding renegotiation extension" \
1638 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1639 -s "found renegotiation extension" \
1640 -s "server hello, secure renegotiation extension" \
1641 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001642 -c "=> renegotiate" \
1643 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001644 -S "write hello request"
1645
Hanno Becker6a243642017-10-12 15:18:45 +01001646requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001647run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001648 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001649 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001650 0 \
1651 -c "client hello, adding renegotiation extension" \
1652 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1653 -s "found renegotiation extension" \
1654 -s "server hello, secure renegotiation extension" \
1655 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001656 -c "=> renegotiate" \
1657 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001658 -s "write hello request"
1659
Janos Follathb0f148c2017-10-05 12:29:42 +01001660# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1661# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1662# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001663requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001664run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1665 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1666 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1667 0 \
1668 -c "client hello, adding renegotiation extension" \
1669 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1670 -s "found renegotiation extension" \
1671 -s "server hello, secure renegotiation extension" \
1672 -c "found renegotiation extension" \
1673 -c "=> renegotiate" \
1674 -s "=> renegotiate" \
1675 -S "write hello request" \
1676 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1677
1678# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1679# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1680# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001681requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001682run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1683 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1684 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1685 0 \
1686 -c "client hello, adding renegotiation extension" \
1687 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1688 -s "found renegotiation extension" \
1689 -s "server hello, secure renegotiation extension" \
1690 -c "found renegotiation extension" \
1691 -c "=> renegotiate" \
1692 -s "=> renegotiate" \
1693 -s "write hello request" \
1694 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1695
Hanno Becker6a243642017-10-12 15:18:45 +01001696requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001697run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001698 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001699 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001700 0 \
1701 -c "client hello, adding renegotiation extension" \
1702 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1703 -s "found renegotiation extension" \
1704 -s "server hello, secure renegotiation extension" \
1705 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001706 -c "=> renegotiate" \
1707 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001708 -s "write hello request"
1709
Hanno Becker6a243642017-10-12 15:18:45 +01001710requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001711run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001712 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001713 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001714 1 \
1715 -c "client hello, adding renegotiation extension" \
1716 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1717 -S "found renegotiation extension" \
1718 -s "server hello, secure renegotiation extension" \
1719 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001720 -c "=> renegotiate" \
1721 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001722 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001723 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001724 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001725
Hanno Becker6a243642017-10-12 15:18:45 +01001726requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001727run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001728 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 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é-Gonnard780d6712014-02-20 17:19:59 +01001730 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" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001736 -C "=> renegotiate" \
1737 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001738 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001739 -S "SSL - An unexpected message was received from our peer" \
1740 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001741
Hanno Becker6a243642017-10-12 15:18:45 +01001742requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001743run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001744 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001745 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001746 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001747 0 \
1748 -C "client hello, adding renegotiation extension" \
1749 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1750 -S "found renegotiation extension" \
1751 -s "server hello, secure renegotiation extension" \
1752 -c "found renegotiation extension" \
1753 -C "=> renegotiate" \
1754 -S "=> renegotiate" \
1755 -s "write hello request" \
1756 -S "SSL - An unexpected message was received from our peer" \
1757 -S "failed"
1758
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001759# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001760requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001761run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001762 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001763 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001764 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001765 0 \
1766 -C "client hello, adding renegotiation extension" \
1767 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1768 -S "found renegotiation extension" \
1769 -s "server hello, secure renegotiation extension" \
1770 -c "found renegotiation extension" \
1771 -C "=> renegotiate" \
1772 -S "=> renegotiate" \
1773 -s "write hello request" \
1774 -S "SSL - An unexpected message was received from our peer" \
1775 -S "failed"
1776
Hanno Becker6a243642017-10-12 15:18:45 +01001777requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001778run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001779 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001780 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001781 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001782 0 \
1783 -C "client hello, adding renegotiation extension" \
1784 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1785 -S "found renegotiation extension" \
1786 -s "server hello, secure renegotiation extension" \
1787 -c "found renegotiation extension" \
1788 -C "=> renegotiate" \
1789 -S "=> renegotiate" \
1790 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001791 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001792
Hanno Becker6a243642017-10-12 15:18:45 +01001793requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001794run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001795 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001796 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001797 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001798 0 \
1799 -c "client hello, adding renegotiation extension" \
1800 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1801 -s "found renegotiation extension" \
1802 -s "server hello, secure renegotiation extension" \
1803 -c "found renegotiation extension" \
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, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001812 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001813 "$P_CLI debug_level=3 exchanges=2 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
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001827# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001828requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001829run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001830 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001831 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001832 0 \
1833 -c "client hello, adding renegotiation extension" \
1834 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1835 -s "found renegotiation extension" \
1836 -s "server hello, secure renegotiation extension" \
1837 -c "found renegotiation extension" \
1838 -s "record counter limit reached: renegotiate" \
1839 -c "=> renegotiate" \
1840 -s "=> renegotiate" \
1841 -s "write hello request" \
1842 -S "SSL - An unexpected message was received from our peer" \
1843 -S "failed"
1844
Hanno Becker6a243642017-10-12 15:18:45 +01001845requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001846run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001847 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001848 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001849 0 \
1850 -c "client hello, adding renegotiation extension" \
1851 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1852 -s "found renegotiation extension" \
1853 -s "server hello, secure renegotiation extension" \
1854 -c "found renegotiation extension" \
1855 -s "record counter limit reached: renegotiate" \
1856 -c "=> renegotiate" \
1857 -s "=> renegotiate" \
1858 -s "write hello request" \
1859 -S "SSL - An unexpected message was received from our peer" \
1860 -S "failed"
1861
Hanno Becker6a243642017-10-12 15:18:45 +01001862requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001863run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001864 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001865 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1866 0 \
1867 -C "client hello, adding renegotiation extension" \
1868 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1869 -S "found renegotiation extension" \
1870 -s "server hello, secure renegotiation extension" \
1871 -c "found renegotiation extension" \
1872 -S "record counter limit reached: renegotiate" \
1873 -C "=> renegotiate" \
1874 -S "=> renegotiate" \
1875 -S "write hello request" \
1876 -S "SSL - An unexpected message was received from our peer" \
1877 -S "failed"
1878
Hanno Becker6a243642017-10-12 15:18:45 +01001879requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001880run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001881 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001882 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001883 0 \
1884 -c "client hello, adding renegotiation extension" \
1885 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1886 -s "found renegotiation extension" \
1887 -s "server hello, secure renegotiation extension" \
1888 -c "found renegotiation extension" \
1889 -c "=> renegotiate" \
1890 -s "=> renegotiate" \
1891 -S "write hello request"
1892
Hanno Becker6a243642017-10-12 15:18:45 +01001893requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001894run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001895 "$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 +02001896 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001897 0 \
1898 -c "client hello, adding renegotiation extension" \
1899 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1900 -s "found renegotiation extension" \
1901 -s "server hello, secure renegotiation extension" \
1902 -c "found renegotiation extension" \
1903 -c "=> renegotiate" \
1904 -s "=> renegotiate" \
1905 -s "write hello request"
1906
Hanno Becker6a243642017-10-12 15:18:45 +01001907requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001908run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001909 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001910 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001911 0 \
1912 -c "client hello, adding renegotiation extension" \
1913 -c "found renegotiation extension" \
1914 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001915 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001916 -C "error" \
1917 -c "HTTP/1.0 200 [Oo][Kk]"
1918
Paul Bakker539d9722015-02-08 16:18:35 +01001919requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001920requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001921run_test "Renegotiation: gnutls server strict, client-initiated" \
1922 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001923 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001924 0 \
1925 -c "client hello, adding renegotiation extension" \
1926 -c "found renegotiation extension" \
1927 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001928 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001929 -C "error" \
1930 -c "HTTP/1.0 200 [Oo][Kk]"
1931
Paul Bakker539d9722015-02-08 16:18:35 +01001932requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001933requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001934run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1935 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1936 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1937 1 \
1938 -c "client hello, adding renegotiation extension" \
1939 -C "found renegotiation extension" \
1940 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001941 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001942 -c "error" \
1943 -C "HTTP/1.0 200 [Oo][Kk]"
1944
Paul Bakker539d9722015-02-08 16:18:35 +01001945requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001946requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001947run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1948 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1949 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1950 allow_legacy=0" \
1951 1 \
1952 -c "client hello, adding renegotiation extension" \
1953 -C "found renegotiation extension" \
1954 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001955 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001956 -c "error" \
1957 -C "HTTP/1.0 200 [Oo][Kk]"
1958
Paul Bakker539d9722015-02-08 16:18:35 +01001959requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001960requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001961run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1962 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1963 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1964 allow_legacy=1" \
1965 0 \
1966 -c "client hello, adding renegotiation extension" \
1967 -C "found renegotiation extension" \
1968 -c "=> renegotiate" \
1969 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001970 -C "error" \
1971 -c "HTTP/1.0 200 [Oo][Kk]"
1972
Hanno Becker6a243642017-10-12 15:18:45 +01001973requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001974run_test "Renegotiation: DTLS, client-initiated" \
1975 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1976 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1977 0 \
1978 -c "client hello, adding renegotiation extension" \
1979 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1980 -s "found renegotiation extension" \
1981 -s "server hello, secure renegotiation extension" \
1982 -c "found renegotiation extension" \
1983 -c "=> renegotiate" \
1984 -s "=> renegotiate" \
1985 -S "write hello request"
1986
Hanno Becker6a243642017-10-12 15:18:45 +01001987requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001988run_test "Renegotiation: DTLS, server-initiated" \
1989 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001990 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1991 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001992 0 \
1993 -c "client hello, adding renegotiation extension" \
1994 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1995 -s "found renegotiation extension" \
1996 -s "server hello, secure renegotiation extension" \
1997 -c "found renegotiation extension" \
1998 -c "=> renegotiate" \
1999 -s "=> renegotiate" \
2000 -s "write hello request"
2001
Hanno Becker6a243642017-10-12 15:18:45 +01002002requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002003run_test "Renegotiation: DTLS, renego_period overflow" \
2004 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2005 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2006 0 \
2007 -c "client hello, adding renegotiation extension" \
2008 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2009 -s "found renegotiation extension" \
2010 -s "server hello, secure renegotiation extension" \
2011 -s "record counter limit reached: renegotiate" \
2012 -c "=> renegotiate" \
2013 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002014 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002015
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002016requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002017requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002018run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2019 "$G_SRV -u --mtu 4096" \
2020 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2021 0 \
2022 -c "client hello, adding renegotiation extension" \
2023 -c "found renegotiation extension" \
2024 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002025 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002026 -C "error" \
2027 -s "Extra-header:"
2028
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002029# Test for the "secure renegotation" extension only (no actual renegotiation)
2030
Paul Bakker539d9722015-02-08 16:18:35 +01002031requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002032run_test "Renego ext: gnutls server strict, client default" \
2033 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2034 "$P_CLI debug_level=3" \
2035 0 \
2036 -c "found renegotiation extension" \
2037 -C "error" \
2038 -c "HTTP/1.0 200 [Oo][Kk]"
2039
Paul Bakker539d9722015-02-08 16:18:35 +01002040requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002041run_test "Renego ext: gnutls server unsafe, client default" \
2042 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2043 "$P_CLI debug_level=3" \
2044 0 \
2045 -C "found renegotiation extension" \
2046 -C "error" \
2047 -c "HTTP/1.0 200 [Oo][Kk]"
2048
Paul Bakker539d9722015-02-08 16:18:35 +01002049requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002050run_test "Renego ext: gnutls server unsafe, client break legacy" \
2051 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2052 "$P_CLI debug_level=3 allow_legacy=-1" \
2053 1 \
2054 -C "found renegotiation extension" \
2055 -c "error" \
2056 -C "HTTP/1.0 200 [Oo][Kk]"
2057
Paul Bakker539d9722015-02-08 16:18:35 +01002058requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002059run_test "Renego ext: gnutls client strict, server default" \
2060 "$P_SRV debug_level=3" \
2061 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2062 0 \
2063 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2064 -s "server hello, secure renegotiation extension"
2065
Paul Bakker539d9722015-02-08 16:18:35 +01002066requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002067run_test "Renego ext: gnutls client unsafe, server default" \
2068 "$P_SRV debug_level=3" \
2069 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2070 0 \
2071 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2072 -S "server hello, secure renegotiation extension"
2073
Paul Bakker539d9722015-02-08 16:18:35 +01002074requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002075run_test "Renego ext: gnutls client unsafe, server break legacy" \
2076 "$P_SRV debug_level=3 allow_legacy=-1" \
2077 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2078 1 \
2079 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2080 -S "server hello, secure renegotiation extension"
2081
Janos Follath0b242342016-02-17 10:11:21 +00002082# Tests for silently dropping trailing extra bytes in .der certificates
2083
2084requires_gnutls
2085run_test "DER format: no trailing bytes" \
2086 "$P_SRV crt_file=data_files/server5-der0.crt \
2087 key_file=data_files/server5.key" \
2088 "$G_CLI " \
2089 0 \
2090 -c "Handshake was completed" \
2091
2092requires_gnutls
2093run_test "DER format: with a trailing zero byte" \
2094 "$P_SRV crt_file=data_files/server5-der1a.crt \
2095 key_file=data_files/server5.key" \
2096 "$G_CLI " \
2097 0 \
2098 -c "Handshake was completed" \
2099
2100requires_gnutls
2101run_test "DER format: with a trailing random byte" \
2102 "$P_SRV crt_file=data_files/server5-der1b.crt \
2103 key_file=data_files/server5.key" \
2104 "$G_CLI " \
2105 0 \
2106 -c "Handshake was completed" \
2107
2108requires_gnutls
2109run_test "DER format: with 2 trailing random bytes" \
2110 "$P_SRV crt_file=data_files/server5-der2.crt \
2111 key_file=data_files/server5.key" \
2112 "$G_CLI " \
2113 0 \
2114 -c "Handshake was completed" \
2115
2116requires_gnutls
2117run_test "DER format: with 4 trailing random bytes" \
2118 "$P_SRV crt_file=data_files/server5-der4.crt \
2119 key_file=data_files/server5.key" \
2120 "$G_CLI " \
2121 0 \
2122 -c "Handshake was completed" \
2123
2124requires_gnutls
2125run_test "DER format: with 8 trailing random bytes" \
2126 "$P_SRV crt_file=data_files/server5-der8.crt \
2127 key_file=data_files/server5.key" \
2128 "$G_CLI " \
2129 0 \
2130 -c "Handshake was completed" \
2131
2132requires_gnutls
2133run_test "DER format: with 9 trailing random bytes" \
2134 "$P_SRV crt_file=data_files/server5-der9.crt \
2135 key_file=data_files/server5.key" \
2136 "$G_CLI " \
2137 0 \
2138 -c "Handshake was completed" \
2139
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002140# Tests for auth_mode
2141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002142run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002143 "$P_SRV crt_file=data_files/server5-badsign.crt \
2144 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002145 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002146 1 \
2147 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002148 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002149 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002150 -c "X509 - Certificate verification failed"
2151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002152run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002153 "$P_SRV crt_file=data_files/server5-badsign.crt \
2154 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002155 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002156 0 \
2157 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002158 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002159 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002160 -C "X509 - Certificate verification failed"
2161
Hanno Beckere6706e62017-05-15 16:05:15 +01002162run_test "Authentication: server goodcert, client optional, no trusted CA" \
2163 "$P_SRV" \
2164 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2165 0 \
2166 -c "x509_verify_cert() returned" \
2167 -c "! The certificate is not correctly signed by the trusted CA" \
2168 -c "! Certificate verification flags"\
2169 -C "! mbedtls_ssl_handshake returned" \
2170 -C "X509 - Certificate verification failed" \
2171 -C "SSL - No CA Chain is set, but required to operate"
2172
2173run_test "Authentication: server goodcert, client required, no trusted CA" \
2174 "$P_SRV" \
2175 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2176 1 \
2177 -c "x509_verify_cert() returned" \
2178 -c "! The certificate is not correctly signed by the trusted CA" \
2179 -c "! Certificate verification flags"\
2180 -c "! mbedtls_ssl_handshake returned" \
2181 -c "SSL - No CA Chain is set, but required to operate"
2182
2183# The purpose of the next two tests is to test the client's behaviour when receiving a server
2184# certificate with an unsupported elliptic curve. This should usually not happen because
2185# the client informs the server about the supported curves - it does, though, in the
2186# corner case of a static ECDH suite, because the server doesn't check the curve on that
2187# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2188# different means to have the server ignoring the client's supported curve list.
2189
2190requires_config_enabled MBEDTLS_ECP_C
2191run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2192 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2193 crt_file=data_files/server5.ku-ka.crt" \
2194 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2195 1 \
2196 -c "bad certificate (EC key curve)"\
2197 -c "! Certificate verification flags"\
2198 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2199
2200requires_config_enabled MBEDTLS_ECP_C
2201run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2202 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2203 crt_file=data_files/server5.ku-ka.crt" \
2204 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2205 1 \
2206 -c "bad certificate (EC key curve)"\
2207 -c "! Certificate verification flags"\
2208 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2209
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002210run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002211 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002212 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002213 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002214 0 \
2215 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002216 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002217 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002218 -C "X509 - Certificate verification failed"
2219
Simon Butcher99000142016-10-13 17:21:01 +01002220run_test "Authentication: client SHA256, server required" \
2221 "$P_SRV auth_mode=required" \
2222 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2223 key_file=data_files/server6.key \
2224 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2225 0 \
2226 -c "Supported Signature Algorithm found: 4," \
2227 -c "Supported Signature Algorithm found: 5,"
2228
2229run_test "Authentication: client SHA384, server required" \
2230 "$P_SRV auth_mode=required" \
2231 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2232 key_file=data_files/server6.key \
2233 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2234 0 \
2235 -c "Supported Signature Algorithm found: 4," \
2236 -c "Supported Signature Algorithm found: 5,"
2237
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002238requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2239run_test "Authentication: client has no cert, server required (SSLv3)" \
2240 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2241 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
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 "got no certificate to send" \
2248 -S "x509_verify_cert() returned" \
2249 -s "client has no certificate" \
2250 -s "! mbedtls_ssl_handshake returned" \
2251 -c "! mbedtls_ssl_handshake returned" \
2252 -s "No client certification received from the client, but required by the authentication mode"
2253
2254run_test "Authentication: client has no cert, server required (TLS)" \
2255 "$P_SRV debug_level=3 auth_mode=required" \
2256 "$P_CLI debug_level=3 crt_file=none \
2257 key_file=data_files/server5.key" \
2258 1 \
2259 -S "skip write certificate request" \
2260 -C "skip parse certificate request" \
2261 -c "got a certificate request" \
2262 -c "= write certificate$" \
2263 -C "skip write certificate$" \
2264 -S "x509_verify_cert() returned" \
2265 -s "client has no certificate" \
2266 -s "! mbedtls_ssl_handshake returned" \
2267 -c "! mbedtls_ssl_handshake returned" \
2268 -s "No client certification received from the client, but required by the authentication mode"
2269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002270run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002271 "$P_SRV debug_level=3 auth_mode=required" \
2272 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002273 key_file=data_files/server5.key" \
2274 1 \
2275 -S "skip write certificate request" \
2276 -C "skip parse certificate request" \
2277 -c "got a certificate request" \
2278 -C "skip write certificate" \
2279 -C "skip write certificate verify" \
2280 -S "skip parse certificate verify" \
2281 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002282 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002283 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002284 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002285 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002286 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002287# We don't check that the client receives the alert because it might
2288# detect that its write end of the connection is closed and abort
2289# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002290
Janos Follath89baba22017-04-10 14:34:35 +01002291run_test "Authentication: client cert not trusted, server required" \
2292 "$P_SRV debug_level=3 auth_mode=required" \
2293 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2294 key_file=data_files/server5.key" \
2295 1 \
2296 -S "skip write certificate request" \
2297 -C "skip parse certificate request" \
2298 -c "got a certificate request" \
2299 -C "skip write certificate" \
2300 -C "skip write certificate verify" \
2301 -S "skip parse certificate verify" \
2302 -s "x509_verify_cert() returned" \
2303 -s "! The certificate is not correctly signed by the trusted CA" \
2304 -s "! mbedtls_ssl_handshake returned" \
2305 -c "! mbedtls_ssl_handshake returned" \
2306 -s "X509 - Certificate verification failed"
2307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002308run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002309 "$P_SRV debug_level=3 auth_mode=optional" \
2310 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002311 key_file=data_files/server5.key" \
2312 0 \
2313 -S "skip write certificate request" \
2314 -C "skip parse certificate request" \
2315 -c "got a certificate request" \
2316 -C "skip write certificate" \
2317 -C "skip write certificate verify" \
2318 -S "skip parse certificate verify" \
2319 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002320 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002321 -S "! mbedtls_ssl_handshake returned" \
2322 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002323 -S "X509 - Certificate verification failed"
2324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002325run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002326 "$P_SRV debug_level=3 auth_mode=none" \
2327 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002328 key_file=data_files/server5.key" \
2329 0 \
2330 -s "skip write certificate request" \
2331 -C "skip parse certificate request" \
2332 -c "got no certificate request" \
2333 -c "skip write certificate" \
2334 -c "skip write certificate verify" \
2335 -s "skip parse certificate verify" \
2336 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002337 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002338 -S "! mbedtls_ssl_handshake returned" \
2339 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002340 -S "X509 - Certificate verification failed"
2341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002342run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002343 "$P_SRV debug_level=3 auth_mode=optional" \
2344 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002345 0 \
2346 -S "skip write certificate request" \
2347 -C "skip parse certificate request" \
2348 -c "got a certificate request" \
2349 -C "skip write certificate$" \
2350 -C "got no certificate to send" \
2351 -S "SSLv3 client has no certificate" \
2352 -c "skip write certificate verify" \
2353 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002354 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002355 -S "! mbedtls_ssl_handshake returned" \
2356 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002357 -S "X509 - Certificate verification failed"
2358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002359run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002360 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002361 "$O_CLI" \
2362 0 \
2363 -S "skip write certificate request" \
2364 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002365 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002366 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002367 -S "X509 - Certificate verification failed"
2368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002369run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002370 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002371 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002372 0 \
2373 -C "skip parse certificate request" \
2374 -c "got a certificate request" \
2375 -C "skip write certificate$" \
2376 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002377 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002378
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002379run_test "Authentication: client no cert, openssl server required" \
2380 "$O_SRV -Verify 10" \
2381 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2382 1 \
2383 -C "skip parse certificate request" \
2384 -c "got a certificate request" \
2385 -C "skip write certificate$" \
2386 -c "skip write certificate verify" \
2387 -c "! mbedtls_ssl_handshake returned"
2388
Janos Follathe2681a42016-03-07 15:57:05 +00002389requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002390run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002391 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002392 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002393 0 \
2394 -S "skip write certificate request" \
2395 -C "skip parse certificate request" \
2396 -c "got a certificate request" \
2397 -C "skip write certificate$" \
2398 -c "skip write certificate verify" \
2399 -c "got no certificate to send" \
2400 -s "SSLv3 client has no certificate" \
2401 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002402 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002403 -S "! mbedtls_ssl_handshake returned" \
2404 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002405 -S "X509 - Certificate verification failed"
2406
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002407# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2408# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002409
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002410MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002411MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002412
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002413if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002414 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002415 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002416 printf "test value of ${MAX_IM_CA}. \n"
2417 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002418 printf "The tests assume this value and if it changes, the tests in this\n"
2419 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002420 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002421
2422 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002423fi
2424
Angus Grattonc4dd0732018-04-11 16:28:39 +10002425requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002426run_test "Authentication: server max_int chain, client default" \
2427 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2428 key_file=data_files/dir-maxpath/09.key" \
2429 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2430 0 \
2431 -C "X509 - A fatal error occured"
2432
Angus Grattonc4dd0732018-04-11 16:28:39 +10002433requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002434run_test "Authentication: server max_int+1 chain, client default" \
2435 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2436 key_file=data_files/dir-maxpath/10.key" \
2437 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2438 1 \
2439 -c "X509 - A fatal error occured"
2440
Angus Grattonc4dd0732018-04-11 16:28:39 +10002441requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002442run_test "Authentication: server max_int+1 chain, client optional" \
2443 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2444 key_file=data_files/dir-maxpath/10.key" \
2445 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2446 auth_mode=optional" \
2447 1 \
2448 -c "X509 - A fatal error occured"
2449
Angus Grattonc4dd0732018-04-11 16:28:39 +10002450requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002451run_test "Authentication: server max_int+1 chain, client none" \
2452 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2453 key_file=data_files/dir-maxpath/10.key" \
2454 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2455 auth_mode=none" \
2456 0 \
2457 -C "X509 - A fatal error occured"
2458
Angus Grattonc4dd0732018-04-11 16:28:39 +10002459requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002460run_test "Authentication: client max_int+1 chain, server default" \
2461 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2462 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2463 key_file=data_files/dir-maxpath/10.key" \
2464 0 \
2465 -S "X509 - A fatal error occured"
2466
Angus Grattonc4dd0732018-04-11 16:28:39 +10002467requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002468run_test "Authentication: client max_int+1 chain, server optional" \
2469 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2470 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2471 key_file=data_files/dir-maxpath/10.key" \
2472 1 \
2473 -s "X509 - A fatal error occured"
2474
Angus Grattonc4dd0732018-04-11 16:28:39 +10002475requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002476run_test "Authentication: client max_int+1 chain, server required" \
2477 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2478 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2479 key_file=data_files/dir-maxpath/10.key" \
2480 1 \
2481 -s "X509 - A fatal error occured"
2482
Angus Grattonc4dd0732018-04-11 16:28:39 +10002483requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002484run_test "Authentication: client max_int chain, server required" \
2485 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2486 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2487 key_file=data_files/dir-maxpath/09.key" \
2488 0 \
2489 -S "X509 - A fatal error occured"
2490
Janos Follath89baba22017-04-10 14:34:35 +01002491# Tests for CA list in CertificateRequest messages
2492
2493run_test "Authentication: send CA list in CertificateRequest (default)" \
2494 "$P_SRV debug_level=3 auth_mode=required" \
2495 "$P_CLI crt_file=data_files/server6.crt \
2496 key_file=data_files/server6.key" \
2497 0 \
2498 -s "requested DN"
2499
2500run_test "Authentication: do not send CA list in CertificateRequest" \
2501 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2502 "$P_CLI crt_file=data_files/server6.crt \
2503 key_file=data_files/server6.key" \
2504 0 \
2505 -S "requested DN"
2506
2507run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2508 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2509 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2510 key_file=data_files/server5.key" \
2511 1 \
2512 -S "requested DN" \
2513 -s "x509_verify_cert() returned" \
2514 -s "! The certificate is not correctly signed by the trusted CA" \
2515 -s "! mbedtls_ssl_handshake returned" \
2516 -c "! mbedtls_ssl_handshake returned" \
2517 -s "X509 - Certificate verification failed"
2518
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002519# Tests for certificate selection based on SHA verson
2520
2521run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2522 "$P_SRV crt_file=data_files/server5.crt \
2523 key_file=data_files/server5.key \
2524 crt_file2=data_files/server5-sha1.crt \
2525 key_file2=data_files/server5.key" \
2526 "$P_CLI force_version=tls1_2" \
2527 0 \
2528 -c "signed using.*ECDSA with SHA256" \
2529 -C "signed using.*ECDSA with SHA1"
2530
2531run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2532 "$P_SRV crt_file=data_files/server5.crt \
2533 key_file=data_files/server5.key \
2534 crt_file2=data_files/server5-sha1.crt \
2535 key_file2=data_files/server5.key" \
2536 "$P_CLI force_version=tls1_1" \
2537 0 \
2538 -C "signed using.*ECDSA with SHA256" \
2539 -c "signed using.*ECDSA with SHA1"
2540
2541run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2542 "$P_SRV crt_file=data_files/server5.crt \
2543 key_file=data_files/server5.key \
2544 crt_file2=data_files/server5-sha1.crt \
2545 key_file2=data_files/server5.key" \
2546 "$P_CLI force_version=tls1" \
2547 0 \
2548 -C "signed using.*ECDSA with SHA256" \
2549 -c "signed using.*ECDSA with SHA1"
2550
2551run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2552 "$P_SRV crt_file=data_files/server5.crt \
2553 key_file=data_files/server5.key \
2554 crt_file2=data_files/server6.crt \
2555 key_file2=data_files/server6.key" \
2556 "$P_CLI force_version=tls1_1" \
2557 0 \
2558 -c "serial number.*09" \
2559 -c "signed using.*ECDSA with SHA256" \
2560 -C "signed using.*ECDSA with SHA1"
2561
2562run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2563 "$P_SRV crt_file=data_files/server6.crt \
2564 key_file=data_files/server6.key \
2565 crt_file2=data_files/server5.crt \
2566 key_file2=data_files/server5.key" \
2567 "$P_CLI force_version=tls1_1" \
2568 0 \
2569 -c "serial number.*0A" \
2570 -c "signed using.*ECDSA with SHA256" \
2571 -C "signed using.*ECDSA with SHA1"
2572
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002573# tests for SNI
2574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002576 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002577 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002578 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002579 0 \
2580 -S "parse ServerName extension" \
2581 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2582 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002584run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002585 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002586 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002587 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 +02002588 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002589 0 \
2590 -s "parse ServerName extension" \
2591 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2592 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002594run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002595 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002596 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002597 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 +02002598 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002599 0 \
2600 -s "parse ServerName extension" \
2601 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2602 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002604run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002605 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002606 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002607 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 +02002608 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002609 1 \
2610 -s "parse ServerName extension" \
2611 -s "ssl_sni_wrapper() returned" \
2612 -s "mbedtls_ssl_handshake returned" \
2613 -c "mbedtls_ssl_handshake returned" \
2614 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002615
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002616run_test "SNI: client auth no override: optional" \
2617 "$P_SRV debug_level=3 auth_mode=optional \
2618 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2619 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2620 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002621 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002622 -S "skip write certificate request" \
2623 -C "skip parse certificate request" \
2624 -c "got a certificate request" \
2625 -C "skip write certificate" \
2626 -C "skip write certificate verify" \
2627 -S "skip parse certificate verify"
2628
2629run_test "SNI: client auth override: none -> optional" \
2630 "$P_SRV debug_level=3 auth_mode=none \
2631 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2632 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2633 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002634 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002635 -S "skip write certificate request" \
2636 -C "skip parse certificate request" \
2637 -c "got a certificate request" \
2638 -C "skip write certificate" \
2639 -C "skip write certificate verify" \
2640 -S "skip parse certificate verify"
2641
2642run_test "SNI: client auth override: optional -> none" \
2643 "$P_SRV debug_level=3 auth_mode=optional \
2644 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2645 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2646 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002647 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002648 -s "skip write certificate request" \
2649 -C "skip parse certificate request" \
2650 -c "got no certificate request" \
2651 -c "skip write certificate" \
2652 -c "skip write certificate verify" \
2653 -s "skip parse certificate verify"
2654
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002655run_test "SNI: CA no override" \
2656 "$P_SRV debug_level=3 auth_mode=optional \
2657 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2658 ca_file=data_files/test-ca.crt \
2659 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2660 "$P_CLI debug_level=3 server_name=localhost \
2661 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2662 1 \
2663 -S "skip write certificate request" \
2664 -C "skip parse certificate request" \
2665 -c "got a certificate request" \
2666 -C "skip write certificate" \
2667 -C "skip write certificate verify" \
2668 -S "skip parse certificate verify" \
2669 -s "x509_verify_cert() returned" \
2670 -s "! The certificate is not correctly signed by the trusted CA" \
2671 -S "The certificate has been revoked (is on a CRL)"
2672
2673run_test "SNI: CA override" \
2674 "$P_SRV debug_level=3 auth_mode=optional \
2675 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2676 ca_file=data_files/test-ca.crt \
2677 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2678 "$P_CLI debug_level=3 server_name=localhost \
2679 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2680 0 \
2681 -S "skip write certificate request" \
2682 -C "skip parse certificate request" \
2683 -c "got a certificate request" \
2684 -C "skip write certificate" \
2685 -C "skip write certificate verify" \
2686 -S "skip parse certificate verify" \
2687 -S "x509_verify_cert() returned" \
2688 -S "! The certificate is not correctly signed by the trusted CA" \
2689 -S "The certificate has been revoked (is on a CRL)"
2690
2691run_test "SNI: CA override with CRL" \
2692 "$P_SRV debug_level=3 auth_mode=optional \
2693 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2694 ca_file=data_files/test-ca.crt \
2695 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2696 "$P_CLI debug_level=3 server_name=localhost \
2697 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2698 1 \
2699 -S "skip write certificate request" \
2700 -C "skip parse certificate request" \
2701 -c "got a certificate request" \
2702 -C "skip write certificate" \
2703 -C "skip write certificate verify" \
2704 -S "skip parse certificate verify" \
2705 -s "x509_verify_cert() returned" \
2706 -S "! The certificate is not correctly signed by the trusted CA" \
2707 -s "The certificate has been revoked (is on a CRL)"
2708
Andres AG1a834452016-12-07 10:01:30 +00002709# Tests for SNI and DTLS
2710
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002711run_test "SNI: DTLS, no SNI callback" \
2712 "$P_SRV debug_level=3 dtls=1 \
2713 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2714 "$P_CLI server_name=localhost dtls=1" \
2715 0 \
2716 -S "parse ServerName extension" \
2717 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2718 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2719
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002720run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00002721 "$P_SRV debug_level=3 dtls=1 \
2722 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2723 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2724 "$P_CLI server_name=localhost dtls=1" \
2725 0 \
2726 -s "parse ServerName extension" \
2727 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2728 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2729
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002730run_test "SNI: DTLS, matching cert 2" \
2731 "$P_SRV debug_level=3 dtls=1 \
2732 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2733 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2734 "$P_CLI server_name=polarssl.example dtls=1" \
2735 0 \
2736 -s "parse ServerName extension" \
2737 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2738 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2739
2740run_test "SNI: DTLS, no matching cert" \
2741 "$P_SRV debug_level=3 dtls=1 \
2742 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2743 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2744 "$P_CLI server_name=nonesuch.example dtls=1" \
2745 1 \
2746 -s "parse ServerName extension" \
2747 -s "ssl_sni_wrapper() returned" \
2748 -s "mbedtls_ssl_handshake returned" \
2749 -c "mbedtls_ssl_handshake returned" \
2750 -c "SSL - A fatal alert message was received from our peer"
2751
2752run_test "SNI: DTLS, client auth no override: optional" \
2753 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2754 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2755 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2756 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2757 0 \
2758 -S "skip write certificate request" \
2759 -C "skip parse certificate request" \
2760 -c "got a certificate request" \
2761 -C "skip write certificate" \
2762 -C "skip write certificate verify" \
2763 -S "skip parse certificate verify"
2764
2765run_test "SNI: DTLS, client auth override: none -> optional" \
2766 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2767 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2768 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2769 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2770 0 \
2771 -S "skip write certificate request" \
2772 -C "skip parse certificate request" \
2773 -c "got a certificate request" \
2774 -C "skip write certificate" \
2775 -C "skip write certificate verify" \
2776 -S "skip parse certificate verify"
2777
2778run_test "SNI: DTLS, client auth override: optional -> none" \
2779 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2780 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2781 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2782 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2783 0 \
2784 -s "skip write certificate request" \
2785 -C "skip parse certificate request" \
2786 -c "got no certificate request" \
2787 -c "skip write certificate" \
2788 -c "skip write certificate verify" \
2789 -s "skip parse certificate verify"
2790
2791run_test "SNI: DTLS, CA no override" \
2792 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2793 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2794 ca_file=data_files/test-ca.crt \
2795 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2796 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2797 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2798 1 \
2799 -S "skip write certificate request" \
2800 -C "skip parse certificate request" \
2801 -c "got a certificate request" \
2802 -C "skip write certificate" \
2803 -C "skip write certificate verify" \
2804 -S "skip parse certificate verify" \
2805 -s "x509_verify_cert() returned" \
2806 -s "! The certificate is not correctly signed by the trusted CA" \
2807 -S "The certificate has been revoked (is on a CRL)"
2808
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002809run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00002810 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2811 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2812 ca_file=data_files/test-ca.crt \
2813 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2814 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2815 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2816 0 \
2817 -S "skip write certificate request" \
2818 -C "skip parse certificate request" \
2819 -c "got a certificate request" \
2820 -C "skip write certificate" \
2821 -C "skip write certificate verify" \
2822 -S "skip parse certificate verify" \
2823 -S "x509_verify_cert() returned" \
2824 -S "! The certificate is not correctly signed by the trusted CA" \
2825 -S "The certificate has been revoked (is on a CRL)"
2826
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002827run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00002828 "$P_SRV debug_level=3 auth_mode=optional \
2829 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2830 ca_file=data_files/test-ca.crt \
2831 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2832 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2833 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2834 1 \
2835 -S "skip write certificate request" \
2836 -C "skip parse certificate request" \
2837 -c "got a certificate request" \
2838 -C "skip write certificate" \
2839 -C "skip write certificate verify" \
2840 -S "skip parse certificate verify" \
2841 -s "x509_verify_cert() returned" \
2842 -S "! The certificate is not correctly signed by the trusted CA" \
2843 -s "The certificate has been revoked (is on a CRL)"
2844
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002845# Tests for non-blocking I/O: exercise a variety of handshake flows
2846
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002847run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002848 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2849 "$P_CLI nbio=2 tickets=0" \
2850 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002851 -S "mbedtls_ssl_handshake returned" \
2852 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002853 -c "Read from server: .* bytes read"
2854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002855run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002856 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2857 "$P_CLI nbio=2 tickets=0" \
2858 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002859 -S "mbedtls_ssl_handshake returned" \
2860 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002861 -c "Read from server: .* bytes read"
2862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002863run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002864 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2865 "$P_CLI nbio=2 tickets=1" \
2866 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002867 -S "mbedtls_ssl_handshake returned" \
2868 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002869 -c "Read from server: .* bytes read"
2870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002871run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002872 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2873 "$P_CLI nbio=2 tickets=1" \
2874 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002875 -S "mbedtls_ssl_handshake returned" \
2876 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002877 -c "Read from server: .* bytes read"
2878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002879run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002880 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2881 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2882 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002883 -S "mbedtls_ssl_handshake returned" \
2884 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002885 -c "Read from server: .* bytes read"
2886
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002887run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002888 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2889 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2890 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002891 -S "mbedtls_ssl_handshake returned" \
2892 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002893 -c "Read from server: .* bytes read"
2894
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002895run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002896 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2897 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2898 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002899 -S "mbedtls_ssl_handshake returned" \
2900 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002901 -c "Read from server: .* bytes read"
2902
Hanno Becker00076712017-11-15 16:39:08 +00002903# Tests for event-driven I/O: exercise a variety of handshake flows
2904
2905run_test "Event-driven I/O: basic handshake" \
2906 "$P_SRV event=1 tickets=0 auth_mode=none" \
2907 "$P_CLI event=1 tickets=0" \
2908 0 \
2909 -S "mbedtls_ssl_handshake returned" \
2910 -C "mbedtls_ssl_handshake returned" \
2911 -c "Read from server: .* bytes read"
2912
2913run_test "Event-driven I/O: client auth" \
2914 "$P_SRV event=1 tickets=0 auth_mode=required" \
2915 "$P_CLI event=1 tickets=0" \
2916 0 \
2917 -S "mbedtls_ssl_handshake returned" \
2918 -C "mbedtls_ssl_handshake returned" \
2919 -c "Read from server: .* bytes read"
2920
2921run_test "Event-driven I/O: ticket" \
2922 "$P_SRV event=1 tickets=1 auth_mode=none" \
2923 "$P_CLI event=1 tickets=1" \
2924 0 \
2925 -S "mbedtls_ssl_handshake returned" \
2926 -C "mbedtls_ssl_handshake returned" \
2927 -c "Read from server: .* bytes read"
2928
2929run_test "Event-driven I/O: ticket + client auth" \
2930 "$P_SRV event=1 tickets=1 auth_mode=required" \
2931 "$P_CLI event=1 tickets=1" \
2932 0 \
2933 -S "mbedtls_ssl_handshake returned" \
2934 -C "mbedtls_ssl_handshake returned" \
2935 -c "Read from server: .* bytes read"
2936
2937run_test "Event-driven I/O: ticket + client auth + resume" \
2938 "$P_SRV event=1 tickets=1 auth_mode=required" \
2939 "$P_CLI event=1 tickets=1 reconnect=1" \
2940 0 \
2941 -S "mbedtls_ssl_handshake returned" \
2942 -C "mbedtls_ssl_handshake returned" \
2943 -c "Read from server: .* bytes read"
2944
2945run_test "Event-driven I/O: ticket + resume" \
2946 "$P_SRV event=1 tickets=1 auth_mode=none" \
2947 "$P_CLI event=1 tickets=1 reconnect=1" \
2948 0 \
2949 -S "mbedtls_ssl_handshake returned" \
2950 -C "mbedtls_ssl_handshake returned" \
2951 -c "Read from server: .* bytes read"
2952
2953run_test "Event-driven I/O: session-id resume" \
2954 "$P_SRV event=1 tickets=0 auth_mode=none" \
2955 "$P_CLI event=1 tickets=0 reconnect=1" \
2956 0 \
2957 -S "mbedtls_ssl_handshake returned" \
2958 -C "mbedtls_ssl_handshake returned" \
2959 -c "Read from server: .* bytes read"
2960
Hanno Becker6a33f592018-03-13 11:38:46 +00002961run_test "Event-driven I/O, DTLS: basic handshake" \
2962 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2963 "$P_CLI dtls=1 event=1 tickets=0" \
2964 0 \
2965 -c "Read from server: .* bytes read"
2966
2967run_test "Event-driven I/O, DTLS: client auth" \
2968 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
2969 "$P_CLI dtls=1 event=1 tickets=0" \
2970 0 \
2971 -c "Read from server: .* bytes read"
2972
2973run_test "Event-driven I/O, DTLS: ticket" \
2974 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2975 "$P_CLI dtls=1 event=1 tickets=1" \
2976 0 \
2977 -c "Read from server: .* bytes read"
2978
2979run_test "Event-driven I/O, DTLS: ticket + client auth" \
2980 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2981 "$P_CLI dtls=1 event=1 tickets=1" \
2982 0 \
2983 -c "Read from server: .* bytes read"
2984
2985run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
2986 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2987 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2988 0 \
2989 -c "Read from server: .* bytes read"
2990
2991run_test "Event-driven I/O, DTLS: ticket + resume" \
2992 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2993 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2994 0 \
2995 -c "Read from server: .* bytes read"
2996
2997run_test "Event-driven I/O, DTLS: session-id resume" \
2998 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2999 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
3000 0 \
3001 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003002
3003# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3004# During session resumption, the client will send its ApplicationData record
3005# within the same datagram as the Finished messages. In this situation, the
3006# server MUST NOT idle on the underlying transport after handshake completion,
3007# because the ApplicationData request has already been queued internally.
3008run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003009 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003010 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3011 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
3012 0 \
3013 -c "Read from server: .* bytes read"
3014
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003015# Tests for version negotiation
3016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003017run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003018 "$P_SRV" \
3019 "$P_CLI" \
3020 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003021 -S "mbedtls_ssl_handshake returned" \
3022 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003023 -s "Protocol is TLSv1.2" \
3024 -c "Protocol is TLSv1.2"
3025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003026run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003027 "$P_SRV" \
3028 "$P_CLI max_version=tls1_1" \
3029 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003030 -S "mbedtls_ssl_handshake returned" \
3031 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003032 -s "Protocol is TLSv1.1" \
3033 -c "Protocol is TLSv1.1"
3034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003035run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003036 "$P_SRV max_version=tls1_1" \
3037 "$P_CLI" \
3038 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003039 -S "mbedtls_ssl_handshake returned" \
3040 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003041 -s "Protocol is TLSv1.1" \
3042 -c "Protocol is TLSv1.1"
3043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003044run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003045 "$P_SRV max_version=tls1_1" \
3046 "$P_CLI max_version=tls1_1" \
3047 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003048 -S "mbedtls_ssl_handshake returned" \
3049 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003050 -s "Protocol is TLSv1.1" \
3051 -c "Protocol is TLSv1.1"
3052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003053run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003054 "$P_SRV min_version=tls1_1" \
3055 "$P_CLI max_version=tls1_1" \
3056 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003057 -S "mbedtls_ssl_handshake returned" \
3058 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003059 -s "Protocol is TLSv1.1" \
3060 -c "Protocol is TLSv1.1"
3061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003062run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003063 "$P_SRV max_version=tls1_1" \
3064 "$P_CLI min_version=tls1_1" \
3065 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003066 -S "mbedtls_ssl_handshake returned" \
3067 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003068 -s "Protocol is TLSv1.1" \
3069 -c "Protocol is TLSv1.1"
3070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003071run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003072 "$P_SRV max_version=tls1_1" \
3073 "$P_CLI min_version=tls1_2" \
3074 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003075 -s "mbedtls_ssl_handshake returned" \
3076 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003077 -c "SSL - Handshake protocol not within min/max boundaries"
3078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003079run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003080 "$P_SRV min_version=tls1_2" \
3081 "$P_CLI max_version=tls1_1" \
3082 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003083 -s "mbedtls_ssl_handshake returned" \
3084 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003085 -s "SSL - Handshake protocol not within min/max boundaries"
3086
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003087# Tests for ALPN extension
3088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003089run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003090 "$P_SRV debug_level=3" \
3091 "$P_CLI debug_level=3" \
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" \
3099 -S "Application Layer Protocol is"
3100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003101run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003102 "$P_SRV debug_level=3" \
3103 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003104 0 \
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 (none)" \
3111 -S "Application Layer Protocol is"
3112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003113run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003114 "$P_SRV debug_level=3 alpn=abc,1234" \
3115 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003116 0 \
3117 -C "client hello, adding alpn extension" \
3118 -S "found alpn extension" \
3119 -C "got an alert message, type: \\[2:120]" \
3120 -S "server hello, adding alpn extension" \
3121 -C "found alpn extension " \
3122 -C "Application Layer Protocol is" \
3123 -s "Application Layer Protocol is (none)"
3124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003125run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003126 "$P_SRV debug_level=3 alpn=abc,1234" \
3127 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003128 0 \
3129 -c "client hello, adding alpn extension" \
3130 -s "found alpn extension" \
3131 -C "got an alert message, type: \\[2:120]" \
3132 -s "server hello, adding alpn extension" \
3133 -c "found alpn extension" \
3134 -c "Application Layer Protocol is abc" \
3135 -s "Application Layer Protocol is abc"
3136
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003137run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003138 "$P_SRV debug_level=3 alpn=abc,1234" \
3139 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003140 0 \
3141 -c "client hello, adding alpn extension" \
3142 -s "found alpn extension" \
3143 -C "got an alert message, type: \\[2:120]" \
3144 -s "server hello, adding alpn extension" \
3145 -c "found alpn extension" \
3146 -c "Application Layer Protocol is abc" \
3147 -s "Application Layer Protocol is abc"
3148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003149run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003150 "$P_SRV debug_level=3 alpn=abc,1234" \
3151 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003152 0 \
3153 -c "client hello, adding alpn extension" \
3154 -s "found alpn extension" \
3155 -C "got an alert message, type: \\[2:120]" \
3156 -s "server hello, adding alpn extension" \
3157 -c "found alpn extension" \
3158 -c "Application Layer Protocol is 1234" \
3159 -s "Application Layer Protocol is 1234"
3160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003161run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003162 "$P_SRV debug_level=3 alpn=abc,123" \
3163 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003164 1 \
3165 -c "client hello, adding alpn extension" \
3166 -s "found alpn extension" \
3167 -c "got an alert message, type: \\[2:120]" \
3168 -S "server hello, adding alpn extension" \
3169 -C "found alpn extension" \
3170 -C "Application Layer Protocol is 1234" \
3171 -S "Application Layer Protocol is 1234"
3172
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003173
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003174# Tests for keyUsage in leaf certificates, part 1:
3175# server-side certificate/suite selection
3176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003177run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003178 "$P_SRV key_file=data_files/server2.key \
3179 crt_file=data_files/server2.ku-ds.crt" \
3180 "$P_CLI" \
3181 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003182 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003183
3184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003185run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003186 "$P_SRV key_file=data_files/server2.key \
3187 crt_file=data_files/server2.ku-ke.crt" \
3188 "$P_CLI" \
3189 0 \
3190 -c "Ciphersuite is TLS-RSA-WITH-"
3191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003192run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003193 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003194 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003195 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003196 1 \
3197 -C "Ciphersuite is "
3198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003199run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003200 "$P_SRV key_file=data_files/server5.key \
3201 crt_file=data_files/server5.ku-ds.crt" \
3202 "$P_CLI" \
3203 0 \
3204 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3205
3206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003207run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003208 "$P_SRV key_file=data_files/server5.key \
3209 crt_file=data_files/server5.ku-ka.crt" \
3210 "$P_CLI" \
3211 0 \
3212 -c "Ciphersuite is TLS-ECDH-"
3213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003214run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003215 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003216 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003217 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003218 1 \
3219 -C "Ciphersuite is "
3220
3221# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003222# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003224run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003225 "$O_SRV -key data_files/server2.key \
3226 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003227 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003228 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3229 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003230 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003231 -C "Processing of the Certificate handshake message failed" \
3232 -c "Ciphersuite is TLS-"
3233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003234run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003235 "$O_SRV -key data_files/server2.key \
3236 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003237 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003238 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3239 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003240 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003241 -C "Processing of the Certificate handshake message failed" \
3242 -c "Ciphersuite is TLS-"
3243
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003244run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003245 "$O_SRV -key data_files/server2.key \
3246 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003247 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003248 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3249 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003250 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003251 -C "Processing of the Certificate handshake message failed" \
3252 -c "Ciphersuite is TLS-"
3253
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003254run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003255 "$O_SRV -key data_files/server2.key \
3256 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003257 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003258 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3259 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003260 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003261 -c "Processing of the Certificate handshake message failed" \
3262 -C "Ciphersuite is TLS-"
3263
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003264run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3265 "$O_SRV -key data_files/server2.key \
3266 -cert data_files/server2.ku-ke.crt" \
3267 "$P_CLI debug_level=1 auth_mode=optional \
3268 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3269 0 \
3270 -c "bad certificate (usage extensions)" \
3271 -C "Processing of the Certificate handshake message failed" \
3272 -c "Ciphersuite is TLS-" \
3273 -c "! Usage does not match the keyUsage extension"
3274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003275run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003276 "$O_SRV -key data_files/server2.key \
3277 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003278 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003279 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3280 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003281 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003282 -C "Processing of the Certificate handshake message failed" \
3283 -c "Ciphersuite is TLS-"
3284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003285run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003286 "$O_SRV -key data_files/server2.key \
3287 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003288 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003289 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3290 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003291 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003292 -c "Processing of the Certificate handshake message failed" \
3293 -C "Ciphersuite is TLS-"
3294
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003295run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3296 "$O_SRV -key data_files/server2.key \
3297 -cert data_files/server2.ku-ds.crt" \
3298 "$P_CLI debug_level=1 auth_mode=optional \
3299 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3300 0 \
3301 -c "bad certificate (usage extensions)" \
3302 -C "Processing of the Certificate handshake message failed" \
3303 -c "Ciphersuite is TLS-" \
3304 -c "! Usage does not match the keyUsage extension"
3305
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003306# Tests for keyUsage in leaf certificates, part 3:
3307# server-side checking of client cert
3308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003309run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003310 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003311 "$O_CLI -key data_files/server2.key \
3312 -cert data_files/server2.ku-ds.crt" \
3313 0 \
3314 -S "bad certificate (usage extensions)" \
3315 -S "Processing of the Certificate handshake message failed"
3316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003317run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003318 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003319 "$O_CLI -key data_files/server2.key \
3320 -cert data_files/server2.ku-ke.crt" \
3321 0 \
3322 -s "bad certificate (usage extensions)" \
3323 -S "Processing of the Certificate handshake message failed"
3324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003325run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003326 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003327 "$O_CLI -key data_files/server2.key \
3328 -cert data_files/server2.ku-ke.crt" \
3329 1 \
3330 -s "bad certificate (usage extensions)" \
3331 -s "Processing of the Certificate handshake message failed"
3332
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003333run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003334 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003335 "$O_CLI -key data_files/server5.key \
3336 -cert data_files/server5.ku-ds.crt" \
3337 0 \
3338 -S "bad certificate (usage extensions)" \
3339 -S "Processing of the Certificate handshake message failed"
3340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003341run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003342 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003343 "$O_CLI -key data_files/server5.key \
3344 -cert data_files/server5.ku-ka.crt" \
3345 0 \
3346 -s "bad certificate (usage extensions)" \
3347 -S "Processing of the Certificate handshake message failed"
3348
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003349# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003351run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003352 "$P_SRV key_file=data_files/server5.key \
3353 crt_file=data_files/server5.eku-srv.crt" \
3354 "$P_CLI" \
3355 0
3356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003357run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003358 "$P_SRV key_file=data_files/server5.key \
3359 crt_file=data_files/server5.eku-srv.crt" \
3360 "$P_CLI" \
3361 0
3362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003363run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003364 "$P_SRV key_file=data_files/server5.key \
3365 crt_file=data_files/server5.eku-cs_any.crt" \
3366 "$P_CLI" \
3367 0
3368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003369run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003370 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003371 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003372 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003373 1
3374
3375# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003377run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003378 "$O_SRV -key data_files/server5.key \
3379 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003380 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003381 0 \
3382 -C "bad certificate (usage extensions)" \
3383 -C "Processing of the Certificate handshake message failed" \
3384 -c "Ciphersuite is TLS-"
3385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003386run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003387 "$O_SRV -key data_files/server5.key \
3388 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003389 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003390 0 \
3391 -C "bad certificate (usage extensions)" \
3392 -C "Processing of the Certificate handshake message failed" \
3393 -c "Ciphersuite is TLS-"
3394
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003395run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003396 "$O_SRV -key data_files/server5.key \
3397 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003398 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003399 0 \
3400 -C "bad certificate (usage extensions)" \
3401 -C "Processing of the Certificate handshake message failed" \
3402 -c "Ciphersuite is TLS-"
3403
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003404run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003405 "$O_SRV -key data_files/server5.key \
3406 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003407 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003408 1 \
3409 -c "bad certificate (usage extensions)" \
3410 -c "Processing of the Certificate handshake message failed" \
3411 -C "Ciphersuite is TLS-"
3412
3413# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3414
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003415run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003416 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003417 "$O_CLI -key data_files/server5.key \
3418 -cert data_files/server5.eku-cli.crt" \
3419 0 \
3420 -S "bad certificate (usage extensions)" \
3421 -S "Processing of the Certificate handshake message failed"
3422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003423run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003424 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003425 "$O_CLI -key data_files/server5.key \
3426 -cert data_files/server5.eku-srv_cli.crt" \
3427 0 \
3428 -S "bad certificate (usage extensions)" \
3429 -S "Processing of the Certificate handshake message failed"
3430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003431run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003432 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003433 "$O_CLI -key data_files/server5.key \
3434 -cert data_files/server5.eku-cs_any.crt" \
3435 0 \
3436 -S "bad certificate (usage extensions)" \
3437 -S "Processing of the Certificate handshake message failed"
3438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003439run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003440 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003441 "$O_CLI -key data_files/server5.key \
3442 -cert data_files/server5.eku-cs.crt" \
3443 0 \
3444 -s "bad certificate (usage extensions)" \
3445 -S "Processing of the Certificate handshake message failed"
3446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003447run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003448 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003449 "$O_CLI -key data_files/server5.key \
3450 -cert data_files/server5.eku-cs.crt" \
3451 1 \
3452 -s "bad certificate (usage extensions)" \
3453 -s "Processing of the Certificate handshake message failed"
3454
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003455# Tests for DHM parameters loading
3456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003457run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003458 "$P_SRV" \
3459 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3460 debug_level=3" \
3461 0 \
3462 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003463 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003464
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003465run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003466 "$P_SRV dhm_file=data_files/dhparams.pem" \
3467 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3468 debug_level=3" \
3469 0 \
3470 -c "value of 'DHM: P ' (1024 bits)" \
3471 -c "value of 'DHM: G ' (2 bits)"
3472
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003473# Tests for DHM client-side size checking
3474
3475run_test "DHM size: server default, client default, OK" \
3476 "$P_SRV" \
3477 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3478 debug_level=1" \
3479 0 \
3480 -C "DHM prime too short:"
3481
3482run_test "DHM size: server default, client 2048, OK" \
3483 "$P_SRV" \
3484 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3485 debug_level=1 dhmlen=2048" \
3486 0 \
3487 -C "DHM prime too short:"
3488
3489run_test "DHM size: server 1024, client default, OK" \
3490 "$P_SRV dhm_file=data_files/dhparams.pem" \
3491 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3492 debug_level=1" \
3493 0 \
3494 -C "DHM prime too short:"
3495
3496run_test "DHM size: server 1000, client default, rejected" \
3497 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3498 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3499 debug_level=1" \
3500 1 \
3501 -c "DHM prime too short:"
3502
3503run_test "DHM size: server default, client 2049, rejected" \
3504 "$P_SRV" \
3505 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3506 debug_level=1 dhmlen=2049" \
3507 1 \
3508 -c "DHM prime too short:"
3509
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003510# Tests for PSK callback
3511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003512run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003513 "$P_SRV psk=abc123 psk_identity=foo" \
3514 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3515 psk_identity=foo psk=abc123" \
3516 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003517 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003518 -S "SSL - Unknown identity received" \
3519 -S "SSL - Verification of the message MAC failed"
3520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003521run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003522 "$P_SRV" \
3523 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3524 psk_identity=foo psk=abc123" \
3525 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003526 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003527 -S "SSL - Unknown identity received" \
3528 -S "SSL - Verification of the message MAC failed"
3529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003530run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003531 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3532 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3533 psk_identity=foo psk=abc123" \
3534 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003535 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003536 -s "SSL - Unknown identity received" \
3537 -S "SSL - Verification of the message MAC failed"
3538
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003539run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003540 "$P_SRV psk_list=abc,dead,def,beef" \
3541 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3542 psk_identity=abc psk=dead" \
3543 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003544 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003545 -S "SSL - Unknown identity received" \
3546 -S "SSL - Verification of the message MAC failed"
3547
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003548run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003549 "$P_SRV psk_list=abc,dead,def,beef" \
3550 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3551 psk_identity=def psk=beef" \
3552 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003553 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003554 -S "SSL - Unknown identity received" \
3555 -S "SSL - Verification of the message MAC failed"
3556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003557run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003558 "$P_SRV psk_list=abc,dead,def,beef" \
3559 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3560 psk_identity=ghi psk=beef" \
3561 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003562 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003563 -s "SSL - Unknown identity received" \
3564 -S "SSL - Verification of the message MAC failed"
3565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003566run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003567 "$P_SRV psk_list=abc,dead,def,beef" \
3568 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3569 psk_identity=abc psk=beef" \
3570 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003571 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003572 -S "SSL - Unknown identity received" \
3573 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003574
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003575# Tests for EC J-PAKE
3576
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003577requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003578run_test "ECJPAKE: client not configured" \
3579 "$P_SRV debug_level=3" \
3580 "$P_CLI debug_level=3" \
3581 0 \
3582 -C "add ciphersuite: c0ff" \
3583 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003584 -S "found ecjpake kkpp extension" \
3585 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003586 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003587 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003588 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003589 -S "None of the common ciphersuites is usable"
3590
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003591requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003592run_test "ECJPAKE: server not configured" \
3593 "$P_SRV debug_level=3" \
3594 "$P_CLI debug_level=3 ecjpake_pw=bla \
3595 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3596 1 \
3597 -c "add ciphersuite: c0ff" \
3598 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003599 -s "found ecjpake kkpp extension" \
3600 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003601 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003602 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003603 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003604 -s "None of the common ciphersuites is usable"
3605
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003606requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003607run_test "ECJPAKE: working, TLS" \
3608 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3609 "$P_CLI debug_level=3 ecjpake_pw=bla \
3610 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003611 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003612 -c "add ciphersuite: c0ff" \
3613 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003614 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003615 -s "found ecjpake kkpp extension" \
3616 -S "skip ecjpake kkpp extension" \
3617 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003618 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003619 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003620 -S "None of the common ciphersuites is usable" \
3621 -S "SSL - Verification of the message MAC failed"
3622
Janos Follath74537a62016-09-02 13:45:28 +01003623server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003624requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003625run_test "ECJPAKE: password mismatch, TLS" \
3626 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3627 "$P_CLI debug_level=3 ecjpake_pw=bad \
3628 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3629 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003630 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003631 -s "SSL - Verification of the message MAC failed"
3632
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003633requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003634run_test "ECJPAKE: working, DTLS" \
3635 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3636 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3637 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3638 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003639 -c "re-using cached ecjpake parameters" \
3640 -S "SSL - Verification of the message MAC failed"
3641
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003642requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003643run_test "ECJPAKE: working, DTLS, no cookie" \
3644 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3645 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3646 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3647 0 \
3648 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003649 -S "SSL - Verification of the message MAC failed"
3650
Janos Follath74537a62016-09-02 13:45:28 +01003651server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003652requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003653run_test "ECJPAKE: password mismatch, DTLS" \
3654 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3655 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3656 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3657 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003658 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003659 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003660
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003661# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003662requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003663run_test "ECJPAKE: working, DTLS, nolog" \
3664 "$P_SRV dtls=1 ecjpake_pw=bla" \
3665 "$P_CLI dtls=1 ecjpake_pw=bla \
3666 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3667 0
3668
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003669# Tests for ciphersuites per version
3670
Janos Follathe2681a42016-03-07 15:57:05 +00003671requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003672run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003673 "$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 +02003674 "$P_CLI force_version=ssl3" \
3675 0 \
3676 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003678run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003679 "$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 +01003680 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003681 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003682 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003684run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003685 "$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 +02003686 "$P_CLI force_version=tls1_1" \
3687 0 \
3688 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3689
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003690run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003691 "$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 +02003692 "$P_CLI force_version=tls1_2" \
3693 0 \
3694 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3695
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003696# Test for ClientHello without extensions
3697
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003698requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003699run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003700 "$P_SRV debug_level=3" \
3701 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3702 0 \
3703 -s "dumping 'client hello extensions' (0 bytes)"
3704
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003705requires_gnutls
3706run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3707 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3708 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3709 0 \
3710 -s "dumping 'client hello extensions' (0 bytes)"
3711
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003712# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003713
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003714run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003715 "$P_SRV" \
3716 "$P_CLI request_size=100" \
3717 0 \
3718 -s "Read from client: 100 bytes read$"
3719
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003720run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003721 "$P_SRV" \
3722 "$P_CLI request_size=500" \
3723 0 \
3724 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003725
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003726# Tests for small packets
3727
Janos Follathe2681a42016-03-07 15:57:05 +00003728requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003729run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003730 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003731 "$P_CLI request_size=1 force_version=ssl3 \
3732 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3733 0 \
3734 -s "Read from client: 1 bytes read"
3735
Janos Follathe2681a42016-03-07 15:57:05 +00003736requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003737run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003738 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003739 "$P_CLI request_size=1 force_version=ssl3 \
3740 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3741 0 \
3742 -s "Read from client: 1 bytes read"
3743
3744run_test "Small packet TLS 1.0 BlockCipher" \
3745 "$P_SRV" \
3746 "$P_CLI request_size=1 force_version=tls1 \
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.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003752 "$P_SRV" \
3753 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3754 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3755 0 \
3756 -s "Read from client: 1 bytes read"
3757
Hanno Becker32c55012017-11-10 08:42:54 +00003758requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003759run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003760 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003761 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003762 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003763 0 \
3764 -s "Read from client: 1 bytes read"
3765
Hanno Becker32c55012017-11-10 08:42:54 +00003766requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003767run_test "Small packet TLS 1.0 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 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003770 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003771 0 \
3772 -s "Read from client: 1 bytes read"
3773
3774run_test "Small packet TLS 1.0 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 \
Hanno Becker8501f982017-11-10 08:59:04 +00003777 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3778 0 \
3779 -s "Read from client: 1 bytes read"
3780
3781run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3782 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3783 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003784 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003785 0 \
3786 -s "Read from client: 1 bytes read"
3787
3788requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3789run_test "Small packet TLS 1.0 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 \
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 Becker8501f982017-11-10 08:59:04 +00003796requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3797run_test "Small packet TLS 1.0 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" \
3799 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3800 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.1 BlockCipher" \
3805 "$P_SRV" \
3806 "$P_CLI request_size=1 force_version=tls1_1 \
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.1 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_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003814 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003815 0 \
3816 -s "Read from client: 1 bytes read"
3817
3818requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3819run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003820 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003821 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003822 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003823 0 \
3824 -s "Read from client: 1 bytes read"
3825
3826requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3827run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003828 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003829 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003830 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003831 0 \
3832 -s "Read from client: 1 bytes read"
3833
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003834run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003835 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003836 "$P_CLI request_size=1 force_version=tls1_1 \
3837 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3838 0 \
3839 -s "Read from client: 1 bytes read"
3840
Hanno Becker8501f982017-11-10 08:59:04 +00003841run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3842 "$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_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003844 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003845 0 \
3846 -s "Read from client: 1 bytes read"
3847
Hanno Becker8501f982017-11-10 08:59:04 +00003848requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3849run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003850 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003851 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003852 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003853 0 \
3854 -s "Read from client: 1 bytes read"
3855
Hanno Becker32c55012017-11-10 08:42:54 +00003856requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003857run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003858 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003859 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003860 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003861 0 \
3862 -s "Read from client: 1 bytes read"
3863
3864run_test "Small packet TLS 1.2 BlockCipher" \
3865 "$P_SRV" \
3866 "$P_CLI request_size=1 force_version=tls1_2 \
3867 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3868 0 \
3869 -s "Read from client: 1 bytes read"
3870
Hanno Becker8501f982017-11-10 08:59:04 +00003871run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003872 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003873 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003874 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003875 0 \
3876 -s "Read from client: 1 bytes read"
3877
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003878run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3879 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003880 "$P_CLI request_size=1 force_version=tls1_2 \
3881 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003882 0 \
3883 -s "Read from client: 1 bytes read"
3884
Hanno Becker32c55012017-11-10 08:42:54 +00003885requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003886run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003887 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003888 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003889 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003890 0 \
3891 -s "Read from client: 1 bytes read"
3892
Hanno Becker8501f982017-11-10 08:59:04 +00003893requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3894run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003895 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003896 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003897 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003898 0 \
3899 -s "Read from client: 1 bytes read"
3900
3901run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003902 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003903 "$P_CLI request_size=1 force_version=tls1_2 \
3904 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3905 0 \
3906 -s "Read from client: 1 bytes read"
3907
Hanno Becker8501f982017-11-10 08:59:04 +00003908run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003909 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003910 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003911 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003912 0 \
3913 -s "Read from client: 1 bytes read"
3914
Hanno Becker32c55012017-11-10 08:42:54 +00003915requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003916run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003917 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003918 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003919 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003920 0 \
3921 -s "Read from client: 1 bytes read"
3922
Hanno Becker8501f982017-11-10 08:59:04 +00003923requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3924run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003925 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003926 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003927 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003928 0 \
3929 -s "Read from client: 1 bytes read"
3930
3931run_test "Small packet TLS 1.2 AEAD" \
3932 "$P_SRV" \
3933 "$P_CLI request_size=1 force_version=tls1_2 \
3934 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3935 0 \
3936 -s "Read from client: 1 bytes read"
3937
3938run_test "Small packet TLS 1.2 AEAD shorter tag" \
3939 "$P_SRV" \
3940 "$P_CLI request_size=1 force_version=tls1_2 \
3941 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3942 0 \
3943 -s "Read from client: 1 bytes read"
3944
Hanno Beckere2148042017-11-10 08:59:18 +00003945# Tests for small packets in DTLS
3946
3947requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3948run_test "Small packet DTLS 1.0" \
3949 "$P_SRV dtls=1 force_version=dtls1" \
3950 "$P_CLI dtls=1 request_size=1 \
3951 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3952 0 \
3953 -s "Read from client: 1 bytes read"
3954
3955requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3956run_test "Small packet DTLS 1.0, without EtM" \
3957 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3958 "$P_CLI dtls=1 request_size=1 \
3959 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3960 0 \
3961 -s "Read from client: 1 bytes read"
3962
3963requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3964requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3965run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003966 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3967 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003968 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3969 0 \
3970 -s "Read from client: 1 bytes read"
3971
3972requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3973requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3974run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003975 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003976 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003977 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003978 0 \
3979 -s "Read from client: 1 bytes read"
3980
3981requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3982run_test "Small packet DTLS 1.2" \
3983 "$P_SRV dtls=1 force_version=dtls1_2" \
3984 "$P_CLI dtls=1 request_size=1 \
3985 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3986 0 \
3987 -s "Read from client: 1 bytes read"
3988
3989requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3990run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003991 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003992 "$P_CLI dtls=1 request_size=1 \
3993 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3994 0 \
3995 -s "Read from client: 1 bytes read"
3996
3997requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3998requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3999run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004000 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004001 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004002 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004003 0 \
4004 -s "Read from client: 1 bytes read"
4005
4006requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4007requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4008run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004009 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004010 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004011 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004012 0 \
4013 -s "Read from client: 1 bytes read"
4014
Janos Follath00efff72016-05-06 13:48:23 +01004015# A test for extensions in SSLv3
4016
4017requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4018run_test "SSLv3 with extensions, server side" \
4019 "$P_SRV min_version=ssl3 debug_level=3" \
4020 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4021 0 \
4022 -S "dumping 'client hello extensions'" \
4023 -S "server hello, total extension length:"
4024
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004025# Test for large packets
4026
Angus Grattonc4dd0732018-04-11 16:28:39 +10004027# How many fragments do we expect to write $1 bytes?
4028fragments_for_write() {
4029 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4030}
4031
Janos Follathe2681a42016-03-07 15:57:05 +00004032requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004033run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004034 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004035 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004036 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4037 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004038 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4039 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004040
Janos Follathe2681a42016-03-07 15:57:05 +00004041requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004042run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004043 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004044 "$P_CLI request_size=16384 force_version=ssl3 \
4045 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4046 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004047 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4048 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004049
4050run_test "Large packet TLS 1.0 BlockCipher" \
4051 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004052 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004053 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4054 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004055 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4056 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004057
Hanno Becker278fc7a2017-11-10 09:16:28 +00004058run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004059 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004060 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4061 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4062 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004063 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004064
Hanno Becker32c55012017-11-10 08:42:54 +00004065requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004066run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004067 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004068 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004069 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004070 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004071 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4072 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004073
Hanno Becker32c55012017-11-10 08:42:54 +00004074requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004075run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004076 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004077 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004078 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004079 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004080 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004081
4082run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004083 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004084 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004085 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4086 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004087 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004088
4089run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
4090 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4091 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004092 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004093 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004094 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004095
4096requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4097run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004098 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004099 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004100 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004101 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004102 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004103
Hanno Becker278fc7a2017-11-10 09:16:28 +00004104requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4105run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004106 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004107 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004108 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004109 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004110 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4111 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004112
4113run_test "Large packet TLS 1.1 BlockCipher" \
4114 "$P_SRV" \
4115 "$P_CLI request_size=16384 force_version=tls1_1 \
4116 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4117 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004118 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4119 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004120
Hanno Becker278fc7a2017-11-10 09:16:28 +00004121run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
4122 "$P_SRV" \
4123 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4124 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004125 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004126 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004127
Hanno Becker32c55012017-11-10 08:42:54 +00004128requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004129run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004130 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004131 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004132 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004133 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004134 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004135
Hanno Becker32c55012017-11-10 08:42:54 +00004136requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004137run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004138 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004139 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004140 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004141 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004142 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004143
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004144run_test "Large packet TLS 1.1 StreamCipher" \
4145 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4146 "$P_CLI request_size=16384 force_version=tls1_1 \
4147 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4148 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004149 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4150 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004151
Hanno Becker278fc7a2017-11-10 09:16:28 +00004152run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
4153 "$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_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004155 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004156 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004157 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4158 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004159
Hanno Becker278fc7a2017-11-10 09:16:28 +00004160requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4161run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004162 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004163 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004164 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004165 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004166 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004167
Hanno Becker278fc7a2017-11-10 09:16:28 +00004168requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4169run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004170 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004171 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004172 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004173 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004174 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4175 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004176
4177run_test "Large packet TLS 1.2 BlockCipher" \
4178 "$P_SRV" \
4179 "$P_CLI request_size=16384 force_version=tls1_2 \
4180 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4181 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004182 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4183 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004184
Hanno Becker278fc7a2017-11-10 09:16:28 +00004185run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
4186 "$P_SRV" \
4187 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4188 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4189 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004190 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004191
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004192run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
4193 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004194 "$P_CLI request_size=16384 force_version=tls1_2 \
4195 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004196 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004197 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4198 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004199
Hanno Becker32c55012017-11-10 08:42:54 +00004200requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004201run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004202 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004203 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004204 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004205 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004206 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004207
Hanno Becker278fc7a2017-11-10 09:16:28 +00004208requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4209run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004210 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004211 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004212 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004213 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004214 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4215 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004216
4217run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004218 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004219 "$P_CLI request_size=16384 force_version=tls1_2 \
4220 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4221 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004222 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4223 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004224
Hanno Becker278fc7a2017-11-10 09:16:28 +00004225run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004226 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004227 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004228 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4229 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004230 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004231
Hanno Becker32c55012017-11-10 08:42:54 +00004232requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004233run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004234 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004235 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004236 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004237 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004238 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004239
Hanno Becker278fc7a2017-11-10 09:16:28 +00004240requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4241run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004242 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004243 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004244 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004245 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004246 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4247 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004248
4249run_test "Large packet TLS 1.2 AEAD" \
4250 "$P_SRV" \
4251 "$P_CLI request_size=16384 force_version=tls1_2 \
4252 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4253 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004254 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4255 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004256
4257run_test "Large packet TLS 1.2 AEAD shorter tag" \
4258 "$P_SRV" \
4259 "$P_CLI request_size=16384 force_version=tls1_2 \
4260 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4261 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004262 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4263 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004264
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004265# Tests of asynchronous private key support in SSL
4266
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004267requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004268run_test "SSL async private: sign, delay=0" \
4269 "$P_SRV \
4270 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004271 "$P_CLI" \
4272 0 \
4273 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004274 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004275
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004276requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004277run_test "SSL async private: sign, delay=1" \
4278 "$P_SRV \
4279 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004280 "$P_CLI" \
4281 0 \
4282 -s "Async sign callback: using key slot " \
4283 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004284 -s "Async resume (slot [0-9]): sign done, status=0"
4285
Gilles Peskine12d0cc12018-04-26 15:06:56 +02004286requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4287run_test "SSL async private: sign, delay=2" \
4288 "$P_SRV \
4289 async_operations=s async_private_delay1=2 async_private_delay2=2" \
4290 "$P_CLI" \
4291 0 \
4292 -s "Async sign callback: using key slot " \
4293 -U "Async sign callback: using key slot " \
4294 -s "Async resume (slot [0-9]): call 1 more times." \
4295 -s "Async resume (slot [0-9]): call 0 more times." \
4296 -s "Async resume (slot [0-9]): sign done, status=0"
4297
Gilles Peskined3268832018-04-26 06:23:59 +02004298# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
4299# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
4300requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4301requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4302run_test "SSL async private: sign, RSA, TLS 1.1" \
4303 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
4304 async_operations=s async_private_delay1=0 async_private_delay2=0" \
4305 "$P_CLI force_version=tls1_1" \
4306 0 \
4307 -s "Async sign callback: using key slot " \
4308 -s "Async resume (slot [0-9]): sign done, status=0"
4309
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004310requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02004311run_test "SSL async private: sign, SNI" \
4312 "$P_SRV debug_level=3 \
4313 async_operations=s async_private_delay1=0 async_private_delay2=0 \
4314 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4315 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4316 "$P_CLI server_name=polarssl.example" \
4317 0 \
4318 -s "Async sign callback: using key slot " \
4319 -s "Async resume (slot [0-9]): sign done, status=0" \
4320 -s "parse ServerName extension" \
4321 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4322 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4323
4324requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004325run_test "SSL async private: decrypt, delay=0" \
4326 "$P_SRV \
4327 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4328 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4329 0 \
4330 -s "Async decrypt callback: using key slot " \
4331 -s "Async resume (slot [0-9]): decrypt done, status=0"
4332
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004333requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004334run_test "SSL async private: decrypt, delay=1" \
4335 "$P_SRV \
4336 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4337 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4338 0 \
4339 -s "Async decrypt callback: using key slot " \
4340 -s "Async resume (slot [0-9]): call 0 more times." \
4341 -s "Async resume (slot [0-9]): decrypt done, status=0"
4342
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004343requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004344run_test "SSL async private: decrypt RSA-PSK, delay=0" \
4345 "$P_SRV psk=abc123 \
4346 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4347 "$P_CLI psk=abc123 \
4348 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4349 0 \
4350 -s "Async decrypt callback: using key slot " \
4351 -s "Async resume (slot [0-9]): decrypt done, status=0"
4352
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004353requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004354run_test "SSL async private: decrypt RSA-PSK, delay=1" \
4355 "$P_SRV psk=abc123 \
4356 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4357 "$P_CLI psk=abc123 \
4358 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4359 0 \
4360 -s "Async decrypt callback: using key slot " \
4361 -s "Async resume (slot [0-9]): call 0 more times." \
4362 -s "Async resume (slot [0-9]): decrypt done, status=0"
4363
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004364requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004365run_test "SSL async private: sign callback not present" \
4366 "$P_SRV \
4367 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4368 "$P_CLI; [ \$? -eq 1 ] &&
4369 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4370 0 \
4371 -S "Async sign callback" \
4372 -s "! mbedtls_ssl_handshake returned" \
4373 -s "The own private key or pre-shared key is not set, but needed" \
4374 -s "Async resume (slot [0-9]): decrypt done, status=0" \
4375 -s "Successful connection"
4376
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004377requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004378run_test "SSL async private: decrypt callback not present" \
4379 "$P_SRV debug_level=1 \
4380 async_operations=s async_private_delay1=1 async_private_delay2=1" \
4381 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
4382 [ \$? -eq 1 ] && $P_CLI" \
4383 0 \
4384 -S "Async decrypt callback" \
4385 -s "! mbedtls_ssl_handshake returned" \
4386 -s "got no RSA private key" \
4387 -s "Async resume (slot [0-9]): sign done, status=0" \
4388 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004389
4390# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004391requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004392run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004393 "$P_SRV \
4394 async_operations=s async_private_delay1=1 \
4395 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4396 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004397 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4398 0 \
4399 -s "Async sign callback: using key slot 0," \
4400 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004401 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004402
4403# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004404requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004405run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004406 "$P_SRV \
4407 async_operations=s async_private_delay2=1 \
4408 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4409 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004410 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4411 0 \
4412 -s "Async sign callback: using key slot 0," \
4413 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004414 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004415
4416# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004417requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02004418run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004419 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02004420 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004421 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4422 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004423 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4424 0 \
4425 -s "Async sign callback: using key slot 1," \
4426 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004427 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004428
4429# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004430requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004431run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004432 "$P_SRV \
4433 async_operations=s async_private_delay1=1 \
4434 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4435 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004436 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4437 0 \
4438 -s "Async sign callback: no key matches this certificate."
4439
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004440requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004441run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004442 "$P_SRV \
4443 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4444 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004445 "$P_CLI" \
4446 1 \
4447 -s "Async sign callback: injected error" \
4448 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004449 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004450 -s "! mbedtls_ssl_handshake returned"
4451
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004452requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004453run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004454 "$P_SRV \
4455 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4456 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004457 "$P_CLI" \
4458 1 \
4459 -s "Async sign callback: using key slot " \
4460 -S "Async resume" \
4461 -s "Async cancel"
4462
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004463requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004464run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004465 "$P_SRV \
4466 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4467 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004468 "$P_CLI" \
4469 1 \
4470 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004471 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004472 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004473 -s "! mbedtls_ssl_handshake returned"
4474
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004475requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004476run_test "SSL async private: decrypt, error in start" \
4477 "$P_SRV \
4478 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4479 async_private_error=1" \
4480 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4481 1 \
4482 -s "Async decrypt callback: injected error" \
4483 -S "Async resume" \
4484 -S "Async cancel" \
4485 -s "! mbedtls_ssl_handshake returned"
4486
4487requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4488run_test "SSL async private: decrypt, cancel after start" \
4489 "$P_SRV \
4490 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4491 async_private_error=2" \
4492 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4493 1 \
4494 -s "Async decrypt callback: using key slot " \
4495 -S "Async resume" \
4496 -s "Async cancel"
4497
4498requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4499run_test "SSL async private: decrypt, error in resume" \
4500 "$P_SRV \
4501 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4502 async_private_error=3" \
4503 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4504 1 \
4505 -s "Async decrypt callback: using key slot " \
4506 -s "Async resume callback: decrypt done but injected error" \
4507 -S "Async cancel" \
4508 -s "! mbedtls_ssl_handshake returned"
4509
4510requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004511run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004512 "$P_SRV \
4513 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4514 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004515 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4516 0 \
4517 -s "Async cancel" \
4518 -s "! mbedtls_ssl_handshake returned" \
4519 -s "Async resume" \
4520 -s "Successful connection"
4521
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004522requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004523run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004524 "$P_SRV \
4525 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4526 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004527 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4528 0 \
4529 -s "! mbedtls_ssl_handshake returned" \
4530 -s "Async resume" \
4531 -s "Successful connection"
4532
4533# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004534requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004535run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004536 "$P_SRV \
4537 async_operations=s async_private_delay1=1 async_private_error=-2 \
4538 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4539 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004540 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4541 [ \$? -eq 1 ] &&
4542 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4543 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02004544 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004545 -S "Async resume" \
4546 -s "Async cancel" \
4547 -s "! mbedtls_ssl_handshake returned" \
4548 -s "Async sign callback: no key matches this certificate." \
4549 -s "Successful connection"
4550
4551# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004552requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004553run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004554 "$P_SRV \
4555 async_operations=s async_private_delay1=1 async_private_error=-3 \
4556 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4557 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004558 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4559 [ \$? -eq 1 ] &&
4560 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4561 0 \
4562 -s "Async resume" \
4563 -s "! mbedtls_ssl_handshake returned" \
4564 -s "Async sign callback: no key matches this certificate." \
4565 -s "Successful connection"
4566
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004567requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004568requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004569run_test "SSL async private: renegotiation: client-initiated; sign" \
4570 "$P_SRV \
4571 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004572 exchanges=2 renegotiation=1" \
4573 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
4574 0 \
4575 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004576 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004577
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004578requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004579requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004580run_test "SSL async private: renegotiation: server-initiated; sign" \
4581 "$P_SRV \
4582 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004583 exchanges=2 renegotiation=1 renegotiate=1" \
4584 "$P_CLI exchanges=2 renegotiation=1" \
4585 0 \
4586 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004587 -s "Async resume (slot [0-9]): sign done, status=0"
4588
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004589requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004590requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4591run_test "SSL async private: renegotiation: client-initiated; decrypt" \
4592 "$P_SRV \
4593 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4594 exchanges=2 renegotiation=1" \
4595 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
4596 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4597 0 \
4598 -s "Async decrypt callback: using key slot " \
4599 -s "Async resume (slot [0-9]): decrypt done, status=0"
4600
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004601requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004602requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4603run_test "SSL async private: renegotiation: server-initiated; decrypt" \
4604 "$P_SRV \
4605 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4606 exchanges=2 renegotiation=1 renegotiate=1" \
4607 "$P_CLI exchanges=2 renegotiation=1 \
4608 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4609 0 \
4610 -s "Async decrypt callback: using key slot " \
4611 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004612
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004613# Tests for DTLS HelloVerifyRequest
4614
4615run_test "DTLS cookie: enabled" \
4616 "$P_SRV dtls=1 debug_level=2" \
4617 "$P_CLI dtls=1 debug_level=2" \
4618 0 \
4619 -s "cookie verification failed" \
4620 -s "cookie verification passed" \
4621 -S "cookie verification skipped" \
4622 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004623 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004624 -S "SSL - The requested feature is not available"
4625
4626run_test "DTLS cookie: disabled" \
4627 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4628 "$P_CLI dtls=1 debug_level=2" \
4629 0 \
4630 -S "cookie verification failed" \
4631 -S "cookie verification passed" \
4632 -s "cookie verification skipped" \
4633 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004634 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004635 -S "SSL - The requested feature is not available"
4636
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004637run_test "DTLS cookie: default (failing)" \
4638 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4639 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4640 1 \
4641 -s "cookie verification failed" \
4642 -S "cookie verification passed" \
4643 -S "cookie verification skipped" \
4644 -C "received hello verify request" \
4645 -S "hello verification requested" \
4646 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004647
4648requires_ipv6
4649run_test "DTLS cookie: enabled, IPv6" \
4650 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4651 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4652 0 \
4653 -s "cookie verification failed" \
4654 -s "cookie verification passed" \
4655 -S "cookie verification skipped" \
4656 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004657 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004658 -S "SSL - The requested feature is not available"
4659
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004660run_test "DTLS cookie: enabled, nbio" \
4661 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4662 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4663 0 \
4664 -s "cookie verification failed" \
4665 -s "cookie verification passed" \
4666 -S "cookie verification skipped" \
4667 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004668 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004669 -S "SSL - The requested feature is not available"
4670
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004671# Tests for client reconnecting from the same port with DTLS
4672
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004673not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004674run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004675 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4676 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004677 0 \
4678 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004679 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004680 -S "Client initiated reconnection from same port"
4681
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004682not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004683run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004684 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4685 "$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 +02004686 0 \
4687 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004688 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004689 -s "Client initiated reconnection from same port"
4690
Paul Bakker362689d2016-05-13 10:33:25 +01004691not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4692run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004693 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4694 "$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 +02004695 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004696 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004697 -s "Client initiated reconnection from same port"
4698
Paul Bakker362689d2016-05-13 10:33:25 +01004699only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4700run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4701 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4702 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4703 0 \
4704 -S "The operation timed out" \
4705 -s "Client initiated reconnection from same port"
4706
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004707run_test "DTLS client reconnect from same port: no cookies" \
4708 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004709 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4710 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004711 -s "The operation timed out" \
4712 -S "Client initiated reconnection from same port"
4713
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004714# Tests for various cases of client authentication with DTLS
4715# (focused on handshake flows and message parsing)
4716
4717run_test "DTLS client auth: required" \
4718 "$P_SRV dtls=1 auth_mode=required" \
4719 "$P_CLI dtls=1" \
4720 0 \
4721 -s "Verifying peer X.509 certificate... ok"
4722
4723run_test "DTLS client auth: optional, client has no cert" \
4724 "$P_SRV dtls=1 auth_mode=optional" \
4725 "$P_CLI dtls=1 crt_file=none key_file=none" \
4726 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004727 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004728
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004729run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004730 "$P_SRV dtls=1 auth_mode=none" \
4731 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
4732 0 \
4733 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004734 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004735
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02004736run_test "DTLS wrong PSK: badmac alert" \
4737 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
4738 "$P_CLI dtls=1 psk=abc124" \
4739 1 \
4740 -s "SSL - Verification of the message MAC failed" \
4741 -c "SSL - A fatal alert message was received from our peer"
4742
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02004743# Tests for receiving fragmented handshake messages with DTLS
4744
4745requires_gnutls
4746run_test "DTLS reassembly: no fragmentation (gnutls server)" \
4747 "$G_SRV -u --mtu 2048 -a" \
4748 "$P_CLI dtls=1 debug_level=2" \
4749 0 \
4750 -C "found fragmented DTLS handshake message" \
4751 -C "error"
4752
4753requires_gnutls
4754run_test "DTLS reassembly: some fragmentation (gnutls server)" \
4755 "$G_SRV -u --mtu 512" \
4756 "$P_CLI dtls=1 debug_level=2" \
4757 0 \
4758 -c "found fragmented DTLS handshake message" \
4759 -C "error"
4760
4761requires_gnutls
4762run_test "DTLS reassembly: more fragmentation (gnutls server)" \
4763 "$G_SRV -u --mtu 128" \
4764 "$P_CLI dtls=1 debug_level=2" \
4765 0 \
4766 -c "found fragmented DTLS handshake message" \
4767 -C "error"
4768
4769requires_gnutls
4770run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
4771 "$G_SRV -u --mtu 128" \
4772 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4773 0 \
4774 -c "found fragmented DTLS handshake message" \
4775 -C "error"
4776
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004777requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004778requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004779run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4780 "$G_SRV -u --mtu 256" \
4781 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4782 0 \
4783 -c "found fragmented DTLS handshake message" \
4784 -c "client hello, adding renegotiation extension" \
4785 -c "found renegotiation extension" \
4786 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004787 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004788 -C "error" \
4789 -s "Extra-header:"
4790
4791requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004792requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004793run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4794 "$G_SRV -u --mtu 256" \
4795 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4796 0 \
4797 -c "found fragmented DTLS handshake message" \
4798 -c "client hello, adding renegotiation extension" \
4799 -c "found renegotiation extension" \
4800 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004801 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004802 -C "error" \
4803 -s "Extra-header:"
4804
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004805run_test "DTLS reassembly: no fragmentation (openssl server)" \
4806 "$O_SRV -dtls1 -mtu 2048" \
4807 "$P_CLI dtls=1 debug_level=2" \
4808 0 \
4809 -C "found fragmented DTLS handshake message" \
4810 -C "error"
4811
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004812run_test "DTLS reassembly: some fragmentation (openssl server)" \
4813 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004814 "$P_CLI dtls=1 debug_level=2" \
4815 0 \
4816 -c "found fragmented DTLS handshake message" \
4817 -C "error"
4818
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004819run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004820 "$O_SRV -dtls1 -mtu 256" \
4821 "$P_CLI dtls=1 debug_level=2" \
4822 0 \
4823 -c "found fragmented DTLS handshake message" \
4824 -C "error"
4825
4826run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4827 "$O_SRV -dtls1 -mtu 256" \
4828 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4829 0 \
4830 -c "found fragmented DTLS handshake message" \
4831 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004832
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004833# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004834
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004835not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004836run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004837 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004838 "$P_SRV dtls=1 debug_level=2" \
4839 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004840 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004841 -C "replayed record" \
4842 -S "replayed record" \
4843 -C "record from another epoch" \
4844 -S "record from another epoch" \
4845 -C "discarding invalid record" \
4846 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004847 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004848 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004849 -c "HTTP/1.0 200 OK"
4850
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004851not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004852run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004853 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004854 "$P_SRV dtls=1 debug_level=2" \
4855 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004856 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004857 -c "replayed record" \
4858 -s "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004859 -c "record from another epoch" \
4860 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004861 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004862 -s "Extra-header:" \
4863 -c "HTTP/1.0 200 OK"
4864
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004865run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4866 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004867 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4868 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004869 0 \
4870 -c "replayed record" \
4871 -S "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004872 -c "record from another epoch" \
4873 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004874 -c "resend" \
4875 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004876 -s "Extra-header:" \
4877 -c "HTTP/1.0 200 OK"
4878
Hanno Becker72a4f032017-11-15 16:39:20 +00004879run_test "DTLS proxy: multiple records in same datagram" \
Hanno Becker8d832182018-03-15 10:14:19 +00004880 -p "$P_PXY pack=50" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004881 "$P_SRV dtls=1 debug_level=2" \
4882 "$P_CLI dtls=1 debug_level=2" \
4883 0 \
4884 -c "next record in same datagram" \
4885 -s "next record in same datagram"
4886
4887run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
Hanno Becker8d832182018-03-15 10:14:19 +00004888 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004889 "$P_SRV dtls=1 debug_level=2" \
4890 "$P_CLI dtls=1 debug_level=2" \
4891 0 \
4892 -c "next record in same datagram" \
4893 -s "next record in same datagram"
4894
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004895run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004896 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004897 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004898 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004899 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004900 -c "discarding invalid record (mac)" \
4901 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004902 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004903 -c "HTTP/1.0 200 OK" \
4904 -S "too many records with bad MAC" \
4905 -S "Verification of the message MAC failed"
4906
4907run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4908 -p "$P_PXY bad_ad=1" \
4909 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4910 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4911 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004912 -C "discarding invalid record (mac)" \
4913 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004914 -S "Extra-header:" \
4915 -C "HTTP/1.0 200 OK" \
4916 -s "too many records with bad MAC" \
4917 -s "Verification of the message MAC failed"
4918
4919run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4920 -p "$P_PXY bad_ad=1" \
4921 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4922 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4923 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004924 -c "discarding invalid record (mac)" \
4925 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004926 -s "Extra-header:" \
4927 -c "HTTP/1.0 200 OK" \
4928 -S "too many records with bad MAC" \
4929 -S "Verification of the message MAC failed"
4930
4931run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4932 -p "$P_PXY bad_ad=1" \
4933 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4934 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4935 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004936 -c "discarding invalid record (mac)" \
4937 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004938 -s "Extra-header:" \
4939 -c "HTTP/1.0 200 OK" \
4940 -s "too many records with bad MAC" \
4941 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004942
4943run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004944 -p "$P_PXY delay_ccs=1" \
4945 "$P_SRV dtls=1 debug_level=1" \
4946 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004947 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004948 -c "record from another epoch" \
4949 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004950 -s "Extra-header:" \
4951 -c "HTTP/1.0 200 OK"
4952
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004953# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004954
Janos Follath74537a62016-09-02 13:45:28 +01004955client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004956run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004957 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004958 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4959 psk=abc123" \
4960 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004961 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4962 0 \
4963 -s "Extra-header:" \
4964 -c "HTTP/1.0 200 OK"
4965
Janos Follath74537a62016-09-02 13:45:28 +01004966client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004967run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4968 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004969 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4970 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004971 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4972 0 \
4973 -s "Extra-header:" \
4974 -c "HTTP/1.0 200 OK"
4975
Janos Follath74537a62016-09-02 13:45:28 +01004976client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004977run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4978 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004979 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4980 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004981 0 \
4982 -s "Extra-header:" \
4983 -c "HTTP/1.0 200 OK"
4984
Janos Follath74537a62016-09-02 13:45:28 +01004985client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004986run_test "DTLS proxy: 3d, FS, client auth" \
4987 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004988 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4989 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004990 0 \
4991 -s "Extra-header:" \
4992 -c "HTTP/1.0 200 OK"
4993
Janos Follath74537a62016-09-02 13:45:28 +01004994client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004995run_test "DTLS proxy: 3d, FS, ticket" \
4996 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004997 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4998 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004999 0 \
5000 -s "Extra-header:" \
5001 -c "HTTP/1.0 200 OK"
5002
Janos Follath74537a62016-09-02 13:45:28 +01005003client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005004run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
5005 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005006 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
5007 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005008 0 \
5009 -s "Extra-header:" \
5010 -c "HTTP/1.0 200 OK"
5011
Janos Follath74537a62016-09-02 13:45:28 +01005012client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005013run_test "DTLS proxy: 3d, max handshake, nbio" \
5014 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005015 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
5016 auth_mode=required" \
5017 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005018 0 \
5019 -s "Extra-header:" \
5020 -c "HTTP/1.0 200 OK"
5021
Janos Follath74537a62016-09-02 13:45:28 +01005022client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005023run_test "DTLS proxy: 3d, min handshake, resumption" \
5024 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5025 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5026 psk=abc123 debug_level=3" \
5027 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5028 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5029 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5030 0 \
5031 -s "a session has been resumed" \
5032 -c "a session has been resumed" \
5033 -s "Extra-header:" \
5034 -c "HTTP/1.0 200 OK"
5035
Janos Follath74537a62016-09-02 13:45:28 +01005036client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005037run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
5038 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5039 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5040 psk=abc123 debug_level=3 nbio=2" \
5041 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5042 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5043 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
5044 0 \
5045 -s "a session has been resumed" \
5046 -c "a session has been resumed" \
5047 -s "Extra-header:" \
5048 -c "HTTP/1.0 200 OK"
5049
Janos Follath74537a62016-09-02 13:45:28 +01005050client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005051requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005052run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005053 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005054 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5055 psk=abc123 renegotiation=1 debug_level=2" \
5056 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5057 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005058 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5059 0 \
5060 -c "=> renegotiate" \
5061 -s "=> renegotiate" \
5062 -s "Extra-header:" \
5063 -c "HTTP/1.0 200 OK"
5064
Janos Follath74537a62016-09-02 13:45:28 +01005065client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005066requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005067run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
5068 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005069 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5070 psk=abc123 renegotiation=1 debug_level=2" \
5071 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5072 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005073 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5074 0 \
5075 -c "=> renegotiate" \
5076 -s "=> renegotiate" \
5077 -s "Extra-header:" \
5078 -c "HTTP/1.0 200 OK"
5079
Janos Follath74537a62016-09-02 13:45:28 +01005080client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005081requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005082run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005083 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005084 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005085 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005086 debug_level=2" \
5087 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005088 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005089 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5090 0 \
5091 -c "=> renegotiate" \
5092 -s "=> renegotiate" \
5093 -s "Extra-header:" \
5094 -c "HTTP/1.0 200 OK"
5095
Janos Follath74537a62016-09-02 13:45:28 +01005096client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005097requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005098run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005099 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005100 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005101 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005102 debug_level=2 nbio=2" \
5103 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005104 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005105 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5106 0 \
5107 -c "=> renegotiate" \
5108 -s "=> renegotiate" \
5109 -s "Extra-header:" \
5110 -c "HTTP/1.0 200 OK"
5111
Janos Follath74537a62016-09-02 13:45:28 +01005112client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005113not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005114run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005115 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5116 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005117 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005118 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005119 -c "HTTP/1.0 200 OK"
5120
Janos Follath74537a62016-09-02 13:45:28 +01005121client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005122not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005123run_test "DTLS proxy: 3d, openssl server, fragmentation" \
5124 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5125 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005126 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005127 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005128 -c "HTTP/1.0 200 OK"
5129
Janos Follath74537a62016-09-02 13:45:28 +01005130client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005131not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005132run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
5133 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5134 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005135 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005136 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005137 -c "HTTP/1.0 200 OK"
5138
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005139requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005140client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005141not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005142run_test "DTLS proxy: 3d, gnutls server" \
5143 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5144 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005145 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005146 0 \
5147 -s "Extra-header:" \
5148 -c "Extra-header:"
5149
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005150requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005151client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005152not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005153run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
5154 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5155 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005156 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005157 0 \
5158 -s "Extra-header:" \
5159 -c "Extra-header:"
5160
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005161requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005162client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005163not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005164run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
5165 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5166 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005167 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005168 0 \
5169 -s "Extra-header:" \
5170 -c "Extra-header:"
5171
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01005172# Final report
5173
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005174echo "------------------------------------------------------------------------"
5175
5176if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005177 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005178else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005179 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005180fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02005181PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02005182echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005183
5184exit $FAILS