blob: a1c7d04904d3dadc20ba74f025b468172f0507c2 [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
635 fi
636
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200637 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100638}
639
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100640cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200641 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200642 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
643 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
644 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
645 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100646 exit 1
647}
648
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100649#
650# MAIN
651#
652
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100653get_options "$@"
654
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100655# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100656P_SRV_BIN="${P_SRV%%[ ]*}"
657P_CLI_BIN="${P_CLI%%[ ]*}"
658P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100659if [ ! -x "$P_SRV_BIN" ]; then
660 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100661 exit 1
662fi
Hanno Becker17c04932017-10-10 14:44:53 +0100663if [ ! -x "$P_CLI_BIN" ]; then
664 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100665 exit 1
666fi
Hanno Becker17c04932017-10-10 14:44:53 +0100667if [ ! -x "$P_PXY_BIN" ]; then
668 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200669 exit 1
670fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100671if [ "$MEMCHECK" -gt 0 ]; then
672 if which valgrind >/dev/null 2>&1; then :; else
673 echo "Memcheck not possible. Valgrind not found"
674 exit 1
675 fi
676fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100677if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
678 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100679 exit 1
680fi
681
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200682# used by watchdog
683MAIN_PID="$$"
684
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100685# We use somewhat arbitrary delays for tests:
686# - how long do we wait for the server to start (when lsof not available)?
687# - how long do we allow for the client to finish?
688# (not to check performance, just to avoid waiting indefinitely)
689# Things are slower with valgrind, so give extra time here.
690#
691# Note: without lsof, there is a trade-off between the running time of this
692# script and the risk of spurious errors because we didn't wait long enough.
693# The watchdog delay on the other hand doesn't affect normal running time of
694# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200695if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100696 START_DELAY=6
697 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200698else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100699 START_DELAY=2
700 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200701fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100702
703# some particular tests need more time:
704# - for the client, we multiply the usual watchdog limit by a factor
705# - for the server, we sleep for a number of seconds after the client exits
706# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200707CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100708SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200709
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200710# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000711# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200712P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
713P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100714P_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 +0200715O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200716O_CLI="$O_CLI -connect localhost:+SRV_PORT"
717G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000718G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200719
Gilles Peskine62469d92017-05-10 10:13:59 +0200720# Allow SHA-1, because many of our test certificates use it
721P_SRV="$P_SRV allow_sha1=1"
722P_CLI="$P_CLI allow_sha1=1"
723
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200724# Also pick a unique name for intermediate files
725SRV_OUT="srv_out.$$"
726CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200727PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200728SESSION="session.$$"
729
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200730SKIP_NEXT="NO"
731
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100732trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100733
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200734# Basic test
735
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200736# Checks that:
737# - things work with all ciphersuites active (used with config-full in all.sh)
738# - the expected (highest security) parameters are selected
739# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200740run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200741 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200742 "$P_CLI" \
743 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200744 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200745 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200746 -s "client hello v3, signature_algorithm ext: 6" \
747 -s "ECDHE curve: secp521r1" \
748 -S "error" \
749 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200750
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000751run_test "Default, DTLS" \
752 "$P_SRV dtls=1" \
753 "$P_CLI dtls=1" \
754 0 \
755 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200756 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000757
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100758# Test current time in ServerHello
759requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200760run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100761 "$P_SRV debug_level=3" \
762 "$P_CLI debug_level=3" \
763 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100764 -f "check_server_hello_time" \
765 -F "check_server_hello_time"
766
Simon Butcher8e004102016-10-14 00:48:33 +0100767# Test for uniqueness of IVs in AEAD ciphersuites
768run_test "Unique IV in GCM" \
769 "$P_SRV exchanges=20 debug_level=4" \
770 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
771 0 \
772 -u "IV used" \
773 -U "IV used"
774
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100775# Tests for rc4 option
776
Simon Butchera410af52016-05-19 22:12:18 +0100777requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100778run_test "RC4: server disabled, client enabled" \
779 "$P_SRV" \
780 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
781 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100782 -s "SSL - The server has no ciphersuites in common"
783
Simon Butchera410af52016-05-19 22:12:18 +0100784requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100785run_test "RC4: server half, client enabled" \
786 "$P_SRV arc4=1" \
787 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
788 1 \
789 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100790
791run_test "RC4: server enabled, client disabled" \
792 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
793 "$P_CLI" \
794 1 \
795 -s "SSL - The server has no ciphersuites in common"
796
797run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100798 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100799 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
800 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100801 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100802 -S "SSL - The server has no ciphersuites in common"
803
Gilles Peskinebc70a182017-05-09 15:59:24 +0200804# Tests for SHA-1 support
805
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200806requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200807run_test "SHA-1 forbidden by default in server certificate" \
808 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
809 "$P_CLI debug_level=2 allow_sha1=0" \
810 1 \
811 -c "The certificate is signed with an unacceptable hash"
812
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200813requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
814run_test "SHA-1 forbidden by default in server certificate" \
815 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
816 "$P_CLI debug_level=2 allow_sha1=0" \
817 0
818
Gilles Peskinebc70a182017-05-09 15:59:24 +0200819run_test "SHA-1 explicitly allowed in server certificate" \
820 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
821 "$P_CLI allow_sha1=1" \
822 0
823
824run_test "SHA-256 allowed by default in server certificate" \
825 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
826 "$P_CLI allow_sha1=0" \
827 0
828
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200829requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200830run_test "SHA-1 forbidden by default in client certificate" \
831 "$P_SRV auth_mode=required allow_sha1=0" \
832 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
833 1 \
834 -s "The certificate is signed with an unacceptable hash"
835
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200836requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
837run_test "SHA-1 forbidden by default in client certificate" \
838 "$P_SRV auth_mode=required allow_sha1=0" \
839 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
840 0
841
Gilles Peskinebc70a182017-05-09 15:59:24 +0200842run_test "SHA-1 explicitly allowed in client certificate" \
843 "$P_SRV auth_mode=required allow_sha1=1" \
844 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
845 0
846
847run_test "SHA-256 allowed by default in client certificate" \
848 "$P_SRV auth_mode=required allow_sha1=0" \
849 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
850 0
851
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100852# Tests for Truncated HMAC extension
853
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100854run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200855 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100856 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100857 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000858 -s "dumping 'expected mac' (20 bytes)" \
859 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100860
Hanno Becker32c55012017-11-10 08:42:54 +0000861requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100862run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200863 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000864 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100865 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000866 -s "dumping 'expected mac' (20 bytes)" \
867 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100868
Hanno Becker32c55012017-11-10 08:42:54 +0000869requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100870run_test "Truncated HMAC: client enabled, server default" \
871 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000872 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100873 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000874 -s "dumping 'expected mac' (20 bytes)" \
875 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100876
Hanno Becker32c55012017-11-10 08:42:54 +0000877requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100878run_test "Truncated HMAC: client enabled, server disabled" \
879 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000880 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100881 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000882 -s "dumping 'expected mac' (20 bytes)" \
883 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100884
Hanno Becker32c55012017-11-10 08:42:54 +0000885requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000886run_test "Truncated HMAC: client disabled, server enabled" \
887 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000888 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000889 0 \
890 -s "dumping 'expected mac' (20 bytes)" \
891 -S "dumping 'expected mac' (10 bytes)"
892
893requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100894run_test "Truncated HMAC: client enabled, server enabled" \
895 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000896 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100897 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000898 -S "dumping 'expected mac' (20 bytes)" \
899 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100900
Hanno Becker4c4f4102017-11-10 09:16:05 +0000901run_test "Truncated HMAC, DTLS: client default, server default" \
902 "$P_SRV dtls=1 debug_level=4" \
903 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
904 0 \
905 -s "dumping 'expected mac' (20 bytes)" \
906 -S "dumping 'expected mac' (10 bytes)"
907
908requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
909run_test "Truncated HMAC, DTLS: client disabled, server default" \
910 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000911 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000912 0 \
913 -s "dumping 'expected mac' (20 bytes)" \
914 -S "dumping 'expected mac' (10 bytes)"
915
916requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
917run_test "Truncated HMAC, DTLS: client enabled, server default" \
918 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000919 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000920 0 \
921 -s "dumping 'expected mac' (20 bytes)" \
922 -S "dumping 'expected mac' (10 bytes)"
923
924requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
925run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
926 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000927 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000928 0 \
929 -s "dumping 'expected mac' (20 bytes)" \
930 -S "dumping 'expected mac' (10 bytes)"
931
932requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
933run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
934 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000935 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000936 0 \
937 -s "dumping 'expected mac' (20 bytes)" \
938 -S "dumping 'expected mac' (10 bytes)"
939
940requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
941run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
942 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000943 "$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 +0100944 0 \
945 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100946 -s "dumping 'expected mac' (10 bytes)"
947
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100948# Tests for Encrypt-then-MAC extension
949
950run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100951 "$P_SRV debug_level=3 \
952 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100953 "$P_CLI debug_level=3" \
954 0 \
955 -c "client hello, adding encrypt_then_mac extension" \
956 -s "found encrypt then mac extension" \
957 -s "server hello, adding encrypt then mac extension" \
958 -c "found encrypt_then_mac extension" \
959 -c "using encrypt then mac" \
960 -s "using encrypt then mac"
961
962run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100963 "$P_SRV debug_level=3 etm=0 \
964 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100965 "$P_CLI debug_level=3 etm=1" \
966 0 \
967 -c "client hello, adding encrypt_then_mac extension" \
968 -s "found encrypt then mac extension" \
969 -S "server hello, adding encrypt then mac extension" \
970 -C "found encrypt_then_mac extension" \
971 -C "using encrypt then mac" \
972 -S "using encrypt then mac"
973
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100974run_test "Encrypt then MAC: client enabled, aead cipher" \
975 "$P_SRV debug_level=3 etm=1 \
976 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
977 "$P_CLI debug_level=3 etm=1" \
978 0 \
979 -c "client hello, adding encrypt_then_mac extension" \
980 -s "found encrypt then mac extension" \
981 -S "server hello, adding encrypt then mac extension" \
982 -C "found encrypt_then_mac extension" \
983 -C "using encrypt then mac" \
984 -S "using encrypt then mac"
985
986run_test "Encrypt then MAC: client enabled, stream cipher" \
987 "$P_SRV debug_level=3 etm=1 \
988 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100989 "$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 +0100990 0 \
991 -c "client hello, adding encrypt_then_mac extension" \
992 -s "found encrypt then mac extension" \
993 -S "server hello, adding encrypt then mac extension" \
994 -C "found encrypt_then_mac extension" \
995 -C "using encrypt then mac" \
996 -S "using encrypt then mac"
997
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100998run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100999 "$P_SRV debug_level=3 etm=1 \
1000 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001001 "$P_CLI debug_level=3 etm=0" \
1002 0 \
1003 -C "client hello, adding encrypt_then_mac extension" \
1004 -S "found encrypt then mac extension" \
1005 -S "server hello, adding encrypt then mac extension" \
1006 -C "found encrypt_then_mac extension" \
1007 -C "using encrypt then mac" \
1008 -S "using encrypt then mac"
1009
Janos Follathe2681a42016-03-07 15:57:05 +00001010requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001011run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001012 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001013 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001014 "$P_CLI debug_level=3 force_version=ssl3" \
1015 0 \
1016 -C "client hello, adding encrypt_then_mac extension" \
1017 -S "found encrypt then mac extension" \
1018 -S "server hello, adding encrypt then mac extension" \
1019 -C "found encrypt_then_mac extension" \
1020 -C "using encrypt then mac" \
1021 -S "using encrypt then mac"
1022
Janos Follathe2681a42016-03-07 15:57:05 +00001023requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001024run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001025 "$P_SRV debug_level=3 force_version=ssl3 \
1026 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001027 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001028 0 \
1029 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001030 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001031 -S "server hello, adding encrypt then mac extension" \
1032 -C "found encrypt_then_mac extension" \
1033 -C "using encrypt then mac" \
1034 -S "using encrypt then mac"
1035
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001036# Tests for Extended Master Secret extension
1037
1038run_test "Extended Master Secret: default" \
1039 "$P_SRV debug_level=3" \
1040 "$P_CLI debug_level=3" \
1041 0 \
1042 -c "client hello, adding extended_master_secret extension" \
1043 -s "found extended master secret extension" \
1044 -s "server hello, adding extended master secret extension" \
1045 -c "found extended_master_secret extension" \
1046 -c "using extended master secret" \
1047 -s "using extended master secret"
1048
1049run_test "Extended Master Secret: client enabled, server disabled" \
1050 "$P_SRV debug_level=3 extended_ms=0" \
1051 "$P_CLI debug_level=3 extended_ms=1" \
1052 0 \
1053 -c "client hello, adding extended_master_secret extension" \
1054 -s "found extended master secret extension" \
1055 -S "server hello, adding extended master secret extension" \
1056 -C "found extended_master_secret extension" \
1057 -C "using extended master secret" \
1058 -S "using extended master secret"
1059
1060run_test "Extended Master Secret: client disabled, server enabled" \
1061 "$P_SRV debug_level=3 extended_ms=1" \
1062 "$P_CLI debug_level=3 extended_ms=0" \
1063 0 \
1064 -C "client hello, adding extended_master_secret extension" \
1065 -S "found extended master secret extension" \
1066 -S "server hello, adding extended master secret extension" \
1067 -C "found extended_master_secret extension" \
1068 -C "using extended master secret" \
1069 -S "using extended master secret"
1070
Janos Follathe2681a42016-03-07 15:57:05 +00001071requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001072run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001073 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001074 "$P_CLI debug_level=3 force_version=ssl3" \
1075 0 \
1076 -C "client hello, adding extended_master_secret extension" \
1077 -S "found extended master secret extension" \
1078 -S "server hello, adding extended master secret extension" \
1079 -C "found extended_master_secret extension" \
1080 -C "using extended master secret" \
1081 -S "using extended master secret"
1082
Janos Follathe2681a42016-03-07 15:57:05 +00001083requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001084run_test "Extended Master Secret: client enabled, server SSLv3" \
1085 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001086 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001087 0 \
1088 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001089 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001090 -S "server hello, adding extended master secret extension" \
1091 -C "found extended_master_secret extension" \
1092 -C "using extended master secret" \
1093 -S "using extended master secret"
1094
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001095# Tests for FALLBACK_SCSV
1096
1097run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001098 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001099 "$P_CLI debug_level=3 force_version=tls1_1" \
1100 0 \
1101 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001102 -S "received FALLBACK_SCSV" \
1103 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001104 -C "is a fatal alert message (msg 86)"
1105
1106run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001107 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001108 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1109 0 \
1110 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001111 -S "received FALLBACK_SCSV" \
1112 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001113 -C "is a fatal alert message (msg 86)"
1114
1115run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001116 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001117 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001118 1 \
1119 -c "adding FALLBACK_SCSV" \
1120 -s "received FALLBACK_SCSV" \
1121 -s "inapropriate fallback" \
1122 -c "is a fatal alert message (msg 86)"
1123
1124run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001125 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001126 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001127 0 \
1128 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001129 -s "received FALLBACK_SCSV" \
1130 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001131 -C "is a fatal alert message (msg 86)"
1132
1133requires_openssl_with_fallback_scsv
1134run_test "Fallback SCSV: default, openssl server" \
1135 "$O_SRV" \
1136 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1137 0 \
1138 -C "adding FALLBACK_SCSV" \
1139 -C "is a fatal alert message (msg 86)"
1140
1141requires_openssl_with_fallback_scsv
1142run_test "Fallback SCSV: enabled, openssl server" \
1143 "$O_SRV" \
1144 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1145 1 \
1146 -c "adding FALLBACK_SCSV" \
1147 -c "is a fatal alert message (msg 86)"
1148
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001149requires_openssl_with_fallback_scsv
1150run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001151 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001152 "$O_CLI -tls1_1" \
1153 0 \
1154 -S "received FALLBACK_SCSV" \
1155 -S "inapropriate fallback"
1156
1157requires_openssl_with_fallback_scsv
1158run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001159 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001160 "$O_CLI -tls1_1 -fallback_scsv" \
1161 1 \
1162 -s "received FALLBACK_SCSV" \
1163 -s "inapropriate fallback"
1164
1165requires_openssl_with_fallback_scsv
1166run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001167 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001168 "$O_CLI -fallback_scsv" \
1169 0 \
1170 -s "received FALLBACK_SCSV" \
1171 -S "inapropriate fallback"
1172
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001173# Test sending and receiving empty application data records
1174
1175run_test "Encrypt then MAC: empty application data record" \
1176 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1177 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1178 0 \
1179 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1180 -s "dumping 'input payload after decrypt' (0 bytes)" \
1181 -c "0 bytes written in 1 fragments"
1182
1183run_test "Default, no Encrypt then MAC: empty application data record" \
1184 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1185 "$P_CLI auth_mode=none etm=0 request_size=0" \
1186 0 \
1187 -s "dumping 'input payload after decrypt' (0 bytes)" \
1188 -c "0 bytes written in 1 fragments"
1189
1190run_test "Encrypt then MAC, DTLS: empty application data record" \
1191 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1192 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1193 0 \
1194 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1195 -s "dumping 'input payload after decrypt' (0 bytes)" \
1196 -c "0 bytes written in 1 fragments"
1197
1198run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
1199 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1200 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1201 0 \
1202 -s "dumping 'input payload after decrypt' (0 bytes)" \
1203 -c "0 bytes written in 1 fragments"
1204
Gilles Peskined50177f2017-05-16 17:53:03 +02001205## ClientHello generated with
1206## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1207## then manually twiddling the ciphersuite list.
1208## The ClientHello content is spelled out below as a hex string as
1209## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1210## The expected response is an inappropriate_fallback alert.
1211requires_openssl_with_fallback_scsv
1212run_test "Fallback SCSV: beginning of list" \
1213 "$P_SRV debug_level=2" \
1214 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1215 0 \
1216 -s "received FALLBACK_SCSV" \
1217 -s "inapropriate fallback"
1218
1219requires_openssl_with_fallback_scsv
1220run_test "Fallback SCSV: end of list" \
1221 "$P_SRV debug_level=2" \
1222 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1223 0 \
1224 -s "received FALLBACK_SCSV" \
1225 -s "inapropriate fallback"
1226
1227## Here the expected response is a valid ServerHello prefix, up to the random.
1228requires_openssl_with_fallback_scsv
1229run_test "Fallback SCSV: not in list" \
1230 "$P_SRV debug_level=2" \
1231 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1232 0 \
1233 -S "received FALLBACK_SCSV" \
1234 -S "inapropriate fallback"
1235
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001236# Tests for CBC 1/n-1 record splitting
1237
1238run_test "CBC Record splitting: TLS 1.2, no splitting" \
1239 "$P_SRV" \
1240 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1241 request_size=123 force_version=tls1_2" \
1242 0 \
1243 -s "Read from client: 123 bytes read" \
1244 -S "Read from client: 1 bytes read" \
1245 -S "122 bytes read"
1246
1247run_test "CBC Record splitting: TLS 1.1, no splitting" \
1248 "$P_SRV" \
1249 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1250 request_size=123 force_version=tls1_1" \
1251 0 \
1252 -s "Read from client: 123 bytes read" \
1253 -S "Read from client: 1 bytes read" \
1254 -S "122 bytes read"
1255
1256run_test "CBC Record splitting: TLS 1.0, splitting" \
1257 "$P_SRV" \
1258 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1259 request_size=123 force_version=tls1" \
1260 0 \
1261 -S "Read from client: 123 bytes read" \
1262 -s "Read from client: 1 bytes read" \
1263 -s "122 bytes read"
1264
Janos Follathe2681a42016-03-07 15:57:05 +00001265requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001266run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001267 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001268 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1269 request_size=123 force_version=ssl3" \
1270 0 \
1271 -S "Read from client: 123 bytes read" \
1272 -s "Read from client: 1 bytes read" \
1273 -s "122 bytes read"
1274
1275run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001276 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001277 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1278 request_size=123 force_version=tls1" \
1279 0 \
1280 -s "Read from client: 123 bytes read" \
1281 -S "Read from client: 1 bytes read" \
1282 -S "122 bytes read"
1283
1284run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1285 "$P_SRV" \
1286 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1287 request_size=123 force_version=tls1 recsplit=0" \
1288 0 \
1289 -s "Read from client: 123 bytes read" \
1290 -S "Read from client: 1 bytes read" \
1291 -S "122 bytes read"
1292
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001293run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1294 "$P_SRV nbio=2" \
1295 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1296 request_size=123 force_version=tls1" \
1297 0 \
1298 -S "Read from client: 123 bytes read" \
1299 -s "Read from client: 1 bytes read" \
1300 -s "122 bytes read"
1301
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001302# Tests for Session Tickets
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001305 "$P_SRV debug_level=3 tickets=1" \
1306 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001307 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001308 -c "client hello, adding session ticket extension" \
1309 -s "found session ticket extension" \
1310 -s "server hello, adding session ticket extension" \
1311 -c "found session_ticket extension" \
1312 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001313 -S "session successfully restored from cache" \
1314 -s "session successfully restored from ticket" \
1315 -s "a session has been resumed" \
1316 -c "a session has been resumed"
1317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001318run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001319 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1320 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001321 0 \
1322 -c "client hello, adding session ticket extension" \
1323 -s "found session ticket extension" \
1324 -s "server hello, adding session ticket extension" \
1325 -c "found session_ticket extension" \
1326 -c "parse new session ticket" \
1327 -S "session successfully restored from cache" \
1328 -s "session successfully restored from ticket" \
1329 -s "a session has been resumed" \
1330 -c "a session has been resumed"
1331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001332run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1334 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001335 0 \
1336 -c "client hello, adding session ticket extension" \
1337 -s "found session ticket extension" \
1338 -s "server hello, adding session ticket extension" \
1339 -c "found session_ticket extension" \
1340 -c "parse new session ticket" \
1341 -S "session successfully restored from cache" \
1342 -S "session successfully restored from ticket" \
1343 -S "a session has been resumed" \
1344 -C "a session has been resumed"
1345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001347 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001348 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001349 0 \
1350 -c "client hello, adding session ticket extension" \
1351 -c "found session_ticket extension" \
1352 -c "parse new session ticket" \
1353 -c "a session has been resumed"
1354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001355run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001356 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001357 "( $O_CLI -sess_out $SESSION; \
1358 $O_CLI -sess_in $SESSION; \
1359 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001360 0 \
1361 -s "found session ticket extension" \
1362 -s "server hello, adding session ticket extension" \
1363 -S "session successfully restored from cache" \
1364 -s "session successfully restored from ticket" \
1365 -s "a session has been resumed"
1366
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001367# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001369run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001370 "$P_SRV debug_level=3 tickets=0" \
1371 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001372 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001373 -c "client hello, adding session ticket extension" \
1374 -s "found session ticket extension" \
1375 -S "server hello, adding session ticket extension" \
1376 -C "found session_ticket extension" \
1377 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001378 -s "session successfully restored from cache" \
1379 -S "session successfully restored from ticket" \
1380 -s "a session has been resumed" \
1381 -c "a session has been resumed"
1382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001383run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001384 "$P_SRV debug_level=3 tickets=1" \
1385 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001386 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001387 -C "client hello, adding session ticket extension" \
1388 -S "found session ticket extension" \
1389 -S "server hello, adding session ticket extension" \
1390 -C "found session_ticket extension" \
1391 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001392 -s "session successfully restored from cache" \
1393 -S "session successfully restored from ticket" \
1394 -s "a session has been resumed" \
1395 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001397run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001398 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1399 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001400 0 \
1401 -S "session successfully restored from cache" \
1402 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001403 -S "a session has been resumed" \
1404 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001406run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001407 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1408 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001409 0 \
1410 -s "session successfully restored from cache" \
1411 -S "session successfully restored from ticket" \
1412 -s "a session has been resumed" \
1413 -c "a session has been resumed"
1414
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001415run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001416 "$P_SRV debug_level=3 tickets=0" \
1417 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001418 0 \
1419 -s "session successfully restored from cache" \
1420 -S "session successfully restored from ticket" \
1421 -s "a session has been resumed" \
1422 -c "a session has been resumed"
1423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001424run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001425 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1426 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001427 0 \
1428 -S "session successfully restored from cache" \
1429 -S "session successfully restored from ticket" \
1430 -S "a session has been resumed" \
1431 -C "a session has been resumed"
1432
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001433run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001434 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1435 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001436 0 \
1437 -s "session successfully restored from cache" \
1438 -S "session successfully restored from ticket" \
1439 -s "a session has been resumed" \
1440 -c "a session has been resumed"
1441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001442run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001443 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001444 "( $O_CLI -sess_out $SESSION; \
1445 $O_CLI -sess_in $SESSION; \
1446 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001447 0 \
1448 -s "found session ticket extension" \
1449 -S "server hello, adding session ticket extension" \
1450 -s "session successfully restored from cache" \
1451 -S "session successfully restored from ticket" \
1452 -s "a session has been resumed"
1453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001454run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001455 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001456 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001457 0 \
1458 -C "found session_ticket extension" \
1459 -C "parse new session ticket" \
1460 -c "a session has been resumed"
1461
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001462# Tests for Max Fragment Length extension
1463
Angus Grattonc4dd0732018-04-11 16:28:39 +10001464if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
1465 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 +01001466 exit 1
1467fi
1468
Angus Grattonc4dd0732018-04-11 16:28:39 +10001469if [ $MAX_CONTENT_LEN -ne 16384 ]; then
1470 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
1471fi
1472
Hanno Becker4aed27e2017-09-18 15:00:34 +01001473requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001474run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001475 "$P_SRV debug_level=3" \
1476 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001477 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001478 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1479 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001480 -C "client hello, adding max_fragment_length extension" \
1481 -S "found max fragment length extension" \
1482 -S "server hello, max_fragment_length extension" \
1483 -C "found max_fragment_length extension"
1484
Hanno Becker4aed27e2017-09-18 15:00:34 +01001485requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001486run_test "Max fragment length: enabled, default, larger message" \
1487 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001488 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001489 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001490 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1491 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001492 -C "client hello, adding max_fragment_length extension" \
1493 -S "found max fragment length extension" \
1494 -S "server hello, max_fragment_length extension" \
1495 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001496 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1497 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001498 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001499
1500requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1501run_test "Max fragment length, DTLS: enabled, default, larger message" \
1502 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001503 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001504 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001505 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1506 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001507 -C "client hello, adding max_fragment_length extension" \
1508 -S "found max fragment length extension" \
1509 -S "server hello, max_fragment_length extension" \
1510 -C "found max_fragment_length extension" \
1511 -c "fragment larger than.*maximum "
1512
Angus Grattonc4dd0732018-04-11 16:28:39 +10001513# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1514# (session fragment length will be 16384 regardless of mbedtls
1515# content length configuration.)
1516
Hanno Beckerc5266962017-09-18 15:01:50 +01001517requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1518run_test "Max fragment length: disabled, larger message" \
1519 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001520 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001521 0 \
1522 -C "Maximum fragment length is 16384" \
1523 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001524 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1525 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001526 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001527
1528requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1529run_test "Max fragment length DTLS: disabled, larger message" \
1530 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001531 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001532 1 \
1533 -C "Maximum fragment length is 16384" \
1534 -S "Maximum fragment length is 16384" \
1535 -c "fragment larger than.*maximum "
1536
1537requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001538run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001539 "$P_SRV debug_level=3" \
1540 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001541 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001542 -c "Maximum fragment length is 4096" \
1543 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001544 -c "client hello, adding max_fragment_length extension" \
1545 -s "found max fragment length extension" \
1546 -s "server hello, max_fragment_length extension" \
1547 -c "found max_fragment_length extension"
1548
Hanno Becker4aed27e2017-09-18 15:00:34 +01001549requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001550run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001551 "$P_SRV debug_level=3 max_frag_len=4096" \
1552 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001553 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001554 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001555 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001556 -C "client hello, adding max_fragment_length extension" \
1557 -S "found max fragment length extension" \
1558 -S "server hello, max_fragment_length extension" \
1559 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001560
Hanno Becker4aed27e2017-09-18 15:00:34 +01001561requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562requires_gnutls
1563run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001564 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001565 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001566 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001567 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001568 -c "client hello, adding max_fragment_length extension" \
1569 -c "found max_fragment_length extension"
1570
Hanno Becker4aed27e2017-09-18 15:00:34 +01001571requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001572run_test "Max fragment length: client, message just fits" \
1573 "$P_SRV debug_level=3" \
1574 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1575 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001576 -c "Maximum fragment length is 2048" \
1577 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001578 -c "client hello, adding max_fragment_length extension" \
1579 -s "found max fragment length extension" \
1580 -s "server hello, max_fragment_length extension" \
1581 -c "found max_fragment_length extension" \
1582 -c "2048 bytes written in 1 fragments" \
1583 -s "2048 bytes read"
1584
Hanno Becker4aed27e2017-09-18 15:00:34 +01001585requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001586run_test "Max fragment length: client, larger message" \
1587 "$P_SRV debug_level=3" \
1588 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1589 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001590 -c "Maximum fragment length is 2048" \
1591 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001592 -c "client hello, adding max_fragment_length extension" \
1593 -s "found max fragment length extension" \
1594 -s "server hello, max_fragment_length extension" \
1595 -c "found max_fragment_length extension" \
1596 -c "2345 bytes written in 2 fragments" \
1597 -s "2048 bytes read" \
1598 -s "297 bytes read"
1599
Hanno Becker4aed27e2017-09-18 15:00:34 +01001600requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001601run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001602 "$P_SRV debug_level=3 dtls=1" \
1603 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1604 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001605 -c "Maximum fragment length is 2048" \
1606 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001607 -c "client hello, adding max_fragment_length extension" \
1608 -s "found max fragment length extension" \
1609 -s "server hello, max_fragment_length extension" \
1610 -c "found max_fragment_length extension" \
1611 -c "fragment larger than.*maximum"
1612
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001613# Tests for renegotiation
1614
Hanno Becker6a243642017-10-12 15:18:45 +01001615# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001616run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001617 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001618 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001619 0 \
1620 -C "client hello, adding renegotiation extension" \
1621 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1622 -S "found renegotiation extension" \
1623 -s "server hello, secure renegotiation extension" \
1624 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001625 -C "=> renegotiate" \
1626 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001627 -S "write hello request"
1628
Hanno Becker6a243642017-10-12 15:18:45 +01001629requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001630run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001631 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001632 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001633 0 \
1634 -c "client hello, adding renegotiation extension" \
1635 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1636 -s "found renegotiation extension" \
1637 -s "server hello, secure renegotiation extension" \
1638 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001639 -c "=> renegotiate" \
1640 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001641 -S "write hello request"
1642
Hanno Becker6a243642017-10-12 15:18:45 +01001643requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001644run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001645 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001646 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001647 0 \
1648 -c "client hello, adding renegotiation extension" \
1649 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1650 -s "found renegotiation extension" \
1651 -s "server hello, secure renegotiation extension" \
1652 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001653 -c "=> renegotiate" \
1654 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001655 -s "write hello request"
1656
Janos Follathb0f148c2017-10-05 12:29:42 +01001657# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1658# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1659# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001660requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001661run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1662 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1663 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1664 0 \
1665 -c "client hello, adding renegotiation extension" \
1666 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1667 -s "found renegotiation extension" \
1668 -s "server hello, secure renegotiation extension" \
1669 -c "found renegotiation extension" \
1670 -c "=> renegotiate" \
1671 -s "=> renegotiate" \
1672 -S "write hello request" \
1673 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1674
1675# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1676# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1677# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001678requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001679run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1680 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1681 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1682 0 \
1683 -c "client hello, adding renegotiation extension" \
1684 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1685 -s "found renegotiation extension" \
1686 -s "server hello, secure renegotiation extension" \
1687 -c "found renegotiation extension" \
1688 -c "=> renegotiate" \
1689 -s "=> renegotiate" \
1690 -s "write hello request" \
1691 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1692
Hanno Becker6a243642017-10-12 15:18:45 +01001693requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001694run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001695 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001696 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001697 0 \
1698 -c "client hello, adding renegotiation extension" \
1699 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1700 -s "found renegotiation extension" \
1701 -s "server hello, secure renegotiation extension" \
1702 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001703 -c "=> renegotiate" \
1704 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001705 -s "write hello request"
1706
Hanno Becker6a243642017-10-12 15:18:45 +01001707requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001708run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001709 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001710 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001711 1 \
1712 -c "client hello, adding renegotiation extension" \
1713 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1714 -S "found renegotiation extension" \
1715 -s "server hello, secure renegotiation extension" \
1716 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001717 -c "=> renegotiate" \
1718 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001719 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001720 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001721 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001722
Hanno Becker6a243642017-10-12 15:18:45 +01001723requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001724run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001725 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001726 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001727 0 \
1728 -C "client hello, adding renegotiation extension" \
1729 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1730 -S "found renegotiation extension" \
1731 -s "server hello, secure renegotiation extension" \
1732 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001733 -C "=> renegotiate" \
1734 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001735 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001736 -S "SSL - An unexpected message was received from our peer" \
1737 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001738
Hanno Becker6a243642017-10-12 15:18:45 +01001739requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001740run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001741 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001742 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001743 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001744 0 \
1745 -C "client hello, adding renegotiation extension" \
1746 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1747 -S "found renegotiation extension" \
1748 -s "server hello, secure renegotiation extension" \
1749 -c "found renegotiation extension" \
1750 -C "=> renegotiate" \
1751 -S "=> renegotiate" \
1752 -s "write hello request" \
1753 -S "SSL - An unexpected message was received from our peer" \
1754 -S "failed"
1755
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001756# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001757requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001758run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001759 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001760 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001761 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001762 0 \
1763 -C "client hello, adding renegotiation extension" \
1764 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1765 -S "found renegotiation extension" \
1766 -s "server hello, secure renegotiation extension" \
1767 -c "found renegotiation extension" \
1768 -C "=> renegotiate" \
1769 -S "=> renegotiate" \
1770 -s "write hello request" \
1771 -S "SSL - An unexpected message was received from our peer" \
1772 -S "failed"
1773
Hanno Becker6a243642017-10-12 15:18:45 +01001774requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001775run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001776 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001777 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001778 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001779 0 \
1780 -C "client hello, adding renegotiation extension" \
1781 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1782 -S "found renegotiation extension" \
1783 -s "server hello, secure renegotiation extension" \
1784 -c "found renegotiation extension" \
1785 -C "=> renegotiate" \
1786 -S "=> renegotiate" \
1787 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001788 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001789
Hanno Becker6a243642017-10-12 15:18:45 +01001790requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001791run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001792 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001793 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001794 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001795 0 \
1796 -c "client hello, adding renegotiation extension" \
1797 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1798 -s "found renegotiation extension" \
1799 -s "server hello, secure renegotiation extension" \
1800 -c "found renegotiation extension" \
1801 -c "=> renegotiate" \
1802 -s "=> renegotiate" \
1803 -s "write hello request" \
1804 -S "SSL - An unexpected message was received from our peer" \
1805 -S "failed"
1806
Hanno Becker6a243642017-10-12 15:18:45 +01001807requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001808run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001809 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001810 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1811 0 \
1812 -C "client hello, adding renegotiation extension" \
1813 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1814 -S "found renegotiation extension" \
1815 -s "server hello, secure renegotiation extension" \
1816 -c "found renegotiation extension" \
1817 -S "record counter limit reached: renegotiate" \
1818 -C "=> renegotiate" \
1819 -S "=> renegotiate" \
1820 -S "write hello request" \
1821 -S "SSL - An unexpected message was received from our peer" \
1822 -S "failed"
1823
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001824# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001825requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001826run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001827 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001828 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001829 0 \
1830 -c "client hello, adding renegotiation extension" \
1831 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1832 -s "found renegotiation extension" \
1833 -s "server hello, secure renegotiation extension" \
1834 -c "found renegotiation extension" \
1835 -s "record counter limit reached: renegotiate" \
1836 -c "=> renegotiate" \
1837 -s "=> renegotiate" \
1838 -s "write hello request" \
1839 -S "SSL - An unexpected message was received from our peer" \
1840 -S "failed"
1841
Hanno Becker6a243642017-10-12 15:18:45 +01001842requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001843run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001844 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001845 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001846 0 \
1847 -c "client hello, adding renegotiation extension" \
1848 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1849 -s "found renegotiation extension" \
1850 -s "server hello, secure renegotiation extension" \
1851 -c "found renegotiation extension" \
1852 -s "record counter limit reached: renegotiate" \
1853 -c "=> renegotiate" \
1854 -s "=> renegotiate" \
1855 -s "write hello request" \
1856 -S "SSL - An unexpected message was received from our peer" \
1857 -S "failed"
1858
Hanno Becker6a243642017-10-12 15:18:45 +01001859requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001860run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001861 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001862 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1863 0 \
1864 -C "client hello, adding renegotiation extension" \
1865 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1866 -S "found renegotiation extension" \
1867 -s "server hello, secure renegotiation extension" \
1868 -c "found renegotiation extension" \
1869 -S "record counter limit reached: renegotiate" \
1870 -C "=> renegotiate" \
1871 -S "=> renegotiate" \
1872 -S "write hello request" \
1873 -S "SSL - An unexpected message was received from our peer" \
1874 -S "failed"
1875
Hanno Becker6a243642017-10-12 15:18:45 +01001876requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001877run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001878 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001879 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001880 0 \
1881 -c "client hello, adding renegotiation extension" \
1882 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1883 -s "found renegotiation extension" \
1884 -s "server hello, secure renegotiation extension" \
1885 -c "found renegotiation extension" \
1886 -c "=> renegotiate" \
1887 -s "=> renegotiate" \
1888 -S "write hello request"
1889
Hanno Becker6a243642017-10-12 15:18:45 +01001890requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001891run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001892 "$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 +02001893 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001894 0 \
1895 -c "client hello, adding renegotiation extension" \
1896 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1897 -s "found renegotiation extension" \
1898 -s "server hello, secure renegotiation extension" \
1899 -c "found renegotiation extension" \
1900 -c "=> renegotiate" \
1901 -s "=> renegotiate" \
1902 -s "write hello request"
1903
Hanno Becker6a243642017-10-12 15:18:45 +01001904requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001905run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001906 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001907 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001908 0 \
1909 -c "client hello, adding renegotiation extension" \
1910 -c "found renegotiation extension" \
1911 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001912 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001913 -C "error" \
1914 -c "HTTP/1.0 200 [Oo][Kk]"
1915
Paul Bakker539d9722015-02-08 16:18:35 +01001916requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001917requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001918run_test "Renegotiation: gnutls server strict, client-initiated" \
1919 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001920 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001921 0 \
1922 -c "client hello, adding renegotiation extension" \
1923 -c "found renegotiation extension" \
1924 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001925 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001926 -C "error" \
1927 -c "HTTP/1.0 200 [Oo][Kk]"
1928
Paul Bakker539d9722015-02-08 16:18:35 +01001929requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001930requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001931run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1932 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1933 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1934 1 \
1935 -c "client hello, adding renegotiation extension" \
1936 -C "found renegotiation extension" \
1937 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001938 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001939 -c "error" \
1940 -C "HTTP/1.0 200 [Oo][Kk]"
1941
Paul Bakker539d9722015-02-08 16:18:35 +01001942requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001943requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001944run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1945 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1946 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1947 allow_legacy=0" \
1948 1 \
1949 -c "client hello, adding renegotiation extension" \
1950 -C "found renegotiation extension" \
1951 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001952 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001953 -c "error" \
1954 -C "HTTP/1.0 200 [Oo][Kk]"
1955
Paul Bakker539d9722015-02-08 16:18:35 +01001956requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001957requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001958run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1959 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1960 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1961 allow_legacy=1" \
1962 0 \
1963 -c "client hello, adding renegotiation extension" \
1964 -C "found renegotiation extension" \
1965 -c "=> renegotiate" \
1966 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001967 -C "error" \
1968 -c "HTTP/1.0 200 [Oo][Kk]"
1969
Hanno Becker6a243642017-10-12 15:18:45 +01001970requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001971run_test "Renegotiation: DTLS, client-initiated" \
1972 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1973 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1974 0 \
1975 -c "client hello, adding renegotiation extension" \
1976 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1977 -s "found renegotiation extension" \
1978 -s "server hello, secure renegotiation extension" \
1979 -c "found renegotiation extension" \
1980 -c "=> renegotiate" \
1981 -s "=> renegotiate" \
1982 -S "write hello request"
1983
Hanno Becker6a243642017-10-12 15:18:45 +01001984requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001985run_test "Renegotiation: DTLS, server-initiated" \
1986 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001987 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1988 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001989 0 \
1990 -c "client hello, adding renegotiation extension" \
1991 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1992 -s "found renegotiation extension" \
1993 -s "server hello, secure renegotiation extension" \
1994 -c "found renegotiation extension" \
1995 -c "=> renegotiate" \
1996 -s "=> renegotiate" \
1997 -s "write hello request"
1998
Hanno Becker6a243642017-10-12 15:18:45 +01001999requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002000run_test "Renegotiation: DTLS, renego_period overflow" \
2001 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2002 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2003 0 \
2004 -c "client hello, adding renegotiation extension" \
2005 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2006 -s "found renegotiation extension" \
2007 -s "server hello, secure renegotiation extension" \
2008 -s "record counter limit reached: renegotiate" \
2009 -c "=> renegotiate" \
2010 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002011 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002012
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002013requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002014requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002015run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2016 "$G_SRV -u --mtu 4096" \
2017 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2018 0 \
2019 -c "client hello, adding renegotiation extension" \
2020 -c "found renegotiation extension" \
2021 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002022 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002023 -C "error" \
2024 -s "Extra-header:"
2025
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002026# Test for the "secure renegotation" extension only (no actual renegotiation)
2027
Paul Bakker539d9722015-02-08 16:18:35 +01002028requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002029run_test "Renego ext: gnutls server strict, client default" \
2030 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2031 "$P_CLI debug_level=3" \
2032 0 \
2033 -c "found renegotiation extension" \
2034 -C "error" \
2035 -c "HTTP/1.0 200 [Oo][Kk]"
2036
Paul Bakker539d9722015-02-08 16:18:35 +01002037requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002038run_test "Renego ext: gnutls server unsafe, client default" \
2039 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2040 "$P_CLI debug_level=3" \
2041 0 \
2042 -C "found renegotiation extension" \
2043 -C "error" \
2044 -c "HTTP/1.0 200 [Oo][Kk]"
2045
Paul Bakker539d9722015-02-08 16:18:35 +01002046requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002047run_test "Renego ext: gnutls server unsafe, client break legacy" \
2048 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2049 "$P_CLI debug_level=3 allow_legacy=-1" \
2050 1 \
2051 -C "found renegotiation extension" \
2052 -c "error" \
2053 -C "HTTP/1.0 200 [Oo][Kk]"
2054
Paul Bakker539d9722015-02-08 16:18:35 +01002055requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002056run_test "Renego ext: gnutls client strict, server default" \
2057 "$P_SRV debug_level=3" \
2058 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2059 0 \
2060 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2061 -s "server hello, secure renegotiation extension"
2062
Paul Bakker539d9722015-02-08 16:18:35 +01002063requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002064run_test "Renego ext: gnutls client unsafe, server default" \
2065 "$P_SRV debug_level=3" \
2066 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2067 0 \
2068 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2069 -S "server hello, secure renegotiation extension"
2070
Paul Bakker539d9722015-02-08 16:18:35 +01002071requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002072run_test "Renego ext: gnutls client unsafe, server break legacy" \
2073 "$P_SRV debug_level=3 allow_legacy=-1" \
2074 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2075 1 \
2076 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2077 -S "server hello, secure renegotiation extension"
2078
Janos Follath0b242342016-02-17 10:11:21 +00002079# Tests for silently dropping trailing extra bytes in .der certificates
2080
2081requires_gnutls
2082run_test "DER format: no trailing bytes" \
2083 "$P_SRV crt_file=data_files/server5-der0.crt \
2084 key_file=data_files/server5.key" \
2085 "$G_CLI " \
2086 0 \
2087 -c "Handshake was completed" \
2088
2089requires_gnutls
2090run_test "DER format: with a trailing zero byte" \
2091 "$P_SRV crt_file=data_files/server5-der1a.crt \
2092 key_file=data_files/server5.key" \
2093 "$G_CLI " \
2094 0 \
2095 -c "Handshake was completed" \
2096
2097requires_gnutls
2098run_test "DER format: with a trailing random byte" \
2099 "$P_SRV crt_file=data_files/server5-der1b.crt \
2100 key_file=data_files/server5.key" \
2101 "$G_CLI " \
2102 0 \
2103 -c "Handshake was completed" \
2104
2105requires_gnutls
2106run_test "DER format: with 2 trailing random bytes" \
2107 "$P_SRV crt_file=data_files/server5-der2.crt \
2108 key_file=data_files/server5.key" \
2109 "$G_CLI " \
2110 0 \
2111 -c "Handshake was completed" \
2112
2113requires_gnutls
2114run_test "DER format: with 4 trailing random bytes" \
2115 "$P_SRV crt_file=data_files/server5-der4.crt \
2116 key_file=data_files/server5.key" \
2117 "$G_CLI " \
2118 0 \
2119 -c "Handshake was completed" \
2120
2121requires_gnutls
2122run_test "DER format: with 8 trailing random bytes" \
2123 "$P_SRV crt_file=data_files/server5-der8.crt \
2124 key_file=data_files/server5.key" \
2125 "$G_CLI " \
2126 0 \
2127 -c "Handshake was completed" \
2128
2129requires_gnutls
2130run_test "DER format: with 9 trailing random bytes" \
2131 "$P_SRV crt_file=data_files/server5-der9.crt \
2132 key_file=data_files/server5.key" \
2133 "$G_CLI " \
2134 0 \
2135 -c "Handshake was completed" \
2136
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002137# Tests for auth_mode
2138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002139run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002140 "$P_SRV crt_file=data_files/server5-badsign.crt \
2141 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002142 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002143 1 \
2144 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002145 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002146 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002147 -c "X509 - Certificate verification failed"
2148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002149run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002150 "$P_SRV crt_file=data_files/server5-badsign.crt \
2151 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002152 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002153 0 \
2154 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002155 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002156 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002157 -C "X509 - Certificate verification failed"
2158
Hanno Beckere6706e62017-05-15 16:05:15 +01002159run_test "Authentication: server goodcert, client optional, no trusted CA" \
2160 "$P_SRV" \
2161 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2162 0 \
2163 -c "x509_verify_cert() returned" \
2164 -c "! The certificate is not correctly signed by the trusted CA" \
2165 -c "! Certificate verification flags"\
2166 -C "! mbedtls_ssl_handshake returned" \
2167 -C "X509 - Certificate verification failed" \
2168 -C "SSL - No CA Chain is set, but required to operate"
2169
2170run_test "Authentication: server goodcert, client required, no trusted CA" \
2171 "$P_SRV" \
2172 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2173 1 \
2174 -c "x509_verify_cert() returned" \
2175 -c "! The certificate is not correctly signed by the trusted CA" \
2176 -c "! Certificate verification flags"\
2177 -c "! mbedtls_ssl_handshake returned" \
2178 -c "SSL - No CA Chain is set, but required to operate"
2179
2180# The purpose of the next two tests is to test the client's behaviour when receiving a server
2181# certificate with an unsupported elliptic curve. This should usually not happen because
2182# the client informs the server about the supported curves - it does, though, in the
2183# corner case of a static ECDH suite, because the server doesn't check the curve on that
2184# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2185# different means to have the server ignoring the client's supported curve list.
2186
2187requires_config_enabled MBEDTLS_ECP_C
2188run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2189 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2190 crt_file=data_files/server5.ku-ka.crt" \
2191 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2192 1 \
2193 -c "bad certificate (EC key curve)"\
2194 -c "! Certificate verification flags"\
2195 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2196
2197requires_config_enabled MBEDTLS_ECP_C
2198run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2199 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2200 crt_file=data_files/server5.ku-ka.crt" \
2201 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2202 1 \
2203 -c "bad certificate (EC key curve)"\
2204 -c "! Certificate verification flags"\
2205 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002208 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002209 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002210 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002211 0 \
2212 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002213 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002214 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002215 -C "X509 - Certificate verification failed"
2216
Simon Butcher99000142016-10-13 17:21:01 +01002217run_test "Authentication: client SHA256, server required" \
2218 "$P_SRV auth_mode=required" \
2219 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2220 key_file=data_files/server6.key \
2221 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2222 0 \
2223 -c "Supported Signature Algorithm found: 4," \
2224 -c "Supported Signature Algorithm found: 5,"
2225
2226run_test "Authentication: client SHA384, server required" \
2227 "$P_SRV auth_mode=required" \
2228 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2229 key_file=data_files/server6.key \
2230 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2231 0 \
2232 -c "Supported Signature Algorithm found: 4," \
2233 -c "Supported Signature Algorithm found: 5,"
2234
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002235requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2236run_test "Authentication: client has no cert, server required (SSLv3)" \
2237 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2238 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2239 key_file=data_files/server5.key" \
2240 1 \
2241 -S "skip write certificate request" \
2242 -C "skip parse certificate request" \
2243 -c "got a certificate request" \
2244 -c "got no certificate to send" \
2245 -S "x509_verify_cert() returned" \
2246 -s "client has no certificate" \
2247 -s "! mbedtls_ssl_handshake returned" \
2248 -c "! mbedtls_ssl_handshake returned" \
2249 -s "No client certification received from the client, but required by the authentication mode"
2250
2251run_test "Authentication: client has no cert, server required (TLS)" \
2252 "$P_SRV debug_level=3 auth_mode=required" \
2253 "$P_CLI debug_level=3 crt_file=none \
2254 key_file=data_files/server5.key" \
2255 1 \
2256 -S "skip write certificate request" \
2257 -C "skip parse certificate request" \
2258 -c "got a certificate request" \
2259 -c "= write certificate$" \
2260 -C "skip write certificate$" \
2261 -S "x509_verify_cert() returned" \
2262 -s "client has no certificate" \
2263 -s "! mbedtls_ssl_handshake returned" \
2264 -c "! mbedtls_ssl_handshake returned" \
2265 -s "No client certification received from the client, but required by the authentication mode"
2266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002267run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002268 "$P_SRV debug_level=3 auth_mode=required" \
2269 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002270 key_file=data_files/server5.key" \
2271 1 \
2272 -S "skip write certificate request" \
2273 -C "skip parse certificate request" \
2274 -c "got a certificate request" \
2275 -C "skip write certificate" \
2276 -C "skip write certificate verify" \
2277 -S "skip parse certificate verify" \
2278 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002279 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002280 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002281 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002282 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002283 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002284# We don't check that the client receives the alert because it might
2285# detect that its write end of the connection is closed and abort
2286# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002287
Janos Follath89baba22017-04-10 14:34:35 +01002288run_test "Authentication: client cert not trusted, server required" \
2289 "$P_SRV debug_level=3 auth_mode=required" \
2290 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2291 key_file=data_files/server5.key" \
2292 1 \
2293 -S "skip write certificate request" \
2294 -C "skip parse certificate request" \
2295 -c "got a certificate request" \
2296 -C "skip write certificate" \
2297 -C "skip write certificate verify" \
2298 -S "skip parse certificate verify" \
2299 -s "x509_verify_cert() returned" \
2300 -s "! The certificate is not correctly signed by the trusted CA" \
2301 -s "! mbedtls_ssl_handshake returned" \
2302 -c "! mbedtls_ssl_handshake returned" \
2303 -s "X509 - Certificate verification failed"
2304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002305run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002306 "$P_SRV debug_level=3 auth_mode=optional" \
2307 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002308 key_file=data_files/server5.key" \
2309 0 \
2310 -S "skip write certificate request" \
2311 -C "skip parse certificate request" \
2312 -c "got a certificate request" \
2313 -C "skip write certificate" \
2314 -C "skip write certificate verify" \
2315 -S "skip parse certificate verify" \
2316 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002317 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002318 -S "! mbedtls_ssl_handshake returned" \
2319 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002320 -S "X509 - Certificate verification failed"
2321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002322run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002323 "$P_SRV debug_level=3 auth_mode=none" \
2324 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002325 key_file=data_files/server5.key" \
2326 0 \
2327 -s "skip write certificate request" \
2328 -C "skip parse certificate request" \
2329 -c "got no certificate request" \
2330 -c "skip write certificate" \
2331 -c "skip write certificate verify" \
2332 -s "skip parse certificate verify" \
2333 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002334 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002335 -S "! mbedtls_ssl_handshake returned" \
2336 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002337 -S "X509 - Certificate verification failed"
2338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002339run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002340 "$P_SRV debug_level=3 auth_mode=optional" \
2341 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002342 0 \
2343 -S "skip write certificate request" \
2344 -C "skip parse certificate request" \
2345 -c "got a certificate request" \
2346 -C "skip write certificate$" \
2347 -C "got no certificate to send" \
2348 -S "SSLv3 client has no certificate" \
2349 -c "skip write certificate verify" \
2350 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002351 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002352 -S "! mbedtls_ssl_handshake returned" \
2353 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002354 -S "X509 - Certificate verification failed"
2355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002356run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002357 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002358 "$O_CLI" \
2359 0 \
2360 -S "skip write certificate request" \
2361 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002362 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002363 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002364 -S "X509 - Certificate verification failed"
2365
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002366run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002367 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002368 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002369 0 \
2370 -C "skip parse certificate request" \
2371 -c "got a certificate request" \
2372 -C "skip write certificate$" \
2373 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002374 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002375
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002376run_test "Authentication: client no cert, openssl server required" \
2377 "$O_SRV -Verify 10" \
2378 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2379 1 \
2380 -C "skip parse certificate request" \
2381 -c "got a certificate request" \
2382 -C "skip write certificate$" \
2383 -c "skip write certificate verify" \
2384 -c "! mbedtls_ssl_handshake returned"
2385
Janos Follathe2681a42016-03-07 15:57:05 +00002386requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002387run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002388 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002389 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002390 0 \
2391 -S "skip write certificate request" \
2392 -C "skip parse certificate request" \
2393 -c "got a certificate request" \
2394 -C "skip write certificate$" \
2395 -c "skip write certificate verify" \
2396 -c "got no certificate to send" \
2397 -s "SSLv3 client has no certificate" \
2398 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002399 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002400 -S "! mbedtls_ssl_handshake returned" \
2401 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002402 -S "X509 - Certificate verification failed"
2403
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002404# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2405# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002406
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002407MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002408MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002409
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002410if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002411 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002412 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002413 printf "test value of ${MAX_IM_CA}. \n"
2414 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002415 printf "The tests assume this value and if it changes, the tests in this\n"
2416 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002417 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002418
2419 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002420fi
2421
Angus Grattonc4dd0732018-04-11 16:28:39 +10002422requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002423run_test "Authentication: server max_int chain, client default" \
2424 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2425 key_file=data_files/dir-maxpath/09.key" \
2426 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2427 0 \
2428 -C "X509 - A fatal error occured"
2429
Angus Grattonc4dd0732018-04-11 16:28:39 +10002430requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002431run_test "Authentication: server max_int+1 chain, client default" \
2432 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2433 key_file=data_files/dir-maxpath/10.key" \
2434 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2435 1 \
2436 -c "X509 - A fatal error occured"
2437
Angus Grattonc4dd0732018-04-11 16:28:39 +10002438requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002439run_test "Authentication: server max_int+1 chain, client optional" \
2440 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2441 key_file=data_files/dir-maxpath/10.key" \
2442 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2443 auth_mode=optional" \
2444 1 \
2445 -c "X509 - A fatal error occured"
2446
Angus Grattonc4dd0732018-04-11 16:28:39 +10002447requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002448run_test "Authentication: server max_int+1 chain, client none" \
2449 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2450 key_file=data_files/dir-maxpath/10.key" \
2451 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2452 auth_mode=none" \
2453 0 \
2454 -C "X509 - A fatal error occured"
2455
Angus Grattonc4dd0732018-04-11 16:28:39 +10002456requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002457run_test "Authentication: client max_int+1 chain, server default" \
2458 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2459 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2460 key_file=data_files/dir-maxpath/10.key" \
2461 0 \
2462 -S "X509 - A fatal error occured"
2463
Angus Grattonc4dd0732018-04-11 16:28:39 +10002464requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002465run_test "Authentication: client max_int+1 chain, server optional" \
2466 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2467 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2468 key_file=data_files/dir-maxpath/10.key" \
2469 1 \
2470 -s "X509 - A fatal error occured"
2471
Angus Grattonc4dd0732018-04-11 16:28:39 +10002472requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002473run_test "Authentication: client max_int+1 chain, server required" \
2474 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2475 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2476 key_file=data_files/dir-maxpath/10.key" \
2477 1 \
2478 -s "X509 - A fatal error occured"
2479
Angus Grattonc4dd0732018-04-11 16:28:39 +10002480requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002481run_test "Authentication: client max_int chain, server required" \
2482 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2483 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2484 key_file=data_files/dir-maxpath/09.key" \
2485 0 \
2486 -S "X509 - A fatal error occured"
2487
Janos Follath89baba22017-04-10 14:34:35 +01002488# Tests for CA list in CertificateRequest messages
2489
2490run_test "Authentication: send CA list in CertificateRequest (default)" \
2491 "$P_SRV debug_level=3 auth_mode=required" \
2492 "$P_CLI crt_file=data_files/server6.crt \
2493 key_file=data_files/server6.key" \
2494 0 \
2495 -s "requested DN"
2496
2497run_test "Authentication: do not send CA list in CertificateRequest" \
2498 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2499 "$P_CLI crt_file=data_files/server6.crt \
2500 key_file=data_files/server6.key" \
2501 0 \
2502 -S "requested DN"
2503
2504run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2505 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2506 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2507 key_file=data_files/server5.key" \
2508 1 \
2509 -S "requested DN" \
2510 -s "x509_verify_cert() returned" \
2511 -s "! The certificate is not correctly signed by the trusted CA" \
2512 -s "! mbedtls_ssl_handshake returned" \
2513 -c "! mbedtls_ssl_handshake returned" \
2514 -s "X509 - Certificate verification failed"
2515
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002516# Tests for certificate selection based on SHA verson
2517
2518run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2519 "$P_SRV crt_file=data_files/server5.crt \
2520 key_file=data_files/server5.key \
2521 crt_file2=data_files/server5-sha1.crt \
2522 key_file2=data_files/server5.key" \
2523 "$P_CLI force_version=tls1_2" \
2524 0 \
2525 -c "signed using.*ECDSA with SHA256" \
2526 -C "signed using.*ECDSA with SHA1"
2527
2528run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2529 "$P_SRV crt_file=data_files/server5.crt \
2530 key_file=data_files/server5.key \
2531 crt_file2=data_files/server5-sha1.crt \
2532 key_file2=data_files/server5.key" \
2533 "$P_CLI force_version=tls1_1" \
2534 0 \
2535 -C "signed using.*ECDSA with SHA256" \
2536 -c "signed using.*ECDSA with SHA1"
2537
2538run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2539 "$P_SRV crt_file=data_files/server5.crt \
2540 key_file=data_files/server5.key \
2541 crt_file2=data_files/server5-sha1.crt \
2542 key_file2=data_files/server5.key" \
2543 "$P_CLI force_version=tls1" \
2544 0 \
2545 -C "signed using.*ECDSA with SHA256" \
2546 -c "signed using.*ECDSA with SHA1"
2547
2548run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2549 "$P_SRV crt_file=data_files/server5.crt \
2550 key_file=data_files/server5.key \
2551 crt_file2=data_files/server6.crt \
2552 key_file2=data_files/server6.key" \
2553 "$P_CLI force_version=tls1_1" \
2554 0 \
2555 -c "serial number.*09" \
2556 -c "signed using.*ECDSA with SHA256" \
2557 -C "signed using.*ECDSA with SHA1"
2558
2559run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2560 "$P_SRV crt_file=data_files/server6.crt \
2561 key_file=data_files/server6.key \
2562 crt_file2=data_files/server5.crt \
2563 key_file2=data_files/server5.key" \
2564 "$P_CLI force_version=tls1_1" \
2565 0 \
2566 -c "serial number.*0A" \
2567 -c "signed using.*ECDSA with SHA256" \
2568 -C "signed using.*ECDSA with SHA1"
2569
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002570# tests for SNI
2571
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002572run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002573 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002574 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002575 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002576 0 \
2577 -S "parse ServerName extension" \
2578 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2579 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002581run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002582 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002583 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002584 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 +02002585 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002586 0 \
2587 -s "parse ServerName extension" \
2588 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2589 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002591run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002592 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002593 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002594 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 +02002595 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002596 0 \
2597 -s "parse ServerName extension" \
2598 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2599 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002601run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002602 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002603 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002604 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 +02002605 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002606 1 \
2607 -s "parse ServerName extension" \
2608 -s "ssl_sni_wrapper() returned" \
2609 -s "mbedtls_ssl_handshake returned" \
2610 -c "mbedtls_ssl_handshake returned" \
2611 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002612
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002613run_test "SNI: client auth no override: optional" \
2614 "$P_SRV debug_level=3 auth_mode=optional \
2615 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2616 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2617 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002618 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002619 -S "skip write certificate request" \
2620 -C "skip parse certificate request" \
2621 -c "got a certificate request" \
2622 -C "skip write certificate" \
2623 -C "skip write certificate verify" \
2624 -S "skip parse certificate verify"
2625
2626run_test "SNI: client auth override: none -> optional" \
2627 "$P_SRV debug_level=3 auth_mode=none \
2628 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2629 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2630 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002631 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002632 -S "skip write certificate request" \
2633 -C "skip parse certificate request" \
2634 -c "got a certificate request" \
2635 -C "skip write certificate" \
2636 -C "skip write certificate verify" \
2637 -S "skip parse certificate verify"
2638
2639run_test "SNI: client auth override: optional -> none" \
2640 "$P_SRV debug_level=3 auth_mode=optional \
2641 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2642 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2643 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002644 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002645 -s "skip write certificate request" \
2646 -C "skip parse certificate request" \
2647 -c "got no certificate request" \
2648 -c "skip write certificate" \
2649 -c "skip write certificate verify" \
2650 -s "skip parse certificate verify"
2651
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002652run_test "SNI: CA no override" \
2653 "$P_SRV debug_level=3 auth_mode=optional \
2654 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2655 ca_file=data_files/test-ca.crt \
2656 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2657 "$P_CLI debug_level=3 server_name=localhost \
2658 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2659 1 \
2660 -S "skip write certificate request" \
2661 -C "skip parse certificate request" \
2662 -c "got a certificate request" \
2663 -C "skip write certificate" \
2664 -C "skip write certificate verify" \
2665 -S "skip parse certificate verify" \
2666 -s "x509_verify_cert() returned" \
2667 -s "! The certificate is not correctly signed by the trusted CA" \
2668 -S "The certificate has been revoked (is on a CRL)"
2669
2670run_test "SNI: CA override" \
2671 "$P_SRV debug_level=3 auth_mode=optional \
2672 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2673 ca_file=data_files/test-ca.crt \
2674 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2675 "$P_CLI debug_level=3 server_name=localhost \
2676 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2677 0 \
2678 -S "skip write certificate request" \
2679 -C "skip parse certificate request" \
2680 -c "got a certificate request" \
2681 -C "skip write certificate" \
2682 -C "skip write certificate verify" \
2683 -S "skip parse certificate verify" \
2684 -S "x509_verify_cert() returned" \
2685 -S "! The certificate is not correctly signed by the trusted CA" \
2686 -S "The certificate has been revoked (is on a CRL)"
2687
2688run_test "SNI: CA override with CRL" \
2689 "$P_SRV debug_level=3 auth_mode=optional \
2690 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2691 ca_file=data_files/test-ca.crt \
2692 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2693 "$P_CLI debug_level=3 server_name=localhost \
2694 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2695 1 \
2696 -S "skip write certificate request" \
2697 -C "skip parse certificate request" \
2698 -c "got a certificate request" \
2699 -C "skip write certificate" \
2700 -C "skip write certificate verify" \
2701 -S "skip parse certificate verify" \
2702 -s "x509_verify_cert() returned" \
2703 -S "! The certificate is not correctly signed by the trusted CA" \
2704 -s "The certificate has been revoked (is on a CRL)"
2705
Andres AG1a834452016-12-07 10:01:30 +00002706# Tests for SNI and DTLS
2707
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002708run_test "SNI: DTLS, no SNI callback" \
2709 "$P_SRV debug_level=3 dtls=1 \
2710 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2711 "$P_CLI server_name=localhost dtls=1" \
2712 0 \
2713 -S "parse ServerName extension" \
2714 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2715 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2716
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002717run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00002718 "$P_SRV debug_level=3 dtls=1 \
2719 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2720 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2721 "$P_CLI server_name=localhost dtls=1" \
2722 0 \
2723 -s "parse ServerName extension" \
2724 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2725 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2726
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002727run_test "SNI: DTLS, matching cert 2" \
2728 "$P_SRV debug_level=3 dtls=1 \
2729 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2730 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2731 "$P_CLI server_name=polarssl.example dtls=1" \
2732 0 \
2733 -s "parse ServerName extension" \
2734 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2735 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2736
2737run_test "SNI: DTLS, no matching cert" \
2738 "$P_SRV debug_level=3 dtls=1 \
2739 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2740 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2741 "$P_CLI server_name=nonesuch.example dtls=1" \
2742 1 \
2743 -s "parse ServerName extension" \
2744 -s "ssl_sni_wrapper() returned" \
2745 -s "mbedtls_ssl_handshake returned" \
2746 -c "mbedtls_ssl_handshake returned" \
2747 -c "SSL - A fatal alert message was received from our peer"
2748
2749run_test "SNI: DTLS, client auth no override: optional" \
2750 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2751 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2752 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2753 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2754 0 \
2755 -S "skip write certificate request" \
2756 -C "skip parse certificate request" \
2757 -c "got a certificate request" \
2758 -C "skip write certificate" \
2759 -C "skip write certificate verify" \
2760 -S "skip parse certificate verify"
2761
2762run_test "SNI: DTLS, client auth override: none -> optional" \
2763 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2764 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2765 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2766 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2767 0 \
2768 -S "skip write certificate request" \
2769 -C "skip parse certificate request" \
2770 -c "got a certificate request" \
2771 -C "skip write certificate" \
2772 -C "skip write certificate verify" \
2773 -S "skip parse certificate verify"
2774
2775run_test "SNI: DTLS, client auth override: optional -> none" \
2776 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2777 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2778 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2779 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2780 0 \
2781 -s "skip write certificate request" \
2782 -C "skip parse certificate request" \
2783 -c "got no certificate request" \
2784 -c "skip write certificate" \
2785 -c "skip write certificate verify" \
2786 -s "skip parse certificate verify"
2787
2788run_test "SNI: DTLS, CA no override" \
2789 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2790 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2791 ca_file=data_files/test-ca.crt \
2792 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2793 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2794 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2795 1 \
2796 -S "skip write certificate request" \
2797 -C "skip parse certificate request" \
2798 -c "got a certificate request" \
2799 -C "skip write certificate" \
2800 -C "skip write certificate verify" \
2801 -S "skip parse certificate verify" \
2802 -s "x509_verify_cert() returned" \
2803 -s "! The certificate is not correctly signed by the trusted CA" \
2804 -S "The certificate has been revoked (is on a CRL)"
2805
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002806run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00002807 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2808 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2809 ca_file=data_files/test-ca.crt \
2810 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2811 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2812 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2813 0 \
2814 -S "skip write certificate request" \
2815 -C "skip parse certificate request" \
2816 -c "got a certificate request" \
2817 -C "skip write certificate" \
2818 -C "skip write certificate verify" \
2819 -S "skip parse certificate verify" \
2820 -S "x509_verify_cert() returned" \
2821 -S "! The certificate is not correctly signed by the trusted CA" \
2822 -S "The certificate has been revoked (is on a CRL)"
2823
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002824run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00002825 "$P_SRV debug_level=3 auth_mode=optional \
2826 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2827 ca_file=data_files/test-ca.crt \
2828 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2829 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2830 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2831 1 \
2832 -S "skip write certificate request" \
2833 -C "skip parse certificate request" \
2834 -c "got a certificate request" \
2835 -C "skip write certificate" \
2836 -C "skip write certificate verify" \
2837 -S "skip parse certificate verify" \
2838 -s "x509_verify_cert() returned" \
2839 -S "! The certificate is not correctly signed by the trusted CA" \
2840 -s "The certificate has been revoked (is on a CRL)"
2841
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002842# Tests for non-blocking I/O: exercise a variety of handshake flows
2843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002844run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002845 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2846 "$P_CLI nbio=2 tickets=0" \
2847 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002848 -S "mbedtls_ssl_handshake returned" \
2849 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002850 -c "Read from server: .* bytes read"
2851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002852run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002853 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2854 "$P_CLI nbio=2 tickets=0" \
2855 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002856 -S "mbedtls_ssl_handshake returned" \
2857 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002858 -c "Read from server: .* bytes read"
2859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002860run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002861 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2862 "$P_CLI nbio=2 tickets=1" \
2863 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002864 -S "mbedtls_ssl_handshake returned" \
2865 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002866 -c "Read from server: .* bytes read"
2867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002868run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002869 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2870 "$P_CLI nbio=2 tickets=1" \
2871 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002872 -S "mbedtls_ssl_handshake returned" \
2873 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002874 -c "Read from server: .* bytes read"
2875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002876run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002877 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2878 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2879 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002880 -S "mbedtls_ssl_handshake returned" \
2881 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002882 -c "Read from server: .* bytes read"
2883
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002884run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002885 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2886 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2887 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002888 -S "mbedtls_ssl_handshake returned" \
2889 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002890 -c "Read from server: .* bytes read"
2891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002892run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002893 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2894 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2895 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002896 -S "mbedtls_ssl_handshake returned" \
2897 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002898 -c "Read from server: .* bytes read"
2899
Hanno Becker00076712017-11-15 16:39:08 +00002900# Tests for event-driven I/O: exercise a variety of handshake flows
2901
2902run_test "Event-driven I/O: basic handshake" \
2903 "$P_SRV event=1 tickets=0 auth_mode=none" \
2904 "$P_CLI event=1 tickets=0" \
2905 0 \
2906 -S "mbedtls_ssl_handshake returned" \
2907 -C "mbedtls_ssl_handshake returned" \
2908 -c "Read from server: .* bytes read"
2909
2910run_test "Event-driven I/O: client auth" \
2911 "$P_SRV event=1 tickets=0 auth_mode=required" \
2912 "$P_CLI event=1 tickets=0" \
2913 0 \
2914 -S "mbedtls_ssl_handshake returned" \
2915 -C "mbedtls_ssl_handshake returned" \
2916 -c "Read from server: .* bytes read"
2917
2918run_test "Event-driven I/O: ticket" \
2919 "$P_SRV event=1 tickets=1 auth_mode=none" \
2920 "$P_CLI event=1 tickets=1" \
2921 0 \
2922 -S "mbedtls_ssl_handshake returned" \
2923 -C "mbedtls_ssl_handshake returned" \
2924 -c "Read from server: .* bytes read"
2925
2926run_test "Event-driven I/O: ticket + client auth" \
2927 "$P_SRV event=1 tickets=1 auth_mode=required" \
2928 "$P_CLI event=1 tickets=1" \
2929 0 \
2930 -S "mbedtls_ssl_handshake returned" \
2931 -C "mbedtls_ssl_handshake returned" \
2932 -c "Read from server: .* bytes read"
2933
2934run_test "Event-driven I/O: ticket + client auth + resume" \
2935 "$P_SRV event=1 tickets=1 auth_mode=required" \
2936 "$P_CLI event=1 tickets=1 reconnect=1" \
2937 0 \
2938 -S "mbedtls_ssl_handshake returned" \
2939 -C "mbedtls_ssl_handshake returned" \
2940 -c "Read from server: .* bytes read"
2941
2942run_test "Event-driven I/O: ticket + resume" \
2943 "$P_SRV event=1 tickets=1 auth_mode=none" \
2944 "$P_CLI event=1 tickets=1 reconnect=1" \
2945 0 \
2946 -S "mbedtls_ssl_handshake returned" \
2947 -C "mbedtls_ssl_handshake returned" \
2948 -c "Read from server: .* bytes read"
2949
2950run_test "Event-driven I/O: session-id resume" \
2951 "$P_SRV event=1 tickets=0 auth_mode=none" \
2952 "$P_CLI event=1 tickets=0 reconnect=1" \
2953 0 \
2954 -S "mbedtls_ssl_handshake returned" \
2955 -C "mbedtls_ssl_handshake returned" \
2956 -c "Read from server: .* bytes read"
2957
Hanno Becker6a33f592018-03-13 11:38:46 +00002958run_test "Event-driven I/O, DTLS: basic handshake" \
2959 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2960 "$P_CLI dtls=1 event=1 tickets=0" \
2961 0 \
2962 -c "Read from server: .* bytes read"
2963
2964run_test "Event-driven I/O, DTLS: client auth" \
2965 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
2966 "$P_CLI dtls=1 event=1 tickets=0" \
2967 0 \
2968 -c "Read from server: .* bytes read"
2969
2970run_test "Event-driven I/O, DTLS: ticket" \
2971 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2972 "$P_CLI dtls=1 event=1 tickets=1" \
2973 0 \
2974 -c "Read from server: .* bytes read"
2975
2976run_test "Event-driven I/O, DTLS: ticket + client auth" \
2977 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2978 "$P_CLI dtls=1 event=1 tickets=1" \
2979 0 \
2980 -c "Read from server: .* bytes read"
2981
2982run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
2983 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2984 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2985 0 \
2986 -c "Read from server: .* bytes read"
2987
2988run_test "Event-driven I/O, DTLS: ticket + resume" \
2989 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2990 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2991 0 \
2992 -c "Read from server: .* bytes read"
2993
2994run_test "Event-driven I/O, DTLS: session-id resume" \
2995 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2996 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
2997 0 \
2998 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00002999
3000# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3001# During session resumption, the client will send its ApplicationData record
3002# within the same datagram as the Finished messages. In this situation, the
3003# server MUST NOT idle on the underlying transport after handshake completion,
3004# because the ApplicationData request has already been queued internally.
3005run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003006 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003007 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3008 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
3009 0 \
3010 -c "Read from server: .* bytes read"
3011
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003012# Tests for version negotiation
3013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003014run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003015 "$P_SRV" \
3016 "$P_CLI" \
3017 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003018 -S "mbedtls_ssl_handshake returned" \
3019 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003020 -s "Protocol is TLSv1.2" \
3021 -c "Protocol is TLSv1.2"
3022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003023run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003024 "$P_SRV" \
3025 "$P_CLI max_version=tls1_1" \
3026 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003027 -S "mbedtls_ssl_handshake returned" \
3028 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003029 -s "Protocol is TLSv1.1" \
3030 -c "Protocol is TLSv1.1"
3031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003032run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003033 "$P_SRV max_version=tls1_1" \
3034 "$P_CLI" \
3035 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003036 -S "mbedtls_ssl_handshake returned" \
3037 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003038 -s "Protocol is TLSv1.1" \
3039 -c "Protocol is TLSv1.1"
3040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003041run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003042 "$P_SRV max_version=tls1_1" \
3043 "$P_CLI max_version=tls1_1" \
3044 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003045 -S "mbedtls_ssl_handshake returned" \
3046 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003047 -s "Protocol is TLSv1.1" \
3048 -c "Protocol is TLSv1.1"
3049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003050run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003051 "$P_SRV min_version=tls1_1" \
3052 "$P_CLI max_version=tls1_1" \
3053 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003054 -S "mbedtls_ssl_handshake returned" \
3055 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003056 -s "Protocol is TLSv1.1" \
3057 -c "Protocol is TLSv1.1"
3058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003059run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003060 "$P_SRV max_version=tls1_1" \
3061 "$P_CLI min_version=tls1_1" \
3062 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003063 -S "mbedtls_ssl_handshake returned" \
3064 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003065 -s "Protocol is TLSv1.1" \
3066 -c "Protocol is TLSv1.1"
3067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003068run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003069 "$P_SRV max_version=tls1_1" \
3070 "$P_CLI min_version=tls1_2" \
3071 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003072 -s "mbedtls_ssl_handshake returned" \
3073 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003074 -c "SSL - Handshake protocol not within min/max boundaries"
3075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003076run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003077 "$P_SRV min_version=tls1_2" \
3078 "$P_CLI max_version=tls1_1" \
3079 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003080 -s "mbedtls_ssl_handshake returned" \
3081 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003082 -s "SSL - Handshake protocol not within min/max boundaries"
3083
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003084# Tests for ALPN extension
3085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003086run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003087 "$P_SRV debug_level=3" \
3088 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003089 0 \
3090 -C "client hello, adding alpn extension" \
3091 -S "found alpn extension" \
3092 -C "got an alert message, type: \\[2:120]" \
3093 -S "server hello, adding alpn extension" \
3094 -C "found alpn extension " \
3095 -C "Application Layer Protocol is" \
3096 -S "Application Layer Protocol is"
3097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003098run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003099 "$P_SRV debug_level=3" \
3100 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003101 0 \
3102 -c "client hello, adding alpn extension" \
3103 -s "found alpn extension" \
3104 -C "got an alert message, type: \\[2:120]" \
3105 -S "server hello, adding alpn extension" \
3106 -C "found alpn extension " \
3107 -c "Application Layer Protocol is (none)" \
3108 -S "Application Layer Protocol is"
3109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003110run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003111 "$P_SRV debug_level=3 alpn=abc,1234" \
3112 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003113 0 \
3114 -C "client hello, adding alpn extension" \
3115 -S "found alpn extension" \
3116 -C "got an alert message, type: \\[2:120]" \
3117 -S "server hello, adding alpn extension" \
3118 -C "found alpn extension " \
3119 -C "Application Layer Protocol is" \
3120 -s "Application Layer Protocol is (none)"
3121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003122run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003123 "$P_SRV debug_level=3 alpn=abc,1234" \
3124 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003125 0 \
3126 -c "client hello, adding alpn extension" \
3127 -s "found alpn extension" \
3128 -C "got an alert message, type: \\[2:120]" \
3129 -s "server hello, adding alpn extension" \
3130 -c "found alpn extension" \
3131 -c "Application Layer Protocol is abc" \
3132 -s "Application Layer Protocol is abc"
3133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003134run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003135 "$P_SRV debug_level=3 alpn=abc,1234" \
3136 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003137 0 \
3138 -c "client hello, adding alpn extension" \
3139 -s "found alpn extension" \
3140 -C "got an alert message, type: \\[2:120]" \
3141 -s "server hello, adding alpn extension" \
3142 -c "found alpn extension" \
3143 -c "Application Layer Protocol is abc" \
3144 -s "Application Layer Protocol is abc"
3145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003146run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003147 "$P_SRV debug_level=3 alpn=abc,1234" \
3148 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003149 0 \
3150 -c "client hello, adding alpn extension" \
3151 -s "found alpn extension" \
3152 -C "got an alert message, type: \\[2:120]" \
3153 -s "server hello, adding alpn extension" \
3154 -c "found alpn extension" \
3155 -c "Application Layer Protocol is 1234" \
3156 -s "Application Layer Protocol is 1234"
3157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003158run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003159 "$P_SRV debug_level=3 alpn=abc,123" \
3160 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003161 1 \
3162 -c "client hello, adding alpn extension" \
3163 -s "found alpn extension" \
3164 -c "got an alert message, type: \\[2:120]" \
3165 -S "server hello, adding alpn extension" \
3166 -C "found alpn extension" \
3167 -C "Application Layer Protocol is 1234" \
3168 -S "Application Layer Protocol is 1234"
3169
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003170
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003171# Tests for keyUsage in leaf certificates, part 1:
3172# server-side certificate/suite selection
3173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003174run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003175 "$P_SRV key_file=data_files/server2.key \
3176 crt_file=data_files/server2.ku-ds.crt" \
3177 "$P_CLI" \
3178 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003179 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003180
3181
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003182run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003183 "$P_SRV key_file=data_files/server2.key \
3184 crt_file=data_files/server2.ku-ke.crt" \
3185 "$P_CLI" \
3186 0 \
3187 -c "Ciphersuite is TLS-RSA-WITH-"
3188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003189run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003190 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003191 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003192 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003193 1 \
3194 -C "Ciphersuite is "
3195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003196run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003197 "$P_SRV key_file=data_files/server5.key \
3198 crt_file=data_files/server5.ku-ds.crt" \
3199 "$P_CLI" \
3200 0 \
3201 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3202
3203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003204run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003205 "$P_SRV key_file=data_files/server5.key \
3206 crt_file=data_files/server5.ku-ka.crt" \
3207 "$P_CLI" \
3208 0 \
3209 -c "Ciphersuite is TLS-ECDH-"
3210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003211run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003212 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003213 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003214 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003215 1 \
3216 -C "Ciphersuite is "
3217
3218# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003219# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003221run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003222 "$O_SRV -key data_files/server2.key \
3223 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003224 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003225 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3226 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003227 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003228 -C "Processing of the Certificate handshake message failed" \
3229 -c "Ciphersuite is TLS-"
3230
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003231run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003232 "$O_SRV -key data_files/server2.key \
3233 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003234 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003235 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3236 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003237 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003238 -C "Processing of the Certificate handshake message failed" \
3239 -c "Ciphersuite is TLS-"
3240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003241run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003242 "$O_SRV -key data_files/server2.key \
3243 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003244 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003245 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3246 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003247 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003248 -C "Processing of the Certificate handshake message failed" \
3249 -c "Ciphersuite is TLS-"
3250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003251run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003252 "$O_SRV -key data_files/server2.key \
3253 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003254 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003255 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3256 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003257 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003258 -c "Processing of the Certificate handshake message failed" \
3259 -C "Ciphersuite is TLS-"
3260
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003261run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3262 "$O_SRV -key data_files/server2.key \
3263 -cert data_files/server2.ku-ke.crt" \
3264 "$P_CLI debug_level=1 auth_mode=optional \
3265 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3266 0 \
3267 -c "bad certificate (usage extensions)" \
3268 -C "Processing of the Certificate handshake message failed" \
3269 -c "Ciphersuite is TLS-" \
3270 -c "! Usage does not match the keyUsage extension"
3271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003272run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003273 "$O_SRV -key data_files/server2.key \
3274 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003275 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003276 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3277 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003278 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003279 -C "Processing of the Certificate handshake message failed" \
3280 -c "Ciphersuite is TLS-"
3281
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003282run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003283 "$O_SRV -key data_files/server2.key \
3284 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003285 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003286 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3287 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003288 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003289 -c "Processing of the Certificate handshake message failed" \
3290 -C "Ciphersuite is TLS-"
3291
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003292run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3293 "$O_SRV -key data_files/server2.key \
3294 -cert data_files/server2.ku-ds.crt" \
3295 "$P_CLI debug_level=1 auth_mode=optional \
3296 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3297 0 \
3298 -c "bad certificate (usage extensions)" \
3299 -C "Processing of the Certificate handshake message failed" \
3300 -c "Ciphersuite is TLS-" \
3301 -c "! Usage does not match the keyUsage extension"
3302
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003303# Tests for keyUsage in leaf certificates, part 3:
3304# server-side checking of client cert
3305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003306run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003307 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003308 "$O_CLI -key data_files/server2.key \
3309 -cert data_files/server2.ku-ds.crt" \
3310 0 \
3311 -S "bad certificate (usage extensions)" \
3312 -S "Processing of the Certificate handshake message failed"
3313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003314run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003315 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003316 "$O_CLI -key data_files/server2.key \
3317 -cert data_files/server2.ku-ke.crt" \
3318 0 \
3319 -s "bad certificate (usage extensions)" \
3320 -S "Processing of the Certificate handshake message failed"
3321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003322run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003323 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003324 "$O_CLI -key data_files/server2.key \
3325 -cert data_files/server2.ku-ke.crt" \
3326 1 \
3327 -s "bad certificate (usage extensions)" \
3328 -s "Processing of the Certificate handshake message failed"
3329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003330run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003331 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003332 "$O_CLI -key data_files/server5.key \
3333 -cert data_files/server5.ku-ds.crt" \
3334 0 \
3335 -S "bad certificate (usage extensions)" \
3336 -S "Processing of the Certificate handshake message failed"
3337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003338run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003339 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003340 "$O_CLI -key data_files/server5.key \
3341 -cert data_files/server5.ku-ka.crt" \
3342 0 \
3343 -s "bad certificate (usage extensions)" \
3344 -S "Processing of the Certificate handshake message failed"
3345
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003346# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003348run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003349 "$P_SRV key_file=data_files/server5.key \
3350 crt_file=data_files/server5.eku-srv.crt" \
3351 "$P_CLI" \
3352 0
3353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003354run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003355 "$P_SRV key_file=data_files/server5.key \
3356 crt_file=data_files/server5.eku-srv.crt" \
3357 "$P_CLI" \
3358 0
3359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003360run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003361 "$P_SRV key_file=data_files/server5.key \
3362 crt_file=data_files/server5.eku-cs_any.crt" \
3363 "$P_CLI" \
3364 0
3365
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003366run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003367 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003368 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003369 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003370 1
3371
3372# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3373
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003374run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003375 "$O_SRV -key data_files/server5.key \
3376 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003377 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003378 0 \
3379 -C "bad certificate (usage extensions)" \
3380 -C "Processing of the Certificate handshake message failed" \
3381 -c "Ciphersuite is TLS-"
3382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003383run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003384 "$O_SRV -key data_files/server5.key \
3385 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003386 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003387 0 \
3388 -C "bad certificate (usage extensions)" \
3389 -C "Processing of the Certificate handshake message failed" \
3390 -c "Ciphersuite is TLS-"
3391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003392run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003393 "$O_SRV -key data_files/server5.key \
3394 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003395 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003396 0 \
3397 -C "bad certificate (usage extensions)" \
3398 -C "Processing of the Certificate handshake message failed" \
3399 -c "Ciphersuite is TLS-"
3400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003401run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003402 "$O_SRV -key data_files/server5.key \
3403 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003404 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003405 1 \
3406 -c "bad certificate (usage extensions)" \
3407 -c "Processing of the Certificate handshake message failed" \
3408 -C "Ciphersuite is TLS-"
3409
3410# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003412run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003413 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003414 "$O_CLI -key data_files/server5.key \
3415 -cert data_files/server5.eku-cli.crt" \
3416 0 \
3417 -S "bad certificate (usage extensions)" \
3418 -S "Processing of the Certificate handshake message failed"
3419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003420run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003421 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003422 "$O_CLI -key data_files/server5.key \
3423 -cert data_files/server5.eku-srv_cli.crt" \
3424 0 \
3425 -S "bad certificate (usage extensions)" \
3426 -S "Processing of the Certificate handshake message failed"
3427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003428run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003429 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003430 "$O_CLI -key data_files/server5.key \
3431 -cert data_files/server5.eku-cs_any.crt" \
3432 0 \
3433 -S "bad certificate (usage extensions)" \
3434 -S "Processing of the Certificate handshake message failed"
3435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003436run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003437 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003438 "$O_CLI -key data_files/server5.key \
3439 -cert data_files/server5.eku-cs.crt" \
3440 0 \
3441 -s "bad certificate (usage extensions)" \
3442 -S "Processing of the Certificate handshake message failed"
3443
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003444run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003445 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003446 "$O_CLI -key data_files/server5.key \
3447 -cert data_files/server5.eku-cs.crt" \
3448 1 \
3449 -s "bad certificate (usage extensions)" \
3450 -s "Processing of the Certificate handshake message failed"
3451
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003452# Tests for DHM parameters loading
3453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003454run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003455 "$P_SRV" \
3456 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3457 debug_level=3" \
3458 0 \
3459 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003460 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003462run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003463 "$P_SRV dhm_file=data_files/dhparams.pem" \
3464 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3465 debug_level=3" \
3466 0 \
3467 -c "value of 'DHM: P ' (1024 bits)" \
3468 -c "value of 'DHM: G ' (2 bits)"
3469
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003470# Tests for DHM client-side size checking
3471
3472run_test "DHM size: server default, client default, OK" \
3473 "$P_SRV" \
3474 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3475 debug_level=1" \
3476 0 \
3477 -C "DHM prime too short:"
3478
3479run_test "DHM size: server default, client 2048, OK" \
3480 "$P_SRV" \
3481 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3482 debug_level=1 dhmlen=2048" \
3483 0 \
3484 -C "DHM prime too short:"
3485
3486run_test "DHM size: server 1024, client default, OK" \
3487 "$P_SRV dhm_file=data_files/dhparams.pem" \
3488 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3489 debug_level=1" \
3490 0 \
3491 -C "DHM prime too short:"
3492
3493run_test "DHM size: server 1000, client default, rejected" \
3494 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3495 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3496 debug_level=1" \
3497 1 \
3498 -c "DHM prime too short:"
3499
3500run_test "DHM size: server default, client 2049, rejected" \
3501 "$P_SRV" \
3502 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3503 debug_level=1 dhmlen=2049" \
3504 1 \
3505 -c "DHM prime too short:"
3506
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003507# Tests for PSK callback
3508
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003509run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003510 "$P_SRV psk=abc123 psk_identity=foo" \
3511 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3512 psk_identity=foo psk=abc123" \
3513 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003514 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003515 -S "SSL - Unknown identity received" \
3516 -S "SSL - Verification of the message MAC failed"
3517
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003518run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003519 "$P_SRV" \
3520 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3521 psk_identity=foo psk=abc123" \
3522 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003523 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003524 -S "SSL - Unknown identity received" \
3525 -S "SSL - Verification of the message MAC failed"
3526
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003527run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003528 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3529 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3530 psk_identity=foo psk=abc123" \
3531 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003532 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003533 -s "SSL - Unknown identity received" \
3534 -S "SSL - Verification of the message MAC failed"
3535
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003536run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003537 "$P_SRV psk_list=abc,dead,def,beef" \
3538 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3539 psk_identity=abc psk=dead" \
3540 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003541 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003542 -S "SSL - Unknown identity received" \
3543 -S "SSL - Verification of the message MAC failed"
3544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003545run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003546 "$P_SRV psk_list=abc,dead,def,beef" \
3547 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3548 psk_identity=def psk=beef" \
3549 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003550 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003551 -S "SSL - Unknown identity received" \
3552 -S "SSL - Verification of the message MAC failed"
3553
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003554run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003555 "$P_SRV psk_list=abc,dead,def,beef" \
3556 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3557 psk_identity=ghi psk=beef" \
3558 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003559 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003560 -s "SSL - Unknown identity received" \
3561 -S "SSL - Verification of the message MAC failed"
3562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003563run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003564 "$P_SRV psk_list=abc,dead,def,beef" \
3565 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3566 psk_identity=abc psk=beef" \
3567 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003568 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003569 -S "SSL - Unknown identity received" \
3570 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003571
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003572# Tests for EC J-PAKE
3573
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003574requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003575run_test "ECJPAKE: client not configured" \
3576 "$P_SRV debug_level=3" \
3577 "$P_CLI debug_level=3" \
3578 0 \
3579 -C "add ciphersuite: c0ff" \
3580 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003581 -S "found ecjpake kkpp extension" \
3582 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003583 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003584 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003585 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003586 -S "None of the common ciphersuites is usable"
3587
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003588requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003589run_test "ECJPAKE: server not configured" \
3590 "$P_SRV debug_level=3" \
3591 "$P_CLI debug_level=3 ecjpake_pw=bla \
3592 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3593 1 \
3594 -c "add ciphersuite: c0ff" \
3595 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003596 -s "found ecjpake kkpp extension" \
3597 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003598 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003599 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003600 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003601 -s "None of the common ciphersuites is usable"
3602
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003603requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003604run_test "ECJPAKE: working, TLS" \
3605 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3606 "$P_CLI debug_level=3 ecjpake_pw=bla \
3607 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003608 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003609 -c "add ciphersuite: c0ff" \
3610 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003611 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003612 -s "found ecjpake kkpp extension" \
3613 -S "skip ecjpake kkpp extension" \
3614 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003615 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003616 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003617 -S "None of the common ciphersuites is usable" \
3618 -S "SSL - Verification of the message MAC failed"
3619
Janos Follath74537a62016-09-02 13:45:28 +01003620server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003621requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003622run_test "ECJPAKE: password mismatch, TLS" \
3623 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3624 "$P_CLI debug_level=3 ecjpake_pw=bad \
3625 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3626 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003627 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003628 -s "SSL - Verification of the message MAC failed"
3629
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003630requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003631run_test "ECJPAKE: working, DTLS" \
3632 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3633 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3634 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3635 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003636 -c "re-using cached ecjpake parameters" \
3637 -S "SSL - Verification of the message MAC failed"
3638
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003639requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003640run_test "ECJPAKE: working, DTLS, no cookie" \
3641 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3642 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3643 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3644 0 \
3645 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003646 -S "SSL - Verification of the message MAC failed"
3647
Janos Follath74537a62016-09-02 13:45:28 +01003648server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003649requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003650run_test "ECJPAKE: password mismatch, DTLS" \
3651 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3652 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3653 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3654 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003655 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003656 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003657
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003658# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003659requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003660run_test "ECJPAKE: working, DTLS, nolog" \
3661 "$P_SRV dtls=1 ecjpake_pw=bla" \
3662 "$P_CLI dtls=1 ecjpake_pw=bla \
3663 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3664 0
3665
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003666# Tests for ciphersuites per version
3667
Janos Follathe2681a42016-03-07 15:57:05 +00003668requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003669run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003670 "$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 +02003671 "$P_CLI force_version=ssl3" \
3672 0 \
3673 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003675run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003676 "$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 +01003677 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003678 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003679 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003681run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003682 "$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 +02003683 "$P_CLI force_version=tls1_1" \
3684 0 \
3685 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003687run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003688 "$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 +02003689 "$P_CLI force_version=tls1_2" \
3690 0 \
3691 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3692
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003693# Test for ClientHello without extensions
3694
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003695requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003696run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003697 "$P_SRV debug_level=3" \
3698 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3699 0 \
3700 -s "dumping 'client hello extensions' (0 bytes)"
3701
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003702requires_gnutls
3703run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3704 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3705 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3706 0 \
3707 -s "dumping 'client hello extensions' (0 bytes)"
3708
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003709# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003710
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003711run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003712 "$P_SRV" \
3713 "$P_CLI request_size=100" \
3714 0 \
3715 -s "Read from client: 100 bytes read$"
3716
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003717run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003718 "$P_SRV" \
3719 "$P_CLI request_size=500" \
3720 0 \
3721 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003722
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003723# Tests for small packets
3724
Janos Follathe2681a42016-03-07 15:57:05 +00003725requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003726run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003727 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003728 "$P_CLI request_size=1 force_version=ssl3 \
3729 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3730 0 \
3731 -s "Read from client: 1 bytes read"
3732
Janos Follathe2681a42016-03-07 15:57:05 +00003733requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003734run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003735 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003736 "$P_CLI request_size=1 force_version=ssl3 \
3737 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3738 0 \
3739 -s "Read from client: 1 bytes read"
3740
3741run_test "Small packet TLS 1.0 BlockCipher" \
3742 "$P_SRV" \
3743 "$P_CLI request_size=1 force_version=tls1 \
3744 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3745 0 \
3746 -s "Read from client: 1 bytes read"
3747
Hanno Becker8501f982017-11-10 08:59:04 +00003748run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003749 "$P_SRV" \
3750 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3751 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3752 0 \
3753 -s "Read from client: 1 bytes read"
3754
Hanno Becker32c55012017-11-10 08:42:54 +00003755requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003756run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003757 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003758 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003759 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003760 0 \
3761 -s "Read from client: 1 bytes read"
3762
Hanno Becker32c55012017-11-10 08:42:54 +00003763requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003764run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003765 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003766 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003767 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003768 0 \
3769 -s "Read from client: 1 bytes read"
3770
3771run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003772 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003773 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003774 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3775 0 \
3776 -s "Read from client: 1 bytes read"
3777
3778run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3779 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3780 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003781 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003782 0 \
3783 -s "Read from client: 1 bytes read"
3784
3785requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3786run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003787 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003788 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003789 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003790 0 \
3791 -s "Read from client: 1 bytes read"
3792
Hanno Becker8501f982017-11-10 08:59:04 +00003793requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3794run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003795 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3796 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3797 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003798 0 \
3799 -s "Read from client: 1 bytes read"
3800
3801run_test "Small packet TLS 1.1 BlockCipher" \
3802 "$P_SRV" \
3803 "$P_CLI request_size=1 force_version=tls1_1 \
3804 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3805 0 \
3806 -s "Read from client: 1 bytes read"
3807
Hanno Becker8501f982017-11-10 08:59:04 +00003808run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003809 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003810 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003811 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003812 0 \
3813 -s "Read from client: 1 bytes read"
3814
3815requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3816run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003817 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003818 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003819 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003820 0 \
3821 -s "Read from client: 1 bytes read"
3822
3823requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3824run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003825 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003826 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003827 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003828 0 \
3829 -s "Read from client: 1 bytes read"
3830
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003831run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003832 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003833 "$P_CLI request_size=1 force_version=tls1_1 \
3834 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3835 0 \
3836 -s "Read from client: 1 bytes read"
3837
Hanno Becker8501f982017-11-10 08:59:04 +00003838run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3839 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003840 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003841 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003842 0 \
3843 -s "Read from client: 1 bytes read"
3844
Hanno Becker8501f982017-11-10 08:59:04 +00003845requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3846run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003847 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003848 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003849 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003850 0 \
3851 -s "Read from client: 1 bytes read"
3852
Hanno Becker32c55012017-11-10 08:42:54 +00003853requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003854run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003855 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003856 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003857 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003858 0 \
3859 -s "Read from client: 1 bytes read"
3860
3861run_test "Small packet TLS 1.2 BlockCipher" \
3862 "$P_SRV" \
3863 "$P_CLI request_size=1 force_version=tls1_2 \
3864 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3865 0 \
3866 -s "Read from client: 1 bytes read"
3867
Hanno Becker8501f982017-11-10 08:59:04 +00003868run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003869 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003870 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003871 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003872 0 \
3873 -s "Read from client: 1 bytes read"
3874
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003875run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3876 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003877 "$P_CLI request_size=1 force_version=tls1_2 \
3878 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003879 0 \
3880 -s "Read from client: 1 bytes read"
3881
Hanno Becker32c55012017-11-10 08:42:54 +00003882requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003883run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003884 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003885 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003886 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003887 0 \
3888 -s "Read from client: 1 bytes read"
3889
Hanno Becker8501f982017-11-10 08:59:04 +00003890requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3891run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003892 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003893 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003894 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003895 0 \
3896 -s "Read from client: 1 bytes read"
3897
3898run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003899 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003900 "$P_CLI request_size=1 force_version=tls1_2 \
3901 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3902 0 \
3903 -s "Read from client: 1 bytes read"
3904
Hanno Becker8501f982017-11-10 08:59:04 +00003905run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003906 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003907 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003908 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003909 0 \
3910 -s "Read from client: 1 bytes read"
3911
Hanno Becker32c55012017-11-10 08:42:54 +00003912requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003913run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003914 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003915 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003916 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003917 0 \
3918 -s "Read from client: 1 bytes read"
3919
Hanno Becker8501f982017-11-10 08:59:04 +00003920requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3921run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003922 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003923 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003924 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003925 0 \
3926 -s "Read from client: 1 bytes read"
3927
3928run_test "Small packet TLS 1.2 AEAD" \
3929 "$P_SRV" \
3930 "$P_CLI request_size=1 force_version=tls1_2 \
3931 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3932 0 \
3933 -s "Read from client: 1 bytes read"
3934
3935run_test "Small packet TLS 1.2 AEAD shorter tag" \
3936 "$P_SRV" \
3937 "$P_CLI request_size=1 force_version=tls1_2 \
3938 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3939 0 \
3940 -s "Read from client: 1 bytes read"
3941
Hanno Beckere2148042017-11-10 08:59:18 +00003942# Tests for small packets in DTLS
3943
3944requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3945run_test "Small packet DTLS 1.0" \
3946 "$P_SRV dtls=1 force_version=dtls1" \
3947 "$P_CLI dtls=1 request_size=1 \
3948 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3949 0 \
3950 -s "Read from client: 1 bytes read"
3951
3952requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3953run_test "Small packet DTLS 1.0, without EtM" \
3954 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3955 "$P_CLI dtls=1 request_size=1 \
3956 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3957 0 \
3958 -s "Read from client: 1 bytes read"
3959
3960requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3961requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3962run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003963 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3964 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003965 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3966 0 \
3967 -s "Read from client: 1 bytes read"
3968
3969requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3970requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3971run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003972 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003973 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003974 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003975 0 \
3976 -s "Read from client: 1 bytes read"
3977
3978requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3979run_test "Small packet DTLS 1.2" \
3980 "$P_SRV dtls=1 force_version=dtls1_2" \
3981 "$P_CLI dtls=1 request_size=1 \
3982 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3983 0 \
3984 -s "Read from client: 1 bytes read"
3985
3986requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3987run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003988 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003989 "$P_CLI dtls=1 request_size=1 \
3990 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3991 0 \
3992 -s "Read from client: 1 bytes read"
3993
3994requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3995requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3996run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003997 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003998 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003999 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004000 0 \
4001 -s "Read from client: 1 bytes read"
4002
4003requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4004requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4005run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004006 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004007 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004008 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004009 0 \
4010 -s "Read from client: 1 bytes read"
4011
Janos Follath00efff72016-05-06 13:48:23 +01004012# A test for extensions in SSLv3
4013
4014requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4015run_test "SSLv3 with extensions, server side" \
4016 "$P_SRV min_version=ssl3 debug_level=3" \
4017 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4018 0 \
4019 -S "dumping 'client hello extensions'" \
4020 -S "server hello, total extension length:"
4021
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004022# Test for large packets
4023
Angus Grattonc4dd0732018-04-11 16:28:39 +10004024# How many fragments do we expect to write $1 bytes?
4025fragments_for_write() {
4026 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4027}
4028
Janos Follathe2681a42016-03-07 15:57:05 +00004029requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004030run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004031 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004032 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004033 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4034 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004035 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4036 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004037
Janos Follathe2681a42016-03-07 15:57:05 +00004038requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004039run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004040 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004041 "$P_CLI request_size=16384 force_version=ssl3 \
4042 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4043 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004044 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4045 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004046
4047run_test "Large packet TLS 1.0 BlockCipher" \
4048 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004049 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004050 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4051 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004052 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4053 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004054
Hanno Becker278fc7a2017-11-10 09:16:28 +00004055run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004056 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004057 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4058 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4059 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004060 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004061
Hanno Becker32c55012017-11-10 08:42:54 +00004062requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004063run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004064 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004065 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004066 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004067 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004068 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4069 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004070
Hanno Becker32c55012017-11-10 08:42:54 +00004071requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004072run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004073 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004074 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004075 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004076 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004077 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004078
4079run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004080 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004081 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004082 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4083 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004084 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004085
4086run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
4087 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4088 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004089 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004090 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004091 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004092
4093requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4094run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004095 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004096 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004097 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004098 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004099 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004100
Hanno Becker278fc7a2017-11-10 09:16:28 +00004101requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4102run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004103 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004104 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004105 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004106 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004107 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4108 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004109
4110run_test "Large packet TLS 1.1 BlockCipher" \
4111 "$P_SRV" \
4112 "$P_CLI request_size=16384 force_version=tls1_1 \
4113 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4114 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004115 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4116 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004117
Hanno Becker278fc7a2017-11-10 09:16:28 +00004118run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
4119 "$P_SRV" \
4120 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4121 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004122 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004123 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004124
Hanno Becker32c55012017-11-10 08:42:54 +00004125requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004126run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004127 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004128 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004129 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004130 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004131 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004132
Hanno Becker32c55012017-11-10 08:42:54 +00004133requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004134run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004135 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004136 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004137 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004138 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004139 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004140
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004141run_test "Large packet TLS 1.1 StreamCipher" \
4142 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4143 "$P_CLI request_size=16384 force_version=tls1_1 \
4144 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4145 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004146 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4147 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004148
Hanno Becker278fc7a2017-11-10 09:16:28 +00004149run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
4150 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004151 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004152 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004153 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004154 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4155 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004156
Hanno Becker278fc7a2017-11-10 09:16:28 +00004157requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4158run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004159 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004160 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004161 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004162 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004163 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004164
Hanno Becker278fc7a2017-11-10 09:16:28 +00004165requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4166run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004167 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004168 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004169 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004170 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004171 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4172 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004173
4174run_test "Large packet TLS 1.2 BlockCipher" \
4175 "$P_SRV" \
4176 "$P_CLI request_size=16384 force_version=tls1_2 \
4177 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4178 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004179 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4180 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004181
Hanno Becker278fc7a2017-11-10 09:16:28 +00004182run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
4183 "$P_SRV" \
4184 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4185 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4186 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004187 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004188
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004189run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
4190 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004191 "$P_CLI request_size=16384 force_version=tls1_2 \
4192 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004193 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004194 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4195 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004196
Hanno Becker32c55012017-11-10 08:42:54 +00004197requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004198run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004199 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004200 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004201 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004202 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004203 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004204
Hanno Becker278fc7a2017-11-10 09:16:28 +00004205requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4206run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004207 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004208 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004209 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004210 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004211 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4212 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004213
4214run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004215 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004216 "$P_CLI request_size=16384 force_version=tls1_2 \
4217 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4218 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004219 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4220 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004221
Hanno Becker278fc7a2017-11-10 09:16:28 +00004222run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004223 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004224 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004225 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4226 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004227 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004228
Hanno Becker32c55012017-11-10 08:42:54 +00004229requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004230run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004231 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004232 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004233 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004234 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004235 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004236
Hanno Becker278fc7a2017-11-10 09:16:28 +00004237requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4238run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004239 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004240 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004241 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004242 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004243 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4244 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004245
4246run_test "Large packet TLS 1.2 AEAD" \
4247 "$P_SRV" \
4248 "$P_CLI request_size=16384 force_version=tls1_2 \
4249 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4250 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004251 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4252 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004253
4254run_test "Large packet TLS 1.2 AEAD shorter tag" \
4255 "$P_SRV" \
4256 "$P_CLI request_size=16384 force_version=tls1_2 \
4257 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4258 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004259 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4260 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004261
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004262# Tests of asynchronous private key support in SSL
4263
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004264requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004265run_test "SSL async private: sign, delay=0" \
4266 "$P_SRV \
4267 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004268 "$P_CLI" \
4269 0 \
4270 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004271 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004272
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004273requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004274run_test "SSL async private: sign, delay=1" \
4275 "$P_SRV \
4276 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004277 "$P_CLI" \
4278 0 \
4279 -s "Async sign callback: using key slot " \
4280 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004281 -s "Async resume (slot [0-9]): sign done, status=0"
4282
Gilles Peskine12d0cc12018-04-26 15:06:56 +02004283requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4284run_test "SSL async private: sign, delay=2" \
4285 "$P_SRV \
4286 async_operations=s async_private_delay1=2 async_private_delay2=2" \
4287 "$P_CLI" \
4288 0 \
4289 -s "Async sign callback: using key slot " \
4290 -U "Async sign callback: using key slot " \
4291 -s "Async resume (slot [0-9]): call 1 more times." \
4292 -s "Async resume (slot [0-9]): call 0 more times." \
4293 -s "Async resume (slot [0-9]): sign done, status=0"
4294
Gilles Peskined3268832018-04-26 06:23:59 +02004295# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
4296# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
4297requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4298requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4299run_test "SSL async private: sign, RSA, TLS 1.1" \
4300 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
4301 async_operations=s async_private_delay1=0 async_private_delay2=0" \
4302 "$P_CLI force_version=tls1_1" \
4303 0 \
4304 -s "Async sign callback: using key slot " \
4305 -s "Async resume (slot [0-9]): sign done, status=0"
4306
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004307requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02004308run_test "SSL async private: sign, SNI" \
4309 "$P_SRV debug_level=3 \
4310 async_operations=s async_private_delay1=0 async_private_delay2=0 \
4311 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4312 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4313 "$P_CLI server_name=polarssl.example" \
4314 0 \
4315 -s "Async sign callback: using key slot " \
4316 -s "Async resume (slot [0-9]): sign done, status=0" \
4317 -s "parse ServerName extension" \
4318 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4319 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4320
4321requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004322run_test "SSL async private: decrypt, delay=0" \
4323 "$P_SRV \
4324 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4325 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4326 0 \
4327 -s "Async decrypt callback: using key slot " \
4328 -s "Async resume (slot [0-9]): decrypt done, status=0"
4329
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004330requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004331run_test "SSL async private: decrypt, delay=1" \
4332 "$P_SRV \
4333 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4334 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4335 0 \
4336 -s "Async decrypt callback: using key slot " \
4337 -s "Async resume (slot [0-9]): call 0 more times." \
4338 -s "Async resume (slot [0-9]): decrypt done, status=0"
4339
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004340requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004341run_test "SSL async private: decrypt RSA-PSK, delay=0" \
4342 "$P_SRV psk=abc123 \
4343 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4344 "$P_CLI psk=abc123 \
4345 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4346 0 \
4347 -s "Async decrypt callback: using key slot " \
4348 -s "Async resume (slot [0-9]): decrypt done, status=0"
4349
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004350requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004351run_test "SSL async private: decrypt RSA-PSK, delay=1" \
4352 "$P_SRV psk=abc123 \
4353 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4354 "$P_CLI psk=abc123 \
4355 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4356 0 \
4357 -s "Async decrypt callback: using key slot " \
4358 -s "Async resume (slot [0-9]): call 0 more times." \
4359 -s "Async resume (slot [0-9]): decrypt done, status=0"
4360
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004361requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004362run_test "SSL async private: sign callback not present" \
4363 "$P_SRV \
4364 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4365 "$P_CLI; [ \$? -eq 1 ] &&
4366 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4367 0 \
4368 -S "Async sign callback" \
4369 -s "! mbedtls_ssl_handshake returned" \
4370 -s "The own private key or pre-shared key is not set, but needed" \
4371 -s "Async resume (slot [0-9]): decrypt done, status=0" \
4372 -s "Successful connection"
4373
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004374requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004375run_test "SSL async private: decrypt callback not present" \
4376 "$P_SRV debug_level=1 \
4377 async_operations=s async_private_delay1=1 async_private_delay2=1" \
4378 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
4379 [ \$? -eq 1 ] && $P_CLI" \
4380 0 \
4381 -S "Async decrypt callback" \
4382 -s "! mbedtls_ssl_handshake returned" \
4383 -s "got no RSA private key" \
4384 -s "Async resume (slot [0-9]): sign done, status=0" \
4385 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004386
4387# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004388requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004389run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004390 "$P_SRV \
4391 async_operations=s async_private_delay1=1 \
4392 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4393 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004394 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4395 0 \
4396 -s "Async sign callback: using key slot 0," \
4397 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004398 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004399
4400# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004401requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004402run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004403 "$P_SRV \
4404 async_operations=s async_private_delay2=1 \
4405 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4406 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004407 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4408 0 \
4409 -s "Async sign callback: using key slot 0," \
4410 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004411 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004412
4413# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004414requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02004415run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004416 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02004417 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004418 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4419 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004420 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4421 0 \
4422 -s "Async sign callback: using key slot 1," \
4423 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004424 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004425
4426# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004427requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004428run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004429 "$P_SRV \
4430 async_operations=s async_private_delay1=1 \
4431 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4432 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004433 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4434 0 \
4435 -s "Async sign callback: no key matches this certificate."
4436
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004437requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004438run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004439 "$P_SRV \
4440 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4441 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004442 "$P_CLI" \
4443 1 \
4444 -s "Async sign callback: injected error" \
4445 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004446 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004447 -s "! mbedtls_ssl_handshake returned"
4448
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004449requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004450run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004451 "$P_SRV \
4452 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4453 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004454 "$P_CLI" \
4455 1 \
4456 -s "Async sign callback: using key slot " \
4457 -S "Async resume" \
4458 -s "Async cancel"
4459
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004460requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004461run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004462 "$P_SRV \
4463 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4464 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004465 "$P_CLI" \
4466 1 \
4467 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004468 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004469 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004470 -s "! mbedtls_ssl_handshake returned"
4471
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004472requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004473run_test "SSL async private: decrypt, error in start" \
4474 "$P_SRV \
4475 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4476 async_private_error=1" \
4477 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4478 1 \
4479 -s "Async decrypt callback: injected error" \
4480 -S "Async resume" \
4481 -S "Async cancel" \
4482 -s "! mbedtls_ssl_handshake returned"
4483
4484requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4485run_test "SSL async private: decrypt, cancel after start" \
4486 "$P_SRV \
4487 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4488 async_private_error=2" \
4489 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4490 1 \
4491 -s "Async decrypt callback: using key slot " \
4492 -S "Async resume" \
4493 -s "Async cancel"
4494
4495requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4496run_test "SSL async private: decrypt, error in resume" \
4497 "$P_SRV \
4498 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4499 async_private_error=3" \
4500 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4501 1 \
4502 -s "Async decrypt callback: using key slot " \
4503 -s "Async resume callback: decrypt done but injected error" \
4504 -S "Async cancel" \
4505 -s "! mbedtls_ssl_handshake returned"
4506
4507requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004508run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004509 "$P_SRV \
4510 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4511 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004512 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4513 0 \
4514 -s "Async cancel" \
4515 -s "! mbedtls_ssl_handshake returned" \
4516 -s "Async resume" \
4517 -s "Successful connection"
4518
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004519requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004520run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004521 "$P_SRV \
4522 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4523 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004524 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4525 0 \
4526 -s "! mbedtls_ssl_handshake returned" \
4527 -s "Async resume" \
4528 -s "Successful connection"
4529
4530# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004531requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004532run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004533 "$P_SRV \
4534 async_operations=s async_private_delay1=1 async_private_error=-2 \
4535 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4536 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004537 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4538 [ \$? -eq 1 ] &&
4539 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4540 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02004541 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004542 -S "Async resume" \
4543 -s "Async cancel" \
4544 -s "! mbedtls_ssl_handshake returned" \
4545 -s "Async sign callback: no key matches this certificate." \
4546 -s "Successful connection"
4547
4548# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004549requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004550run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004551 "$P_SRV \
4552 async_operations=s async_private_delay1=1 async_private_error=-3 \
4553 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4554 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004555 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4556 [ \$? -eq 1 ] &&
4557 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4558 0 \
4559 -s "Async resume" \
4560 -s "! mbedtls_ssl_handshake returned" \
4561 -s "Async sign callback: no key matches this certificate." \
4562 -s "Successful connection"
4563
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004564requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004565requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004566run_test "SSL async private: renegotiation: client-initiated; sign" \
4567 "$P_SRV \
4568 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004569 exchanges=2 renegotiation=1" \
4570 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
4571 0 \
4572 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004573 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004574
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004575requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004576requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004577run_test "SSL async private: renegotiation: server-initiated; sign" \
4578 "$P_SRV \
4579 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004580 exchanges=2 renegotiation=1 renegotiate=1" \
4581 "$P_CLI exchanges=2 renegotiation=1" \
4582 0 \
4583 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004584 -s "Async resume (slot [0-9]): sign done, status=0"
4585
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004586requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004587requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4588run_test "SSL async private: renegotiation: client-initiated; decrypt" \
4589 "$P_SRV \
4590 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4591 exchanges=2 renegotiation=1" \
4592 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
4593 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4594 0 \
4595 -s "Async decrypt callback: using key slot " \
4596 -s "Async resume (slot [0-9]): decrypt done, status=0"
4597
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004598requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004599requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4600run_test "SSL async private: renegotiation: server-initiated; decrypt" \
4601 "$P_SRV \
4602 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4603 exchanges=2 renegotiation=1 renegotiate=1" \
4604 "$P_CLI exchanges=2 renegotiation=1 \
4605 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4606 0 \
4607 -s "Async decrypt callback: using key slot " \
4608 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004609
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004610# Tests for DTLS HelloVerifyRequest
4611
4612run_test "DTLS cookie: enabled" \
4613 "$P_SRV dtls=1 debug_level=2" \
4614 "$P_CLI dtls=1 debug_level=2" \
4615 0 \
4616 -s "cookie verification failed" \
4617 -s "cookie verification passed" \
4618 -S "cookie verification skipped" \
4619 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004620 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004621 -S "SSL - The requested feature is not available"
4622
4623run_test "DTLS cookie: disabled" \
4624 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4625 "$P_CLI dtls=1 debug_level=2" \
4626 0 \
4627 -S "cookie verification failed" \
4628 -S "cookie verification passed" \
4629 -s "cookie verification skipped" \
4630 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004631 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004632 -S "SSL - The requested feature is not available"
4633
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004634run_test "DTLS cookie: default (failing)" \
4635 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4636 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4637 1 \
4638 -s "cookie verification failed" \
4639 -S "cookie verification passed" \
4640 -S "cookie verification skipped" \
4641 -C "received hello verify request" \
4642 -S "hello verification requested" \
4643 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004644
4645requires_ipv6
4646run_test "DTLS cookie: enabled, IPv6" \
4647 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4648 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4649 0 \
4650 -s "cookie verification failed" \
4651 -s "cookie verification passed" \
4652 -S "cookie verification skipped" \
4653 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004654 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004655 -S "SSL - The requested feature is not available"
4656
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004657run_test "DTLS cookie: enabled, nbio" \
4658 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4659 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4660 0 \
4661 -s "cookie verification failed" \
4662 -s "cookie verification passed" \
4663 -S "cookie verification skipped" \
4664 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004665 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004666 -S "SSL - The requested feature is not available"
4667
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004668# Tests for client reconnecting from the same port with DTLS
4669
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004670not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004671run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004672 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4673 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004674 0 \
4675 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004676 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004677 -S "Client initiated reconnection from same port"
4678
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004679not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004680run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004681 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4682 "$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 +02004683 0 \
4684 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004685 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004686 -s "Client initiated reconnection from same port"
4687
Paul Bakker362689d2016-05-13 10:33:25 +01004688not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4689run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004690 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4691 "$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 +02004692 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004693 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004694 -s "Client initiated reconnection from same port"
4695
Paul Bakker362689d2016-05-13 10:33:25 +01004696only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4697run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4698 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4699 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4700 0 \
4701 -S "The operation timed out" \
4702 -s "Client initiated reconnection from same port"
4703
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004704run_test "DTLS client reconnect from same port: no cookies" \
4705 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004706 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4707 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004708 -s "The operation timed out" \
4709 -S "Client initiated reconnection from same port"
4710
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004711# Tests for various cases of client authentication with DTLS
4712# (focused on handshake flows and message parsing)
4713
4714run_test "DTLS client auth: required" \
4715 "$P_SRV dtls=1 auth_mode=required" \
4716 "$P_CLI dtls=1" \
4717 0 \
4718 -s "Verifying peer X.509 certificate... ok"
4719
4720run_test "DTLS client auth: optional, client has no cert" \
4721 "$P_SRV dtls=1 auth_mode=optional" \
4722 "$P_CLI dtls=1 crt_file=none key_file=none" \
4723 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004724 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004725
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004726run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004727 "$P_SRV dtls=1 auth_mode=none" \
4728 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
4729 0 \
4730 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004731 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004732
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02004733run_test "DTLS wrong PSK: badmac alert" \
4734 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
4735 "$P_CLI dtls=1 psk=abc124" \
4736 1 \
4737 -s "SSL - Verification of the message MAC failed" \
4738 -c "SSL - A fatal alert message was received from our peer"
4739
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02004740# Tests for receiving fragmented handshake messages with DTLS
4741
4742requires_gnutls
4743run_test "DTLS reassembly: no fragmentation (gnutls server)" \
4744 "$G_SRV -u --mtu 2048 -a" \
4745 "$P_CLI dtls=1 debug_level=2" \
4746 0 \
4747 -C "found fragmented DTLS handshake message" \
4748 -C "error"
4749
4750requires_gnutls
4751run_test "DTLS reassembly: some fragmentation (gnutls server)" \
4752 "$G_SRV -u --mtu 512" \
4753 "$P_CLI dtls=1 debug_level=2" \
4754 0 \
4755 -c "found fragmented DTLS handshake message" \
4756 -C "error"
4757
4758requires_gnutls
4759run_test "DTLS reassembly: more fragmentation (gnutls server)" \
4760 "$G_SRV -u --mtu 128" \
4761 "$P_CLI dtls=1 debug_level=2" \
4762 0 \
4763 -c "found fragmented DTLS handshake message" \
4764 -C "error"
4765
4766requires_gnutls
4767run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
4768 "$G_SRV -u --mtu 128" \
4769 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4770 0 \
4771 -c "found fragmented DTLS handshake message" \
4772 -C "error"
4773
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004774requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004775requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004776run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4777 "$G_SRV -u --mtu 256" \
4778 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4779 0 \
4780 -c "found fragmented DTLS handshake message" \
4781 -c "client hello, adding renegotiation extension" \
4782 -c "found renegotiation extension" \
4783 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004784 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004785 -C "error" \
4786 -s "Extra-header:"
4787
4788requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004789requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004790run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4791 "$G_SRV -u --mtu 256" \
4792 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4793 0 \
4794 -c "found fragmented DTLS handshake message" \
4795 -c "client hello, adding renegotiation extension" \
4796 -c "found renegotiation extension" \
4797 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004798 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004799 -C "error" \
4800 -s "Extra-header:"
4801
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004802run_test "DTLS reassembly: no fragmentation (openssl server)" \
4803 "$O_SRV -dtls1 -mtu 2048" \
4804 "$P_CLI dtls=1 debug_level=2" \
4805 0 \
4806 -C "found fragmented DTLS handshake message" \
4807 -C "error"
4808
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004809run_test "DTLS reassembly: some fragmentation (openssl server)" \
4810 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004811 "$P_CLI dtls=1 debug_level=2" \
4812 0 \
4813 -c "found fragmented DTLS handshake message" \
4814 -C "error"
4815
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004816run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004817 "$O_SRV -dtls1 -mtu 256" \
4818 "$P_CLI dtls=1 debug_level=2" \
4819 0 \
4820 -c "found fragmented DTLS handshake message" \
4821 -C "error"
4822
4823run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4824 "$O_SRV -dtls1 -mtu 256" \
4825 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4826 0 \
4827 -c "found fragmented DTLS handshake message" \
4828 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004829
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004830# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004831
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004832not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004833run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004834 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004835 "$P_SRV dtls=1 debug_level=2" \
4836 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004837 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004838 -C "replayed record" \
4839 -S "replayed record" \
4840 -C "record from another epoch" \
4841 -S "record from another epoch" \
4842 -C "discarding invalid record" \
4843 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004844 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004845 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004846 -c "HTTP/1.0 200 OK"
4847
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004848not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004849run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004850 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004851 "$P_SRV dtls=1 debug_level=2" \
4852 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004853 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004854 -c "replayed record" \
4855 -s "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004856 -c "record from another epoch" \
4857 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004858 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004859 -s "Extra-header:" \
4860 -c "HTTP/1.0 200 OK"
4861
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004862run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4863 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004864 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4865 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004866 0 \
4867 -c "replayed record" \
4868 -S "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004869 -c "record from another epoch" \
4870 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004871 -c "resend" \
4872 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004873 -s "Extra-header:" \
4874 -c "HTTP/1.0 200 OK"
4875
Hanno Becker72a4f032017-11-15 16:39:20 +00004876run_test "DTLS proxy: multiple records in same datagram" \
Hanno Becker8d832182018-03-15 10:14:19 +00004877 -p "$P_PXY pack=50" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004878 "$P_SRV dtls=1 debug_level=2" \
4879 "$P_CLI dtls=1 debug_level=2" \
4880 0 \
4881 -c "next record in same datagram" \
4882 -s "next record in same datagram"
4883
4884run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
Hanno Becker8d832182018-03-15 10:14:19 +00004885 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004886 "$P_SRV dtls=1 debug_level=2" \
4887 "$P_CLI dtls=1 debug_level=2" \
4888 0 \
4889 -c "next record in same datagram" \
4890 -s "next record in same datagram"
4891
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004892run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004893 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004894 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004895 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004896 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004897 -c "discarding invalid record (mac)" \
4898 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004899 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004900 -c "HTTP/1.0 200 OK" \
4901 -S "too many records with bad MAC" \
4902 -S "Verification of the message MAC failed"
4903
4904run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4905 -p "$P_PXY bad_ad=1" \
4906 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4907 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4908 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004909 -C "discarding invalid record (mac)" \
4910 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004911 -S "Extra-header:" \
4912 -C "HTTP/1.0 200 OK" \
4913 -s "too many records with bad MAC" \
4914 -s "Verification of the message MAC failed"
4915
4916run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4917 -p "$P_PXY bad_ad=1" \
4918 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4919 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4920 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004921 -c "discarding invalid record (mac)" \
4922 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004923 -s "Extra-header:" \
4924 -c "HTTP/1.0 200 OK" \
4925 -S "too many records with bad MAC" \
4926 -S "Verification of the message MAC failed"
4927
4928run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4929 -p "$P_PXY bad_ad=1" \
4930 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4931 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4932 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004933 -c "discarding invalid record (mac)" \
4934 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004935 -s "Extra-header:" \
4936 -c "HTTP/1.0 200 OK" \
4937 -s "too many records with bad MAC" \
4938 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004939
4940run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004941 -p "$P_PXY delay_ccs=1" \
4942 "$P_SRV dtls=1 debug_level=1" \
4943 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004944 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004945 -c "record from another epoch" \
4946 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004947 -s "Extra-header:" \
4948 -c "HTTP/1.0 200 OK"
4949
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004950# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004951
Janos Follath74537a62016-09-02 13:45:28 +01004952client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004953run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004954 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004955 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4956 psk=abc123" \
4957 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004958 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4959 0 \
4960 -s "Extra-header:" \
4961 -c "HTTP/1.0 200 OK"
4962
Janos Follath74537a62016-09-02 13:45:28 +01004963client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004964run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4965 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004966 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4967 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004968 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4969 0 \
4970 -s "Extra-header:" \
4971 -c "HTTP/1.0 200 OK"
4972
Janos Follath74537a62016-09-02 13:45:28 +01004973client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004974run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4975 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004976 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4977 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004978 0 \
4979 -s "Extra-header:" \
4980 -c "HTTP/1.0 200 OK"
4981
Janos Follath74537a62016-09-02 13:45:28 +01004982client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004983run_test "DTLS proxy: 3d, FS, client auth" \
4984 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004985 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4986 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004987 0 \
4988 -s "Extra-header:" \
4989 -c "HTTP/1.0 200 OK"
4990
Janos Follath74537a62016-09-02 13:45:28 +01004991client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004992run_test "DTLS proxy: 3d, FS, ticket" \
4993 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004994 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4995 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004996 0 \
4997 -s "Extra-header:" \
4998 -c "HTTP/1.0 200 OK"
4999
Janos Follath74537a62016-09-02 13:45:28 +01005000client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005001run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
5002 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005003 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
5004 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005005 0 \
5006 -s "Extra-header:" \
5007 -c "HTTP/1.0 200 OK"
5008
Janos Follath74537a62016-09-02 13:45:28 +01005009client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005010run_test "DTLS proxy: 3d, max handshake, nbio" \
5011 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005012 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
5013 auth_mode=required" \
5014 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005015 0 \
5016 -s "Extra-header:" \
5017 -c "HTTP/1.0 200 OK"
5018
Janos Follath74537a62016-09-02 13:45:28 +01005019client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005020run_test "DTLS proxy: 3d, min handshake, resumption" \
5021 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5022 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5023 psk=abc123 debug_level=3" \
5024 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5025 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5026 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5027 0 \
5028 -s "a session has been resumed" \
5029 -c "a session has been resumed" \
5030 -s "Extra-header:" \
5031 -c "HTTP/1.0 200 OK"
5032
Janos Follath74537a62016-09-02 13:45:28 +01005033client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005034run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
5035 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5036 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5037 psk=abc123 debug_level=3 nbio=2" \
5038 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5039 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5040 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
5041 0 \
5042 -s "a session has been resumed" \
5043 -c "a session has been resumed" \
5044 -s "Extra-header:" \
5045 -c "HTTP/1.0 200 OK"
5046
Janos Follath74537a62016-09-02 13:45:28 +01005047client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005048requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005049run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005050 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005051 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5052 psk=abc123 renegotiation=1 debug_level=2" \
5053 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5054 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005055 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5056 0 \
5057 -c "=> renegotiate" \
5058 -s "=> renegotiate" \
5059 -s "Extra-header:" \
5060 -c "HTTP/1.0 200 OK"
5061
Janos Follath74537a62016-09-02 13:45:28 +01005062client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005063requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005064run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
5065 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005066 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5067 psk=abc123 renegotiation=1 debug_level=2" \
5068 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5069 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005070 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5071 0 \
5072 -c "=> renegotiate" \
5073 -s "=> renegotiate" \
5074 -s "Extra-header:" \
5075 -c "HTTP/1.0 200 OK"
5076
Janos Follath74537a62016-09-02 13:45:28 +01005077client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005078requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005079run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005080 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005081 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005082 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005083 debug_level=2" \
5084 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005085 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005086 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5087 0 \
5088 -c "=> renegotiate" \
5089 -s "=> renegotiate" \
5090 -s "Extra-header:" \
5091 -c "HTTP/1.0 200 OK"
5092
Janos Follath74537a62016-09-02 13:45:28 +01005093client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005094requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005095run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005096 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005097 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005098 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005099 debug_level=2 nbio=2" \
5100 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005101 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005102 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5103 0 \
5104 -c "=> renegotiate" \
5105 -s "=> renegotiate" \
5106 -s "Extra-header:" \
5107 -c "HTTP/1.0 200 OK"
5108
Janos Follath74537a62016-09-02 13:45:28 +01005109client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005110not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005111run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005112 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5113 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005114 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005115 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005116 -c "HTTP/1.0 200 OK"
5117
Janos Follath74537a62016-09-02 13:45:28 +01005118client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005119not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005120run_test "DTLS proxy: 3d, openssl server, fragmentation" \
5121 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5122 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005123 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005124 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005125 -c "HTTP/1.0 200 OK"
5126
Janos Follath74537a62016-09-02 13:45:28 +01005127client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005128not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005129run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
5130 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5131 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005132 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005133 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005134 -c "HTTP/1.0 200 OK"
5135
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005136requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005137client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005138not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005139run_test "DTLS proxy: 3d, gnutls server" \
5140 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5141 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005142 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005143 0 \
5144 -s "Extra-header:" \
5145 -c "Extra-header:"
5146
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005147requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005148client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005149not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005150run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
5151 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5152 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005153 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005154 0 \
5155 -s "Extra-header:" \
5156 -c "Extra-header:"
5157
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005158requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005159client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005160not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005161run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
5162 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5163 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005164 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005165 0 \
5166 -s "Extra-header:" \
5167 -c "Extra-header:"
5168
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01005169# Final report
5170
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005171echo "------------------------------------------------------------------------"
5172
5173if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005174 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005175else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005176 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005177fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02005178PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02005179echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005180
5181exit $FAILS