blob: 34598451d52a71e294ca9f7c4a3fadd2fdbc0122 [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 Peskine3c9e2b52018-01-08 12:38:15 +0100335 echo "Warning: lsof not available, wait_server_start = sleep $START_DELAY"
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" \
745 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
746 -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" \
756 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
757
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100758# Test current time in ServerHello
759requires_config_enabled MBEDTLS_HAVE_TIME
760run_test "Default, ServerHello contains gmt_unix_time" \
761 "$P_SRV debug_level=3" \
762 "$P_CLI debug_level=3" \
763 0 \
764 -s "Protocol is TLSv1.2" \
765 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
766 -s "client hello v3, signature_algorithm ext: 6" \
767 -s "ECDHE curve: secp521r1" \
768 -S "error" \
769 -C "error" \
770 -f "check_server_hello_time" \
771 -F "check_server_hello_time"
772
Simon Butcher8e004102016-10-14 00:48:33 +0100773# Test for uniqueness of IVs in AEAD ciphersuites
774run_test "Unique IV in GCM" \
775 "$P_SRV exchanges=20 debug_level=4" \
776 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
777 0 \
778 -u "IV used" \
779 -U "IV used"
780
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100781# Tests for rc4 option
782
Simon Butchera410af52016-05-19 22:12:18 +0100783requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100784run_test "RC4: server disabled, client enabled" \
785 "$P_SRV" \
786 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
787 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100788 -s "SSL - The server has no ciphersuites in common"
789
Simon Butchera410af52016-05-19 22:12:18 +0100790requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100791run_test "RC4: server half, client enabled" \
792 "$P_SRV arc4=1" \
793 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
794 1 \
795 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100796
797run_test "RC4: server enabled, client disabled" \
798 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
799 "$P_CLI" \
800 1 \
801 -s "SSL - The server has no ciphersuites in common"
802
803run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100804 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100805 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
806 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100807 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100808 -S "SSL - The server has no ciphersuites in common"
809
Gilles Peskinebc70a182017-05-09 15:59:24 +0200810# Tests for SHA-1 support
811
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200812requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200813run_test "SHA-1 forbidden by default in server certificate" \
814 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
815 "$P_CLI debug_level=2 allow_sha1=0" \
816 1 \
817 -c "The certificate is signed with an unacceptable hash"
818
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200819requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
820run_test "SHA-1 forbidden by default in server certificate" \
821 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
822 "$P_CLI debug_level=2 allow_sha1=0" \
823 0
824
Gilles Peskinebc70a182017-05-09 15:59:24 +0200825run_test "SHA-1 explicitly allowed in server certificate" \
826 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
827 "$P_CLI allow_sha1=1" \
828 0
829
830run_test "SHA-256 allowed by default in server certificate" \
831 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
832 "$P_CLI allow_sha1=0" \
833 0
834
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200835requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200836run_test "SHA-1 forbidden by default in client certificate" \
837 "$P_SRV auth_mode=required allow_sha1=0" \
838 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
839 1 \
840 -s "The certificate is signed with an unacceptable hash"
841
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200842requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
843run_test "SHA-1 forbidden by default in client certificate" \
844 "$P_SRV auth_mode=required allow_sha1=0" \
845 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
846 0
847
Gilles Peskinebc70a182017-05-09 15:59:24 +0200848run_test "SHA-1 explicitly allowed in client certificate" \
849 "$P_SRV auth_mode=required allow_sha1=1" \
850 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
851 0
852
853run_test "SHA-256 allowed by default in client certificate" \
854 "$P_SRV auth_mode=required allow_sha1=0" \
855 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
856 0
857
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100858# Tests for Truncated HMAC extension
859
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100860run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200861 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100862 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100863 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000864 -s "dumping 'expected mac' (20 bytes)" \
865 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100866
Hanno Becker32c55012017-11-10 08:42:54 +0000867requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100868run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200869 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000870 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100871 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000872 -s "dumping 'expected mac' (20 bytes)" \
873 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100874
Hanno Becker32c55012017-11-10 08:42:54 +0000875requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100876run_test "Truncated HMAC: client enabled, server default" \
877 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000878 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100879 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000880 -s "dumping 'expected mac' (20 bytes)" \
881 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100882
Hanno Becker32c55012017-11-10 08:42:54 +0000883requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100884run_test "Truncated HMAC: client enabled, server disabled" \
885 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000886 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100887 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000888 -s "dumping 'expected mac' (20 bytes)" \
889 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100890
Hanno Becker32c55012017-11-10 08:42:54 +0000891requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000892run_test "Truncated HMAC: client disabled, server enabled" \
893 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000894 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000895 0 \
896 -s "dumping 'expected mac' (20 bytes)" \
897 -S "dumping 'expected mac' (10 bytes)"
898
899requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100900run_test "Truncated HMAC: client enabled, server enabled" \
901 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000902 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100903 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000904 -S "dumping 'expected mac' (20 bytes)" \
905 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100906
Hanno Becker4c4f4102017-11-10 09:16:05 +0000907run_test "Truncated HMAC, DTLS: client default, server default" \
908 "$P_SRV dtls=1 debug_level=4" \
909 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
910 0 \
911 -s "dumping 'expected mac' (20 bytes)" \
912 -S "dumping 'expected mac' (10 bytes)"
913
914requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
915run_test "Truncated HMAC, DTLS: client disabled, server default" \
916 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000917 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000918 0 \
919 -s "dumping 'expected mac' (20 bytes)" \
920 -S "dumping 'expected mac' (10 bytes)"
921
922requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
923run_test "Truncated HMAC, DTLS: client enabled, server default" \
924 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000925 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000926 0 \
927 -s "dumping 'expected mac' (20 bytes)" \
928 -S "dumping 'expected mac' (10 bytes)"
929
930requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
931run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
932 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000933 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000934 0 \
935 -s "dumping 'expected mac' (20 bytes)" \
936 -S "dumping 'expected mac' (10 bytes)"
937
938requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
939run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
940 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000941 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000942 0 \
943 -s "dumping 'expected mac' (20 bytes)" \
944 -S "dumping 'expected mac' (10 bytes)"
945
946requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
947run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
948 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000949 "$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 +0100950 0 \
951 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100952 -s "dumping 'expected mac' (10 bytes)"
953
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100954# Tests for Encrypt-then-MAC extension
955
956run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100957 "$P_SRV debug_level=3 \
958 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100959 "$P_CLI debug_level=3" \
960 0 \
961 -c "client hello, adding encrypt_then_mac extension" \
962 -s "found encrypt then mac extension" \
963 -s "server hello, adding encrypt then mac extension" \
964 -c "found encrypt_then_mac extension" \
965 -c "using encrypt then mac" \
966 -s "using encrypt then mac"
967
968run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100969 "$P_SRV debug_level=3 etm=0 \
970 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100971 "$P_CLI debug_level=3 etm=1" \
972 0 \
973 -c "client hello, adding encrypt_then_mac extension" \
974 -s "found encrypt then mac extension" \
975 -S "server hello, adding encrypt then mac extension" \
976 -C "found encrypt_then_mac extension" \
977 -C "using encrypt then mac" \
978 -S "using encrypt then mac"
979
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100980run_test "Encrypt then MAC: client enabled, aead cipher" \
981 "$P_SRV debug_level=3 etm=1 \
982 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
983 "$P_CLI debug_level=3 etm=1" \
984 0 \
985 -c "client hello, adding encrypt_then_mac extension" \
986 -s "found encrypt then mac extension" \
987 -S "server hello, adding encrypt then mac extension" \
988 -C "found encrypt_then_mac extension" \
989 -C "using encrypt then mac" \
990 -S "using encrypt then mac"
991
992run_test "Encrypt then MAC: client enabled, stream cipher" \
993 "$P_SRV debug_level=3 etm=1 \
994 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100995 "$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 +0100996 0 \
997 -c "client hello, adding encrypt_then_mac extension" \
998 -s "found encrypt then mac extension" \
999 -S "server hello, adding encrypt then mac extension" \
1000 -C "found encrypt_then_mac extension" \
1001 -C "using encrypt then mac" \
1002 -S "using encrypt then mac"
1003
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001004run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001005 "$P_SRV debug_level=3 etm=1 \
1006 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001007 "$P_CLI debug_level=3 etm=0" \
1008 0 \
1009 -C "client hello, adding encrypt_then_mac extension" \
1010 -S "found encrypt then mac extension" \
1011 -S "server hello, adding encrypt then mac extension" \
1012 -C "found encrypt_then_mac extension" \
1013 -C "using encrypt then mac" \
1014 -S "using encrypt then mac"
1015
Janos Follathe2681a42016-03-07 15:57:05 +00001016requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001017run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001018 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001019 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001020 "$P_CLI debug_level=3 force_version=ssl3" \
1021 0 \
1022 -C "client hello, adding encrypt_then_mac extension" \
1023 -S "found encrypt then mac extension" \
1024 -S "server hello, adding encrypt then mac extension" \
1025 -C "found encrypt_then_mac extension" \
1026 -C "using encrypt then mac" \
1027 -S "using encrypt then mac"
1028
Janos Follathe2681a42016-03-07 15:57:05 +00001029requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001030run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001031 "$P_SRV debug_level=3 force_version=ssl3 \
1032 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001033 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001034 0 \
1035 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001036 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001037 -S "server hello, adding encrypt then mac extension" \
1038 -C "found encrypt_then_mac extension" \
1039 -C "using encrypt then mac" \
1040 -S "using encrypt then mac"
1041
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001042# Tests for Extended Master Secret extension
1043
1044run_test "Extended Master Secret: default" \
1045 "$P_SRV debug_level=3" \
1046 "$P_CLI debug_level=3" \
1047 0 \
1048 -c "client hello, adding extended_master_secret extension" \
1049 -s "found extended master secret extension" \
1050 -s "server hello, adding extended master secret extension" \
1051 -c "found extended_master_secret extension" \
1052 -c "using extended master secret" \
1053 -s "using extended master secret"
1054
1055run_test "Extended Master Secret: client enabled, server disabled" \
1056 "$P_SRV debug_level=3 extended_ms=0" \
1057 "$P_CLI debug_level=3 extended_ms=1" \
1058 0 \
1059 -c "client hello, adding extended_master_secret extension" \
1060 -s "found extended master secret extension" \
1061 -S "server hello, adding extended master secret extension" \
1062 -C "found extended_master_secret extension" \
1063 -C "using extended master secret" \
1064 -S "using extended master secret"
1065
1066run_test "Extended Master Secret: client disabled, server enabled" \
1067 "$P_SRV debug_level=3 extended_ms=1" \
1068 "$P_CLI debug_level=3 extended_ms=0" \
1069 0 \
1070 -C "client hello, adding extended_master_secret extension" \
1071 -S "found extended master secret extension" \
1072 -S "server hello, adding extended master secret extension" \
1073 -C "found extended_master_secret extension" \
1074 -C "using extended master secret" \
1075 -S "using extended master secret"
1076
Janos Follathe2681a42016-03-07 15:57:05 +00001077requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001078run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001079 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001080 "$P_CLI debug_level=3 force_version=ssl3" \
1081 0 \
1082 -C "client hello, adding extended_master_secret extension" \
1083 -S "found extended master secret extension" \
1084 -S "server hello, adding extended master secret extension" \
1085 -C "found extended_master_secret extension" \
1086 -C "using extended master secret" \
1087 -S "using extended master secret"
1088
Janos Follathe2681a42016-03-07 15:57:05 +00001089requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001090run_test "Extended Master Secret: client enabled, server SSLv3" \
1091 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001092 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001093 0 \
1094 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001095 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001096 -S "server hello, adding extended master secret extension" \
1097 -C "found extended_master_secret extension" \
1098 -C "using extended master secret" \
1099 -S "using extended master secret"
1100
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001101# Tests for FALLBACK_SCSV
1102
1103run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001104 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001105 "$P_CLI debug_level=3 force_version=tls1_1" \
1106 0 \
1107 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001108 -S "received FALLBACK_SCSV" \
1109 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001110 -C "is a fatal alert message (msg 86)"
1111
1112run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001113 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001114 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1115 0 \
1116 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001117 -S "received FALLBACK_SCSV" \
1118 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001119 -C "is a fatal alert message (msg 86)"
1120
1121run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001122 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001123 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001124 1 \
1125 -c "adding FALLBACK_SCSV" \
1126 -s "received FALLBACK_SCSV" \
1127 -s "inapropriate fallback" \
1128 -c "is a fatal alert message (msg 86)"
1129
1130run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001131 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001132 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001133 0 \
1134 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001135 -s "received FALLBACK_SCSV" \
1136 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001137 -C "is a fatal alert message (msg 86)"
1138
1139requires_openssl_with_fallback_scsv
1140run_test "Fallback SCSV: default, openssl server" \
1141 "$O_SRV" \
1142 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1143 0 \
1144 -C "adding FALLBACK_SCSV" \
1145 -C "is a fatal alert message (msg 86)"
1146
1147requires_openssl_with_fallback_scsv
1148run_test "Fallback SCSV: enabled, openssl server" \
1149 "$O_SRV" \
1150 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1151 1 \
1152 -c "adding FALLBACK_SCSV" \
1153 -c "is a fatal alert message (msg 86)"
1154
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001155requires_openssl_with_fallback_scsv
1156run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001157 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001158 "$O_CLI -tls1_1" \
1159 0 \
1160 -S "received FALLBACK_SCSV" \
1161 -S "inapropriate fallback"
1162
1163requires_openssl_with_fallback_scsv
1164run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001165 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001166 "$O_CLI -tls1_1 -fallback_scsv" \
1167 1 \
1168 -s "received FALLBACK_SCSV" \
1169 -s "inapropriate fallback"
1170
1171requires_openssl_with_fallback_scsv
1172run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001173 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001174 "$O_CLI -fallback_scsv" \
1175 0 \
1176 -s "received FALLBACK_SCSV" \
1177 -S "inapropriate fallback"
1178
Gilles Peskined50177f2017-05-16 17:53:03 +02001179## ClientHello generated with
1180## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1181## then manually twiddling the ciphersuite list.
1182## The ClientHello content is spelled out below as a hex string as
1183## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1184## The expected response is an inappropriate_fallback alert.
1185requires_openssl_with_fallback_scsv
1186run_test "Fallback SCSV: beginning of list" \
1187 "$P_SRV debug_level=2" \
1188 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1189 0 \
1190 -s "received FALLBACK_SCSV" \
1191 -s "inapropriate fallback"
1192
1193requires_openssl_with_fallback_scsv
1194run_test "Fallback SCSV: end of list" \
1195 "$P_SRV debug_level=2" \
1196 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1197 0 \
1198 -s "received FALLBACK_SCSV" \
1199 -s "inapropriate fallback"
1200
1201## Here the expected response is a valid ServerHello prefix, up to the random.
1202requires_openssl_with_fallback_scsv
1203run_test "Fallback SCSV: not in list" \
1204 "$P_SRV debug_level=2" \
1205 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1206 0 \
1207 -S "received FALLBACK_SCSV" \
1208 -S "inapropriate fallback"
1209
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001210# Tests for CBC 1/n-1 record splitting
1211
1212run_test "CBC Record splitting: TLS 1.2, no splitting" \
1213 "$P_SRV" \
1214 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1215 request_size=123 force_version=tls1_2" \
1216 0 \
1217 -s "Read from client: 123 bytes read" \
1218 -S "Read from client: 1 bytes read" \
1219 -S "122 bytes read"
1220
1221run_test "CBC Record splitting: TLS 1.1, no splitting" \
1222 "$P_SRV" \
1223 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1224 request_size=123 force_version=tls1_1" \
1225 0 \
1226 -s "Read from client: 123 bytes read" \
1227 -S "Read from client: 1 bytes read" \
1228 -S "122 bytes read"
1229
1230run_test "CBC Record splitting: TLS 1.0, splitting" \
1231 "$P_SRV" \
1232 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1233 request_size=123 force_version=tls1" \
1234 0 \
1235 -S "Read from client: 123 bytes read" \
1236 -s "Read from client: 1 bytes read" \
1237 -s "122 bytes read"
1238
Janos Follathe2681a42016-03-07 15:57:05 +00001239requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001240run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001241 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001242 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1243 request_size=123 force_version=ssl3" \
1244 0 \
1245 -S "Read from client: 123 bytes read" \
1246 -s "Read from client: 1 bytes read" \
1247 -s "122 bytes read"
1248
1249run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001250 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001251 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1252 request_size=123 force_version=tls1" \
1253 0 \
1254 -s "Read from client: 123 bytes read" \
1255 -S "Read from client: 1 bytes read" \
1256 -S "122 bytes read"
1257
1258run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1259 "$P_SRV" \
1260 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1261 request_size=123 force_version=tls1 recsplit=0" \
1262 0 \
1263 -s "Read from client: 123 bytes read" \
1264 -S "Read from client: 1 bytes read" \
1265 -S "122 bytes read"
1266
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001267run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1268 "$P_SRV nbio=2" \
1269 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1270 request_size=123 force_version=tls1" \
1271 0 \
1272 -S "Read from client: 123 bytes read" \
1273 -s "Read from client: 1 bytes read" \
1274 -s "122 bytes read"
1275
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001276# Tests for Session Tickets
1277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001278run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001279 "$P_SRV debug_level=3 tickets=1" \
1280 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001281 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001282 -c "client hello, adding session ticket extension" \
1283 -s "found session ticket extension" \
1284 -s "server hello, adding session ticket extension" \
1285 -c "found session_ticket extension" \
1286 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001287 -S "session successfully restored from cache" \
1288 -s "session successfully restored from ticket" \
1289 -s "a session has been resumed" \
1290 -c "a session has been resumed"
1291
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001292run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001293 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1294 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001295 0 \
1296 -c "client hello, adding session ticket extension" \
1297 -s "found session ticket extension" \
1298 -s "server hello, adding session ticket extension" \
1299 -c "found session_ticket extension" \
1300 -c "parse new session ticket" \
1301 -S "session successfully restored from cache" \
1302 -s "session successfully restored from ticket" \
1303 -s "a session has been resumed" \
1304 -c "a session has been resumed"
1305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001306run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001307 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1308 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001309 0 \
1310 -c "client hello, adding session ticket extension" \
1311 -s "found session ticket extension" \
1312 -s "server hello, adding session ticket extension" \
1313 -c "found session_ticket extension" \
1314 -c "parse new session ticket" \
1315 -S "session successfully restored from cache" \
1316 -S "session successfully restored from ticket" \
1317 -S "a session has been resumed" \
1318 -C "a session has been resumed"
1319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001320run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001321 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001322 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001323 0 \
1324 -c "client hello, adding session ticket extension" \
1325 -c "found session_ticket extension" \
1326 -c "parse new session ticket" \
1327 -c "a session has been resumed"
1328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001329run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001330 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001331 "( $O_CLI -sess_out $SESSION; \
1332 $O_CLI -sess_in $SESSION; \
1333 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001334 0 \
1335 -s "found session ticket extension" \
1336 -s "server hello, adding session ticket extension" \
1337 -S "session successfully restored from cache" \
1338 -s "session successfully restored from ticket" \
1339 -s "a session has been resumed"
1340
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001341# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001343run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001344 "$P_SRV debug_level=3 tickets=0" \
1345 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001346 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001347 -c "client hello, adding session ticket extension" \
1348 -s "found session ticket extension" \
1349 -S "server hello, adding session ticket extension" \
1350 -C "found session_ticket extension" \
1351 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001352 -s "session successfully restored from cache" \
1353 -S "session successfully restored from ticket" \
1354 -s "a session has been resumed" \
1355 -c "a session has been resumed"
1356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001357run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001358 "$P_SRV debug_level=3 tickets=1" \
1359 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001360 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001361 -C "client hello, adding session ticket extension" \
1362 -S "found session ticket extension" \
1363 -S "server hello, adding session ticket extension" \
1364 -C "found session_ticket extension" \
1365 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001366 -s "session successfully restored from cache" \
1367 -S "session successfully restored from ticket" \
1368 -s "a session has been resumed" \
1369 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001370
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001371run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001372 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1373 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001374 0 \
1375 -S "session successfully restored from cache" \
1376 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001377 -S "a session has been resumed" \
1378 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001380run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1382 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001383 0 \
1384 -s "session successfully restored from cache" \
1385 -S "session successfully restored from ticket" \
1386 -s "a session has been resumed" \
1387 -c "a session has been resumed"
1388
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001389run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001390 "$P_SRV debug_level=3 tickets=0" \
1391 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001392 0 \
1393 -s "session successfully restored from cache" \
1394 -S "session successfully restored from ticket" \
1395 -s "a session has been resumed" \
1396 -c "a session has been resumed"
1397
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001398run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001399 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1400 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001401 0 \
1402 -S "session successfully restored from cache" \
1403 -S "session successfully restored from ticket" \
1404 -S "a session has been resumed" \
1405 -C "a session has been resumed"
1406
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001407run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001408 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1409 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001410 0 \
1411 -s "session successfully restored from cache" \
1412 -S "session successfully restored from ticket" \
1413 -s "a session has been resumed" \
1414 -c "a session has been resumed"
1415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001416run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001417 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001418 "( $O_CLI -sess_out $SESSION; \
1419 $O_CLI -sess_in $SESSION; \
1420 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001421 0 \
1422 -s "found session ticket extension" \
1423 -S "server hello, adding session ticket extension" \
1424 -s "session successfully restored from cache" \
1425 -S "session successfully restored from ticket" \
1426 -s "a session has been resumed"
1427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001428run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001429 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001430 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001431 0 \
1432 -C "found session_ticket extension" \
1433 -C "parse new session ticket" \
1434 -c "a session has been resumed"
1435
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001436# Tests for Max Fragment Length extension
1437
Angus Grattonc4dd0732018-04-11 16:28:39 +10001438if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
1439 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 +01001440 exit 1
1441fi
1442
Angus Grattonc4dd0732018-04-11 16:28:39 +10001443if [ $MAX_CONTENT_LEN -ne 16384 ]; then
1444 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
1445fi
1446
Hanno Becker4aed27e2017-09-18 15:00:34 +01001447requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001448run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001449 "$P_SRV debug_level=3" \
1450 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001451 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001452 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1453 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001454 -C "client hello, adding max_fragment_length extension" \
1455 -S "found max fragment length extension" \
1456 -S "server hello, max_fragment_length extension" \
1457 -C "found max_fragment_length extension"
1458
Hanno Becker4aed27e2017-09-18 15:00:34 +01001459requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001460run_test "Max fragment length: enabled, default, larger message" \
1461 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001462 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001463 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001464 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1465 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001466 -C "client hello, adding max_fragment_length extension" \
1467 -S "found max fragment length extension" \
1468 -S "server hello, max_fragment_length extension" \
1469 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001470 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1471 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001472 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001473
1474requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1475run_test "Max fragment length, DTLS: enabled, default, larger message" \
1476 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001477 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001478 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001479 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1480 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001481 -C "client hello, adding max_fragment_length extension" \
1482 -S "found max fragment length extension" \
1483 -S "server hello, max_fragment_length extension" \
1484 -C "found max_fragment_length extension" \
1485 -c "fragment larger than.*maximum "
1486
Angus Grattonc4dd0732018-04-11 16:28:39 +10001487# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1488# (session fragment length will be 16384 regardless of mbedtls
1489# content length configuration.)
1490
Hanno Beckerc5266962017-09-18 15:01:50 +01001491requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1492run_test "Max fragment length: disabled, larger message" \
1493 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001494 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001495 0 \
1496 -C "Maximum fragment length is 16384" \
1497 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001498 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1499 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001500 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001501
1502requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1503run_test "Max fragment length DTLS: disabled, larger message" \
1504 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001505 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001506 1 \
1507 -C "Maximum fragment length is 16384" \
1508 -S "Maximum fragment length is 16384" \
1509 -c "fragment larger than.*maximum "
1510
1511requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001512run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001513 "$P_SRV debug_level=3" \
1514 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001515 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001516 -c "Maximum fragment length is 4096" \
1517 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001518 -c "client hello, adding max_fragment_length extension" \
1519 -s "found max fragment length extension" \
1520 -s "server hello, max_fragment_length extension" \
1521 -c "found max_fragment_length extension"
1522
Hanno Becker4aed27e2017-09-18 15:00:34 +01001523requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001524run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_SRV debug_level=3 max_frag_len=4096" \
1526 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001527 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001528 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001529 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001530 -C "client hello, adding max_fragment_length extension" \
1531 -S "found max fragment length extension" \
1532 -S "server hello, max_fragment_length extension" \
1533 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001534
Hanno Becker4aed27e2017-09-18 15:00:34 +01001535requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001536requires_gnutls
1537run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001538 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001539 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001540 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001541 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001542 -c "client hello, adding max_fragment_length extension" \
1543 -c "found max_fragment_length extension"
1544
Hanno Becker4aed27e2017-09-18 15:00:34 +01001545requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001546run_test "Max fragment length: client, message just fits" \
1547 "$P_SRV debug_level=3" \
1548 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1549 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001550 -c "Maximum fragment length is 2048" \
1551 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001552 -c "client hello, adding max_fragment_length extension" \
1553 -s "found max fragment length extension" \
1554 -s "server hello, max_fragment_length extension" \
1555 -c "found max_fragment_length extension" \
1556 -c "2048 bytes written in 1 fragments" \
1557 -s "2048 bytes read"
1558
Hanno Becker4aed27e2017-09-18 15:00:34 +01001559requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001560run_test "Max fragment length: client, larger message" \
1561 "$P_SRV debug_level=3" \
1562 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1563 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001564 -c "Maximum fragment length is 2048" \
1565 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001566 -c "client hello, adding max_fragment_length extension" \
1567 -s "found max fragment length extension" \
1568 -s "server hello, max_fragment_length extension" \
1569 -c "found max_fragment_length extension" \
1570 -c "2345 bytes written in 2 fragments" \
1571 -s "2048 bytes read" \
1572 -s "297 bytes read"
1573
Hanno Becker4aed27e2017-09-18 15:00:34 +01001574requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001575run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001576 "$P_SRV debug_level=3 dtls=1" \
1577 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1578 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001579 -c "Maximum fragment length is 2048" \
1580 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001581 -c "client hello, adding max_fragment_length extension" \
1582 -s "found max fragment length extension" \
1583 -s "server hello, max_fragment_length extension" \
1584 -c "found max_fragment_length extension" \
1585 -c "fragment larger than.*maximum"
1586
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001587# Tests for renegotiation
1588
Hanno Becker6a243642017-10-12 15:18:45 +01001589# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001590run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001591 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001592 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001593 0 \
1594 -C "client hello, adding renegotiation extension" \
1595 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1596 -S "found renegotiation extension" \
1597 -s "server hello, secure renegotiation extension" \
1598 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001599 -C "=> renegotiate" \
1600 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001601 -S "write hello request"
1602
Hanno Becker6a243642017-10-12 15:18:45 +01001603requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001604run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001605 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001606 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001607 0 \
1608 -c "client hello, adding renegotiation extension" \
1609 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1610 -s "found renegotiation extension" \
1611 -s "server hello, secure renegotiation extension" \
1612 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001613 -c "=> renegotiate" \
1614 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001615 -S "write hello request"
1616
Hanno Becker6a243642017-10-12 15:18:45 +01001617requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001618run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001619 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001620 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001621 0 \
1622 -c "client hello, adding renegotiation extension" \
1623 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1624 -s "found renegotiation extension" \
1625 -s "server hello, secure renegotiation extension" \
1626 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001627 -c "=> renegotiate" \
1628 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001629 -s "write hello request"
1630
Janos Follathb0f148c2017-10-05 12:29:42 +01001631# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1632# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1633# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001634requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001635run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1636 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1637 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1638 0 \
1639 -c "client hello, adding renegotiation extension" \
1640 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1641 -s "found renegotiation extension" \
1642 -s "server hello, secure renegotiation extension" \
1643 -c "found renegotiation extension" \
1644 -c "=> renegotiate" \
1645 -s "=> renegotiate" \
1646 -S "write hello request" \
1647 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1648
1649# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1650# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1651# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001652requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001653run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1654 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1655 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1656 0 \
1657 -c "client hello, adding renegotiation extension" \
1658 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1659 -s "found renegotiation extension" \
1660 -s "server hello, secure renegotiation extension" \
1661 -c "found renegotiation extension" \
1662 -c "=> renegotiate" \
1663 -s "=> renegotiate" \
1664 -s "write hello request" \
1665 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1666
Hanno Becker6a243642017-10-12 15:18:45 +01001667requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001668run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001669 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001670 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001671 0 \
1672 -c "client hello, adding renegotiation extension" \
1673 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1674 -s "found renegotiation extension" \
1675 -s "server hello, secure renegotiation extension" \
1676 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001677 -c "=> renegotiate" \
1678 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001679 -s "write hello request"
1680
Hanno Becker6a243642017-10-12 15:18:45 +01001681requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001682run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001683 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001684 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001685 1 \
1686 -c "client hello, adding renegotiation extension" \
1687 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1688 -S "found renegotiation extension" \
1689 -s "server hello, secure renegotiation extension" \
1690 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001691 -c "=> renegotiate" \
1692 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001693 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001694 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001695 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001696
Hanno Becker6a243642017-10-12 15:18:45 +01001697requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001698run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001699 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001700 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001701 0 \
1702 -C "client hello, adding renegotiation extension" \
1703 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1704 -S "found renegotiation extension" \
1705 -s "server hello, secure renegotiation extension" \
1706 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001707 -C "=> renegotiate" \
1708 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001709 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001710 -S "SSL - An unexpected message was received from our peer" \
1711 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001712
Hanno Becker6a243642017-10-12 15:18:45 +01001713requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001714run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001715 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001716 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001717 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001718 0 \
1719 -C "client hello, adding renegotiation extension" \
1720 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1721 -S "found renegotiation extension" \
1722 -s "server hello, secure renegotiation extension" \
1723 -c "found renegotiation extension" \
1724 -C "=> renegotiate" \
1725 -S "=> renegotiate" \
1726 -s "write hello request" \
1727 -S "SSL - An unexpected message was received from our peer" \
1728 -S "failed"
1729
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001730# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001731requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001732run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001733 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001734 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001735 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001736 0 \
1737 -C "client hello, adding renegotiation extension" \
1738 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1739 -S "found renegotiation extension" \
1740 -s "server hello, secure renegotiation extension" \
1741 -c "found renegotiation extension" \
1742 -C "=> renegotiate" \
1743 -S "=> renegotiate" \
1744 -s "write hello request" \
1745 -S "SSL - An unexpected message was received from our peer" \
1746 -S "failed"
1747
Hanno Becker6a243642017-10-12 15:18:45 +01001748requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001749run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001750 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001751 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001752 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001753 0 \
1754 -C "client hello, adding renegotiation extension" \
1755 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1756 -S "found renegotiation extension" \
1757 -s "server hello, secure renegotiation extension" \
1758 -c "found renegotiation extension" \
1759 -C "=> renegotiate" \
1760 -S "=> renegotiate" \
1761 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001762 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001763
Hanno Becker6a243642017-10-12 15:18:45 +01001764requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001765run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001766 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001767 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001768 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001769 0 \
1770 -c "client hello, adding renegotiation extension" \
1771 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1772 -s "found renegotiation extension" \
1773 -s "server hello, secure renegotiation extension" \
1774 -c "found renegotiation extension" \
1775 -c "=> renegotiate" \
1776 -s "=> renegotiate" \
1777 -s "write hello request" \
1778 -S "SSL - An unexpected message was received from our peer" \
1779 -S "failed"
1780
Hanno Becker6a243642017-10-12 15:18:45 +01001781requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001782run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001783 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001784 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1785 0 \
1786 -C "client hello, adding renegotiation extension" \
1787 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1788 -S "found renegotiation extension" \
1789 -s "server hello, secure renegotiation extension" \
1790 -c "found renegotiation extension" \
1791 -S "record counter limit reached: renegotiate" \
1792 -C "=> renegotiate" \
1793 -S "=> renegotiate" \
1794 -S "write hello request" \
1795 -S "SSL - An unexpected message was received from our peer" \
1796 -S "failed"
1797
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001798# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001799requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001800run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001801 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001802 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001803 0 \
1804 -c "client hello, adding renegotiation extension" \
1805 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1806 -s "found renegotiation extension" \
1807 -s "server hello, secure renegotiation extension" \
1808 -c "found renegotiation extension" \
1809 -s "record counter limit reached: renegotiate" \
1810 -c "=> renegotiate" \
1811 -s "=> renegotiate" \
1812 -s "write hello request" \
1813 -S "SSL - An unexpected message was received from our peer" \
1814 -S "failed"
1815
Hanno Becker6a243642017-10-12 15:18:45 +01001816requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001817run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001818 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001819 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001820 0 \
1821 -c "client hello, adding renegotiation extension" \
1822 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1823 -s "found renegotiation extension" \
1824 -s "server hello, secure renegotiation extension" \
1825 -c "found renegotiation extension" \
1826 -s "record counter limit reached: renegotiate" \
1827 -c "=> renegotiate" \
1828 -s "=> renegotiate" \
1829 -s "write hello request" \
1830 -S "SSL - An unexpected message was received from our peer" \
1831 -S "failed"
1832
Hanno Becker6a243642017-10-12 15:18:45 +01001833requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001834run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001835 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001836 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1837 0 \
1838 -C "client hello, adding renegotiation extension" \
1839 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1840 -S "found renegotiation extension" \
1841 -s "server hello, secure renegotiation extension" \
1842 -c "found renegotiation extension" \
1843 -S "record counter limit reached: renegotiate" \
1844 -C "=> renegotiate" \
1845 -S "=> renegotiate" \
1846 -S "write hello request" \
1847 -S "SSL - An unexpected message was received from our peer" \
1848 -S "failed"
1849
Hanno Becker6a243642017-10-12 15:18:45 +01001850requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001851run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001852 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001853 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001854 0 \
1855 -c "client hello, adding renegotiation extension" \
1856 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1857 -s "found renegotiation extension" \
1858 -s "server hello, secure renegotiation extension" \
1859 -c "found renegotiation extension" \
1860 -c "=> renegotiate" \
1861 -s "=> renegotiate" \
1862 -S "write hello request"
1863
Hanno Becker6a243642017-10-12 15:18:45 +01001864requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001865run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001866 "$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 +02001867 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001868 0 \
1869 -c "client hello, adding renegotiation extension" \
1870 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1871 -s "found renegotiation extension" \
1872 -s "server hello, secure renegotiation extension" \
1873 -c "found renegotiation extension" \
1874 -c "=> renegotiate" \
1875 -s "=> renegotiate" \
1876 -s "write hello request"
1877
Hanno Becker6a243642017-10-12 15:18:45 +01001878requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001879run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001880 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001881 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001882 0 \
1883 -c "client hello, adding renegotiation extension" \
1884 -c "found renegotiation extension" \
1885 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001886 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001887 -C "error" \
1888 -c "HTTP/1.0 200 [Oo][Kk]"
1889
Paul Bakker539d9722015-02-08 16:18:35 +01001890requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001891requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001892run_test "Renegotiation: gnutls server strict, client-initiated" \
1893 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001894 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001895 0 \
1896 -c "client hello, adding renegotiation extension" \
1897 -c "found renegotiation extension" \
1898 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001899 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001900 -C "error" \
1901 -c "HTTP/1.0 200 [Oo][Kk]"
1902
Paul Bakker539d9722015-02-08 16:18:35 +01001903requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001904requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001905run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1906 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1907 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1908 1 \
1909 -c "client hello, adding renegotiation extension" \
1910 -C "found renegotiation extension" \
1911 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001912 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001913 -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 unsafe, client-inititated no legacy" \
1919 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1920 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1921 allow_legacy=0" \
1922 1 \
1923 -c "client hello, adding renegotiation extension" \
1924 -C "found renegotiation extension" \
1925 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001926 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001927 -c "error" \
1928 -C "HTTP/1.0 200 [Oo][Kk]"
1929
Paul Bakker539d9722015-02-08 16:18:35 +01001930requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001931requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001932run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1933 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1934 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1935 allow_legacy=1" \
1936 0 \
1937 -c "client hello, adding renegotiation extension" \
1938 -C "found renegotiation extension" \
1939 -c "=> renegotiate" \
1940 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001941 -C "error" \
1942 -c "HTTP/1.0 200 [Oo][Kk]"
1943
Hanno Becker6a243642017-10-12 15:18:45 +01001944requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001945run_test "Renegotiation: DTLS, client-initiated" \
1946 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1947 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1948 0 \
1949 -c "client hello, adding renegotiation extension" \
1950 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1951 -s "found renegotiation extension" \
1952 -s "server hello, secure renegotiation extension" \
1953 -c "found renegotiation extension" \
1954 -c "=> renegotiate" \
1955 -s "=> renegotiate" \
1956 -S "write hello request"
1957
Hanno Becker6a243642017-10-12 15:18:45 +01001958requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001959run_test "Renegotiation: DTLS, server-initiated" \
1960 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001961 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1962 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001963 0 \
1964 -c "client hello, adding renegotiation extension" \
1965 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1966 -s "found renegotiation extension" \
1967 -s "server hello, secure renegotiation extension" \
1968 -c "found renegotiation extension" \
1969 -c "=> renegotiate" \
1970 -s "=> renegotiate" \
1971 -s "write hello request"
1972
Hanno Becker6a243642017-10-12 15:18:45 +01001973requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00001974run_test "Renegotiation: DTLS, renego_period overflow" \
1975 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1976 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1977 0 \
1978 -c "client hello, adding renegotiation extension" \
1979 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1980 -s "found renegotiation extension" \
1981 -s "server hello, secure renegotiation extension" \
1982 -s "record counter limit reached: renegotiate" \
1983 -c "=> renegotiate" \
1984 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01001985 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00001986
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001987requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001988requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001989run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1990 "$G_SRV -u --mtu 4096" \
1991 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1992 0 \
1993 -c "client hello, adding renegotiation extension" \
1994 -c "found renegotiation extension" \
1995 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001996 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001997 -C "error" \
1998 -s "Extra-header:"
1999
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002000# Test for the "secure renegotation" extension only (no actual renegotiation)
2001
Paul Bakker539d9722015-02-08 16:18:35 +01002002requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002003run_test "Renego ext: gnutls server strict, client default" \
2004 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2005 "$P_CLI debug_level=3" \
2006 0 \
2007 -c "found renegotiation extension" \
2008 -C "error" \
2009 -c "HTTP/1.0 200 [Oo][Kk]"
2010
Paul Bakker539d9722015-02-08 16:18:35 +01002011requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002012run_test "Renego ext: gnutls server unsafe, client default" \
2013 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2014 "$P_CLI debug_level=3" \
2015 0 \
2016 -C "found renegotiation extension" \
2017 -C "error" \
2018 -c "HTTP/1.0 200 [Oo][Kk]"
2019
Paul Bakker539d9722015-02-08 16:18:35 +01002020requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002021run_test "Renego ext: gnutls server unsafe, client break legacy" \
2022 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2023 "$P_CLI debug_level=3 allow_legacy=-1" \
2024 1 \
2025 -C "found renegotiation extension" \
2026 -c "error" \
2027 -C "HTTP/1.0 200 [Oo][Kk]"
2028
Paul Bakker539d9722015-02-08 16:18:35 +01002029requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002030run_test "Renego ext: gnutls client strict, server default" \
2031 "$P_SRV debug_level=3" \
2032 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2033 0 \
2034 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2035 -s "server hello, secure renegotiation extension"
2036
Paul Bakker539d9722015-02-08 16:18:35 +01002037requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002038run_test "Renego ext: gnutls client unsafe, server default" \
2039 "$P_SRV debug_level=3" \
2040 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2041 0 \
2042 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2043 -S "server hello, secure renegotiation extension"
2044
Paul Bakker539d9722015-02-08 16:18:35 +01002045requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002046run_test "Renego ext: gnutls client unsafe, server break legacy" \
2047 "$P_SRV debug_level=3 allow_legacy=-1" \
2048 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2049 1 \
2050 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2051 -S "server hello, secure renegotiation extension"
2052
Janos Follath0b242342016-02-17 10:11:21 +00002053# Tests for silently dropping trailing extra bytes in .der certificates
2054
2055requires_gnutls
2056run_test "DER format: no trailing bytes" \
2057 "$P_SRV crt_file=data_files/server5-der0.crt \
2058 key_file=data_files/server5.key" \
2059 "$G_CLI " \
2060 0 \
2061 -c "Handshake was completed" \
2062
2063requires_gnutls
2064run_test "DER format: with a trailing zero byte" \
2065 "$P_SRV crt_file=data_files/server5-der1a.crt \
2066 key_file=data_files/server5.key" \
2067 "$G_CLI " \
2068 0 \
2069 -c "Handshake was completed" \
2070
2071requires_gnutls
2072run_test "DER format: with a trailing random byte" \
2073 "$P_SRV crt_file=data_files/server5-der1b.crt \
2074 key_file=data_files/server5.key" \
2075 "$G_CLI " \
2076 0 \
2077 -c "Handshake was completed" \
2078
2079requires_gnutls
2080run_test "DER format: with 2 trailing random bytes" \
2081 "$P_SRV crt_file=data_files/server5-der2.crt \
2082 key_file=data_files/server5.key" \
2083 "$G_CLI " \
2084 0 \
2085 -c "Handshake was completed" \
2086
2087requires_gnutls
2088run_test "DER format: with 4 trailing random bytes" \
2089 "$P_SRV crt_file=data_files/server5-der4.crt \
2090 key_file=data_files/server5.key" \
2091 "$G_CLI " \
2092 0 \
2093 -c "Handshake was completed" \
2094
2095requires_gnutls
2096run_test "DER format: with 8 trailing random bytes" \
2097 "$P_SRV crt_file=data_files/server5-der8.crt \
2098 key_file=data_files/server5.key" \
2099 "$G_CLI " \
2100 0 \
2101 -c "Handshake was completed" \
2102
2103requires_gnutls
2104run_test "DER format: with 9 trailing random bytes" \
2105 "$P_SRV crt_file=data_files/server5-der9.crt \
2106 key_file=data_files/server5.key" \
2107 "$G_CLI " \
2108 0 \
2109 -c "Handshake was completed" \
2110
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002111# Tests for auth_mode
2112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002113run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002114 "$P_SRV crt_file=data_files/server5-badsign.crt \
2115 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002116 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002117 1 \
2118 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002119 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002120 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002121 -c "X509 - Certificate verification failed"
2122
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002123run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002124 "$P_SRV crt_file=data_files/server5-badsign.crt \
2125 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002126 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002127 0 \
2128 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002129 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002130 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002131 -C "X509 - Certificate verification failed"
2132
Hanno Beckere6706e62017-05-15 16:05:15 +01002133run_test "Authentication: server goodcert, client optional, no trusted CA" \
2134 "$P_SRV" \
2135 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2136 0 \
2137 -c "x509_verify_cert() returned" \
2138 -c "! The certificate is not correctly signed by the trusted CA" \
2139 -c "! Certificate verification flags"\
2140 -C "! mbedtls_ssl_handshake returned" \
2141 -C "X509 - Certificate verification failed" \
2142 -C "SSL - No CA Chain is set, but required to operate"
2143
2144run_test "Authentication: server goodcert, client required, no trusted CA" \
2145 "$P_SRV" \
2146 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2147 1 \
2148 -c "x509_verify_cert() returned" \
2149 -c "! The certificate is not correctly signed by the trusted CA" \
2150 -c "! Certificate verification flags"\
2151 -c "! mbedtls_ssl_handshake returned" \
2152 -c "SSL - No CA Chain is set, but required to operate"
2153
2154# The purpose of the next two tests is to test the client's behaviour when receiving a server
2155# certificate with an unsupported elliptic curve. This should usually not happen because
2156# the client informs the server about the supported curves - it does, though, in the
2157# corner case of a static ECDH suite, because the server doesn't check the curve on that
2158# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2159# different means to have the server ignoring the client's supported curve list.
2160
2161requires_config_enabled MBEDTLS_ECP_C
2162run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2163 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2164 crt_file=data_files/server5.ku-ka.crt" \
2165 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2166 1 \
2167 -c "bad certificate (EC key curve)"\
2168 -c "! Certificate verification flags"\
2169 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2170
2171requires_config_enabled MBEDTLS_ECP_C
2172run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2173 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2174 crt_file=data_files/server5.ku-ka.crt" \
2175 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2176 1 \
2177 -c "bad certificate (EC key curve)"\
2178 -c "! Certificate verification flags"\
2179 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002181run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002182 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002183 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002184 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002185 0 \
2186 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002187 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002188 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002189 -C "X509 - Certificate verification failed"
2190
Simon Butcher99000142016-10-13 17:21:01 +01002191run_test "Authentication: client SHA256, server required" \
2192 "$P_SRV auth_mode=required" \
2193 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2194 key_file=data_files/server6.key \
2195 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2196 0 \
2197 -c "Supported Signature Algorithm found: 4," \
2198 -c "Supported Signature Algorithm found: 5,"
2199
2200run_test "Authentication: client SHA384, server required" \
2201 "$P_SRV auth_mode=required" \
2202 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2203 key_file=data_files/server6.key \
2204 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2205 0 \
2206 -c "Supported Signature Algorithm found: 4," \
2207 -c "Supported Signature Algorithm found: 5,"
2208
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002209requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2210run_test "Authentication: client has no cert, server required (SSLv3)" \
2211 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2212 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2213 key_file=data_files/server5.key" \
2214 1 \
2215 -S "skip write certificate request" \
2216 -C "skip parse certificate request" \
2217 -c "got a certificate request" \
2218 -c "got no certificate to send" \
2219 -S "x509_verify_cert() returned" \
2220 -s "client has no certificate" \
2221 -s "! mbedtls_ssl_handshake returned" \
2222 -c "! mbedtls_ssl_handshake returned" \
2223 -s "No client certification received from the client, but required by the authentication mode"
2224
2225run_test "Authentication: client has no cert, server required (TLS)" \
2226 "$P_SRV debug_level=3 auth_mode=required" \
2227 "$P_CLI debug_level=3 crt_file=none \
2228 key_file=data_files/server5.key" \
2229 1 \
2230 -S "skip write certificate request" \
2231 -C "skip parse certificate request" \
2232 -c "got a certificate request" \
2233 -c "= write certificate$" \
2234 -C "skip write certificate$" \
2235 -S "x509_verify_cert() returned" \
2236 -s "client has no certificate" \
2237 -s "! mbedtls_ssl_handshake returned" \
2238 -c "! mbedtls_ssl_handshake returned" \
2239 -s "No client certification received from the client, but required by the authentication mode"
2240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002241run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002242 "$P_SRV debug_level=3 auth_mode=required" \
2243 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002244 key_file=data_files/server5.key" \
2245 1 \
2246 -S "skip write certificate request" \
2247 -C "skip parse certificate request" \
2248 -c "got a certificate request" \
2249 -C "skip write certificate" \
2250 -C "skip write certificate verify" \
2251 -S "skip parse certificate verify" \
2252 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002253 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002254 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002255 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002256 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002257 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002258# We don't check that the client receives the alert because it might
2259# detect that its write end of the connection is closed and abort
2260# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002261
Janos Follath89baba22017-04-10 14:34:35 +01002262run_test "Authentication: client cert not trusted, server required" \
2263 "$P_SRV debug_level=3 auth_mode=required" \
2264 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2265 key_file=data_files/server5.key" \
2266 1 \
2267 -S "skip write certificate request" \
2268 -C "skip parse certificate request" \
2269 -c "got a certificate request" \
2270 -C "skip write certificate" \
2271 -C "skip write certificate verify" \
2272 -S "skip parse certificate verify" \
2273 -s "x509_verify_cert() returned" \
2274 -s "! The certificate is not correctly signed by the trusted CA" \
2275 -s "! mbedtls_ssl_handshake returned" \
2276 -c "! mbedtls_ssl_handshake returned" \
2277 -s "X509 - Certificate verification failed"
2278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002279run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002280 "$P_SRV debug_level=3 auth_mode=optional" \
2281 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002282 key_file=data_files/server5.key" \
2283 0 \
2284 -S "skip write certificate request" \
2285 -C "skip parse certificate request" \
2286 -c "got a certificate request" \
2287 -C "skip write certificate" \
2288 -C "skip write certificate verify" \
2289 -S "skip parse certificate verify" \
2290 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002291 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002292 -S "! mbedtls_ssl_handshake returned" \
2293 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002294 -S "X509 - Certificate verification failed"
2295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002296run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002297 "$P_SRV debug_level=3 auth_mode=none" \
2298 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002299 key_file=data_files/server5.key" \
2300 0 \
2301 -s "skip write certificate request" \
2302 -C "skip parse certificate request" \
2303 -c "got no certificate request" \
2304 -c "skip write certificate" \
2305 -c "skip write certificate verify" \
2306 -s "skip parse certificate verify" \
2307 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002308 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002309 -S "! mbedtls_ssl_handshake returned" \
2310 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002311 -S "X509 - Certificate verification failed"
2312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002313run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002314 "$P_SRV debug_level=3 auth_mode=optional" \
2315 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002316 0 \
2317 -S "skip write certificate request" \
2318 -C "skip parse certificate request" \
2319 -c "got a certificate request" \
2320 -C "skip write certificate$" \
2321 -C "got no certificate to send" \
2322 -S "SSLv3 client has no certificate" \
2323 -c "skip write certificate verify" \
2324 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002325 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002326 -S "! mbedtls_ssl_handshake returned" \
2327 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002328 -S "X509 - Certificate verification failed"
2329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002330run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002331 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002332 "$O_CLI" \
2333 0 \
2334 -S "skip write certificate request" \
2335 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002336 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002337 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002338 -S "X509 - Certificate verification failed"
2339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002340run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002341 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002342 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002343 0 \
2344 -C "skip parse certificate request" \
2345 -c "got a certificate request" \
2346 -C "skip write certificate$" \
2347 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002348 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002349
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002350run_test "Authentication: client no cert, openssl server required" \
2351 "$O_SRV -Verify 10" \
2352 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2353 1 \
2354 -C "skip parse certificate request" \
2355 -c "got a certificate request" \
2356 -C "skip write certificate$" \
2357 -c "skip write certificate verify" \
2358 -c "! mbedtls_ssl_handshake returned"
2359
Janos Follathe2681a42016-03-07 15:57:05 +00002360requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002361run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002362 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002363 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002364 0 \
2365 -S "skip write certificate request" \
2366 -C "skip parse certificate request" \
2367 -c "got a certificate request" \
2368 -C "skip write certificate$" \
2369 -c "skip write certificate verify" \
2370 -c "got no certificate to send" \
2371 -s "SSLv3 client has no certificate" \
2372 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002373 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002374 -S "! mbedtls_ssl_handshake returned" \
2375 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002376 -S "X509 - Certificate verification failed"
2377
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002378# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2379# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002380
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002381MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002382MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002383
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002384if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002385 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002386 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002387 printf "test value of ${MAX_IM_CA}. \n"
2388 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002389 printf "The tests assume this value and if it changes, the tests in this\n"
2390 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002391 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002392
2393 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002394fi
2395
Angus Grattonc4dd0732018-04-11 16:28:39 +10002396requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002397run_test "Authentication: server max_int chain, client default" \
2398 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2399 key_file=data_files/dir-maxpath/09.key" \
2400 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2401 0 \
2402 -C "X509 - A fatal error occured"
2403
Angus Grattonc4dd0732018-04-11 16:28:39 +10002404requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002405run_test "Authentication: server max_int+1 chain, client default" \
2406 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2407 key_file=data_files/dir-maxpath/10.key" \
2408 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2409 1 \
2410 -c "X509 - A fatal error occured"
2411
Angus Grattonc4dd0732018-04-11 16:28:39 +10002412requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002413run_test "Authentication: server max_int+1 chain, client optional" \
2414 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2415 key_file=data_files/dir-maxpath/10.key" \
2416 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2417 auth_mode=optional" \
2418 1 \
2419 -c "X509 - A fatal error occured"
2420
Angus Grattonc4dd0732018-04-11 16:28:39 +10002421requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002422run_test "Authentication: server max_int+1 chain, client none" \
2423 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2424 key_file=data_files/dir-maxpath/10.key" \
2425 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2426 auth_mode=none" \
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: client max_int+1 chain, server default" \
2432 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2433 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2434 key_file=data_files/dir-maxpath/10.key" \
2435 0 \
2436 -S "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: client max_int+1 chain, server optional" \
2440 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2441 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2442 key_file=data_files/dir-maxpath/10.key" \
2443 1 \
2444 -s "X509 - A fatal error occured"
2445
Angus Grattonc4dd0732018-04-11 16:28:39 +10002446requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002447run_test "Authentication: client max_int+1 chain, server required" \
2448 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2449 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2450 key_file=data_files/dir-maxpath/10.key" \
2451 1 \
2452 -s "X509 - A fatal error occured"
2453
Angus Grattonc4dd0732018-04-11 16:28:39 +10002454requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002455run_test "Authentication: client max_int chain, server required" \
2456 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2457 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2458 key_file=data_files/dir-maxpath/09.key" \
2459 0 \
2460 -S "X509 - A fatal error occured"
2461
Janos Follath89baba22017-04-10 14:34:35 +01002462# Tests for CA list in CertificateRequest messages
2463
2464run_test "Authentication: send CA list in CertificateRequest (default)" \
2465 "$P_SRV debug_level=3 auth_mode=required" \
2466 "$P_CLI crt_file=data_files/server6.crt \
2467 key_file=data_files/server6.key" \
2468 0 \
2469 -s "requested DN"
2470
2471run_test "Authentication: do not send CA list in CertificateRequest" \
2472 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2473 "$P_CLI crt_file=data_files/server6.crt \
2474 key_file=data_files/server6.key" \
2475 0 \
2476 -S "requested DN"
2477
2478run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2479 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2480 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2481 key_file=data_files/server5.key" \
2482 1 \
2483 -S "requested DN" \
2484 -s "x509_verify_cert() returned" \
2485 -s "! The certificate is not correctly signed by the trusted CA" \
2486 -s "! mbedtls_ssl_handshake returned" \
2487 -c "! mbedtls_ssl_handshake returned" \
2488 -s "X509 - Certificate verification failed"
2489
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002490# Tests for certificate selection based on SHA verson
2491
2492run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2493 "$P_SRV crt_file=data_files/server5.crt \
2494 key_file=data_files/server5.key \
2495 crt_file2=data_files/server5-sha1.crt \
2496 key_file2=data_files/server5.key" \
2497 "$P_CLI force_version=tls1_2" \
2498 0 \
2499 -c "signed using.*ECDSA with SHA256" \
2500 -C "signed using.*ECDSA with SHA1"
2501
2502run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2503 "$P_SRV crt_file=data_files/server5.crt \
2504 key_file=data_files/server5.key \
2505 crt_file2=data_files/server5-sha1.crt \
2506 key_file2=data_files/server5.key" \
2507 "$P_CLI force_version=tls1_1" \
2508 0 \
2509 -C "signed using.*ECDSA with SHA256" \
2510 -c "signed using.*ECDSA with SHA1"
2511
2512run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2513 "$P_SRV crt_file=data_files/server5.crt \
2514 key_file=data_files/server5.key \
2515 crt_file2=data_files/server5-sha1.crt \
2516 key_file2=data_files/server5.key" \
2517 "$P_CLI force_version=tls1" \
2518 0 \
2519 -C "signed using.*ECDSA with SHA256" \
2520 -c "signed using.*ECDSA with SHA1"
2521
2522run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2523 "$P_SRV crt_file=data_files/server5.crt \
2524 key_file=data_files/server5.key \
2525 crt_file2=data_files/server6.crt \
2526 key_file2=data_files/server6.key" \
2527 "$P_CLI force_version=tls1_1" \
2528 0 \
2529 -c "serial number.*09" \
2530 -c "signed using.*ECDSA with SHA256" \
2531 -C "signed using.*ECDSA with SHA1"
2532
2533run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2534 "$P_SRV crt_file=data_files/server6.crt \
2535 key_file=data_files/server6.key \
2536 crt_file2=data_files/server5.crt \
2537 key_file2=data_files/server5.key" \
2538 "$P_CLI force_version=tls1_1" \
2539 0 \
2540 -c "serial number.*0A" \
2541 -c "signed using.*ECDSA with SHA256" \
2542 -C "signed using.*ECDSA with SHA1"
2543
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002544# tests for SNI
2545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002546run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002547 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002548 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002549 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002550 0 \
2551 -S "parse ServerName extension" \
2552 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2553 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002554
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002555run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002556 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002557 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002558 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 +02002559 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002560 0 \
2561 -s "parse ServerName extension" \
2562 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2563 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002565run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002566 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002567 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002568 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 +02002569 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002570 0 \
2571 -s "parse ServerName extension" \
2572 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2573 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002576 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002577 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002578 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 +02002579 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002580 1 \
2581 -s "parse ServerName extension" \
2582 -s "ssl_sni_wrapper() returned" \
2583 -s "mbedtls_ssl_handshake returned" \
2584 -c "mbedtls_ssl_handshake returned" \
2585 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002586
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002587run_test "SNI: client auth no override: optional" \
2588 "$P_SRV debug_level=3 auth_mode=optional \
2589 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2590 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2591 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002592 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002593 -S "skip write certificate request" \
2594 -C "skip parse certificate request" \
2595 -c "got a certificate request" \
2596 -C "skip write certificate" \
2597 -C "skip write certificate verify" \
2598 -S "skip parse certificate verify"
2599
2600run_test "SNI: client auth override: none -> optional" \
2601 "$P_SRV debug_level=3 auth_mode=none \
2602 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2603 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2604 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002605 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002606 -S "skip write certificate request" \
2607 -C "skip parse certificate request" \
2608 -c "got a certificate request" \
2609 -C "skip write certificate" \
2610 -C "skip write certificate verify" \
2611 -S "skip parse certificate verify"
2612
2613run_test "SNI: client auth override: optional -> none" \
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,-,-,none" \
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 no certificate request" \
2622 -c "skip write certificate" \
2623 -c "skip write certificate verify" \
2624 -s "skip parse certificate verify"
2625
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002626run_test "SNI: CA no override" \
2627 "$P_SRV debug_level=3 auth_mode=optional \
2628 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2629 ca_file=data_files/test-ca.crt \
2630 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2631 "$P_CLI debug_level=3 server_name=localhost \
2632 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2633 1 \
2634 -S "skip write certificate request" \
2635 -C "skip parse certificate request" \
2636 -c "got a certificate request" \
2637 -C "skip write certificate" \
2638 -C "skip write certificate verify" \
2639 -S "skip parse certificate verify" \
2640 -s "x509_verify_cert() returned" \
2641 -s "! The certificate is not correctly signed by the trusted CA" \
2642 -S "The certificate has been revoked (is on a CRL)"
2643
2644run_test "SNI: CA override" \
2645 "$P_SRV debug_level=3 auth_mode=optional \
2646 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2647 ca_file=data_files/test-ca.crt \
2648 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2649 "$P_CLI debug_level=3 server_name=localhost \
2650 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2651 0 \
2652 -S "skip write certificate request" \
2653 -C "skip parse certificate request" \
2654 -c "got a certificate request" \
2655 -C "skip write certificate" \
2656 -C "skip write certificate verify" \
2657 -S "skip parse certificate verify" \
2658 -S "x509_verify_cert() returned" \
2659 -S "! The certificate is not correctly signed by the trusted CA" \
2660 -S "The certificate has been revoked (is on a CRL)"
2661
2662run_test "SNI: CA override with CRL" \
2663 "$P_SRV debug_level=3 auth_mode=optional \
2664 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2665 ca_file=data_files/test-ca.crt \
2666 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2667 "$P_CLI debug_level=3 server_name=localhost \
2668 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2669 1 \
2670 -S "skip write certificate request" \
2671 -C "skip parse certificate request" \
2672 -c "got a certificate request" \
2673 -C "skip write certificate" \
2674 -C "skip write certificate verify" \
2675 -S "skip parse certificate verify" \
2676 -s "x509_verify_cert() returned" \
2677 -S "! The certificate is not correctly signed by the trusted CA" \
2678 -s "The certificate has been revoked (is on a CRL)"
2679
Andres AG1a834452016-12-07 10:01:30 +00002680# Tests for SNI and DTLS
2681
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002682run_test "SNI: DTLS, no SNI callback" \
2683 "$P_SRV debug_level=3 dtls=1 \
2684 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2685 "$P_CLI server_name=localhost dtls=1" \
2686 0 \
2687 -S "parse ServerName extension" \
2688 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2689 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2690
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002691run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00002692 "$P_SRV debug_level=3 dtls=1 \
2693 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2694 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2695 "$P_CLI server_name=localhost dtls=1" \
2696 0 \
2697 -s "parse ServerName extension" \
2698 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2699 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2700
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002701run_test "SNI: DTLS, matching cert 2" \
2702 "$P_SRV debug_level=3 dtls=1 \
2703 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2704 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2705 "$P_CLI server_name=polarssl.example dtls=1" \
2706 0 \
2707 -s "parse ServerName extension" \
2708 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2709 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2710
2711run_test "SNI: DTLS, no matching cert" \
2712 "$P_SRV debug_level=3 dtls=1 \
2713 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2714 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2715 "$P_CLI server_name=nonesuch.example dtls=1" \
2716 1 \
2717 -s "parse ServerName extension" \
2718 -s "ssl_sni_wrapper() returned" \
2719 -s "mbedtls_ssl_handshake returned" \
2720 -c "mbedtls_ssl_handshake returned" \
2721 -c "SSL - A fatal alert message was received from our peer"
2722
2723run_test "SNI: DTLS, client auth no override: optional" \
2724 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2725 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2726 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2727 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2728 0 \
2729 -S "skip write certificate request" \
2730 -C "skip parse certificate request" \
2731 -c "got a certificate request" \
2732 -C "skip write certificate" \
2733 -C "skip write certificate verify" \
2734 -S "skip parse certificate verify"
2735
2736run_test "SNI: DTLS, client auth override: none -> optional" \
2737 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2738 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2739 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2740 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2741 0 \
2742 -S "skip write certificate request" \
2743 -C "skip parse certificate request" \
2744 -c "got a certificate request" \
2745 -C "skip write certificate" \
2746 -C "skip write certificate verify" \
2747 -S "skip parse certificate verify"
2748
2749run_test "SNI: DTLS, client auth override: optional -> none" \
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,-,-,none" \
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 no certificate request" \
2758 -c "skip write certificate" \
2759 -c "skip write certificate verify" \
2760 -s "skip parse certificate verify"
2761
2762run_test "SNI: DTLS, CA no override" \
2763 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2764 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2765 ca_file=data_files/test-ca.crt \
2766 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2767 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2768 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2769 1 \
2770 -S "skip write certificate request" \
2771 -C "skip parse certificate request" \
2772 -c "got a certificate request" \
2773 -C "skip write certificate" \
2774 -C "skip write certificate verify" \
2775 -S "skip parse certificate verify" \
2776 -s "x509_verify_cert() returned" \
2777 -s "! The certificate is not correctly signed by the trusted CA" \
2778 -S "The certificate has been revoked (is on a CRL)"
2779
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002780run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00002781 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2782 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2783 ca_file=data_files/test-ca.crt \
2784 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2785 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2786 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2787 0 \
2788 -S "skip write certificate request" \
2789 -C "skip parse certificate request" \
2790 -c "got a certificate request" \
2791 -C "skip write certificate" \
2792 -C "skip write certificate verify" \
2793 -S "skip parse certificate verify" \
2794 -S "x509_verify_cert() returned" \
2795 -S "! The certificate is not correctly signed by the trusted CA" \
2796 -S "The certificate has been revoked (is on a CRL)"
2797
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002798run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00002799 "$P_SRV debug_level=3 auth_mode=optional \
2800 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2801 ca_file=data_files/test-ca.crt \
2802 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2803 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2804 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2805 1 \
2806 -S "skip write certificate request" \
2807 -C "skip parse certificate request" \
2808 -c "got a certificate request" \
2809 -C "skip write certificate" \
2810 -C "skip write certificate verify" \
2811 -S "skip parse certificate verify" \
2812 -s "x509_verify_cert() returned" \
2813 -S "! The certificate is not correctly signed by the trusted CA" \
2814 -s "The certificate has been revoked (is on a CRL)"
2815
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002816# Tests for non-blocking I/O: exercise a variety of handshake flows
2817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002818run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002819 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2820 "$P_CLI nbio=2 tickets=0" \
2821 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002822 -S "mbedtls_ssl_handshake returned" \
2823 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002824 -c "Read from server: .* bytes read"
2825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002826run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002827 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2828 "$P_CLI nbio=2 tickets=0" \
2829 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002830 -S "mbedtls_ssl_handshake returned" \
2831 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002832 -c "Read from server: .* bytes read"
2833
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002834run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002835 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2836 "$P_CLI nbio=2 tickets=1" \
2837 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002838 -S "mbedtls_ssl_handshake returned" \
2839 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002840 -c "Read from server: .* bytes read"
2841
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002842run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002843 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2844 "$P_CLI nbio=2 tickets=1" \
2845 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002846 -S "mbedtls_ssl_handshake returned" \
2847 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002848 -c "Read from server: .* bytes read"
2849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002850run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002851 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2852 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2853 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002854 -S "mbedtls_ssl_handshake returned" \
2855 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002856 -c "Read from server: .* bytes read"
2857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002858run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002859 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2860 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2861 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002862 -S "mbedtls_ssl_handshake returned" \
2863 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002864 -c "Read from server: .* bytes read"
2865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002866run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002867 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2868 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2869 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002870 -S "mbedtls_ssl_handshake returned" \
2871 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002872 -c "Read from server: .* bytes read"
2873
Hanno Becker00076712017-11-15 16:39:08 +00002874# Tests for event-driven I/O: exercise a variety of handshake flows
2875
2876run_test "Event-driven I/O: basic handshake" \
2877 "$P_SRV event=1 tickets=0 auth_mode=none" \
2878 "$P_CLI event=1 tickets=0" \
2879 0 \
2880 -S "mbedtls_ssl_handshake returned" \
2881 -C "mbedtls_ssl_handshake returned" \
2882 -c "Read from server: .* bytes read"
2883
2884run_test "Event-driven I/O: client auth" \
2885 "$P_SRV event=1 tickets=0 auth_mode=required" \
2886 "$P_CLI event=1 tickets=0" \
2887 0 \
2888 -S "mbedtls_ssl_handshake returned" \
2889 -C "mbedtls_ssl_handshake returned" \
2890 -c "Read from server: .* bytes read"
2891
2892run_test "Event-driven I/O: ticket" \
2893 "$P_SRV event=1 tickets=1 auth_mode=none" \
2894 "$P_CLI event=1 tickets=1" \
2895 0 \
2896 -S "mbedtls_ssl_handshake returned" \
2897 -C "mbedtls_ssl_handshake returned" \
2898 -c "Read from server: .* bytes read"
2899
2900run_test "Event-driven I/O: ticket + client auth" \
2901 "$P_SRV event=1 tickets=1 auth_mode=required" \
2902 "$P_CLI event=1 tickets=1" \
2903 0 \
2904 -S "mbedtls_ssl_handshake returned" \
2905 -C "mbedtls_ssl_handshake returned" \
2906 -c "Read from server: .* bytes read"
2907
2908run_test "Event-driven I/O: ticket + client auth + resume" \
2909 "$P_SRV event=1 tickets=1 auth_mode=required" \
2910 "$P_CLI event=1 tickets=1 reconnect=1" \
2911 0 \
2912 -S "mbedtls_ssl_handshake returned" \
2913 -C "mbedtls_ssl_handshake returned" \
2914 -c "Read from server: .* bytes read"
2915
2916run_test "Event-driven I/O: ticket + resume" \
2917 "$P_SRV event=1 tickets=1 auth_mode=none" \
2918 "$P_CLI event=1 tickets=1 reconnect=1" \
2919 0 \
2920 -S "mbedtls_ssl_handshake returned" \
2921 -C "mbedtls_ssl_handshake returned" \
2922 -c "Read from server: .* bytes read"
2923
2924run_test "Event-driven I/O: session-id resume" \
2925 "$P_SRV event=1 tickets=0 auth_mode=none" \
2926 "$P_CLI event=1 tickets=0 reconnect=1" \
2927 0 \
2928 -S "mbedtls_ssl_handshake returned" \
2929 -C "mbedtls_ssl_handshake returned" \
2930 -c "Read from server: .* bytes read"
2931
Hanno Becker6a33f592018-03-13 11:38:46 +00002932run_test "Event-driven I/O, DTLS: basic handshake" \
2933 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2934 "$P_CLI dtls=1 event=1 tickets=0" \
2935 0 \
2936 -c "Read from server: .* bytes read"
2937
2938run_test "Event-driven I/O, DTLS: client auth" \
2939 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
2940 "$P_CLI dtls=1 event=1 tickets=0" \
2941 0 \
2942 -c "Read from server: .* bytes read"
2943
2944run_test "Event-driven I/O, DTLS: ticket" \
2945 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2946 "$P_CLI dtls=1 event=1 tickets=1" \
2947 0 \
2948 -c "Read from server: .* bytes read"
2949
2950run_test "Event-driven I/O, DTLS: ticket + client auth" \
2951 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2952 "$P_CLI dtls=1 event=1 tickets=1" \
2953 0 \
2954 -c "Read from server: .* bytes read"
2955
2956run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
2957 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2958 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2959 0 \
2960 -c "Read from server: .* bytes read"
2961
2962run_test "Event-driven I/O, DTLS: ticket + resume" \
2963 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2964 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2965 0 \
2966 -c "Read from server: .* bytes read"
2967
2968run_test "Event-driven I/O, DTLS: session-id resume" \
2969 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2970 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
2971 0 \
2972 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00002973
2974# This test demonstrates the need for the mbedtls_ssl_check_pending function.
2975# During session resumption, the client will send its ApplicationData record
2976# within the same datagram as the Finished messages. In this situation, the
2977# server MUST NOT idle on the underlying transport after handshake completion,
2978# because the ApplicationData request has already been queued internally.
2979run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00002980 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00002981 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
2982 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
2983 0 \
2984 -c "Read from server: .* bytes read"
2985
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002986# Tests for version negotiation
2987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002988run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002989 "$P_SRV" \
2990 "$P_CLI" \
2991 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002992 -S "mbedtls_ssl_handshake returned" \
2993 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002994 -s "Protocol is TLSv1.2" \
2995 -c "Protocol is TLSv1.2"
2996
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002997run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002998 "$P_SRV" \
2999 "$P_CLI max_version=tls1_1" \
3000 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003001 -S "mbedtls_ssl_handshake returned" \
3002 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003003 -s "Protocol is TLSv1.1" \
3004 -c "Protocol is TLSv1.1"
3005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003006run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003007 "$P_SRV max_version=tls1_1" \
3008 "$P_CLI" \
3009 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003010 -S "mbedtls_ssl_handshake returned" \
3011 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003012 -s "Protocol is TLSv1.1" \
3013 -c "Protocol is TLSv1.1"
3014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003015run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003016 "$P_SRV max_version=tls1_1" \
3017 "$P_CLI max_version=tls1_1" \
3018 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003019 -S "mbedtls_ssl_handshake returned" \
3020 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003021 -s "Protocol is TLSv1.1" \
3022 -c "Protocol is TLSv1.1"
3023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003024run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003025 "$P_SRV min_version=tls1_1" \
3026 "$P_CLI max_version=tls1_1" \
3027 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003028 -S "mbedtls_ssl_handshake returned" \
3029 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003030 -s "Protocol is TLSv1.1" \
3031 -c "Protocol is TLSv1.1"
3032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003033run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003034 "$P_SRV max_version=tls1_1" \
3035 "$P_CLI min_version=tls1_1" \
3036 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003037 -S "mbedtls_ssl_handshake returned" \
3038 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003039 -s "Protocol is TLSv1.1" \
3040 -c "Protocol is TLSv1.1"
3041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003042run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003043 "$P_SRV max_version=tls1_1" \
3044 "$P_CLI min_version=tls1_2" \
3045 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003046 -s "mbedtls_ssl_handshake returned" \
3047 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003048 -c "SSL - Handshake protocol not within min/max boundaries"
3049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003050run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003051 "$P_SRV min_version=tls1_2" \
3052 "$P_CLI max_version=tls1_1" \
3053 1 \
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 "SSL - Handshake protocol not within min/max boundaries"
3057
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003058# Tests for ALPN extension
3059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003060run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003061 "$P_SRV debug_level=3" \
3062 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003063 0 \
3064 -C "client hello, adding alpn extension" \
3065 -S "found alpn extension" \
3066 -C "got an alert message, type: \\[2:120]" \
3067 -S "server hello, adding alpn extension" \
3068 -C "found alpn extension " \
3069 -C "Application Layer Protocol is" \
3070 -S "Application Layer Protocol is"
3071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003072run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003073 "$P_SRV debug_level=3" \
3074 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003075 0 \
3076 -c "client hello, adding alpn extension" \
3077 -s "found alpn extension" \
3078 -C "got an alert message, type: \\[2:120]" \
3079 -S "server hello, adding alpn extension" \
3080 -C "found alpn extension " \
3081 -c "Application Layer Protocol is (none)" \
3082 -S "Application Layer Protocol is"
3083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003084run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003085 "$P_SRV debug_level=3 alpn=abc,1234" \
3086 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003087 0 \
3088 -C "client hello, adding alpn extension" \
3089 -S "found alpn extension" \
3090 -C "got an alert message, type: \\[2:120]" \
3091 -S "server hello, adding alpn extension" \
3092 -C "found alpn extension " \
3093 -C "Application Layer Protocol is" \
3094 -s "Application Layer Protocol is (none)"
3095
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003096run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003097 "$P_SRV debug_level=3 alpn=abc,1234" \
3098 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003099 0 \
3100 -c "client hello, adding alpn extension" \
3101 -s "found alpn extension" \
3102 -C "got an alert message, type: \\[2:120]" \
3103 -s "server hello, adding alpn extension" \
3104 -c "found alpn extension" \
3105 -c "Application Layer Protocol is abc" \
3106 -s "Application Layer Protocol is abc"
3107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003108run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003109 "$P_SRV debug_level=3 alpn=abc,1234" \
3110 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003111 0 \
3112 -c "client hello, adding alpn extension" \
3113 -s "found alpn extension" \
3114 -C "got an alert message, type: \\[2:120]" \
3115 -s "server hello, adding alpn extension" \
3116 -c "found alpn extension" \
3117 -c "Application Layer Protocol is abc" \
3118 -s "Application Layer Protocol is abc"
3119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003120run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003121 "$P_SRV debug_level=3 alpn=abc,1234" \
3122 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003123 0 \
3124 -c "client hello, adding alpn extension" \
3125 -s "found alpn extension" \
3126 -C "got an alert message, type: \\[2:120]" \
3127 -s "server hello, adding alpn extension" \
3128 -c "found alpn extension" \
3129 -c "Application Layer Protocol is 1234" \
3130 -s "Application Layer Protocol is 1234"
3131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003132run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003133 "$P_SRV debug_level=3 alpn=abc,123" \
3134 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003135 1 \
3136 -c "client hello, adding alpn extension" \
3137 -s "found alpn extension" \
3138 -c "got an alert message, type: \\[2:120]" \
3139 -S "server hello, adding alpn extension" \
3140 -C "found alpn extension" \
3141 -C "Application Layer Protocol is 1234" \
3142 -S "Application Layer Protocol is 1234"
3143
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003144
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003145# Tests for keyUsage in leaf certificates, part 1:
3146# server-side certificate/suite selection
3147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003148run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003149 "$P_SRV key_file=data_files/server2.key \
3150 crt_file=data_files/server2.ku-ds.crt" \
3151 "$P_CLI" \
3152 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003153 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003154
3155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003156run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003157 "$P_SRV key_file=data_files/server2.key \
3158 crt_file=data_files/server2.ku-ke.crt" \
3159 "$P_CLI" \
3160 0 \
3161 -c "Ciphersuite is TLS-RSA-WITH-"
3162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003163run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003164 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003165 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003166 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003167 1 \
3168 -C "Ciphersuite is "
3169
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003170run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003171 "$P_SRV key_file=data_files/server5.key \
3172 crt_file=data_files/server5.ku-ds.crt" \
3173 "$P_CLI" \
3174 0 \
3175 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3176
3177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003178run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003179 "$P_SRV key_file=data_files/server5.key \
3180 crt_file=data_files/server5.ku-ka.crt" \
3181 "$P_CLI" \
3182 0 \
3183 -c "Ciphersuite is TLS-ECDH-"
3184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003185run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003186 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003187 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003188 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003189 1 \
3190 -C "Ciphersuite is "
3191
3192# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003193# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003194
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003195run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003196 "$O_SRV -key data_files/server2.key \
3197 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003198 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003199 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3200 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003201 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003202 -C "Processing of the Certificate handshake message failed" \
3203 -c "Ciphersuite is TLS-"
3204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003205run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003206 "$O_SRV -key data_files/server2.key \
3207 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003208 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003209 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3210 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003211 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003212 -C "Processing of the Certificate handshake message failed" \
3213 -c "Ciphersuite is TLS-"
3214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003215run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003216 "$O_SRV -key data_files/server2.key \
3217 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003218 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003219 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3220 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003221 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003222 -C "Processing of the Certificate handshake message failed" \
3223 -c "Ciphersuite is TLS-"
3224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003225run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003226 "$O_SRV -key data_files/server2.key \
3227 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003228 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003229 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3230 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003231 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003232 -c "Processing of the Certificate handshake message failed" \
3233 -C "Ciphersuite is TLS-"
3234
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003235run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3236 "$O_SRV -key data_files/server2.key \
3237 -cert data_files/server2.ku-ke.crt" \
3238 "$P_CLI debug_level=1 auth_mode=optional \
3239 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3240 0 \
3241 -c "bad certificate (usage extensions)" \
3242 -C "Processing of the Certificate handshake message failed" \
3243 -c "Ciphersuite is TLS-" \
3244 -c "! Usage does not match the keyUsage extension"
3245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003246run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003247 "$O_SRV -key data_files/server2.key \
3248 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003249 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003250 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3251 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003252 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003253 -C "Processing of the Certificate handshake message failed" \
3254 -c "Ciphersuite is TLS-"
3255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003256run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003257 "$O_SRV -key data_files/server2.key \
3258 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003259 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003260 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3261 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003262 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003263 -c "Processing of the Certificate handshake message failed" \
3264 -C "Ciphersuite is TLS-"
3265
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003266run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3267 "$O_SRV -key data_files/server2.key \
3268 -cert data_files/server2.ku-ds.crt" \
3269 "$P_CLI debug_level=1 auth_mode=optional \
3270 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3271 0 \
3272 -c "bad certificate (usage extensions)" \
3273 -C "Processing of the Certificate handshake message failed" \
3274 -c "Ciphersuite is TLS-" \
3275 -c "! Usage does not match the keyUsage extension"
3276
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003277# Tests for keyUsage in leaf certificates, part 3:
3278# server-side checking of client cert
3279
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003280run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003281 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003282 "$O_CLI -key data_files/server2.key \
3283 -cert data_files/server2.ku-ds.crt" \
3284 0 \
3285 -S "bad certificate (usage extensions)" \
3286 -S "Processing of the Certificate handshake message failed"
3287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003288run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003289 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003290 "$O_CLI -key data_files/server2.key \
3291 -cert data_files/server2.ku-ke.crt" \
3292 0 \
3293 -s "bad certificate (usage extensions)" \
3294 -S "Processing of the Certificate handshake message failed"
3295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003296run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003297 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003298 "$O_CLI -key data_files/server2.key \
3299 -cert data_files/server2.ku-ke.crt" \
3300 1 \
3301 -s "bad certificate (usage extensions)" \
3302 -s "Processing of the Certificate handshake message failed"
3303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003304run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003305 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003306 "$O_CLI -key data_files/server5.key \
3307 -cert data_files/server5.ku-ds.crt" \
3308 0 \
3309 -S "bad certificate (usage extensions)" \
3310 -S "Processing of the Certificate handshake message failed"
3311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003312run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003313 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003314 "$O_CLI -key data_files/server5.key \
3315 -cert data_files/server5.ku-ka.crt" \
3316 0 \
3317 -s "bad certificate (usage extensions)" \
3318 -S "Processing of the Certificate handshake message failed"
3319
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003320# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003322run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003323 "$P_SRV key_file=data_files/server5.key \
3324 crt_file=data_files/server5.eku-srv.crt" \
3325 "$P_CLI" \
3326 0
3327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003328run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003329 "$P_SRV key_file=data_files/server5.key \
3330 crt_file=data_files/server5.eku-srv.crt" \
3331 "$P_CLI" \
3332 0
3333
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003334run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003335 "$P_SRV key_file=data_files/server5.key \
3336 crt_file=data_files/server5.eku-cs_any.crt" \
3337 "$P_CLI" \
3338 0
3339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003340run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003341 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003342 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003343 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003344 1
3345
3346# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003348run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003349 "$O_SRV -key data_files/server5.key \
3350 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003351 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003352 0 \
3353 -C "bad certificate (usage extensions)" \
3354 -C "Processing of the Certificate handshake message failed" \
3355 -c "Ciphersuite is TLS-"
3356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003357run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003358 "$O_SRV -key data_files/server5.key \
3359 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003360 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003361 0 \
3362 -C "bad certificate (usage extensions)" \
3363 -C "Processing of the Certificate handshake message failed" \
3364 -c "Ciphersuite is TLS-"
3365
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003366run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003367 "$O_SRV -key data_files/server5.key \
3368 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003369 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003370 0 \
3371 -C "bad certificate (usage extensions)" \
3372 -C "Processing of the Certificate handshake message failed" \
3373 -c "Ciphersuite is TLS-"
3374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003375run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003376 "$O_SRV -key data_files/server5.key \
3377 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003378 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003379 1 \
3380 -c "bad certificate (usage extensions)" \
3381 -c "Processing of the Certificate handshake message failed" \
3382 -C "Ciphersuite is TLS-"
3383
3384# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003386run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003387 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003388 "$O_CLI -key data_files/server5.key \
3389 -cert data_files/server5.eku-cli.crt" \
3390 0 \
3391 -S "bad certificate (usage extensions)" \
3392 -S "Processing of the Certificate handshake message failed"
3393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003394run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003395 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003396 "$O_CLI -key data_files/server5.key \
3397 -cert data_files/server5.eku-srv_cli.crt" \
3398 0 \
3399 -S "bad certificate (usage extensions)" \
3400 -S "Processing of the Certificate handshake message failed"
3401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003402run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003403 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003404 "$O_CLI -key data_files/server5.key \
3405 -cert data_files/server5.eku-cs_any.crt" \
3406 0 \
3407 -S "bad certificate (usage extensions)" \
3408 -S "Processing of the Certificate handshake message failed"
3409
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003410run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003411 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003412 "$O_CLI -key data_files/server5.key \
3413 -cert data_files/server5.eku-cs.crt" \
3414 0 \
3415 -s "bad certificate (usage extensions)" \
3416 -S "Processing of the Certificate handshake message failed"
3417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003418run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003419 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003420 "$O_CLI -key data_files/server5.key \
3421 -cert data_files/server5.eku-cs.crt" \
3422 1 \
3423 -s "bad certificate (usage extensions)" \
3424 -s "Processing of the Certificate handshake message failed"
3425
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003426# Tests for DHM parameters loading
3427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003428run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003429 "$P_SRV" \
3430 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3431 debug_level=3" \
3432 0 \
3433 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003434 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003436run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003437 "$P_SRV dhm_file=data_files/dhparams.pem" \
3438 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3439 debug_level=3" \
3440 0 \
3441 -c "value of 'DHM: P ' (1024 bits)" \
3442 -c "value of 'DHM: G ' (2 bits)"
3443
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003444# Tests for DHM client-side size checking
3445
3446run_test "DHM size: server default, client default, OK" \
3447 "$P_SRV" \
3448 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3449 debug_level=1" \
3450 0 \
3451 -C "DHM prime too short:"
3452
3453run_test "DHM size: server default, client 2048, OK" \
3454 "$P_SRV" \
3455 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3456 debug_level=1 dhmlen=2048" \
3457 0 \
3458 -C "DHM prime too short:"
3459
3460run_test "DHM size: server 1024, client default, OK" \
3461 "$P_SRV dhm_file=data_files/dhparams.pem" \
3462 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3463 debug_level=1" \
3464 0 \
3465 -C "DHM prime too short:"
3466
3467run_test "DHM size: server 1000, client default, rejected" \
3468 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3469 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3470 debug_level=1" \
3471 1 \
3472 -c "DHM prime too short:"
3473
3474run_test "DHM size: server default, client 2049, rejected" \
3475 "$P_SRV" \
3476 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3477 debug_level=1 dhmlen=2049" \
3478 1 \
3479 -c "DHM prime too short:"
3480
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003481# Tests for PSK callback
3482
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003483run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003484 "$P_SRV psk=abc123 psk_identity=foo" \
3485 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3486 psk_identity=foo psk=abc123" \
3487 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003488 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003489 -S "SSL - Unknown identity received" \
3490 -S "SSL - Verification of the message MAC failed"
3491
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003492run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003493 "$P_SRV" \
3494 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3495 psk_identity=foo psk=abc123" \
3496 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003497 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003498 -S "SSL - Unknown identity received" \
3499 -S "SSL - Verification of the message MAC failed"
3500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003501run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003502 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3503 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3504 psk_identity=foo psk=abc123" \
3505 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003506 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003507 -s "SSL - Unknown identity received" \
3508 -S "SSL - Verification of the message MAC failed"
3509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003510run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003511 "$P_SRV psk_list=abc,dead,def,beef" \
3512 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3513 psk_identity=abc psk=dead" \
3514 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003515 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003516 -S "SSL - Unknown identity received" \
3517 -S "SSL - Verification of the message MAC failed"
3518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003519run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003520 "$P_SRV psk_list=abc,dead,def,beef" \
3521 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3522 psk_identity=def psk=beef" \
3523 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003524 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003525 -S "SSL - Unknown identity received" \
3526 -S "SSL - Verification of the message MAC failed"
3527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003528run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003529 "$P_SRV psk_list=abc,dead,def,beef" \
3530 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3531 psk_identity=ghi psk=beef" \
3532 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003533 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003534 -s "SSL - Unknown identity received" \
3535 -S "SSL - Verification of the message MAC failed"
3536
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003537run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003538 "$P_SRV psk_list=abc,dead,def,beef" \
3539 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3540 psk_identity=abc psk=beef" \
3541 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003542 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003543 -S "SSL - Unknown identity received" \
3544 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003545
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003546# Tests for EC J-PAKE
3547
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003548requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003549run_test "ECJPAKE: client not configured" \
3550 "$P_SRV debug_level=3" \
3551 "$P_CLI debug_level=3" \
3552 0 \
3553 -C "add ciphersuite: c0ff" \
3554 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003555 -S "found ecjpake kkpp extension" \
3556 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003557 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003558 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003559 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003560 -S "None of the common ciphersuites is usable"
3561
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003562requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003563run_test "ECJPAKE: server not configured" \
3564 "$P_SRV debug_level=3" \
3565 "$P_CLI debug_level=3 ecjpake_pw=bla \
3566 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3567 1 \
3568 -c "add ciphersuite: c0ff" \
3569 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003570 -s "found ecjpake kkpp extension" \
3571 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003572 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003573 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003574 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003575 -s "None of the common ciphersuites is usable"
3576
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003577requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003578run_test "ECJPAKE: working, TLS" \
3579 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3580 "$P_CLI debug_level=3 ecjpake_pw=bla \
3581 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003582 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003583 -c "add ciphersuite: c0ff" \
3584 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003585 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003586 -s "found ecjpake kkpp extension" \
3587 -S "skip ecjpake kkpp extension" \
3588 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003589 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003590 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003591 -S "None of the common ciphersuites is usable" \
3592 -S "SSL - Verification of the message MAC failed"
3593
Janos Follath74537a62016-09-02 13:45:28 +01003594server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003595requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003596run_test "ECJPAKE: password mismatch, TLS" \
3597 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3598 "$P_CLI debug_level=3 ecjpake_pw=bad \
3599 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3600 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003601 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003602 -s "SSL - Verification of the message MAC failed"
3603
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003604requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003605run_test "ECJPAKE: working, DTLS" \
3606 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3607 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3608 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3609 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003610 -c "re-using cached ecjpake parameters" \
3611 -S "SSL - Verification of the message MAC failed"
3612
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003613requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003614run_test "ECJPAKE: working, DTLS, no cookie" \
3615 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3616 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3617 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3618 0 \
3619 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003620 -S "SSL - Verification of the message MAC failed"
3621
Janos Follath74537a62016-09-02 13:45:28 +01003622server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003623requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003624run_test "ECJPAKE: password mismatch, DTLS" \
3625 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3626 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3627 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3628 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003629 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003630 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003631
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003632# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003633requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003634run_test "ECJPAKE: working, DTLS, nolog" \
3635 "$P_SRV dtls=1 ecjpake_pw=bla" \
3636 "$P_CLI dtls=1 ecjpake_pw=bla \
3637 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3638 0
3639
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003640# Tests for ciphersuites per version
3641
Janos Follathe2681a42016-03-07 15:57:05 +00003642requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003643run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003644 "$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 +02003645 "$P_CLI force_version=ssl3" \
3646 0 \
3647 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003649run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003650 "$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 +01003651 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003652 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003653 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003655run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003656 "$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 +02003657 "$P_CLI force_version=tls1_1" \
3658 0 \
3659 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003661run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003662 "$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 +02003663 "$P_CLI force_version=tls1_2" \
3664 0 \
3665 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3666
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003667# Test for ClientHello without extensions
3668
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003669requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003670run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003671 "$P_SRV debug_level=3" \
3672 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3673 0 \
3674 -s "dumping 'client hello extensions' (0 bytes)"
3675
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003676requires_gnutls
3677run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3678 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3679 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3680 0 \
3681 -s "dumping 'client hello extensions' (0 bytes)"
3682
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003683# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003684
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003685run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003686 "$P_SRV" \
3687 "$P_CLI request_size=100" \
3688 0 \
3689 -s "Read from client: 100 bytes read$"
3690
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003691run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003692 "$P_SRV" \
3693 "$P_CLI request_size=500" \
3694 0 \
3695 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003696
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003697# Tests for small packets
3698
Janos Follathe2681a42016-03-07 15:57:05 +00003699requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003700run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003701 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003702 "$P_CLI request_size=1 force_version=ssl3 \
3703 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3704 0 \
3705 -s "Read from client: 1 bytes read"
3706
Janos Follathe2681a42016-03-07 15:57:05 +00003707requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003708run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003709 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003710 "$P_CLI request_size=1 force_version=ssl3 \
3711 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3712 0 \
3713 -s "Read from client: 1 bytes read"
3714
3715run_test "Small packet TLS 1.0 BlockCipher" \
3716 "$P_SRV" \
3717 "$P_CLI request_size=1 force_version=tls1 \
3718 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3719 0 \
3720 -s "Read from client: 1 bytes read"
3721
Hanno Becker8501f982017-11-10 08:59:04 +00003722run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003723 "$P_SRV" \
3724 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3725 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3726 0 \
3727 -s "Read from client: 1 bytes read"
3728
Hanno Becker32c55012017-11-10 08:42:54 +00003729requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003730run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003731 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003732 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003733 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003734 0 \
3735 -s "Read from client: 1 bytes read"
3736
Hanno Becker32c55012017-11-10 08:42:54 +00003737requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003738run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003739 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003740 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003741 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003742 0 \
3743 -s "Read from client: 1 bytes read"
3744
3745run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003746 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003747 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003748 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3749 0 \
3750 -s "Read from client: 1 bytes read"
3751
3752run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3753 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3754 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003755 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003756 0 \
3757 -s "Read from client: 1 bytes read"
3758
3759requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3760run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003761 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003762 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003763 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003764 0 \
3765 -s "Read from client: 1 bytes read"
3766
Hanno Becker8501f982017-11-10 08:59:04 +00003767requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3768run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003769 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3770 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3771 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003772 0 \
3773 -s "Read from client: 1 bytes read"
3774
3775run_test "Small packet TLS 1.1 BlockCipher" \
3776 "$P_SRV" \
3777 "$P_CLI request_size=1 force_version=tls1_1 \
3778 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3779 0 \
3780 -s "Read from client: 1 bytes read"
3781
Hanno Becker8501f982017-11-10 08:59:04 +00003782run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003783 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003784 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003785 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003786 0 \
3787 -s "Read from client: 1 bytes read"
3788
3789requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3790run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003791 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003792 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003793 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003794 0 \
3795 -s "Read from client: 1 bytes read"
3796
3797requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3798run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003799 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003800 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003801 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003802 0 \
3803 -s "Read from client: 1 bytes read"
3804
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003805run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003806 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003807 "$P_CLI request_size=1 force_version=tls1_1 \
3808 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3809 0 \
3810 -s "Read from client: 1 bytes read"
3811
Hanno Becker8501f982017-11-10 08:59:04 +00003812run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3813 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003814 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003815 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003816 0 \
3817 -s "Read from client: 1 bytes read"
3818
Hanno Becker8501f982017-11-10 08:59:04 +00003819requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3820run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003821 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003822 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003823 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003824 0 \
3825 -s "Read from client: 1 bytes read"
3826
Hanno Becker32c55012017-11-10 08:42:54 +00003827requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003828run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003829 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003830 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003831 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003832 0 \
3833 -s "Read from client: 1 bytes read"
3834
3835run_test "Small packet TLS 1.2 BlockCipher" \
3836 "$P_SRV" \
3837 "$P_CLI request_size=1 force_version=tls1_2 \
3838 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3839 0 \
3840 -s "Read from client: 1 bytes read"
3841
Hanno Becker8501f982017-11-10 08:59:04 +00003842run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003843 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003844 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003845 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003846 0 \
3847 -s "Read from client: 1 bytes read"
3848
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003849run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3850 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003851 "$P_CLI request_size=1 force_version=tls1_2 \
3852 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003853 0 \
3854 -s "Read from client: 1 bytes read"
3855
Hanno Becker32c55012017-11-10 08:42:54 +00003856requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003857run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003858 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003859 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003860 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003861 0 \
3862 -s "Read from client: 1 bytes read"
3863
Hanno Becker8501f982017-11-10 08:59:04 +00003864requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3865run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003866 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003867 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003868 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003869 0 \
3870 -s "Read from client: 1 bytes read"
3871
3872run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003873 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003874 "$P_CLI request_size=1 force_version=tls1_2 \
3875 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3876 0 \
3877 -s "Read from client: 1 bytes read"
3878
Hanno Becker8501f982017-11-10 08:59:04 +00003879run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003880 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003881 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003882 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003883 0 \
3884 -s "Read from client: 1 bytes read"
3885
Hanno Becker32c55012017-11-10 08:42:54 +00003886requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003887run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003888 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003889 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003890 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003891 0 \
3892 -s "Read from client: 1 bytes read"
3893
Hanno Becker8501f982017-11-10 08:59:04 +00003894requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3895run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003896 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003897 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003898 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003899 0 \
3900 -s "Read from client: 1 bytes read"
3901
3902run_test "Small packet TLS 1.2 AEAD" \
3903 "$P_SRV" \
3904 "$P_CLI request_size=1 force_version=tls1_2 \
3905 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3906 0 \
3907 -s "Read from client: 1 bytes read"
3908
3909run_test "Small packet TLS 1.2 AEAD shorter tag" \
3910 "$P_SRV" \
3911 "$P_CLI request_size=1 force_version=tls1_2 \
3912 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3913 0 \
3914 -s "Read from client: 1 bytes read"
3915
Hanno Beckere2148042017-11-10 08:59:18 +00003916# Tests for small packets in DTLS
3917
3918requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3919run_test "Small packet DTLS 1.0" \
3920 "$P_SRV dtls=1 force_version=dtls1" \
3921 "$P_CLI dtls=1 request_size=1 \
3922 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3923 0 \
3924 -s "Read from client: 1 bytes read"
3925
3926requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3927run_test "Small packet DTLS 1.0, without EtM" \
3928 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3929 "$P_CLI dtls=1 request_size=1 \
3930 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3931 0 \
3932 -s "Read from client: 1 bytes read"
3933
3934requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3935requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3936run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003937 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3938 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003939 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3940 0 \
3941 -s "Read from client: 1 bytes read"
3942
3943requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3944requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3945run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003946 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003947 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003948 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003949 0 \
3950 -s "Read from client: 1 bytes read"
3951
3952requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3953run_test "Small packet DTLS 1.2" \
3954 "$P_SRV dtls=1 force_version=dtls1_2" \
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
3961run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003962 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003963 "$P_CLI dtls=1 request_size=1 \
3964 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3965 0 \
3966 -s "Read from client: 1 bytes read"
3967
3968requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3969requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3970run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003971 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003972 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003973 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003974 0 \
3975 -s "Read from client: 1 bytes read"
3976
3977requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3978requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3979run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003980 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003981 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003982 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003983 0 \
3984 -s "Read from client: 1 bytes read"
3985
Janos Follath00efff72016-05-06 13:48:23 +01003986# A test for extensions in SSLv3
3987
3988requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3989run_test "SSLv3 with extensions, server side" \
3990 "$P_SRV min_version=ssl3 debug_level=3" \
3991 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3992 0 \
3993 -S "dumping 'client hello extensions'" \
3994 -S "server hello, total extension length:"
3995
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003996# Test for large packets
3997
Angus Grattonc4dd0732018-04-11 16:28:39 +10003998# How many fragments do we expect to write $1 bytes?
3999fragments_for_write() {
4000 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4001}
4002
Janos Follathe2681a42016-03-07 15:57:05 +00004003requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004004run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004005 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004006 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004007 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4008 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004009 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4010 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004011
Janos Follathe2681a42016-03-07 15:57:05 +00004012requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004013run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004014 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004015 "$P_CLI request_size=16384 force_version=ssl3 \
4016 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4017 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004018 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4019 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004020
4021run_test "Large packet TLS 1.0 BlockCipher" \
4022 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004023 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004024 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4025 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004026 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4027 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004028
Hanno Becker278fc7a2017-11-10 09:16:28 +00004029run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004030 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004031 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4032 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4033 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004034 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004035
Hanno Becker32c55012017-11-10 08:42:54 +00004036requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004037run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004038 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004039 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004040 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004041 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004042 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4043 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004044
Hanno Becker32c55012017-11-10 08:42:54 +00004045requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004046run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004047 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004048 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004049 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004050 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004051 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004052
4053run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004054 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004055 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004056 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4057 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004058 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004059
4060run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
4061 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4062 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004063 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004064 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004065 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004066
4067requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4068run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004069 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004070 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004071 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004072 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004073 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004074
Hanno Becker278fc7a2017-11-10 09:16:28 +00004075requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4076run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004077 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004078 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004079 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004080 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004081 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4082 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004083
4084run_test "Large packet TLS 1.1 BlockCipher" \
4085 "$P_SRV" \
4086 "$P_CLI request_size=16384 force_version=tls1_1 \
4087 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4088 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004089 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4090 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004091
Hanno Becker278fc7a2017-11-10 09:16:28 +00004092run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
4093 "$P_SRV" \
4094 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4095 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004096 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004097 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004098
Hanno Becker32c55012017-11-10 08:42:54 +00004099requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004100run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004101 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004102 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004103 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004104 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004105 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004106
Hanno Becker32c55012017-11-10 08:42:54 +00004107requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004108run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004109 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004110 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004111 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004112 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004113 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004114
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004115run_test "Large packet TLS 1.1 StreamCipher" \
4116 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4117 "$P_CLI request_size=16384 force_version=tls1_1 \
4118 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4119 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004120 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4121 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004122
Hanno Becker278fc7a2017-11-10 09:16:28 +00004123run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
4124 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004125 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004126 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004127 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004128 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4129 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004130
Hanno Becker278fc7a2017-11-10 09:16:28 +00004131requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4132run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004133 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004134 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004135 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004136 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004137 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004138
Hanno Becker278fc7a2017-11-10 09:16:28 +00004139requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4140run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004141 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004142 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004143 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004144 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004145 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4146 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004147
4148run_test "Large packet TLS 1.2 BlockCipher" \
4149 "$P_SRV" \
4150 "$P_CLI request_size=16384 force_version=tls1_2 \
4151 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4152 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004153 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4154 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004155
Hanno Becker278fc7a2017-11-10 09:16:28 +00004156run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
4157 "$P_SRV" \
4158 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4159 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4160 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004161 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004162
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004163run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
4164 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004165 "$P_CLI request_size=16384 force_version=tls1_2 \
4166 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004167 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004168 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4169 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004170
Hanno Becker32c55012017-11-10 08:42:54 +00004171requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004172run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004173 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004174 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004175 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004176 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004177 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004178
Hanno Becker278fc7a2017-11-10 09:16:28 +00004179requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4180run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004181 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004182 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004183 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004184 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004185 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4186 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004187
4188run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004189 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004190 "$P_CLI request_size=16384 force_version=tls1_2 \
4191 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4192 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004193 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4194 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004195
Hanno Becker278fc7a2017-11-10 09:16:28 +00004196run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004197 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004198 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004199 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4200 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004201 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004202
Hanno Becker32c55012017-11-10 08:42:54 +00004203requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004204run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004205 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004206 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004207 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004208 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004209 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004210
Hanno Becker278fc7a2017-11-10 09:16:28 +00004211requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4212run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004213 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004214 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004215 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004216 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004217 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4218 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004219
4220run_test "Large packet TLS 1.2 AEAD" \
4221 "$P_SRV" \
4222 "$P_CLI request_size=16384 force_version=tls1_2 \
4223 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4224 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004225 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4226 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004227
4228run_test "Large packet TLS 1.2 AEAD shorter tag" \
4229 "$P_SRV" \
4230 "$P_CLI request_size=16384 force_version=tls1_2 \
4231 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4232 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004233 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4234 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004235
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004236# Tests of asynchronous private key support in SSL
4237
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004238requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004239run_test "SSL async private: sign, delay=0" \
4240 "$P_SRV \
4241 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004242 "$P_CLI" \
4243 0 \
4244 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004245 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004246
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004247requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004248run_test "SSL async private: sign, delay=1" \
4249 "$P_SRV \
4250 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004251 "$P_CLI" \
4252 0 \
4253 -s "Async sign callback: using key slot " \
4254 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004255 -s "Async resume (slot [0-9]): sign done, status=0"
4256
Gilles Peskine12d0cc12018-04-26 15:06:56 +02004257requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4258run_test "SSL async private: sign, delay=2" \
4259 "$P_SRV \
4260 async_operations=s async_private_delay1=2 async_private_delay2=2" \
4261 "$P_CLI" \
4262 0 \
4263 -s "Async sign callback: using key slot " \
4264 -U "Async sign callback: using key slot " \
4265 -s "Async resume (slot [0-9]): call 1 more times." \
4266 -s "Async resume (slot [0-9]): call 0 more times." \
4267 -s "Async resume (slot [0-9]): sign done, status=0"
4268
Gilles Peskined3268832018-04-26 06:23:59 +02004269# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
4270# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
4271requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4272requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4273run_test "SSL async private: sign, RSA, TLS 1.1" \
4274 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
4275 async_operations=s async_private_delay1=0 async_private_delay2=0" \
4276 "$P_CLI force_version=tls1_1" \
4277 0 \
4278 -s "Async sign callback: using key slot " \
4279 -s "Async resume (slot [0-9]): sign done, status=0"
4280
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004281requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02004282run_test "SSL async private: sign, SNI" \
4283 "$P_SRV debug_level=3 \
4284 async_operations=s async_private_delay1=0 async_private_delay2=0 \
4285 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4286 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4287 "$P_CLI server_name=polarssl.example" \
4288 0 \
4289 -s "Async sign callback: using key slot " \
4290 -s "Async resume (slot [0-9]): sign done, status=0" \
4291 -s "parse ServerName extension" \
4292 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4293 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4294
4295requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004296run_test "SSL async private: decrypt, delay=0" \
4297 "$P_SRV \
4298 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4299 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4300 0 \
4301 -s "Async decrypt callback: using key slot " \
4302 -s "Async resume (slot [0-9]): decrypt done, status=0"
4303
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004304requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004305run_test "SSL async private: decrypt, delay=1" \
4306 "$P_SRV \
4307 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4308 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4309 0 \
4310 -s "Async decrypt callback: using key slot " \
4311 -s "Async resume (slot [0-9]): call 0 more times." \
4312 -s "Async resume (slot [0-9]): decrypt done, status=0"
4313
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004314requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004315run_test "SSL async private: decrypt RSA-PSK, delay=0" \
4316 "$P_SRV psk=abc123 \
4317 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4318 "$P_CLI psk=abc123 \
4319 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4320 0 \
4321 -s "Async decrypt callback: using key slot " \
4322 -s "Async resume (slot [0-9]): decrypt done, status=0"
4323
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004324requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004325run_test "SSL async private: decrypt RSA-PSK, delay=1" \
4326 "$P_SRV psk=abc123 \
4327 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4328 "$P_CLI psk=abc123 \
4329 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4330 0 \
4331 -s "Async decrypt callback: using key slot " \
4332 -s "Async resume (slot [0-9]): call 0 more times." \
4333 -s "Async resume (slot [0-9]): decrypt done, status=0"
4334
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004335requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004336run_test "SSL async private: sign callback not present" \
4337 "$P_SRV \
4338 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4339 "$P_CLI; [ \$? -eq 1 ] &&
4340 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4341 0 \
4342 -S "Async sign callback" \
4343 -s "! mbedtls_ssl_handshake returned" \
4344 -s "The own private key or pre-shared key is not set, but needed" \
4345 -s "Async resume (slot [0-9]): decrypt done, status=0" \
4346 -s "Successful connection"
4347
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004348requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004349run_test "SSL async private: decrypt callback not present" \
4350 "$P_SRV debug_level=1 \
4351 async_operations=s async_private_delay1=1 async_private_delay2=1" \
4352 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
4353 [ \$? -eq 1 ] && $P_CLI" \
4354 0 \
4355 -S "Async decrypt callback" \
4356 -s "! mbedtls_ssl_handshake returned" \
4357 -s "got no RSA private key" \
4358 -s "Async resume (slot [0-9]): sign done, status=0" \
4359 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004360
4361# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004362requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004363run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004364 "$P_SRV \
4365 async_operations=s async_private_delay1=1 \
4366 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4367 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004368 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4369 0 \
4370 -s "Async sign callback: using key slot 0," \
4371 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004372 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004373
4374# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004375requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004376run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004377 "$P_SRV \
4378 async_operations=s async_private_delay2=1 \
4379 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4380 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004381 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4382 0 \
4383 -s "Async sign callback: using key slot 0," \
4384 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004385 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004386
4387# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004388requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02004389run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004390 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02004391 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004392 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-RSA-WITH-AES-128-CBC-SHA256" \
4395 0 \
4396 -s "Async sign callback: using key slot 1," \
4397 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004398 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004399
4400# key1: ECDSA, key2: RSA; use key2 directly
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: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004403 "$P_SRV \
4404 async_operations=s async_private_delay1=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: no key matches this certificate."
4410
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004411requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004412run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004413 "$P_SRV \
4414 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4415 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004416 "$P_CLI" \
4417 1 \
4418 -s "Async sign callback: injected error" \
4419 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004420 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004421 -s "! mbedtls_ssl_handshake returned"
4422
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004423requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004424run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004425 "$P_SRV \
4426 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4427 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004428 "$P_CLI" \
4429 1 \
4430 -s "Async sign callback: using key slot " \
4431 -S "Async resume" \
4432 -s "Async cancel"
4433
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004434requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004435run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004436 "$P_SRV \
4437 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4438 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004439 "$P_CLI" \
4440 1 \
4441 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004442 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004443 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004444 -s "! mbedtls_ssl_handshake returned"
4445
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004446requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004447run_test "SSL async private: decrypt, error in start" \
4448 "$P_SRV \
4449 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4450 async_private_error=1" \
4451 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4452 1 \
4453 -s "Async decrypt callback: injected error" \
4454 -S "Async resume" \
4455 -S "Async cancel" \
4456 -s "! mbedtls_ssl_handshake returned"
4457
4458requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4459run_test "SSL async private: decrypt, cancel after start" \
4460 "$P_SRV \
4461 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4462 async_private_error=2" \
4463 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4464 1 \
4465 -s "Async decrypt callback: using key slot " \
4466 -S "Async resume" \
4467 -s "Async cancel"
4468
4469requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4470run_test "SSL async private: decrypt, error in resume" \
4471 "$P_SRV \
4472 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4473 async_private_error=3" \
4474 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4475 1 \
4476 -s "Async decrypt callback: using key slot " \
4477 -s "Async resume callback: decrypt done but injected error" \
4478 -S "Async cancel" \
4479 -s "! mbedtls_ssl_handshake returned"
4480
4481requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004482run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004483 "$P_SRV \
4484 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4485 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004486 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4487 0 \
4488 -s "Async cancel" \
4489 -s "! mbedtls_ssl_handshake returned" \
4490 -s "Async resume" \
4491 -s "Successful connection"
4492
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004493requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004494run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004495 "$P_SRV \
4496 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4497 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004498 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4499 0 \
4500 -s "! mbedtls_ssl_handshake returned" \
4501 -s "Async resume" \
4502 -s "Successful connection"
4503
4504# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004505requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004506run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004507 "$P_SRV \
4508 async_operations=s async_private_delay1=1 async_private_error=-2 \
4509 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4510 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004511 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4512 [ \$? -eq 1 ] &&
4513 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4514 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02004515 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004516 -S "Async resume" \
4517 -s "Async cancel" \
4518 -s "! mbedtls_ssl_handshake returned" \
4519 -s "Async sign callback: no key matches this certificate." \
4520 -s "Successful connection"
4521
4522# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004523requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004524run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004525 "$P_SRV \
4526 async_operations=s async_private_delay1=1 async_private_error=-3 \
4527 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4528 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004529 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4530 [ \$? -eq 1 ] &&
4531 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4532 0 \
4533 -s "Async resume" \
4534 -s "! mbedtls_ssl_handshake returned" \
4535 -s "Async sign callback: no key matches this certificate." \
4536 -s "Successful connection"
4537
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004538requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004539requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004540run_test "SSL async private: renegotiation: client-initiated; sign" \
4541 "$P_SRV \
4542 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004543 exchanges=2 renegotiation=1" \
4544 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
4545 0 \
4546 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004547 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004548
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004549requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004550requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004551run_test "SSL async private: renegotiation: server-initiated; sign" \
4552 "$P_SRV \
4553 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004554 exchanges=2 renegotiation=1 renegotiate=1" \
4555 "$P_CLI exchanges=2 renegotiation=1" \
4556 0 \
4557 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004558 -s "Async resume (slot [0-9]): sign done, status=0"
4559
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004560requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004561requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4562run_test "SSL async private: renegotiation: client-initiated; decrypt" \
4563 "$P_SRV \
4564 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4565 exchanges=2 renegotiation=1" \
4566 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
4567 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4568 0 \
4569 -s "Async decrypt callback: using key slot " \
4570 -s "Async resume (slot [0-9]): decrypt done, status=0"
4571
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004572requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004573requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4574run_test "SSL async private: renegotiation: server-initiated; decrypt" \
4575 "$P_SRV \
4576 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4577 exchanges=2 renegotiation=1 renegotiate=1" \
4578 "$P_CLI exchanges=2 renegotiation=1 \
4579 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4580 0 \
4581 -s "Async decrypt callback: using key slot " \
4582 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004583
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004584# Tests for DTLS HelloVerifyRequest
4585
4586run_test "DTLS cookie: enabled" \
4587 "$P_SRV dtls=1 debug_level=2" \
4588 "$P_CLI dtls=1 debug_level=2" \
4589 0 \
4590 -s "cookie verification failed" \
4591 -s "cookie verification passed" \
4592 -S "cookie verification skipped" \
4593 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004594 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004595 -S "SSL - The requested feature is not available"
4596
4597run_test "DTLS cookie: disabled" \
4598 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4599 "$P_CLI dtls=1 debug_level=2" \
4600 0 \
4601 -S "cookie verification failed" \
4602 -S "cookie verification passed" \
4603 -s "cookie verification skipped" \
4604 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004605 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004606 -S "SSL - The requested feature is not available"
4607
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004608run_test "DTLS cookie: default (failing)" \
4609 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4610 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4611 1 \
4612 -s "cookie verification failed" \
4613 -S "cookie verification passed" \
4614 -S "cookie verification skipped" \
4615 -C "received hello verify request" \
4616 -S "hello verification requested" \
4617 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004618
4619requires_ipv6
4620run_test "DTLS cookie: enabled, IPv6" \
4621 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4622 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4623 0 \
4624 -s "cookie verification failed" \
4625 -s "cookie verification passed" \
4626 -S "cookie verification skipped" \
4627 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004628 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004629 -S "SSL - The requested feature is not available"
4630
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004631run_test "DTLS cookie: enabled, nbio" \
4632 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4633 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4634 0 \
4635 -s "cookie verification failed" \
4636 -s "cookie verification passed" \
4637 -S "cookie verification skipped" \
4638 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004639 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004640 -S "SSL - The requested feature is not available"
4641
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004642# Tests for client reconnecting from the same port with DTLS
4643
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004644not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004645run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004646 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4647 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004648 0 \
4649 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004650 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004651 -S "Client initiated reconnection from same port"
4652
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004653not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004654run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004655 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4656 "$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 +02004657 0 \
4658 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004659 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004660 -s "Client initiated reconnection from same port"
4661
Paul Bakker362689d2016-05-13 10:33:25 +01004662not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4663run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004664 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4665 "$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 +02004666 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004667 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004668 -s "Client initiated reconnection from same port"
4669
Paul Bakker362689d2016-05-13 10:33:25 +01004670only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4671run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4672 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4673 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4674 0 \
4675 -S "The operation timed out" \
4676 -s "Client initiated reconnection from same port"
4677
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004678run_test "DTLS client reconnect from same port: no cookies" \
4679 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004680 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4681 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004682 -s "The operation timed out" \
4683 -S "Client initiated reconnection from same port"
4684
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004685# Tests for various cases of client authentication with DTLS
4686# (focused on handshake flows and message parsing)
4687
4688run_test "DTLS client auth: required" \
4689 "$P_SRV dtls=1 auth_mode=required" \
4690 "$P_CLI dtls=1" \
4691 0 \
4692 -s "Verifying peer X.509 certificate... ok"
4693
4694run_test "DTLS client auth: optional, client has no cert" \
4695 "$P_SRV dtls=1 auth_mode=optional" \
4696 "$P_CLI dtls=1 crt_file=none key_file=none" \
4697 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004698 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004699
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004700run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004701 "$P_SRV dtls=1 auth_mode=none" \
4702 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
4703 0 \
4704 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004705 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004706
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02004707run_test "DTLS wrong PSK: badmac alert" \
4708 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
4709 "$P_CLI dtls=1 psk=abc124" \
4710 1 \
4711 -s "SSL - Verification of the message MAC failed" \
4712 -c "SSL - A fatal alert message was received from our peer"
4713
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02004714# Tests for receiving fragmented handshake messages with DTLS
4715
4716requires_gnutls
4717run_test "DTLS reassembly: no fragmentation (gnutls server)" \
4718 "$G_SRV -u --mtu 2048 -a" \
4719 "$P_CLI dtls=1 debug_level=2" \
4720 0 \
4721 -C "found fragmented DTLS handshake message" \
4722 -C "error"
4723
4724requires_gnutls
4725run_test "DTLS reassembly: some fragmentation (gnutls server)" \
4726 "$G_SRV -u --mtu 512" \
4727 "$P_CLI dtls=1 debug_level=2" \
4728 0 \
4729 -c "found fragmented DTLS handshake message" \
4730 -C "error"
4731
4732requires_gnutls
4733run_test "DTLS reassembly: more fragmentation (gnutls server)" \
4734 "$G_SRV -u --mtu 128" \
4735 "$P_CLI dtls=1 debug_level=2" \
4736 0 \
4737 -c "found fragmented DTLS handshake message" \
4738 -C "error"
4739
4740requires_gnutls
4741run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
4742 "$G_SRV -u --mtu 128" \
4743 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4744 0 \
4745 -c "found fragmented DTLS handshake message" \
4746 -C "error"
4747
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004748requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004749requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004750run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4751 "$G_SRV -u --mtu 256" \
4752 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4753 0 \
4754 -c "found fragmented DTLS handshake message" \
4755 -c "client hello, adding renegotiation extension" \
4756 -c "found renegotiation extension" \
4757 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004758 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004759 -C "error" \
4760 -s "Extra-header:"
4761
4762requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004763requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004764run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4765 "$G_SRV -u --mtu 256" \
4766 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4767 0 \
4768 -c "found fragmented DTLS handshake message" \
4769 -c "client hello, adding renegotiation extension" \
4770 -c "found renegotiation extension" \
4771 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004772 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004773 -C "error" \
4774 -s "Extra-header:"
4775
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004776run_test "DTLS reassembly: no fragmentation (openssl server)" \
4777 "$O_SRV -dtls1 -mtu 2048" \
4778 "$P_CLI dtls=1 debug_level=2" \
4779 0 \
4780 -C "found fragmented DTLS handshake message" \
4781 -C "error"
4782
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004783run_test "DTLS reassembly: some fragmentation (openssl server)" \
4784 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004785 "$P_CLI dtls=1 debug_level=2" \
4786 0 \
4787 -c "found fragmented DTLS handshake message" \
4788 -C "error"
4789
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004790run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004791 "$O_SRV -dtls1 -mtu 256" \
4792 "$P_CLI dtls=1 debug_level=2" \
4793 0 \
4794 -c "found fragmented DTLS handshake message" \
4795 -C "error"
4796
4797run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4798 "$O_SRV -dtls1 -mtu 256" \
4799 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4800 0 \
4801 -c "found fragmented DTLS handshake message" \
4802 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004803
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004804# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004805
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004806not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004807run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004808 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004809 "$P_SRV dtls=1 debug_level=2" \
4810 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004811 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004812 -C "replayed record" \
4813 -S "replayed record" \
4814 -C "record from another epoch" \
4815 -S "record from another epoch" \
4816 -C "discarding invalid record" \
4817 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004818 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004819 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004820 -c "HTTP/1.0 200 OK"
4821
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004822not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004823run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004824 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004825 "$P_SRV dtls=1 debug_level=2" \
4826 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004827 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004828 -c "replayed record" \
4829 -s "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004830 -c "record from another epoch" \
4831 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004832 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004833 -s "Extra-header:" \
4834 -c "HTTP/1.0 200 OK"
4835
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004836run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4837 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004838 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4839 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004840 0 \
4841 -c "replayed record" \
4842 -S "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004843 -c "record from another epoch" \
4844 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004845 -c "resend" \
4846 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004847 -s "Extra-header:" \
4848 -c "HTTP/1.0 200 OK"
4849
Hanno Becker72a4f032017-11-15 16:39:20 +00004850run_test "DTLS proxy: multiple records in same datagram" \
Hanno Becker8d832182018-03-15 10:14:19 +00004851 -p "$P_PXY pack=50" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004852 "$P_SRV dtls=1 debug_level=2" \
4853 "$P_CLI dtls=1 debug_level=2" \
4854 0 \
4855 -c "next record in same datagram" \
4856 -s "next record in same datagram"
4857
4858run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
Hanno Becker8d832182018-03-15 10:14:19 +00004859 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004860 "$P_SRV dtls=1 debug_level=2" \
4861 "$P_CLI dtls=1 debug_level=2" \
4862 0 \
4863 -c "next record in same datagram" \
4864 -s "next record in same datagram"
4865
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004866run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004867 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004868 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004869 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004870 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004871 -c "discarding invalid record (mac)" \
4872 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004873 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004874 -c "HTTP/1.0 200 OK" \
4875 -S "too many records with bad MAC" \
4876 -S "Verification of the message MAC failed"
4877
4878run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4879 -p "$P_PXY bad_ad=1" \
4880 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4881 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4882 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004883 -C "discarding invalid record (mac)" \
4884 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004885 -S "Extra-header:" \
4886 -C "HTTP/1.0 200 OK" \
4887 -s "too many records with bad MAC" \
4888 -s "Verification of the message MAC failed"
4889
4890run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4891 -p "$P_PXY bad_ad=1" \
4892 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4893 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4894 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004895 -c "discarding invalid record (mac)" \
4896 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004897 -s "Extra-header:" \
4898 -c "HTTP/1.0 200 OK" \
4899 -S "too many records with bad MAC" \
4900 -S "Verification of the message MAC failed"
4901
4902run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4903 -p "$P_PXY bad_ad=1" \
4904 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4905 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4906 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004907 -c "discarding invalid record (mac)" \
4908 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004909 -s "Extra-header:" \
4910 -c "HTTP/1.0 200 OK" \
4911 -s "too many records with bad MAC" \
4912 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004913
4914run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004915 -p "$P_PXY delay_ccs=1" \
4916 "$P_SRV dtls=1 debug_level=1" \
4917 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004918 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004919 -c "record from another epoch" \
4920 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004921 -s "Extra-header:" \
4922 -c "HTTP/1.0 200 OK"
4923
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004924# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004925
Janos Follath74537a62016-09-02 13:45:28 +01004926client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004927run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004928 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004929 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4930 psk=abc123" \
4931 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004932 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4933 0 \
4934 -s "Extra-header:" \
4935 -c "HTTP/1.0 200 OK"
4936
Janos Follath74537a62016-09-02 13:45:28 +01004937client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004938run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4939 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004940 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4941 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004942 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4943 0 \
4944 -s "Extra-header:" \
4945 -c "HTTP/1.0 200 OK"
4946
Janos Follath74537a62016-09-02 13:45:28 +01004947client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004948run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4949 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004950 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4951 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004952 0 \
4953 -s "Extra-header:" \
4954 -c "HTTP/1.0 200 OK"
4955
Janos Follath74537a62016-09-02 13:45:28 +01004956client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004957run_test "DTLS proxy: 3d, FS, client auth" \
4958 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004959 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4960 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004961 0 \
4962 -s "Extra-header:" \
4963 -c "HTTP/1.0 200 OK"
4964
Janos Follath74537a62016-09-02 13:45:28 +01004965client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004966run_test "DTLS proxy: 3d, FS, ticket" \
4967 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004968 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4969 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004970 0 \
4971 -s "Extra-header:" \
4972 -c "HTTP/1.0 200 OK"
4973
Janos Follath74537a62016-09-02 13:45:28 +01004974client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004975run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4976 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004977 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4978 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004979 0 \
4980 -s "Extra-header:" \
4981 -c "HTTP/1.0 200 OK"
4982
Janos Follath74537a62016-09-02 13:45:28 +01004983client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004984run_test "DTLS proxy: 3d, max handshake, nbio" \
4985 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004986 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4987 auth_mode=required" \
4988 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004989 0 \
4990 -s "Extra-header:" \
4991 -c "HTTP/1.0 200 OK"
4992
Janos Follath74537a62016-09-02 13:45:28 +01004993client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004994run_test "DTLS proxy: 3d, min handshake, resumption" \
4995 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4996 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4997 psk=abc123 debug_level=3" \
4998 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4999 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5000 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5001 0 \
5002 -s "a session has been resumed" \
5003 -c "a session has been resumed" \
5004 -s "Extra-header:" \
5005 -c "HTTP/1.0 200 OK"
5006
Janos Follath74537a62016-09-02 13:45:28 +01005007client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005008run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
5009 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5010 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5011 psk=abc123 debug_level=3 nbio=2" \
5012 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5013 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5014 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
5015 0 \
5016 -s "a session has been resumed" \
5017 -c "a session has been resumed" \
5018 -s "Extra-header:" \
5019 -c "HTTP/1.0 200 OK"
5020
Janos Follath74537a62016-09-02 13:45:28 +01005021client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005022requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005023run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005024 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005025 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5026 psk=abc123 renegotiation=1 debug_level=2" \
5027 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5028 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005029 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5030 0 \
5031 -c "=> renegotiate" \
5032 -s "=> renegotiate" \
5033 -s "Extra-header:" \
5034 -c "HTTP/1.0 200 OK"
5035
Janos Follath74537a62016-09-02 13:45:28 +01005036client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005037requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005038run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
5039 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005040 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5041 psk=abc123 renegotiation=1 debug_level=2" \
5042 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5043 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005044 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5045 0 \
5046 -c "=> renegotiate" \
5047 -s "=> renegotiate" \
5048 -s "Extra-header:" \
5049 -c "HTTP/1.0 200 OK"
5050
Janos Follath74537a62016-09-02 13:45:28 +01005051client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005052requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005053run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005054 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005055 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005056 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005057 debug_level=2" \
5058 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005059 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005060 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5061 0 \
5062 -c "=> renegotiate" \
5063 -s "=> renegotiate" \
5064 -s "Extra-header:" \
5065 -c "HTTP/1.0 200 OK"
5066
Janos Follath74537a62016-09-02 13:45:28 +01005067client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005068requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005069run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005070 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005071 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005072 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005073 debug_level=2 nbio=2" \
5074 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005075 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005076 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5077 0 \
5078 -c "=> renegotiate" \
5079 -s "=> renegotiate" \
5080 -s "Extra-header:" \
5081 -c "HTTP/1.0 200 OK"
5082
Janos Follath74537a62016-09-02 13:45:28 +01005083client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005084not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005085run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005086 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5087 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005088 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005089 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005090 -c "HTTP/1.0 200 OK"
5091
Janos Follath74537a62016-09-02 13:45:28 +01005092client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005093not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005094run_test "DTLS proxy: 3d, openssl server, fragmentation" \
5095 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5096 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005097 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005098 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005099 -c "HTTP/1.0 200 OK"
5100
Janos Follath74537a62016-09-02 13:45:28 +01005101client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005102not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005103run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
5104 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5105 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005106 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005107 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005108 -c "HTTP/1.0 200 OK"
5109
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005110requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005111client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005112not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005113run_test "DTLS proxy: 3d, gnutls server" \
5114 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5115 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005116 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005117 0 \
5118 -s "Extra-header:" \
5119 -c "Extra-header:"
5120
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005121requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005122client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005123not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005124run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
5125 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5126 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005127 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005128 0 \
5129 -s "Extra-header:" \
5130 -c "Extra-header:"
5131
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005132requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005133client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005134not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005135run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
5136 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5137 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005138 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005139 0 \
5140 -s "Extra-header:" \
5141 -c "Extra-header:"
5142
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01005143# Final report
5144
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005145echo "------------------------------------------------------------------------"
5146
5147if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005148 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005149else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005150 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005151fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02005152PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02005153echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005154
5155exit $FAILS