blob: 0f6153565c6ab97b3f607b986f76874cc6da3280 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Angus Grattonc4dd0732018-04-11 16:28:39 +100024if cd $( dirname $0 ); then :; else
25 echo "cd $( dirname $0 ) failed" >&2
26 exit 1
27fi
28
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010029# default values, can be overriden by the environment
30: ${P_SRV:=../programs/ssl/ssl_server2}
31: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020032: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010033: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020034: ${GNUTLS_CLI:=gnutls-cli}
35: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020036: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010037
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020038O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010039O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020040G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010041G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020042TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010043
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010044TESTS=0
45FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020046SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010047
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000048CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020049
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010050MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010051FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020052EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053
Paul Bakkere20310a2016-05-10 11:18:17 +010054SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010055RUN_TEST_NUMBER=''
56
Paul Bakkeracaac852016-05-10 11:47:13 +010057PRESERVE_LOGS=0
58
Gilles Peskinef93c7d32017-04-14 17:55:28 +020059# Pick a "unique" server port in the range 10000-19999, and a proxy
60# port which is this plus 10000. Each port number may be independently
61# overridden by a command line option.
62SRV_PORT=$(($$ % 10000 + 10000))
63PXY_PORT=$((SRV_PORT + 10000))
64
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010065print_usage() {
66 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010067 printf " -h|--help\tPrint this help.\n"
68 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
70 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010071 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010072 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010073 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020074 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
75 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010076 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010077}
78
79get_options() {
80 while [ $# -gt 0 ]; do
81 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010082 -f|--filter)
83 shift; FILTER=$1
84 ;;
85 -e|--exclude)
86 shift; EXCLUDE=$1
87 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010088 -m|--memcheck)
89 MEMCHECK=1
90 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010091 -n|--number)
92 shift; RUN_TEST_NUMBER=$1
93 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010094 -s|--show-numbers)
95 SHOW_TEST_NUMBER=1
96 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010097 -p|--preserve-logs)
98 PRESERVE_LOGS=1
99 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200100 --port)
101 shift; SRV_PORT=$1
102 ;;
103 --proxy-port)
104 shift; PXY_PORT=$1
105 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100106 --seed)
107 shift; SEED="$1"
108 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100109 -h|--help)
110 print_usage
111 exit 0
112 ;;
113 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200114 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100115 print_usage
116 exit 1
117 ;;
118 esac
119 shift
120 done
121}
122
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100123# skip next test if the flag is not enabled in config.h
124requires_config_enabled() {
125 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
126 SKIP_NEXT="YES"
127 fi
128}
129
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200130# skip next test if the flag is enabled in config.h
131requires_config_disabled() {
132 if grep "^#define $1" $CONFIG_H > /dev/null; then
133 SKIP_NEXT="YES"
134 fi
135}
136
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200137# skip next test if OpenSSL doesn't support FALLBACK_SCSV
138requires_openssl_with_fallback_scsv() {
139 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
140 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
141 then
142 OPENSSL_HAS_FBSCSV="YES"
143 else
144 OPENSSL_HAS_FBSCSV="NO"
145 fi
146 fi
147 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
148 SKIP_NEXT="YES"
149 fi
150}
151
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200152# skip next test if GnuTLS isn't available
153requires_gnutls() {
154 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200155 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200156 GNUTLS_AVAILABLE="YES"
157 else
158 GNUTLS_AVAILABLE="NO"
159 fi
160 fi
161 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
162 SKIP_NEXT="YES"
163 fi
164}
165
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200166# skip next test if IPv6 isn't available on this host
167requires_ipv6() {
168 if [ -z "${HAS_IPV6:-}" ]; then
169 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
170 SRV_PID=$!
171 sleep 1
172 kill $SRV_PID >/dev/null 2>&1
173 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
174 HAS_IPV6="NO"
175 else
176 HAS_IPV6="YES"
177 fi
178 rm -r $SRV_OUT
179 fi
180
181 if [ "$HAS_IPV6" = "NO" ]; then
182 SKIP_NEXT="YES"
183 fi
184}
185
Angus Grattonc4dd0732018-04-11 16:28:39 +1000186# Calculate the input & output maximum content lengths set in the config
187MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
188MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
189MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
190
191if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
192 MAX_CONTENT_LEN="$MAX_IN_LEN"
193fi
194if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
195 MAX_CONTENT_LEN="$MAX_OUT_LEN"
196fi
197
198# skip the next test if the SSL output buffer is less than 16KB
199requires_full_size_output_buffer() {
200 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
201 SKIP_NEXT="YES"
202 fi
203}
204
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200205# skip the next test if valgrind is in use
206not_with_valgrind() {
207 if [ "$MEMCHECK" -gt 0 ]; then
208 SKIP_NEXT="YES"
209 fi
210}
211
Paul Bakker362689d2016-05-13 10:33:25 +0100212# skip the next test if valgrind is NOT in use
213only_with_valgrind() {
214 if [ "$MEMCHECK" -eq 0 ]; then
215 SKIP_NEXT="YES"
216 fi
217}
218
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200219# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100220client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200221 CLI_DELAY_FACTOR=$1
222}
223
Janos Follath74537a62016-09-02 13:45:28 +0100224# wait for the given seconds after the client finished in the next test
225server_needs_more_time() {
226 SRV_DELAY_SECONDS=$1
227}
228
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100229# print_name <name>
230print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100231 TESTS=$(( $TESTS + 1 ))
232 LINE=""
233
234 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
235 LINE="$TESTS "
236 fi
237
238 LINE="$LINE$1"
239 printf "$LINE "
240 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100241 for i in `seq 1 $LEN`; do printf '.'; done
242 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100243
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100244}
245
246# fail <message>
247fail() {
248 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100249 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100250
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200251 mv $SRV_OUT o-srv-${TESTS}.log
252 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200253 if [ -n "$PXY_CMD" ]; then
254 mv $PXY_OUT o-pxy-${TESTS}.log
255 fi
256 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100257
Azim Khan19d13732018-03-29 11:04:20 +0100258 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot -o "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200259 echo " ! server output:"
260 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200261 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200262 echo " ! client output:"
263 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200264 if [ -n "$PXY_CMD" ]; then
265 echo " ! ========================================================"
266 echo " ! proxy output:"
267 cat o-pxy-${TESTS}.log
268 fi
269 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200270 fi
271
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200272 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100273}
274
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100275# is_polar <cmd_line>
276is_polar() {
277 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
278}
279
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200280# openssl s_server doesn't have -www with DTLS
281check_osrv_dtls() {
282 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
283 NEEDS_INPUT=1
284 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
285 else
286 NEEDS_INPUT=0
287 fi
288}
289
290# provide input to commands that need it
291provide_input() {
292 if [ $NEEDS_INPUT -eq 0 ]; then
293 return
294 fi
295
296 while true; do
297 echo "HTTP/1.0 200 OK"
298 sleep 1
299 done
300}
301
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100302# has_mem_err <log_file_name>
303has_mem_err() {
304 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
305 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
306 then
307 return 1 # false: does not have errors
308 else
309 return 0 # true: has errors
310 fi
311}
312
Gilles Peskine418b5362017-12-14 18:58:42 +0100313# Wait for process $2 to be listening on port $1
314if type lsof >/dev/null 2>/dev/null; then
315 wait_server_start() {
316 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200317 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100318 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200319 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100320 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200321 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100322 # Make a tight loop, server normally takes less than 1s to start.
323 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
324 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
325 echo "SERVERSTART TIMEOUT"
326 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
327 break
328 fi
329 # Linux and *BSD support decimal arguments to sleep. On other
330 # OSes this may be a tight loop.
331 sleep 0.1 2>/dev/null || true
332 done
333 }
334else
Gilles Peskinea9312652018-06-29 15:48:13 +0200335 echo "Warning: lsof not available, wait_server_start = sleep"
Gilles Peskine418b5362017-12-14 18:58:42 +0100336 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200337 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100338 }
339fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200340
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100341# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100342# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100343# acceptable bounds
344check_server_hello_time() {
345 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100346 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100347 # Get the Unix timestamp for now
348 CUR_TIME=$(date +'%s')
349 THRESHOLD_IN_SECS=300
350
351 # Check if the ServerHello time was printed
352 if [ -z "$SERVER_HELLO_TIME" ]; then
353 return 1
354 fi
355
356 # Check the time in ServerHello is within acceptable bounds
357 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
358 # The time in ServerHello is at least 5 minutes before now
359 return 1
360 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100361 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100362 return 1
363 else
364 return 0
365 fi
366}
367
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200368# wait for client to terminate and set CLI_EXIT
369# must be called right after starting the client
370wait_client_done() {
371 CLI_PID=$!
372
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200373 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
374 CLI_DELAY_FACTOR=1
375
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200376 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200377 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200378
379 wait $CLI_PID
380 CLI_EXIT=$?
381
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200382 kill $DOG_PID >/dev/null 2>&1
383 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200384
385 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100386
387 sleep $SRV_DELAY_SECONDS
388 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200389}
390
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200391# check if the given command uses dtls and sets global variable DTLS
392detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200393 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200394 DTLS=1
395 else
396 DTLS=0
397 fi
398}
399
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200400# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100401# Options: -s pattern pattern that must be present in server output
402# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100403# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100404# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100405# -S pattern pattern that must be absent in server output
406# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100407# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100408# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100409run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100410 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200411 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100412
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100413 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
414 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200415 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100416 return
417 fi
418
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100419 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100420
Paul Bakkerb7584a52016-05-10 10:50:43 +0100421 # Do we only run numbered tests?
422 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
423 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
424 else
425 SKIP_NEXT="YES"
426 fi
427
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200428 # should we skip?
429 if [ "X$SKIP_NEXT" = "XYES" ]; then
430 SKIP_NEXT="NO"
431 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200432 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200433 return
434 fi
435
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200436 # does this test use a proxy?
437 if [ "X$1" = "X-p" ]; then
438 PXY_CMD="$2"
439 shift 2
440 else
441 PXY_CMD=""
442 fi
443
444 # get commands and client output
445 SRV_CMD="$1"
446 CLI_CMD="$2"
447 CLI_EXPECT="$3"
448 shift 3
449
450 # fix client port
451 if [ -n "$PXY_CMD" ]; then
452 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
453 else
454 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
455 fi
456
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200457 # update DTLS variable
458 detect_dtls "$SRV_CMD"
459
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100460 # prepend valgrind to our commands if active
461 if [ "$MEMCHECK" -gt 0 ]; then
462 if is_polar "$SRV_CMD"; then
463 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
464 fi
465 if is_polar "$CLI_CMD"; then
466 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
467 fi
468 fi
469
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200470 TIMES_LEFT=2
471 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200472 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200473
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200474 # run the commands
475 if [ -n "$PXY_CMD" ]; then
476 echo "$PXY_CMD" > $PXY_OUT
477 $PXY_CMD >> $PXY_OUT 2>&1 &
478 PXY_PID=$!
479 # assume proxy starts faster than server
480 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200481
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200482 check_osrv_dtls
483 echo "$SRV_CMD" > $SRV_OUT
484 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
485 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100486 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200487
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200488 echo "$CLI_CMD" > $CLI_OUT
489 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
490 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100491
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100492 sleep 0.05
493
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200494 # terminate the server (and the proxy)
495 kill $SRV_PID
496 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100497
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200498 if [ -n "$PXY_CMD" ]; then
499 kill $PXY_PID >/dev/null 2>&1
500 wait $PXY_PID
501 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100502
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200503 # retry only on timeouts
504 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
505 printf "RETRY "
506 else
507 TIMES_LEFT=0
508 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200509 done
510
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100511 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200512 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100513 # expected client exit to incorrectly succeed in case of catastrophic
514 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100515 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200516 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100517 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100518 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100519 return
520 fi
521 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100522 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200523 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100524 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100525 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100526 return
527 fi
528 fi
529
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100530 # check server exit code
531 if [ $? != 0 ]; then
532 fail "server fail"
533 return
534 fi
535
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100536 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100537 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
538 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100539 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200540 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100541 return
542 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100543
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100544 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200545 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100546 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100547 while [ $# -gt 0 ]
548 do
549 case $1 in
550 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100551 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100552 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100553 return
554 fi
555 ;;
556
557 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100558 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100559 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100560 return
561 fi
562 ;;
563
564 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100565 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100566 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100567 return
568 fi
569 ;;
570
571 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100572 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100573 fail "pattern '$2' MUST NOT be present in the Client output"
574 return
575 fi
576 ;;
577
578 # The filtering in the following two options (-u and -U) do the following
579 # - ignore valgrind output
580 # - filter out everything but lines right after the pattern occurances
581 # - keep one of each non-unique line
582 # - count how many lines remain
583 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
584 # if there were no duplicates.
585 "-U")
586 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
587 fail "lines following pattern '$2' must be unique in Server output"
588 return
589 fi
590 ;;
591
592 "-u")
593 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
594 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100595 return
596 fi
597 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100598 "-F")
599 if ! $2 "$SRV_OUT"; then
600 fail "function call to '$2' failed on Server output"
601 return
602 fi
603 ;;
604 "-f")
605 if ! $2 "$CLI_OUT"; then
606 fail "function call to '$2' failed on Client output"
607 return
608 fi
609 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100610
611 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200612 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100613 exit 1
614 esac
615 shift 2
616 done
617
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100618 # check valgrind's results
619 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200620 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100621 fail "Server has memory errors"
622 return
623 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200624 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100625 fail "Client has memory errors"
626 return
627 fi
628 fi
629
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100630 # if we're here, everything is ok
631 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100632 if [ "$PRESERVE_LOGS" -gt 0 ]; then
633 mv $SRV_OUT o-srv-${TESTS}.log
634 mv $CLI_OUT o-cli-${TESTS}.log
635 fi
636
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200637 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100638}
639
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100640cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200641 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200642 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
643 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
644 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
645 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100646 exit 1
647}
648
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100649#
650# MAIN
651#
652
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100653get_options "$@"
654
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100655# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100656P_SRV_BIN="${P_SRV%%[ ]*}"
657P_CLI_BIN="${P_CLI%%[ ]*}"
658P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100659if [ ! -x "$P_SRV_BIN" ]; then
660 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100661 exit 1
662fi
Hanno Becker17c04932017-10-10 14:44:53 +0100663if [ ! -x "$P_CLI_BIN" ]; then
664 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100665 exit 1
666fi
Hanno Becker17c04932017-10-10 14:44:53 +0100667if [ ! -x "$P_PXY_BIN" ]; then
668 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200669 exit 1
670fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100671if [ "$MEMCHECK" -gt 0 ]; then
672 if which valgrind >/dev/null 2>&1; then :; else
673 echo "Memcheck not possible. Valgrind not found"
674 exit 1
675 fi
676fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100677if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
678 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100679 exit 1
680fi
681
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200682# used by watchdog
683MAIN_PID="$$"
684
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100685# We use somewhat arbitrary delays for tests:
686# - how long do we wait for the server to start (when lsof not available)?
687# - how long do we allow for the client to finish?
688# (not to check performance, just to avoid waiting indefinitely)
689# Things are slower with valgrind, so give extra time here.
690#
691# Note: without lsof, there is a trade-off between the running time of this
692# script and the risk of spurious errors because we didn't wait long enough.
693# The watchdog delay on the other hand doesn't affect normal running time of
694# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200695if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100696 START_DELAY=6
697 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200698else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100699 START_DELAY=2
700 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200701fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100702
703# some particular tests need more time:
704# - for the client, we multiply the usual watchdog limit by a factor
705# - for the server, we sleep for a number of seconds after the client exits
706# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200707CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100708SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200709
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200710# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000711# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200712P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
713P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100714P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200715O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200716O_CLI="$O_CLI -connect localhost:+SRV_PORT"
717G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000718G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200719
Gilles Peskine62469d92017-05-10 10:13:59 +0200720# Allow SHA-1, because many of our test certificates use it
721P_SRV="$P_SRV allow_sha1=1"
722P_CLI="$P_CLI allow_sha1=1"
723
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200724# Also pick a unique name for intermediate files
725SRV_OUT="srv_out.$$"
726CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200727PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200728SESSION="session.$$"
729
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200730SKIP_NEXT="NO"
731
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100732trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100733
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200734# Basic test
735
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200736# Checks that:
737# - things work with all ciphersuites active (used with config-full in all.sh)
738# - the expected (highest security) parameters are selected
739# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200740run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200741 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200742 "$P_CLI" \
743 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200744 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200745 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200746 -s "client hello v3, signature_algorithm ext: 6" \
747 -s "ECDHE curve: secp521r1" \
748 -S "error" \
749 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200750
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000751run_test "Default, DTLS" \
752 "$P_SRV dtls=1" \
753 "$P_CLI dtls=1" \
754 0 \
755 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200756 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000757
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100758# Test current time in ServerHello
759requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200760run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100761 "$P_SRV debug_level=3" \
762 "$P_CLI debug_level=3" \
763 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100764 -f "check_server_hello_time" \
765 -F "check_server_hello_time"
766
Simon Butcher8e004102016-10-14 00:48:33 +0100767# Test for uniqueness of IVs in AEAD ciphersuites
768run_test "Unique IV in GCM" \
769 "$P_SRV exchanges=20 debug_level=4" \
770 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
771 0 \
772 -u "IV used" \
773 -U "IV used"
774
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100775# Tests for rc4 option
776
Simon Butchera410af52016-05-19 22:12:18 +0100777requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100778run_test "RC4: server disabled, client enabled" \
779 "$P_SRV" \
780 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
781 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100782 -s "SSL - The server has no ciphersuites in common"
783
Simon Butchera410af52016-05-19 22:12:18 +0100784requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100785run_test "RC4: server half, client enabled" \
786 "$P_SRV arc4=1" \
787 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
788 1 \
789 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100790
791run_test "RC4: server enabled, client disabled" \
792 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
793 "$P_CLI" \
794 1 \
795 -s "SSL - The server has no ciphersuites in common"
796
797run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100798 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100799 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
800 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100801 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100802 -S "SSL - The server has no ciphersuites in common"
803
Gilles Peskinebc70a182017-05-09 15:59:24 +0200804# Tests for SHA-1 support
805
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200806requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200807run_test "SHA-1 forbidden by default in server certificate" \
808 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
809 "$P_CLI debug_level=2 allow_sha1=0" \
810 1 \
811 -c "The certificate is signed with an unacceptable hash"
812
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200813requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
814run_test "SHA-1 forbidden by default in server certificate" \
815 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
816 "$P_CLI debug_level=2 allow_sha1=0" \
817 0
818
Gilles Peskinebc70a182017-05-09 15:59:24 +0200819run_test "SHA-1 explicitly allowed in server certificate" \
820 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
821 "$P_CLI allow_sha1=1" \
822 0
823
824run_test "SHA-256 allowed by default in server certificate" \
825 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
826 "$P_CLI allow_sha1=0" \
827 0
828
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200829requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200830run_test "SHA-1 forbidden by default in client certificate" \
831 "$P_SRV auth_mode=required allow_sha1=0" \
832 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
833 1 \
834 -s "The certificate is signed with an unacceptable hash"
835
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200836requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
837run_test "SHA-1 forbidden by default in client certificate" \
838 "$P_SRV auth_mode=required allow_sha1=0" \
839 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
840 0
841
Gilles Peskinebc70a182017-05-09 15:59:24 +0200842run_test "SHA-1 explicitly allowed in client certificate" \
843 "$P_SRV auth_mode=required allow_sha1=1" \
844 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
845 0
846
847run_test "SHA-256 allowed by default in client certificate" \
848 "$P_SRV auth_mode=required allow_sha1=0" \
849 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
850 0
851
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100852# Tests for Truncated HMAC extension
853
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100854run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200855 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100856 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100857 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000858 -s "dumping 'expected mac' (20 bytes)" \
859 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100860
Hanno Becker32c55012017-11-10 08:42:54 +0000861requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100862run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200863 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000864 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100865 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000866 -s "dumping 'expected mac' (20 bytes)" \
867 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100868
Hanno Becker32c55012017-11-10 08:42:54 +0000869requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100870run_test "Truncated HMAC: client enabled, server default" \
871 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000872 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100873 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000874 -s "dumping 'expected mac' (20 bytes)" \
875 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100876
Hanno Becker32c55012017-11-10 08:42:54 +0000877requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100878run_test "Truncated HMAC: client enabled, server disabled" \
879 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000880 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100881 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000882 -s "dumping 'expected mac' (20 bytes)" \
883 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100884
Hanno Becker32c55012017-11-10 08:42:54 +0000885requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000886run_test "Truncated HMAC: client disabled, server enabled" \
887 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000888 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000889 0 \
890 -s "dumping 'expected mac' (20 bytes)" \
891 -S "dumping 'expected mac' (10 bytes)"
892
893requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100894run_test "Truncated HMAC: client enabled, server enabled" \
895 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000896 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100897 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000898 -S "dumping 'expected mac' (20 bytes)" \
899 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100900
Hanno Becker4c4f4102017-11-10 09:16:05 +0000901run_test "Truncated HMAC, DTLS: client default, server default" \
902 "$P_SRV dtls=1 debug_level=4" \
903 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
904 0 \
905 -s "dumping 'expected mac' (20 bytes)" \
906 -S "dumping 'expected mac' (10 bytes)"
907
908requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
909run_test "Truncated HMAC, DTLS: client disabled, server default" \
910 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000911 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000912 0 \
913 -s "dumping 'expected mac' (20 bytes)" \
914 -S "dumping 'expected mac' (10 bytes)"
915
916requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
917run_test "Truncated HMAC, DTLS: client enabled, server default" \
918 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000919 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000920 0 \
921 -s "dumping 'expected mac' (20 bytes)" \
922 -S "dumping 'expected mac' (10 bytes)"
923
924requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
925run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
926 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000927 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000928 0 \
929 -s "dumping 'expected mac' (20 bytes)" \
930 -S "dumping 'expected mac' (10 bytes)"
931
932requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
933run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
934 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000935 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000936 0 \
937 -s "dumping 'expected mac' (20 bytes)" \
938 -S "dumping 'expected mac' (10 bytes)"
939
940requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
941run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
942 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000943 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100944 0 \
945 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100946 -s "dumping 'expected mac' (10 bytes)"
947
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100948# Tests for Encrypt-then-MAC extension
949
950run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100951 "$P_SRV debug_level=3 \
952 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100953 "$P_CLI debug_level=3" \
954 0 \
955 -c "client hello, adding encrypt_then_mac extension" \
956 -s "found encrypt then mac extension" \
957 -s "server hello, adding encrypt then mac extension" \
958 -c "found encrypt_then_mac extension" \
959 -c "using encrypt then mac" \
960 -s "using encrypt then mac"
961
962run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100963 "$P_SRV debug_level=3 etm=0 \
964 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100965 "$P_CLI debug_level=3 etm=1" \
966 0 \
967 -c "client hello, adding encrypt_then_mac extension" \
968 -s "found encrypt then mac extension" \
969 -S "server hello, adding encrypt then mac extension" \
970 -C "found encrypt_then_mac extension" \
971 -C "using encrypt then mac" \
972 -S "using encrypt then mac"
973
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100974run_test "Encrypt then MAC: client enabled, aead cipher" \
975 "$P_SRV debug_level=3 etm=1 \
976 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
977 "$P_CLI debug_level=3 etm=1" \
978 0 \
979 -c "client hello, adding encrypt_then_mac extension" \
980 -s "found encrypt then mac extension" \
981 -S "server hello, adding encrypt then mac extension" \
982 -C "found encrypt_then_mac extension" \
983 -C "using encrypt then mac" \
984 -S "using encrypt then mac"
985
986run_test "Encrypt then MAC: client enabled, stream cipher" \
987 "$P_SRV debug_level=3 etm=1 \
988 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100989 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100990 0 \
991 -c "client hello, adding encrypt_then_mac extension" \
992 -s "found encrypt then mac extension" \
993 -S "server hello, adding encrypt then mac extension" \
994 -C "found encrypt_then_mac extension" \
995 -C "using encrypt then mac" \
996 -S "using encrypt then mac"
997
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100998run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100999 "$P_SRV debug_level=3 etm=1 \
1000 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001001 "$P_CLI debug_level=3 etm=0" \
1002 0 \
1003 -C "client hello, adding encrypt_then_mac extension" \
1004 -S "found encrypt then mac extension" \
1005 -S "server hello, adding encrypt then mac extension" \
1006 -C "found encrypt_then_mac extension" \
1007 -C "using encrypt then mac" \
1008 -S "using encrypt then mac"
1009
Janos Follathe2681a42016-03-07 15:57:05 +00001010requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001011run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001012 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001013 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001014 "$P_CLI debug_level=3 force_version=ssl3" \
1015 0 \
1016 -C "client hello, adding encrypt_then_mac extension" \
1017 -S "found encrypt then mac extension" \
1018 -S "server hello, adding encrypt then mac extension" \
1019 -C "found encrypt_then_mac extension" \
1020 -C "using encrypt then mac" \
1021 -S "using encrypt then mac"
1022
Janos Follathe2681a42016-03-07 15:57:05 +00001023requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001024run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001025 "$P_SRV debug_level=3 force_version=ssl3 \
1026 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001027 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001028 0 \
1029 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001030 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001031 -S "server hello, adding encrypt then mac extension" \
1032 -C "found encrypt_then_mac extension" \
1033 -C "using encrypt then mac" \
1034 -S "using encrypt then mac"
1035
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001036# Tests for Extended Master Secret extension
1037
1038run_test "Extended Master Secret: default" \
1039 "$P_SRV debug_level=3" \
1040 "$P_CLI debug_level=3" \
1041 0 \
1042 -c "client hello, adding extended_master_secret extension" \
1043 -s "found extended master secret extension" \
1044 -s "server hello, adding extended master secret extension" \
1045 -c "found extended_master_secret extension" \
1046 -c "using extended master secret" \
1047 -s "using extended master secret"
1048
1049run_test "Extended Master Secret: client enabled, server disabled" \
1050 "$P_SRV debug_level=3 extended_ms=0" \
1051 "$P_CLI debug_level=3 extended_ms=1" \
1052 0 \
1053 -c "client hello, adding extended_master_secret extension" \
1054 -s "found extended master secret extension" \
1055 -S "server hello, adding extended master secret extension" \
1056 -C "found extended_master_secret extension" \
1057 -C "using extended master secret" \
1058 -S "using extended master secret"
1059
1060run_test "Extended Master Secret: client disabled, server enabled" \
1061 "$P_SRV debug_level=3 extended_ms=1" \
1062 "$P_CLI debug_level=3 extended_ms=0" \
1063 0 \
1064 -C "client hello, adding extended_master_secret extension" \
1065 -S "found extended master secret extension" \
1066 -S "server hello, adding extended master secret extension" \
1067 -C "found extended_master_secret extension" \
1068 -C "using extended master secret" \
1069 -S "using extended master secret"
1070
Janos Follathe2681a42016-03-07 15:57:05 +00001071requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001072run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001073 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001074 "$P_CLI debug_level=3 force_version=ssl3" \
1075 0 \
1076 -C "client hello, adding extended_master_secret extension" \
1077 -S "found extended master secret extension" \
1078 -S "server hello, adding extended master secret extension" \
1079 -C "found extended_master_secret extension" \
1080 -C "using extended master secret" \
1081 -S "using extended master secret"
1082
Janos Follathe2681a42016-03-07 15:57:05 +00001083requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001084run_test "Extended Master Secret: client enabled, server SSLv3" \
1085 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001086 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001087 0 \
1088 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001089 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001090 -S "server hello, adding extended master secret extension" \
1091 -C "found extended_master_secret extension" \
1092 -C "using extended master secret" \
1093 -S "using extended master secret"
1094
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001095# Tests for FALLBACK_SCSV
1096
1097run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001098 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001099 "$P_CLI debug_level=3 force_version=tls1_1" \
1100 0 \
1101 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001102 -S "received FALLBACK_SCSV" \
1103 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001104 -C "is a fatal alert message (msg 86)"
1105
1106run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001107 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001108 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1109 0 \
1110 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001111 -S "received FALLBACK_SCSV" \
1112 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001113 -C "is a fatal alert message (msg 86)"
1114
1115run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001116 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001117 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001118 1 \
1119 -c "adding FALLBACK_SCSV" \
1120 -s "received FALLBACK_SCSV" \
1121 -s "inapropriate fallback" \
1122 -c "is a fatal alert message (msg 86)"
1123
1124run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001125 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001126 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001127 0 \
1128 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001129 -s "received FALLBACK_SCSV" \
1130 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001131 -C "is a fatal alert message (msg 86)"
1132
1133requires_openssl_with_fallback_scsv
1134run_test "Fallback SCSV: default, openssl server" \
1135 "$O_SRV" \
1136 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1137 0 \
1138 -C "adding FALLBACK_SCSV" \
1139 -C "is a fatal alert message (msg 86)"
1140
1141requires_openssl_with_fallback_scsv
1142run_test "Fallback SCSV: enabled, openssl server" \
1143 "$O_SRV" \
1144 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1145 1 \
1146 -c "adding FALLBACK_SCSV" \
1147 -c "is a fatal alert message (msg 86)"
1148
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001149requires_openssl_with_fallback_scsv
1150run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001151 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001152 "$O_CLI -tls1_1" \
1153 0 \
1154 -S "received FALLBACK_SCSV" \
1155 -S "inapropriate fallback"
1156
1157requires_openssl_with_fallback_scsv
1158run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001159 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001160 "$O_CLI -tls1_1 -fallback_scsv" \
1161 1 \
1162 -s "received FALLBACK_SCSV" \
1163 -s "inapropriate fallback"
1164
1165requires_openssl_with_fallback_scsv
1166run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001167 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001168 "$O_CLI -fallback_scsv" \
1169 0 \
1170 -s "received FALLBACK_SCSV" \
1171 -S "inapropriate fallback"
1172
Gilles Peskined50177f2017-05-16 17:53:03 +02001173## ClientHello generated with
1174## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1175## then manually twiddling the ciphersuite list.
1176## The ClientHello content is spelled out below as a hex string as
1177## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1178## The expected response is an inappropriate_fallback alert.
1179requires_openssl_with_fallback_scsv
1180run_test "Fallback SCSV: beginning of list" \
1181 "$P_SRV debug_level=2" \
1182 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1183 0 \
1184 -s "received FALLBACK_SCSV" \
1185 -s "inapropriate fallback"
1186
1187requires_openssl_with_fallback_scsv
1188run_test "Fallback SCSV: end of list" \
1189 "$P_SRV debug_level=2" \
1190 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1191 0 \
1192 -s "received FALLBACK_SCSV" \
1193 -s "inapropriate fallback"
1194
1195## Here the expected response is a valid ServerHello prefix, up to the random.
1196requires_openssl_with_fallback_scsv
1197run_test "Fallback SCSV: not in list" \
1198 "$P_SRV debug_level=2" \
1199 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1200 0 \
1201 -S "received FALLBACK_SCSV" \
1202 -S "inapropriate fallback"
1203
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001204# Tests for CBC 1/n-1 record splitting
1205
1206run_test "CBC Record splitting: TLS 1.2, no splitting" \
1207 "$P_SRV" \
1208 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1209 request_size=123 force_version=tls1_2" \
1210 0 \
1211 -s "Read from client: 123 bytes read" \
1212 -S "Read from client: 1 bytes read" \
1213 -S "122 bytes read"
1214
1215run_test "CBC Record splitting: TLS 1.1, no splitting" \
1216 "$P_SRV" \
1217 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1218 request_size=123 force_version=tls1_1" \
1219 0 \
1220 -s "Read from client: 123 bytes read" \
1221 -S "Read from client: 1 bytes read" \
1222 -S "122 bytes read"
1223
1224run_test "CBC Record splitting: TLS 1.0, splitting" \
1225 "$P_SRV" \
1226 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1227 request_size=123 force_version=tls1" \
1228 0 \
1229 -S "Read from client: 123 bytes read" \
1230 -s "Read from client: 1 bytes read" \
1231 -s "122 bytes read"
1232
Janos Follathe2681a42016-03-07 15:57:05 +00001233requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001234run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001235 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001236 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1237 request_size=123 force_version=ssl3" \
1238 0 \
1239 -S "Read from client: 123 bytes read" \
1240 -s "Read from client: 1 bytes read" \
1241 -s "122 bytes read"
1242
1243run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001244 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001245 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1246 request_size=123 force_version=tls1" \
1247 0 \
1248 -s "Read from client: 123 bytes read" \
1249 -S "Read from client: 1 bytes read" \
1250 -S "122 bytes read"
1251
1252run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1253 "$P_SRV" \
1254 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1255 request_size=123 force_version=tls1 recsplit=0" \
1256 0 \
1257 -s "Read from client: 123 bytes read" \
1258 -S "Read from client: 1 bytes read" \
1259 -S "122 bytes read"
1260
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001261run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1262 "$P_SRV nbio=2" \
1263 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1264 request_size=123 force_version=tls1" \
1265 0 \
1266 -S "Read from client: 123 bytes read" \
1267 -s "Read from client: 1 bytes read" \
1268 -s "122 bytes read"
1269
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001270# Tests for Session Tickets
1271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001272run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001273 "$P_SRV debug_level=3 tickets=1" \
1274 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001275 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001276 -c "client hello, adding session ticket extension" \
1277 -s "found session ticket extension" \
1278 -s "server hello, adding session ticket extension" \
1279 -c "found session_ticket extension" \
1280 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001281 -S "session successfully restored from cache" \
1282 -s "session successfully restored from ticket" \
1283 -s "a session has been resumed" \
1284 -c "a session has been resumed"
1285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001286run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001287 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1288 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001289 0 \
1290 -c "client hello, adding session ticket extension" \
1291 -s "found session ticket extension" \
1292 -s "server hello, adding session ticket extension" \
1293 -c "found session_ticket extension" \
1294 -c "parse new session ticket" \
1295 -S "session successfully restored from cache" \
1296 -s "session successfully restored from ticket" \
1297 -s "a session has been resumed" \
1298 -c "a session has been resumed"
1299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001300run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001301 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1302 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001303 0 \
1304 -c "client hello, adding session ticket extension" \
1305 -s "found session ticket extension" \
1306 -s "server hello, adding session ticket extension" \
1307 -c "found session_ticket extension" \
1308 -c "parse new session ticket" \
1309 -S "session successfully restored from cache" \
1310 -S "session successfully restored from ticket" \
1311 -S "a session has been resumed" \
1312 -C "a session has been resumed"
1313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001314run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001315 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001316 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001317 0 \
1318 -c "client hello, adding session ticket extension" \
1319 -c "found session_ticket extension" \
1320 -c "parse new session ticket" \
1321 -c "a session has been resumed"
1322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001323run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001324 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001325 "( $O_CLI -sess_out $SESSION; \
1326 $O_CLI -sess_in $SESSION; \
1327 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001328 0 \
1329 -s "found session ticket extension" \
1330 -s "server hello, adding session ticket extension" \
1331 -S "session successfully restored from cache" \
1332 -s "session successfully restored from ticket" \
1333 -s "a session has been resumed"
1334
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001335# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001337run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001338 "$P_SRV debug_level=3 tickets=0" \
1339 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001340 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001341 -c "client hello, adding session ticket extension" \
1342 -s "found session ticket extension" \
1343 -S "server hello, adding session ticket extension" \
1344 -C "found session_ticket extension" \
1345 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001346 -s "session successfully restored from cache" \
1347 -S "session successfully restored from ticket" \
1348 -s "a session has been resumed" \
1349 -c "a session has been resumed"
1350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001351run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001352 "$P_SRV debug_level=3 tickets=1" \
1353 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001354 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001355 -C "client hello, adding session ticket extension" \
1356 -S "found session ticket extension" \
1357 -S "server hello, adding session ticket extension" \
1358 -C "found session_ticket extension" \
1359 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001360 -s "session successfully restored from cache" \
1361 -S "session successfully restored from ticket" \
1362 -s "a session has been resumed" \
1363 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001365run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001366 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1367 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001368 0 \
1369 -S "session successfully restored from cache" \
1370 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001371 -S "a session has been resumed" \
1372 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001373
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001374run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001375 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1376 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001377 0 \
1378 -s "session successfully restored from cache" \
1379 -S "session successfully restored from ticket" \
1380 -s "a session has been resumed" \
1381 -c "a session has been resumed"
1382
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001383run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001384 "$P_SRV debug_level=3 tickets=0" \
1385 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001386 0 \
1387 -s "session successfully restored from cache" \
1388 -S "session successfully restored from ticket" \
1389 -s "a session has been resumed" \
1390 -c "a session has been resumed"
1391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001392run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001393 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1394 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001395 0 \
1396 -S "session successfully restored from cache" \
1397 -S "session successfully restored from ticket" \
1398 -S "a session has been resumed" \
1399 -C "a session has been resumed"
1400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001401run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001402 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1403 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001404 0 \
1405 -s "session successfully restored from cache" \
1406 -S "session successfully restored from ticket" \
1407 -s "a session has been resumed" \
1408 -c "a session has been resumed"
1409
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001410run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001411 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001412 "( $O_CLI -sess_out $SESSION; \
1413 $O_CLI -sess_in $SESSION; \
1414 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001415 0 \
1416 -s "found session ticket extension" \
1417 -S "server hello, adding session ticket extension" \
1418 -s "session successfully restored from cache" \
1419 -S "session successfully restored from ticket" \
1420 -s "a session has been resumed"
1421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001422run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001423 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001424 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001425 0 \
1426 -C "found session_ticket extension" \
1427 -C "parse new session ticket" \
1428 -c "a session has been resumed"
1429
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001430# Tests for Max Fragment Length extension
1431
Angus Grattonc4dd0732018-04-11 16:28:39 +10001432if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
1433 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 +01001434 exit 1
1435fi
1436
Angus Grattonc4dd0732018-04-11 16:28:39 +10001437if [ $MAX_CONTENT_LEN -ne 16384 ]; then
1438 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
1439fi
1440
Hanno Becker4aed27e2017-09-18 15:00:34 +01001441requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001442run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001443 "$P_SRV debug_level=3" \
1444 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001445 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001446 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1447 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001448 -C "client hello, adding max_fragment_length extension" \
1449 -S "found max fragment length extension" \
1450 -S "server hello, max_fragment_length extension" \
1451 -C "found max_fragment_length extension"
1452
Hanno Becker4aed27e2017-09-18 15:00:34 +01001453requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001454run_test "Max fragment length: enabled, default, larger message" \
1455 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001456 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001457 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001458 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1459 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001460 -C "client hello, adding max_fragment_length extension" \
1461 -S "found max fragment length extension" \
1462 -S "server hello, max_fragment_length extension" \
1463 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001464 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1465 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001466 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001467
1468requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1469run_test "Max fragment length, DTLS: enabled, default, larger message" \
1470 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001471 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001472 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001473 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1474 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001475 -C "client hello, adding max_fragment_length extension" \
1476 -S "found max fragment length extension" \
1477 -S "server hello, max_fragment_length extension" \
1478 -C "found max_fragment_length extension" \
1479 -c "fragment larger than.*maximum "
1480
Angus Grattonc4dd0732018-04-11 16:28:39 +10001481# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1482# (session fragment length will be 16384 regardless of mbedtls
1483# content length configuration.)
1484
Hanno Beckerc5266962017-09-18 15:01:50 +01001485requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1486run_test "Max fragment length: disabled, larger message" \
1487 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001488 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001489 0 \
1490 -C "Maximum fragment length is 16384" \
1491 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001492 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1493 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001494 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001495
1496requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1497run_test "Max fragment length DTLS: disabled, larger message" \
1498 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001499 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001500 1 \
1501 -C "Maximum fragment length is 16384" \
1502 -S "Maximum fragment length is 16384" \
1503 -c "fragment larger than.*maximum "
1504
1505requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001506run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001507 "$P_SRV debug_level=3" \
1508 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001509 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001510 -c "Maximum fragment length is 4096" \
1511 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001512 -c "client hello, adding max_fragment_length extension" \
1513 -s "found max fragment length extension" \
1514 -s "server hello, max_fragment_length extension" \
1515 -c "found max_fragment_length extension"
1516
Hanno Becker4aed27e2017-09-18 15:00:34 +01001517requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001518run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001519 "$P_SRV debug_level=3 max_frag_len=4096" \
1520 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001521 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001522 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001523 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001524 -C "client hello, adding max_fragment_length extension" \
1525 -S "found max fragment length extension" \
1526 -S "server hello, max_fragment_length extension" \
1527 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001528
Hanno Becker4aed27e2017-09-18 15:00:34 +01001529requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001530requires_gnutls
1531run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001532 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001533 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001534 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001535 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001536 -c "client hello, adding max_fragment_length extension" \
1537 -c "found max_fragment_length extension"
1538
Hanno Becker4aed27e2017-09-18 15:00:34 +01001539requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001540run_test "Max fragment length: client, message just fits" \
1541 "$P_SRV debug_level=3" \
1542 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1543 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001544 -c "Maximum fragment length is 2048" \
1545 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001546 -c "client hello, adding max_fragment_length extension" \
1547 -s "found max fragment length extension" \
1548 -s "server hello, max_fragment_length extension" \
1549 -c "found max_fragment_length extension" \
1550 -c "2048 bytes written in 1 fragments" \
1551 -s "2048 bytes read"
1552
Hanno Becker4aed27e2017-09-18 15:00:34 +01001553requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001554run_test "Max fragment length: client, larger message" \
1555 "$P_SRV debug_level=3" \
1556 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1557 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001558 -c "Maximum fragment length is 2048" \
1559 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001560 -c "client hello, adding max_fragment_length extension" \
1561 -s "found max fragment length extension" \
1562 -s "server hello, max_fragment_length extension" \
1563 -c "found max_fragment_length extension" \
1564 -c "2345 bytes written in 2 fragments" \
1565 -s "2048 bytes read" \
1566 -s "297 bytes read"
1567
Hanno Becker4aed27e2017-09-18 15:00:34 +01001568requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001569run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001570 "$P_SRV debug_level=3 dtls=1" \
1571 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1572 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001573 -c "Maximum fragment length is 2048" \
1574 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001575 -c "client hello, adding max_fragment_length extension" \
1576 -s "found max fragment length extension" \
1577 -s "server hello, max_fragment_length extension" \
1578 -c "found max_fragment_length extension" \
1579 -c "fragment larger than.*maximum"
1580
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001581# Tests for renegotiation
1582
Hanno Becker6a243642017-10-12 15:18:45 +01001583# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001584run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001585 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001586 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001587 0 \
1588 -C "client hello, adding renegotiation extension" \
1589 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1590 -S "found renegotiation extension" \
1591 -s "server hello, secure renegotiation extension" \
1592 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001593 -C "=> renegotiate" \
1594 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001595 -S "write hello request"
1596
Hanno Becker6a243642017-10-12 15:18:45 +01001597requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001598run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001599 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001600 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001601 0 \
1602 -c "client hello, adding renegotiation extension" \
1603 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1604 -s "found renegotiation extension" \
1605 -s "server hello, secure renegotiation extension" \
1606 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001607 -c "=> renegotiate" \
1608 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001609 -S "write hello request"
1610
Hanno Becker6a243642017-10-12 15:18:45 +01001611requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001612run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001613 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001614 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001615 0 \
1616 -c "client hello, adding renegotiation extension" \
1617 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1618 -s "found renegotiation extension" \
1619 -s "server hello, secure renegotiation extension" \
1620 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001621 -c "=> renegotiate" \
1622 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001623 -s "write hello request"
1624
Janos Follathb0f148c2017-10-05 12:29:42 +01001625# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1626# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1627# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001628requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001629run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1630 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1631 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1632 0 \
1633 -c "client hello, adding renegotiation extension" \
1634 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1635 -s "found renegotiation extension" \
1636 -s "server hello, secure renegotiation extension" \
1637 -c "found renegotiation extension" \
1638 -c "=> renegotiate" \
1639 -s "=> renegotiate" \
1640 -S "write hello request" \
1641 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1642
1643# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1644# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1645# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001646requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001647run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1648 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1649 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1650 0 \
1651 -c "client hello, adding renegotiation extension" \
1652 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1653 -s "found renegotiation extension" \
1654 -s "server hello, secure renegotiation extension" \
1655 -c "found renegotiation extension" \
1656 -c "=> renegotiate" \
1657 -s "=> renegotiate" \
1658 -s "write hello request" \
1659 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1660
Hanno Becker6a243642017-10-12 15:18:45 +01001661requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001662run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001663 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001664 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001665 0 \
1666 -c "client hello, adding renegotiation extension" \
1667 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1668 -s "found renegotiation extension" \
1669 -s "server hello, secure renegotiation extension" \
1670 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001671 -c "=> renegotiate" \
1672 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001673 -s "write hello request"
1674
Hanno Becker6a243642017-10-12 15:18:45 +01001675requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001676run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001677 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001678 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001679 1 \
1680 -c "client hello, adding renegotiation extension" \
1681 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1682 -S "found renegotiation extension" \
1683 -s "server hello, secure renegotiation extension" \
1684 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001685 -c "=> renegotiate" \
1686 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001687 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001688 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001689 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001690
Hanno Becker6a243642017-10-12 15:18:45 +01001691requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001692run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001693 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001694 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001695 0 \
1696 -C "client hello, adding renegotiation extension" \
1697 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1698 -S "found renegotiation extension" \
1699 -s "server hello, secure renegotiation extension" \
1700 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001701 -C "=> renegotiate" \
1702 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001703 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001704 -S "SSL - An unexpected message was received from our peer" \
1705 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001706
Hanno Becker6a243642017-10-12 15:18:45 +01001707requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001708run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001709 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001710 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001711 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001712 0 \
1713 -C "client hello, adding renegotiation extension" \
1714 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1715 -S "found renegotiation extension" \
1716 -s "server hello, secure renegotiation extension" \
1717 -c "found renegotiation extension" \
1718 -C "=> renegotiate" \
1719 -S "=> renegotiate" \
1720 -s "write hello request" \
1721 -S "SSL - An unexpected message was received from our peer" \
1722 -S "failed"
1723
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001724# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001725requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001727 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001728 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001729 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001730 0 \
1731 -C "client hello, adding renegotiation extension" \
1732 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1733 -S "found renegotiation extension" \
1734 -s "server hello, secure renegotiation extension" \
1735 -c "found renegotiation extension" \
1736 -C "=> renegotiate" \
1737 -S "=> renegotiate" \
1738 -s "write hello request" \
1739 -S "SSL - An unexpected message was received from our peer" \
1740 -S "failed"
1741
Hanno Becker6a243642017-10-12 15:18:45 +01001742requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001743run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001744 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001745 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001746 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001747 0 \
1748 -C "client hello, adding renegotiation extension" \
1749 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1750 -S "found renegotiation extension" \
1751 -s "server hello, secure renegotiation extension" \
1752 -c "found renegotiation extension" \
1753 -C "=> renegotiate" \
1754 -S "=> renegotiate" \
1755 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001756 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001757
Hanno Becker6a243642017-10-12 15:18:45 +01001758requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001759run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001760 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001761 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001762 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001763 0 \
1764 -c "client hello, adding renegotiation extension" \
1765 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1766 -s "found renegotiation extension" \
1767 -s "server hello, secure renegotiation extension" \
1768 -c "found renegotiation extension" \
1769 -c "=> renegotiate" \
1770 -s "=> renegotiate" \
1771 -s "write hello request" \
1772 -S "SSL - An unexpected message was received from our peer" \
1773 -S "failed"
1774
Hanno Becker6a243642017-10-12 15:18:45 +01001775requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001776run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001777 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001778 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1779 0 \
1780 -C "client hello, adding renegotiation extension" \
1781 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1782 -S "found renegotiation extension" \
1783 -s "server hello, secure renegotiation extension" \
1784 -c "found renegotiation extension" \
1785 -S "record counter limit reached: renegotiate" \
1786 -C "=> renegotiate" \
1787 -S "=> renegotiate" \
1788 -S "write hello request" \
1789 -S "SSL - An unexpected message was received from our peer" \
1790 -S "failed"
1791
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001792# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001793requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001794run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001795 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001796 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001797 0 \
1798 -c "client hello, adding renegotiation extension" \
1799 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1800 -s "found renegotiation extension" \
1801 -s "server hello, secure renegotiation extension" \
1802 -c "found renegotiation extension" \
1803 -s "record counter limit reached: renegotiate" \
1804 -c "=> renegotiate" \
1805 -s "=> renegotiate" \
1806 -s "write hello request" \
1807 -S "SSL - An unexpected message was received from our peer" \
1808 -S "failed"
1809
Hanno Becker6a243642017-10-12 15:18:45 +01001810requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001811run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001812 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001813 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001814 0 \
1815 -c "client hello, adding renegotiation extension" \
1816 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1817 -s "found renegotiation extension" \
1818 -s "server hello, secure renegotiation extension" \
1819 -c "found renegotiation extension" \
1820 -s "record counter limit reached: renegotiate" \
1821 -c "=> renegotiate" \
1822 -s "=> renegotiate" \
1823 -s "write hello request" \
1824 -S "SSL - An unexpected message was received from our peer" \
1825 -S "failed"
1826
Hanno Becker6a243642017-10-12 15:18:45 +01001827requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001828run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001829 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001830 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1831 0 \
1832 -C "client hello, adding renegotiation extension" \
1833 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1834 -S "found renegotiation extension" \
1835 -s "server hello, secure renegotiation extension" \
1836 -c "found renegotiation extension" \
1837 -S "record counter limit reached: renegotiate" \
1838 -C "=> renegotiate" \
1839 -S "=> renegotiate" \
1840 -S "write hello request" \
1841 -S "SSL - An unexpected message was received from our peer" \
1842 -S "failed"
1843
Hanno Becker6a243642017-10-12 15:18:45 +01001844requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001845run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001846 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001847 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001848 0 \
1849 -c "client hello, adding renegotiation extension" \
1850 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1851 -s "found renegotiation extension" \
1852 -s "server hello, secure renegotiation extension" \
1853 -c "found renegotiation extension" \
1854 -c "=> renegotiate" \
1855 -s "=> renegotiate" \
1856 -S "write hello request"
1857
Hanno Becker6a243642017-10-12 15:18:45 +01001858requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001859run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001860 "$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 +02001861 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001862 0 \
1863 -c "client hello, adding renegotiation extension" \
1864 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1865 -s "found renegotiation extension" \
1866 -s "server hello, secure renegotiation extension" \
1867 -c "found renegotiation extension" \
1868 -c "=> renegotiate" \
1869 -s "=> renegotiate" \
1870 -s "write hello request"
1871
Hanno Becker6a243642017-10-12 15:18:45 +01001872requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001873run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001874 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001875 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001876 0 \
1877 -c "client hello, adding renegotiation extension" \
1878 -c "found renegotiation extension" \
1879 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001880 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001881 -C "error" \
1882 -c "HTTP/1.0 200 [Oo][Kk]"
1883
Paul Bakker539d9722015-02-08 16:18:35 +01001884requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001885requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001886run_test "Renegotiation: gnutls server strict, client-initiated" \
1887 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001888 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001889 0 \
1890 -c "client hello, adding renegotiation extension" \
1891 -c "found renegotiation extension" \
1892 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001893 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001894 -C "error" \
1895 -c "HTTP/1.0 200 [Oo][Kk]"
1896
Paul Bakker539d9722015-02-08 16:18:35 +01001897requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001898requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001899run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1900 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1901 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1902 1 \
1903 -c "client hello, adding renegotiation extension" \
1904 -C "found renegotiation extension" \
1905 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001906 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001907 -c "error" \
1908 -C "HTTP/1.0 200 [Oo][Kk]"
1909
Paul Bakker539d9722015-02-08 16:18:35 +01001910requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001911requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001912run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1913 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1914 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1915 allow_legacy=0" \
1916 1 \
1917 -c "client hello, adding renegotiation extension" \
1918 -C "found renegotiation extension" \
1919 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001920 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001921 -c "error" \
1922 -C "HTTP/1.0 200 [Oo][Kk]"
1923
Paul Bakker539d9722015-02-08 16:18:35 +01001924requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001925requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001926run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1927 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1928 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1929 allow_legacy=1" \
1930 0 \
1931 -c "client hello, adding renegotiation extension" \
1932 -C "found renegotiation extension" \
1933 -c "=> renegotiate" \
1934 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001935 -C "error" \
1936 -c "HTTP/1.0 200 [Oo][Kk]"
1937
Hanno Becker6a243642017-10-12 15:18:45 +01001938requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001939run_test "Renegotiation: DTLS, client-initiated" \
1940 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1941 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1942 0 \
1943 -c "client hello, adding renegotiation extension" \
1944 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1945 -s "found renegotiation extension" \
1946 -s "server hello, secure renegotiation extension" \
1947 -c "found renegotiation extension" \
1948 -c "=> renegotiate" \
1949 -s "=> renegotiate" \
1950 -S "write hello request"
1951
Hanno Becker6a243642017-10-12 15:18:45 +01001952requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001953run_test "Renegotiation: DTLS, server-initiated" \
1954 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001955 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1956 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001957 0 \
1958 -c "client hello, adding renegotiation extension" \
1959 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1960 -s "found renegotiation extension" \
1961 -s "server hello, secure renegotiation extension" \
1962 -c "found renegotiation extension" \
1963 -c "=> renegotiate" \
1964 -s "=> renegotiate" \
1965 -s "write hello request"
1966
Hanno Becker6a243642017-10-12 15:18:45 +01001967requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00001968run_test "Renegotiation: DTLS, renego_period overflow" \
1969 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1970 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1971 0 \
1972 -c "client hello, adding renegotiation extension" \
1973 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1974 -s "found renegotiation extension" \
1975 -s "server hello, secure renegotiation extension" \
1976 -s "record counter limit reached: renegotiate" \
1977 -c "=> renegotiate" \
1978 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01001979 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00001980
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001981requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001982requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001983run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1984 "$G_SRV -u --mtu 4096" \
1985 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1986 0 \
1987 -c "client hello, adding renegotiation extension" \
1988 -c "found renegotiation extension" \
1989 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001990 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001991 -C "error" \
1992 -s "Extra-header:"
1993
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001994# Test for the "secure renegotation" extension only (no actual renegotiation)
1995
Paul Bakker539d9722015-02-08 16:18:35 +01001996requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001997run_test "Renego ext: gnutls server strict, client default" \
1998 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1999 "$P_CLI debug_level=3" \
2000 0 \
2001 -c "found renegotiation extension" \
2002 -C "error" \
2003 -c "HTTP/1.0 200 [Oo][Kk]"
2004
Paul Bakker539d9722015-02-08 16:18:35 +01002005requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002006run_test "Renego ext: gnutls server unsafe, client default" \
2007 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2008 "$P_CLI debug_level=3" \
2009 0 \
2010 -C "found renegotiation extension" \
2011 -C "error" \
2012 -c "HTTP/1.0 200 [Oo][Kk]"
2013
Paul Bakker539d9722015-02-08 16:18:35 +01002014requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002015run_test "Renego ext: gnutls server unsafe, client break legacy" \
2016 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2017 "$P_CLI debug_level=3 allow_legacy=-1" \
2018 1 \
2019 -C "found renegotiation extension" \
2020 -c "error" \
2021 -C "HTTP/1.0 200 [Oo][Kk]"
2022
Paul Bakker539d9722015-02-08 16:18:35 +01002023requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002024run_test "Renego ext: gnutls client strict, server default" \
2025 "$P_SRV debug_level=3" \
2026 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2027 0 \
2028 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2029 -s "server hello, secure renegotiation extension"
2030
Paul Bakker539d9722015-02-08 16:18:35 +01002031requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002032run_test "Renego ext: gnutls client unsafe, server default" \
2033 "$P_SRV debug_level=3" \
2034 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2035 0 \
2036 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2037 -S "server hello, secure renegotiation extension"
2038
Paul Bakker539d9722015-02-08 16:18:35 +01002039requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002040run_test "Renego ext: gnutls client unsafe, server break legacy" \
2041 "$P_SRV debug_level=3 allow_legacy=-1" \
2042 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2043 1 \
2044 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2045 -S "server hello, secure renegotiation extension"
2046
Janos Follath0b242342016-02-17 10:11:21 +00002047# Tests for silently dropping trailing extra bytes in .der certificates
2048
2049requires_gnutls
2050run_test "DER format: no trailing bytes" \
2051 "$P_SRV crt_file=data_files/server5-der0.crt \
2052 key_file=data_files/server5.key" \
2053 "$G_CLI " \
2054 0 \
2055 -c "Handshake was completed" \
2056
2057requires_gnutls
2058run_test "DER format: with a trailing zero byte" \
2059 "$P_SRV crt_file=data_files/server5-der1a.crt \
2060 key_file=data_files/server5.key" \
2061 "$G_CLI " \
2062 0 \
2063 -c "Handshake was completed" \
2064
2065requires_gnutls
2066run_test "DER format: with a trailing random byte" \
2067 "$P_SRV crt_file=data_files/server5-der1b.crt \
2068 key_file=data_files/server5.key" \
2069 "$G_CLI " \
2070 0 \
2071 -c "Handshake was completed" \
2072
2073requires_gnutls
2074run_test "DER format: with 2 trailing random bytes" \
2075 "$P_SRV crt_file=data_files/server5-der2.crt \
2076 key_file=data_files/server5.key" \
2077 "$G_CLI " \
2078 0 \
2079 -c "Handshake was completed" \
2080
2081requires_gnutls
2082run_test "DER format: with 4 trailing random bytes" \
2083 "$P_SRV crt_file=data_files/server5-der4.crt \
2084 key_file=data_files/server5.key" \
2085 "$G_CLI " \
2086 0 \
2087 -c "Handshake was completed" \
2088
2089requires_gnutls
2090run_test "DER format: with 8 trailing random bytes" \
2091 "$P_SRV crt_file=data_files/server5-der8.crt \
2092 key_file=data_files/server5.key" \
2093 "$G_CLI " \
2094 0 \
2095 -c "Handshake was completed" \
2096
2097requires_gnutls
2098run_test "DER format: with 9 trailing random bytes" \
2099 "$P_SRV crt_file=data_files/server5-der9.crt \
2100 key_file=data_files/server5.key" \
2101 "$G_CLI " \
2102 0 \
2103 -c "Handshake was completed" \
2104
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002105# Tests for auth_mode
2106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002107run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002108 "$P_SRV crt_file=data_files/server5-badsign.crt \
2109 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002110 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002111 1 \
2112 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002113 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002114 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002115 -c "X509 - Certificate verification failed"
2116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002117run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002118 "$P_SRV crt_file=data_files/server5-badsign.crt \
2119 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002120 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002121 0 \
2122 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002123 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002124 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002125 -C "X509 - Certificate verification failed"
2126
Hanno Beckere6706e62017-05-15 16:05:15 +01002127run_test "Authentication: server goodcert, client optional, no trusted CA" \
2128 "$P_SRV" \
2129 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2130 0 \
2131 -c "x509_verify_cert() returned" \
2132 -c "! The certificate is not correctly signed by the trusted CA" \
2133 -c "! Certificate verification flags"\
2134 -C "! mbedtls_ssl_handshake returned" \
2135 -C "X509 - Certificate verification failed" \
2136 -C "SSL - No CA Chain is set, but required to operate"
2137
2138run_test "Authentication: server goodcert, client required, no trusted CA" \
2139 "$P_SRV" \
2140 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2141 1 \
2142 -c "x509_verify_cert() returned" \
2143 -c "! The certificate is not correctly signed by the trusted CA" \
2144 -c "! Certificate verification flags"\
2145 -c "! mbedtls_ssl_handshake returned" \
2146 -c "SSL - No CA Chain is set, but required to operate"
2147
2148# The purpose of the next two tests is to test the client's behaviour when receiving a server
2149# certificate with an unsupported elliptic curve. This should usually not happen because
2150# the client informs the server about the supported curves - it does, though, in the
2151# corner case of a static ECDH suite, because the server doesn't check the curve on that
2152# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2153# different means to have the server ignoring the client's supported curve list.
2154
2155requires_config_enabled MBEDTLS_ECP_C
2156run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2157 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2158 crt_file=data_files/server5.ku-ka.crt" \
2159 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2160 1 \
2161 -c "bad certificate (EC key curve)"\
2162 -c "! Certificate verification flags"\
2163 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2164
2165requires_config_enabled MBEDTLS_ECP_C
2166run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2167 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2168 crt_file=data_files/server5.ku-ka.crt" \
2169 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2170 1 \
2171 -c "bad certificate (EC key curve)"\
2172 -c "! Certificate verification flags"\
2173 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2174
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002175run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002176 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002177 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002178 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002179 0 \
2180 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002181 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002182 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002183 -C "X509 - Certificate verification failed"
2184
Simon Butcher99000142016-10-13 17:21:01 +01002185run_test "Authentication: client SHA256, server required" \
2186 "$P_SRV auth_mode=required" \
2187 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2188 key_file=data_files/server6.key \
2189 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2190 0 \
2191 -c "Supported Signature Algorithm found: 4," \
2192 -c "Supported Signature Algorithm found: 5,"
2193
2194run_test "Authentication: client SHA384, server required" \
2195 "$P_SRV auth_mode=required" \
2196 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2197 key_file=data_files/server6.key \
2198 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2199 0 \
2200 -c "Supported Signature Algorithm found: 4," \
2201 -c "Supported Signature Algorithm found: 5,"
2202
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002203requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2204run_test "Authentication: client has no cert, server required (SSLv3)" \
2205 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2206 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2207 key_file=data_files/server5.key" \
2208 1 \
2209 -S "skip write certificate request" \
2210 -C "skip parse certificate request" \
2211 -c "got a certificate request" \
2212 -c "got no certificate to send" \
2213 -S "x509_verify_cert() returned" \
2214 -s "client has no certificate" \
2215 -s "! mbedtls_ssl_handshake returned" \
2216 -c "! mbedtls_ssl_handshake returned" \
2217 -s "No client certification received from the client, but required by the authentication mode"
2218
2219run_test "Authentication: client has no cert, server required (TLS)" \
2220 "$P_SRV debug_level=3 auth_mode=required" \
2221 "$P_CLI debug_level=3 crt_file=none \
2222 key_file=data_files/server5.key" \
2223 1 \
2224 -S "skip write certificate request" \
2225 -C "skip parse certificate request" \
2226 -c "got a certificate request" \
2227 -c "= write certificate$" \
2228 -C "skip write certificate$" \
2229 -S "x509_verify_cert() returned" \
2230 -s "client has no certificate" \
2231 -s "! mbedtls_ssl_handshake returned" \
2232 -c "! mbedtls_ssl_handshake returned" \
2233 -s "No client certification received from the client, but required by the authentication mode"
2234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002235run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002236 "$P_SRV debug_level=3 auth_mode=required" \
2237 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002238 key_file=data_files/server5.key" \
2239 1 \
2240 -S "skip write certificate request" \
2241 -C "skip parse certificate request" \
2242 -c "got a certificate request" \
2243 -C "skip write certificate" \
2244 -C "skip write certificate verify" \
2245 -S "skip parse certificate verify" \
2246 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002247 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002248 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002249 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002250 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002251 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002252# We don't check that the client receives the alert because it might
2253# detect that its write end of the connection is closed and abort
2254# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002255
Janos Follath89baba22017-04-10 14:34:35 +01002256run_test "Authentication: client cert not trusted, server required" \
2257 "$P_SRV debug_level=3 auth_mode=required" \
2258 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2259 key_file=data_files/server5.key" \
2260 1 \
2261 -S "skip write certificate request" \
2262 -C "skip parse certificate request" \
2263 -c "got a certificate request" \
2264 -C "skip write certificate" \
2265 -C "skip write certificate verify" \
2266 -S "skip parse certificate verify" \
2267 -s "x509_verify_cert() returned" \
2268 -s "! The certificate is not correctly signed by the trusted CA" \
2269 -s "! mbedtls_ssl_handshake returned" \
2270 -c "! mbedtls_ssl_handshake returned" \
2271 -s "X509 - Certificate verification failed"
2272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002273run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002274 "$P_SRV debug_level=3 auth_mode=optional" \
2275 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002276 key_file=data_files/server5.key" \
2277 0 \
2278 -S "skip write certificate request" \
2279 -C "skip parse certificate request" \
2280 -c "got a certificate request" \
2281 -C "skip write certificate" \
2282 -C "skip write certificate verify" \
2283 -S "skip parse certificate verify" \
2284 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002285 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002286 -S "! mbedtls_ssl_handshake returned" \
2287 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002288 -S "X509 - Certificate verification failed"
2289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002290run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002291 "$P_SRV debug_level=3 auth_mode=none" \
2292 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002293 key_file=data_files/server5.key" \
2294 0 \
2295 -s "skip write certificate request" \
2296 -C "skip parse certificate request" \
2297 -c "got no certificate request" \
2298 -c "skip write certificate" \
2299 -c "skip write certificate verify" \
2300 -s "skip parse certificate verify" \
2301 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002302 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002303 -S "! mbedtls_ssl_handshake returned" \
2304 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002305 -S "X509 - Certificate verification failed"
2306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002307run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002308 "$P_SRV debug_level=3 auth_mode=optional" \
2309 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002310 0 \
2311 -S "skip write certificate request" \
2312 -C "skip parse certificate request" \
2313 -c "got a certificate request" \
2314 -C "skip write certificate$" \
2315 -C "got no certificate to send" \
2316 -S "SSLv3 client has no certificate" \
2317 -c "skip write certificate verify" \
2318 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002319 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002320 -S "! mbedtls_ssl_handshake returned" \
2321 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002322 -S "X509 - Certificate verification failed"
2323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002324run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002325 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002326 "$O_CLI" \
2327 0 \
2328 -S "skip write certificate request" \
2329 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002330 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002331 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002332 -S "X509 - Certificate verification failed"
2333
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002334run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002335 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002336 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002337 0 \
2338 -C "skip parse certificate request" \
2339 -c "got a certificate request" \
2340 -C "skip write certificate$" \
2341 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002342 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002343
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002344run_test "Authentication: client no cert, openssl server required" \
2345 "$O_SRV -Verify 10" \
2346 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2347 1 \
2348 -C "skip parse certificate request" \
2349 -c "got a certificate request" \
2350 -C "skip write certificate$" \
2351 -c "skip write certificate verify" \
2352 -c "! mbedtls_ssl_handshake returned"
2353
Janos Follathe2681a42016-03-07 15:57:05 +00002354requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002355run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002356 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002357 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002358 0 \
2359 -S "skip write certificate request" \
2360 -C "skip parse certificate request" \
2361 -c "got a certificate request" \
2362 -C "skip write certificate$" \
2363 -c "skip write certificate verify" \
2364 -c "got no certificate to send" \
2365 -s "SSLv3 client has no certificate" \
2366 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002367 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002368 -S "! mbedtls_ssl_handshake returned" \
2369 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002370 -S "X509 - Certificate verification failed"
2371
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002372# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2373# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002374
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002375MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002376MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002377
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002378if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002379 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002380 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002381 printf "test value of ${MAX_IM_CA}. \n"
2382 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002383 printf "The tests assume this value and if it changes, the tests in this\n"
2384 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002385 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002386
2387 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002388fi
2389
Angus Grattonc4dd0732018-04-11 16:28:39 +10002390requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002391run_test "Authentication: server max_int chain, client default" \
2392 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2393 key_file=data_files/dir-maxpath/09.key" \
2394 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2395 0 \
2396 -C "X509 - A fatal error occured"
2397
Angus Grattonc4dd0732018-04-11 16:28:39 +10002398requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002399run_test "Authentication: server max_int+1 chain, client default" \
2400 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2401 key_file=data_files/dir-maxpath/10.key" \
2402 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2403 1 \
2404 -c "X509 - A fatal error occured"
2405
Angus Grattonc4dd0732018-04-11 16:28:39 +10002406requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002407run_test "Authentication: server max_int+1 chain, client optional" \
2408 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2409 key_file=data_files/dir-maxpath/10.key" \
2410 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2411 auth_mode=optional" \
2412 1 \
2413 -c "X509 - A fatal error occured"
2414
Angus Grattonc4dd0732018-04-11 16:28:39 +10002415requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002416run_test "Authentication: server max_int+1 chain, client none" \
2417 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2418 key_file=data_files/dir-maxpath/10.key" \
2419 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2420 auth_mode=none" \
2421 0 \
2422 -C "X509 - A fatal error occured"
2423
Angus Grattonc4dd0732018-04-11 16:28:39 +10002424requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002425run_test "Authentication: client max_int+1 chain, server default" \
2426 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2427 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2428 key_file=data_files/dir-maxpath/10.key" \
2429 0 \
2430 -S "X509 - A fatal error occured"
2431
Angus Grattonc4dd0732018-04-11 16:28:39 +10002432requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002433run_test "Authentication: client max_int+1 chain, server optional" \
2434 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2435 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2436 key_file=data_files/dir-maxpath/10.key" \
2437 1 \
2438 -s "X509 - A fatal error occured"
2439
Angus Grattonc4dd0732018-04-11 16:28:39 +10002440requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002441run_test "Authentication: client max_int+1 chain, server required" \
2442 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2443 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2444 key_file=data_files/dir-maxpath/10.key" \
2445 1 \
2446 -s "X509 - A fatal error occured"
2447
Angus Grattonc4dd0732018-04-11 16:28:39 +10002448requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002449run_test "Authentication: client max_int chain, server required" \
2450 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2451 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2452 key_file=data_files/dir-maxpath/09.key" \
2453 0 \
2454 -S "X509 - A fatal error occured"
2455
Janos Follath89baba22017-04-10 14:34:35 +01002456# Tests for CA list in CertificateRequest messages
2457
2458run_test "Authentication: send CA list in CertificateRequest (default)" \
2459 "$P_SRV debug_level=3 auth_mode=required" \
2460 "$P_CLI crt_file=data_files/server6.crt \
2461 key_file=data_files/server6.key" \
2462 0 \
2463 -s "requested DN"
2464
2465run_test "Authentication: do not send CA list in CertificateRequest" \
2466 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2467 "$P_CLI crt_file=data_files/server6.crt \
2468 key_file=data_files/server6.key" \
2469 0 \
2470 -S "requested DN"
2471
2472run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2473 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2474 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2475 key_file=data_files/server5.key" \
2476 1 \
2477 -S "requested DN" \
2478 -s "x509_verify_cert() returned" \
2479 -s "! The certificate is not correctly signed by the trusted CA" \
2480 -s "! mbedtls_ssl_handshake returned" \
2481 -c "! mbedtls_ssl_handshake returned" \
2482 -s "X509 - Certificate verification failed"
2483
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002484# Tests for certificate selection based on SHA verson
2485
2486run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2487 "$P_SRV crt_file=data_files/server5.crt \
2488 key_file=data_files/server5.key \
2489 crt_file2=data_files/server5-sha1.crt \
2490 key_file2=data_files/server5.key" \
2491 "$P_CLI force_version=tls1_2" \
2492 0 \
2493 -c "signed using.*ECDSA with SHA256" \
2494 -C "signed using.*ECDSA with SHA1"
2495
2496run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2497 "$P_SRV crt_file=data_files/server5.crt \
2498 key_file=data_files/server5.key \
2499 crt_file2=data_files/server5-sha1.crt \
2500 key_file2=data_files/server5.key" \
2501 "$P_CLI force_version=tls1_1" \
2502 0 \
2503 -C "signed using.*ECDSA with SHA256" \
2504 -c "signed using.*ECDSA with SHA1"
2505
2506run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2507 "$P_SRV crt_file=data_files/server5.crt \
2508 key_file=data_files/server5.key \
2509 crt_file2=data_files/server5-sha1.crt \
2510 key_file2=data_files/server5.key" \
2511 "$P_CLI force_version=tls1" \
2512 0 \
2513 -C "signed using.*ECDSA with SHA256" \
2514 -c "signed using.*ECDSA with SHA1"
2515
2516run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2517 "$P_SRV crt_file=data_files/server5.crt \
2518 key_file=data_files/server5.key \
2519 crt_file2=data_files/server6.crt \
2520 key_file2=data_files/server6.key" \
2521 "$P_CLI force_version=tls1_1" \
2522 0 \
2523 -c "serial number.*09" \
2524 -c "signed using.*ECDSA with SHA256" \
2525 -C "signed using.*ECDSA with SHA1"
2526
2527run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2528 "$P_SRV crt_file=data_files/server6.crt \
2529 key_file=data_files/server6.key \
2530 crt_file2=data_files/server5.crt \
2531 key_file2=data_files/server5.key" \
2532 "$P_CLI force_version=tls1_1" \
2533 0 \
2534 -c "serial number.*0A" \
2535 -c "signed using.*ECDSA with SHA256" \
2536 -C "signed using.*ECDSA with SHA1"
2537
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002538# tests for SNI
2539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002540run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002541 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002542 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002543 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002544 0 \
2545 -S "parse ServerName extension" \
2546 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2547 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002549run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002550 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002551 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002552 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 +02002553 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002554 0 \
2555 -s "parse ServerName extension" \
2556 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2557 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002559run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002560 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002561 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002562 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 +02002563 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002564 0 \
2565 -s "parse ServerName extension" \
2566 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2567 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002569run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002570 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002571 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002572 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 +02002573 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002574 1 \
2575 -s "parse ServerName extension" \
2576 -s "ssl_sni_wrapper() returned" \
2577 -s "mbedtls_ssl_handshake returned" \
2578 -c "mbedtls_ssl_handshake returned" \
2579 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002580
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002581run_test "SNI: client auth no override: optional" \
2582 "$P_SRV debug_level=3 auth_mode=optional \
2583 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2584 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2585 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002586 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002587 -S "skip write certificate request" \
2588 -C "skip parse certificate request" \
2589 -c "got a certificate request" \
2590 -C "skip write certificate" \
2591 -C "skip write certificate verify" \
2592 -S "skip parse certificate verify"
2593
2594run_test "SNI: client auth override: none -> optional" \
2595 "$P_SRV debug_level=3 auth_mode=none \
2596 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2597 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2598 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002599 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002600 -S "skip write certificate request" \
2601 -C "skip parse certificate request" \
2602 -c "got a certificate request" \
2603 -C "skip write certificate" \
2604 -C "skip write certificate verify" \
2605 -S "skip parse certificate verify"
2606
2607run_test "SNI: client auth override: optional -> none" \
2608 "$P_SRV debug_level=3 auth_mode=optional \
2609 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2610 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2611 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002612 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002613 -s "skip write certificate request" \
2614 -C "skip parse certificate request" \
2615 -c "got no certificate request" \
2616 -c "skip write certificate" \
2617 -c "skip write certificate verify" \
2618 -s "skip parse certificate verify"
2619
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002620run_test "SNI: CA no override" \
2621 "$P_SRV debug_level=3 auth_mode=optional \
2622 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2623 ca_file=data_files/test-ca.crt \
2624 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2625 "$P_CLI debug_level=3 server_name=localhost \
2626 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2627 1 \
2628 -S "skip write certificate request" \
2629 -C "skip parse certificate request" \
2630 -c "got a certificate request" \
2631 -C "skip write certificate" \
2632 -C "skip write certificate verify" \
2633 -S "skip parse certificate verify" \
2634 -s "x509_verify_cert() returned" \
2635 -s "! The certificate is not correctly signed by the trusted CA" \
2636 -S "The certificate has been revoked (is on a CRL)"
2637
2638run_test "SNI: CA override" \
2639 "$P_SRV debug_level=3 auth_mode=optional \
2640 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2641 ca_file=data_files/test-ca.crt \
2642 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2643 "$P_CLI debug_level=3 server_name=localhost \
2644 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2645 0 \
2646 -S "skip write certificate request" \
2647 -C "skip parse certificate request" \
2648 -c "got a certificate request" \
2649 -C "skip write certificate" \
2650 -C "skip write certificate verify" \
2651 -S "skip parse certificate verify" \
2652 -S "x509_verify_cert() returned" \
2653 -S "! The certificate is not correctly signed by the trusted CA" \
2654 -S "The certificate has been revoked (is on a CRL)"
2655
2656run_test "SNI: CA override with CRL" \
2657 "$P_SRV debug_level=3 auth_mode=optional \
2658 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2659 ca_file=data_files/test-ca.crt \
2660 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2661 "$P_CLI debug_level=3 server_name=localhost \
2662 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2663 1 \
2664 -S "skip write certificate request" \
2665 -C "skip parse certificate request" \
2666 -c "got a certificate request" \
2667 -C "skip write certificate" \
2668 -C "skip write certificate verify" \
2669 -S "skip parse certificate verify" \
2670 -s "x509_verify_cert() returned" \
2671 -S "! The certificate is not correctly signed by the trusted CA" \
2672 -s "The certificate has been revoked (is on a CRL)"
2673
Andres AG1a834452016-12-07 10:01:30 +00002674# Tests for SNI and DTLS
2675
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002676run_test "SNI: DTLS, no SNI callback" \
2677 "$P_SRV debug_level=3 dtls=1 \
2678 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2679 "$P_CLI server_name=localhost dtls=1" \
2680 0 \
2681 -S "parse ServerName extension" \
2682 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2683 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2684
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002685run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00002686 "$P_SRV debug_level=3 dtls=1 \
2687 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2688 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2689 "$P_CLI server_name=localhost dtls=1" \
2690 0 \
2691 -s "parse ServerName extension" \
2692 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2693 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2694
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002695run_test "SNI: DTLS, matching cert 2" \
2696 "$P_SRV debug_level=3 dtls=1 \
2697 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2698 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2699 "$P_CLI server_name=polarssl.example dtls=1" \
2700 0 \
2701 -s "parse ServerName extension" \
2702 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2703 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2704
2705run_test "SNI: DTLS, no matching cert" \
2706 "$P_SRV debug_level=3 dtls=1 \
2707 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2708 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2709 "$P_CLI server_name=nonesuch.example dtls=1" \
2710 1 \
2711 -s "parse ServerName extension" \
2712 -s "ssl_sni_wrapper() returned" \
2713 -s "mbedtls_ssl_handshake returned" \
2714 -c "mbedtls_ssl_handshake returned" \
2715 -c "SSL - A fatal alert message was received from our peer"
2716
2717run_test "SNI: DTLS, client auth no override: optional" \
2718 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2719 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2720 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2721 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2722 0 \
2723 -S "skip write certificate request" \
2724 -C "skip parse certificate request" \
2725 -c "got a certificate request" \
2726 -C "skip write certificate" \
2727 -C "skip write certificate verify" \
2728 -S "skip parse certificate verify"
2729
2730run_test "SNI: DTLS, client auth override: none -> optional" \
2731 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2732 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2733 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2734 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2735 0 \
2736 -S "skip write certificate request" \
2737 -C "skip parse certificate request" \
2738 -c "got a certificate request" \
2739 -C "skip write certificate" \
2740 -C "skip write certificate verify" \
2741 -S "skip parse certificate verify"
2742
2743run_test "SNI: DTLS, client auth override: optional -> none" \
2744 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2745 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2746 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2747 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2748 0 \
2749 -s "skip write certificate request" \
2750 -C "skip parse certificate request" \
2751 -c "got no certificate request" \
2752 -c "skip write certificate" \
2753 -c "skip write certificate verify" \
2754 -s "skip parse certificate verify"
2755
2756run_test "SNI: DTLS, CA no override" \
2757 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2758 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2759 ca_file=data_files/test-ca.crt \
2760 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2761 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2762 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2763 1 \
2764 -S "skip write certificate request" \
2765 -C "skip parse certificate request" \
2766 -c "got a certificate request" \
2767 -C "skip write certificate" \
2768 -C "skip write certificate verify" \
2769 -S "skip parse certificate verify" \
2770 -s "x509_verify_cert() returned" \
2771 -s "! The certificate is not correctly signed by the trusted CA" \
2772 -S "The certificate has been revoked (is on a CRL)"
2773
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002774run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00002775 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2776 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2777 ca_file=data_files/test-ca.crt \
2778 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2779 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2780 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2781 0 \
2782 -S "skip write certificate request" \
2783 -C "skip parse certificate request" \
2784 -c "got a certificate request" \
2785 -C "skip write certificate" \
2786 -C "skip write certificate verify" \
2787 -S "skip parse certificate verify" \
2788 -S "x509_verify_cert() returned" \
2789 -S "! The certificate is not correctly signed by the trusted CA" \
2790 -S "The certificate has been revoked (is on a CRL)"
2791
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002792run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00002793 "$P_SRV debug_level=3 auth_mode=optional \
2794 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2795 ca_file=data_files/test-ca.crt \
2796 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2797 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2798 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2799 1 \
2800 -S "skip write certificate request" \
2801 -C "skip parse certificate request" \
2802 -c "got a certificate request" \
2803 -C "skip write certificate" \
2804 -C "skip write certificate verify" \
2805 -S "skip parse certificate verify" \
2806 -s "x509_verify_cert() returned" \
2807 -S "! The certificate is not correctly signed by the trusted CA" \
2808 -s "The certificate has been revoked (is on a CRL)"
2809
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002810# Tests for non-blocking I/O: exercise a variety of handshake flows
2811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002812run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002813 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2814 "$P_CLI nbio=2 tickets=0" \
2815 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002816 -S "mbedtls_ssl_handshake returned" \
2817 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002818 -c "Read from server: .* bytes read"
2819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002820run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002821 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2822 "$P_CLI nbio=2 tickets=0" \
2823 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002824 -S "mbedtls_ssl_handshake returned" \
2825 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002826 -c "Read from server: .* bytes read"
2827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002828run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002829 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2830 "$P_CLI nbio=2 tickets=1" \
2831 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002832 -S "mbedtls_ssl_handshake returned" \
2833 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002834 -c "Read from server: .* bytes read"
2835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002836run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002837 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2838 "$P_CLI nbio=2 tickets=1" \
2839 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002840 -S "mbedtls_ssl_handshake returned" \
2841 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002842 -c "Read from server: .* bytes read"
2843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002844run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002845 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2846 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2847 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002848 -S "mbedtls_ssl_handshake returned" \
2849 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002850 -c "Read from server: .* bytes read"
2851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002852run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002853 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2854 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2855 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002856 -S "mbedtls_ssl_handshake returned" \
2857 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002858 -c "Read from server: .* bytes read"
2859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002860run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002861 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2862 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2863 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002864 -S "mbedtls_ssl_handshake returned" \
2865 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002866 -c "Read from server: .* bytes read"
2867
Hanno Becker00076712017-11-15 16:39:08 +00002868# Tests for event-driven I/O: exercise a variety of handshake flows
2869
2870run_test "Event-driven I/O: basic handshake" \
2871 "$P_SRV event=1 tickets=0 auth_mode=none" \
2872 "$P_CLI event=1 tickets=0" \
2873 0 \
2874 -S "mbedtls_ssl_handshake returned" \
2875 -C "mbedtls_ssl_handshake returned" \
2876 -c "Read from server: .* bytes read"
2877
2878run_test "Event-driven I/O: client auth" \
2879 "$P_SRV event=1 tickets=0 auth_mode=required" \
2880 "$P_CLI event=1 tickets=0" \
2881 0 \
2882 -S "mbedtls_ssl_handshake returned" \
2883 -C "mbedtls_ssl_handshake returned" \
2884 -c "Read from server: .* bytes read"
2885
2886run_test "Event-driven I/O: ticket" \
2887 "$P_SRV event=1 tickets=1 auth_mode=none" \
2888 "$P_CLI event=1 tickets=1" \
2889 0 \
2890 -S "mbedtls_ssl_handshake returned" \
2891 -C "mbedtls_ssl_handshake returned" \
2892 -c "Read from server: .* bytes read"
2893
2894run_test "Event-driven I/O: ticket + client auth" \
2895 "$P_SRV event=1 tickets=1 auth_mode=required" \
2896 "$P_CLI event=1 tickets=1" \
2897 0 \
2898 -S "mbedtls_ssl_handshake returned" \
2899 -C "mbedtls_ssl_handshake returned" \
2900 -c "Read from server: .* bytes read"
2901
2902run_test "Event-driven I/O: ticket + client auth + resume" \
2903 "$P_SRV event=1 tickets=1 auth_mode=required" \
2904 "$P_CLI event=1 tickets=1 reconnect=1" \
2905 0 \
2906 -S "mbedtls_ssl_handshake returned" \
2907 -C "mbedtls_ssl_handshake returned" \
2908 -c "Read from server: .* bytes read"
2909
2910run_test "Event-driven I/O: ticket + resume" \
2911 "$P_SRV event=1 tickets=1 auth_mode=none" \
2912 "$P_CLI event=1 tickets=1 reconnect=1" \
2913 0 \
2914 -S "mbedtls_ssl_handshake returned" \
2915 -C "mbedtls_ssl_handshake returned" \
2916 -c "Read from server: .* bytes read"
2917
2918run_test "Event-driven I/O: session-id resume" \
2919 "$P_SRV event=1 tickets=0 auth_mode=none" \
2920 "$P_CLI event=1 tickets=0 reconnect=1" \
2921 0 \
2922 -S "mbedtls_ssl_handshake returned" \
2923 -C "mbedtls_ssl_handshake returned" \
2924 -c "Read from server: .* bytes read"
2925
Hanno Becker6a33f592018-03-13 11:38:46 +00002926run_test "Event-driven I/O, DTLS: basic handshake" \
2927 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2928 "$P_CLI dtls=1 event=1 tickets=0" \
2929 0 \
2930 -c "Read from server: .* bytes read"
2931
2932run_test "Event-driven I/O, DTLS: client auth" \
2933 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
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: ticket" \
2939 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2940 "$P_CLI dtls=1 event=1 tickets=1" \
2941 0 \
2942 -c "Read from server: .* bytes read"
2943
2944run_test "Event-driven I/O, DTLS: ticket + client auth" \
2945 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
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 + resume" \
2951 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2952 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2953 0 \
2954 -c "Read from server: .* bytes read"
2955
2956run_test "Event-driven I/O, DTLS: ticket + resume" \
2957 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
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: session-id resume" \
2963 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2964 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
2965 0 \
2966 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00002967
2968# This test demonstrates the need for the mbedtls_ssl_check_pending function.
2969# During session resumption, the client will send its ApplicationData record
2970# within the same datagram as the Finished messages. In this situation, the
2971# server MUST NOT idle on the underlying transport after handshake completion,
2972# because the ApplicationData request has already been queued internally.
2973run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00002974 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00002975 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
2976 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
2977 0 \
2978 -c "Read from server: .* bytes read"
2979
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002980# Tests for version negotiation
2981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002982run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002983 "$P_SRV" \
2984 "$P_CLI" \
2985 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002986 -S "mbedtls_ssl_handshake returned" \
2987 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002988 -s "Protocol is TLSv1.2" \
2989 -c "Protocol is TLSv1.2"
2990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002991run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002992 "$P_SRV" \
2993 "$P_CLI max_version=tls1_1" \
2994 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002995 -S "mbedtls_ssl_handshake returned" \
2996 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002997 -s "Protocol is TLSv1.1" \
2998 -c "Protocol is TLSv1.1"
2999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003000run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003001 "$P_SRV max_version=tls1_1" \
3002 "$P_CLI" \
3003 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003004 -S "mbedtls_ssl_handshake returned" \
3005 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003006 -s "Protocol is TLSv1.1" \
3007 -c "Protocol is TLSv1.1"
3008
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003009run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003010 "$P_SRV max_version=tls1_1" \
3011 "$P_CLI max_version=tls1_1" \
3012 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003013 -S "mbedtls_ssl_handshake returned" \
3014 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003015 -s "Protocol is TLSv1.1" \
3016 -c "Protocol is TLSv1.1"
3017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003018run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003019 "$P_SRV min_version=tls1_1" \
3020 "$P_CLI max_version=tls1_1" \
3021 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003022 -S "mbedtls_ssl_handshake returned" \
3023 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003024 -s "Protocol is TLSv1.1" \
3025 -c "Protocol is TLSv1.1"
3026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003027run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003028 "$P_SRV max_version=tls1_1" \
3029 "$P_CLI min_version=tls1_1" \
3030 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003031 -S "mbedtls_ssl_handshake returned" \
3032 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003033 -s "Protocol is TLSv1.1" \
3034 -c "Protocol is TLSv1.1"
3035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003036run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003037 "$P_SRV max_version=tls1_1" \
3038 "$P_CLI min_version=tls1_2" \
3039 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003040 -s "mbedtls_ssl_handshake returned" \
3041 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003042 -c "SSL - Handshake protocol not within min/max boundaries"
3043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003044run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003045 "$P_SRV min_version=tls1_2" \
3046 "$P_CLI max_version=tls1_1" \
3047 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003048 -s "mbedtls_ssl_handshake returned" \
3049 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003050 -s "SSL - Handshake protocol not within min/max boundaries"
3051
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003052# Tests for ALPN extension
3053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003054run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003055 "$P_SRV debug_level=3" \
3056 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003057 0 \
3058 -C "client hello, adding alpn extension" \
3059 -S "found alpn extension" \
3060 -C "got an alert message, type: \\[2:120]" \
3061 -S "server hello, adding alpn extension" \
3062 -C "found alpn extension " \
3063 -C "Application Layer Protocol is" \
3064 -S "Application Layer Protocol is"
3065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003066run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003067 "$P_SRV debug_level=3" \
3068 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003069 0 \
3070 -c "client hello, adding alpn extension" \
3071 -s "found alpn extension" \
3072 -C "got an alert message, type: \\[2:120]" \
3073 -S "server hello, adding alpn extension" \
3074 -C "found alpn extension " \
3075 -c "Application Layer Protocol is (none)" \
3076 -S "Application Layer Protocol is"
3077
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003078run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003079 "$P_SRV debug_level=3 alpn=abc,1234" \
3080 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003081 0 \
3082 -C "client hello, adding alpn extension" \
3083 -S "found alpn extension" \
3084 -C "got an alert message, type: \\[2:120]" \
3085 -S "server hello, adding alpn extension" \
3086 -C "found alpn extension " \
3087 -C "Application Layer Protocol is" \
3088 -s "Application Layer Protocol is (none)"
3089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003090run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003091 "$P_SRV debug_level=3 alpn=abc,1234" \
3092 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003093 0 \
3094 -c "client hello, adding alpn extension" \
3095 -s "found alpn extension" \
3096 -C "got an alert message, type: \\[2:120]" \
3097 -s "server hello, adding alpn extension" \
3098 -c "found alpn extension" \
3099 -c "Application Layer Protocol is abc" \
3100 -s "Application Layer Protocol is abc"
3101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003102run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003103 "$P_SRV debug_level=3 alpn=abc,1234" \
3104 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003105 0 \
3106 -c "client hello, adding alpn extension" \
3107 -s "found alpn extension" \
3108 -C "got an alert message, type: \\[2:120]" \
3109 -s "server hello, adding alpn extension" \
3110 -c "found alpn extension" \
3111 -c "Application Layer Protocol is abc" \
3112 -s "Application Layer Protocol is abc"
3113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003114run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003115 "$P_SRV debug_level=3 alpn=abc,1234" \
3116 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003117 0 \
3118 -c "client hello, adding alpn extension" \
3119 -s "found alpn extension" \
3120 -C "got an alert message, type: \\[2:120]" \
3121 -s "server hello, adding alpn extension" \
3122 -c "found alpn extension" \
3123 -c "Application Layer Protocol is 1234" \
3124 -s "Application Layer Protocol is 1234"
3125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003126run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003127 "$P_SRV debug_level=3 alpn=abc,123" \
3128 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003129 1 \
3130 -c "client hello, adding alpn extension" \
3131 -s "found alpn extension" \
3132 -c "got an alert message, type: \\[2:120]" \
3133 -S "server hello, adding alpn extension" \
3134 -C "found alpn extension" \
3135 -C "Application Layer Protocol is 1234" \
3136 -S "Application Layer Protocol is 1234"
3137
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003138
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003139# Tests for keyUsage in leaf certificates, part 1:
3140# server-side certificate/suite selection
3141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003142run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003143 "$P_SRV key_file=data_files/server2.key \
3144 crt_file=data_files/server2.ku-ds.crt" \
3145 "$P_CLI" \
3146 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003147 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003148
3149
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003150run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003151 "$P_SRV key_file=data_files/server2.key \
3152 crt_file=data_files/server2.ku-ke.crt" \
3153 "$P_CLI" \
3154 0 \
3155 -c "Ciphersuite is TLS-RSA-WITH-"
3156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003157run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003158 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003159 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003160 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003161 1 \
3162 -C "Ciphersuite is "
3163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003164run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003165 "$P_SRV key_file=data_files/server5.key \
3166 crt_file=data_files/server5.ku-ds.crt" \
3167 "$P_CLI" \
3168 0 \
3169 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3170
3171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003172run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003173 "$P_SRV key_file=data_files/server5.key \
3174 crt_file=data_files/server5.ku-ka.crt" \
3175 "$P_CLI" \
3176 0 \
3177 -c "Ciphersuite is TLS-ECDH-"
3178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003179run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003180 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003181 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003182 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003183 1 \
3184 -C "Ciphersuite is "
3185
3186# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003187# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003189run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003190 "$O_SRV -key data_files/server2.key \
3191 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003192 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003193 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3194 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003195 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003196 -C "Processing of the Certificate handshake message failed" \
3197 -c "Ciphersuite is TLS-"
3198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003199run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003200 "$O_SRV -key data_files/server2.key \
3201 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003202 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003203 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3204 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003205 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003206 -C "Processing of the Certificate handshake message failed" \
3207 -c "Ciphersuite is TLS-"
3208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003209run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003210 "$O_SRV -key data_files/server2.key \
3211 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003212 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003213 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3214 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003215 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003216 -C "Processing of the Certificate handshake message failed" \
3217 -c "Ciphersuite is TLS-"
3218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003219run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003220 "$O_SRV -key data_files/server2.key \
3221 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003222 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003223 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3224 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003225 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003226 -c "Processing of the Certificate handshake message failed" \
3227 -C "Ciphersuite is TLS-"
3228
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003229run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3230 "$O_SRV -key data_files/server2.key \
3231 -cert data_files/server2.ku-ke.crt" \
3232 "$P_CLI debug_level=1 auth_mode=optional \
3233 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3234 0 \
3235 -c "bad certificate (usage extensions)" \
3236 -C "Processing of the Certificate handshake message failed" \
3237 -c "Ciphersuite is TLS-" \
3238 -c "! Usage does not match the keyUsage extension"
3239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003240run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003241 "$O_SRV -key data_files/server2.key \
3242 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003243 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003244 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3245 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003246 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003247 -C "Processing of the Certificate handshake message failed" \
3248 -c "Ciphersuite is TLS-"
3249
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003250run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003251 "$O_SRV -key data_files/server2.key \
3252 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003253 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003254 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3255 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003256 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003257 -c "Processing of the Certificate handshake message failed" \
3258 -C "Ciphersuite is TLS-"
3259
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003260run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3261 "$O_SRV -key data_files/server2.key \
3262 -cert data_files/server2.ku-ds.crt" \
3263 "$P_CLI debug_level=1 auth_mode=optional \
3264 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3265 0 \
3266 -c "bad certificate (usage extensions)" \
3267 -C "Processing of the Certificate handshake message failed" \
3268 -c "Ciphersuite is TLS-" \
3269 -c "! Usage does not match the keyUsage extension"
3270
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003271# Tests for keyUsage in leaf certificates, part 3:
3272# server-side checking of client cert
3273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003274run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003275 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003276 "$O_CLI -key data_files/server2.key \
3277 -cert data_files/server2.ku-ds.crt" \
3278 0 \
3279 -S "bad certificate (usage extensions)" \
3280 -S "Processing of the Certificate handshake message failed"
3281
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003282run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003283 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003284 "$O_CLI -key data_files/server2.key \
3285 -cert data_files/server2.ku-ke.crt" \
3286 0 \
3287 -s "bad certificate (usage extensions)" \
3288 -S "Processing of the Certificate handshake message failed"
3289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003290run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003291 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003292 "$O_CLI -key data_files/server2.key \
3293 -cert data_files/server2.ku-ke.crt" \
3294 1 \
3295 -s "bad certificate (usage extensions)" \
3296 -s "Processing of the Certificate handshake message failed"
3297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003298run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003299 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003300 "$O_CLI -key data_files/server5.key \
3301 -cert data_files/server5.ku-ds.crt" \
3302 0 \
3303 -S "bad certificate (usage extensions)" \
3304 -S "Processing of the Certificate handshake message failed"
3305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003306run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003307 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003308 "$O_CLI -key data_files/server5.key \
3309 -cert data_files/server5.ku-ka.crt" \
3310 0 \
3311 -s "bad certificate (usage extensions)" \
3312 -S "Processing of the Certificate handshake message failed"
3313
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003314# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3315
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003316run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003317 "$P_SRV key_file=data_files/server5.key \
3318 crt_file=data_files/server5.eku-srv.crt" \
3319 "$P_CLI" \
3320 0
3321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003322run_test "extKeyUsage srv: serverAuth,clientAuth -> 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: codeSign,anyEKU -> 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-cs_any.crt" \
3331 "$P_CLI" \
3332 0
3333
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003334run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003335 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003336 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003337 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003338 1
3339
3340# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003342run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003343 "$O_SRV -key data_files/server5.key \
3344 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003345 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003346 0 \
3347 -C "bad certificate (usage extensions)" \
3348 -C "Processing of the Certificate handshake message failed" \
3349 -c "Ciphersuite is TLS-"
3350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003351run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003352 "$O_SRV -key data_files/server5.key \
3353 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003354 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003355 0 \
3356 -C "bad certificate (usage extensions)" \
3357 -C "Processing of the Certificate handshake message failed" \
3358 -c "Ciphersuite is TLS-"
3359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003360run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003361 "$O_SRV -key data_files/server5.key \
3362 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003363 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003364 0 \
3365 -C "bad certificate (usage extensions)" \
3366 -C "Processing of the Certificate handshake message failed" \
3367 -c "Ciphersuite is TLS-"
3368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003369run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003370 "$O_SRV -key data_files/server5.key \
3371 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003372 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003373 1 \
3374 -c "bad certificate (usage extensions)" \
3375 -c "Processing of the Certificate handshake message failed" \
3376 -C "Ciphersuite is TLS-"
3377
3378# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003380run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003381 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003382 "$O_CLI -key data_files/server5.key \
3383 -cert data_files/server5.eku-cli.crt" \
3384 0 \
3385 -S "bad certificate (usage extensions)" \
3386 -S "Processing of the Certificate handshake message failed"
3387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003388run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003389 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003390 "$O_CLI -key data_files/server5.key \
3391 -cert data_files/server5.eku-srv_cli.crt" \
3392 0 \
3393 -S "bad certificate (usage extensions)" \
3394 -S "Processing of the Certificate handshake message failed"
3395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003396run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003397 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003398 "$O_CLI -key data_files/server5.key \
3399 -cert data_files/server5.eku-cs_any.crt" \
3400 0 \
3401 -S "bad certificate (usage extensions)" \
3402 -S "Processing of the Certificate handshake message failed"
3403
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003404run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003405 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003406 "$O_CLI -key data_files/server5.key \
3407 -cert data_files/server5.eku-cs.crt" \
3408 0 \
3409 -s "bad certificate (usage extensions)" \
3410 -S "Processing of the Certificate handshake message failed"
3411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003412run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003413 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003414 "$O_CLI -key data_files/server5.key \
3415 -cert data_files/server5.eku-cs.crt" \
3416 1 \
3417 -s "bad certificate (usage extensions)" \
3418 -s "Processing of the Certificate handshake message failed"
3419
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003420# Tests for DHM parameters loading
3421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003422run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003423 "$P_SRV" \
3424 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3425 debug_level=3" \
3426 0 \
3427 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003428 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003430run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003431 "$P_SRV dhm_file=data_files/dhparams.pem" \
3432 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3433 debug_level=3" \
3434 0 \
3435 -c "value of 'DHM: P ' (1024 bits)" \
3436 -c "value of 'DHM: G ' (2 bits)"
3437
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003438# Tests for DHM client-side size checking
3439
3440run_test "DHM size: server default, client default, OK" \
3441 "$P_SRV" \
3442 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3443 debug_level=1" \
3444 0 \
3445 -C "DHM prime too short:"
3446
3447run_test "DHM size: server default, client 2048, OK" \
3448 "$P_SRV" \
3449 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3450 debug_level=1 dhmlen=2048" \
3451 0 \
3452 -C "DHM prime too short:"
3453
3454run_test "DHM size: server 1024, client default, OK" \
3455 "$P_SRV dhm_file=data_files/dhparams.pem" \
3456 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3457 debug_level=1" \
3458 0 \
3459 -C "DHM prime too short:"
3460
3461run_test "DHM size: server 1000, client default, rejected" \
3462 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3463 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3464 debug_level=1" \
3465 1 \
3466 -c "DHM prime too short:"
3467
3468run_test "DHM size: server default, client 2049, rejected" \
3469 "$P_SRV" \
3470 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3471 debug_level=1 dhmlen=2049" \
3472 1 \
3473 -c "DHM prime too short:"
3474
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003475# Tests for PSK callback
3476
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003477run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003478 "$P_SRV psk=abc123 psk_identity=foo" \
3479 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3480 psk_identity=foo psk=abc123" \
3481 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003482 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003483 -S "SSL - Unknown identity received" \
3484 -S "SSL - Verification of the message MAC failed"
3485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003486run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003487 "$P_SRV" \
3488 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3489 psk_identity=foo psk=abc123" \
3490 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003491 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003492 -S "SSL - Unknown identity received" \
3493 -S "SSL - Verification of the message MAC failed"
3494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003495run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003496 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3497 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3498 psk_identity=foo psk=abc123" \
3499 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003500 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003501 -s "SSL - Unknown identity received" \
3502 -S "SSL - Verification of the message MAC failed"
3503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003504run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003505 "$P_SRV psk_list=abc,dead,def,beef" \
3506 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3507 psk_identity=abc psk=dead" \
3508 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003509 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003510 -S "SSL - Unknown identity received" \
3511 -S "SSL - Verification of the message MAC failed"
3512
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003513run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003514 "$P_SRV psk_list=abc,dead,def,beef" \
3515 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3516 psk_identity=def psk=beef" \
3517 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003518 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003519 -S "SSL - Unknown identity received" \
3520 -S "SSL - Verification of the message MAC failed"
3521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003522run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003523 "$P_SRV psk_list=abc,dead,def,beef" \
3524 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3525 psk_identity=ghi psk=beef" \
3526 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003527 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003528 -s "SSL - Unknown identity received" \
3529 -S "SSL - Verification of the message MAC failed"
3530
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003531run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003532 "$P_SRV psk_list=abc,dead,def,beef" \
3533 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3534 psk_identity=abc psk=beef" \
3535 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003536 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003537 -S "SSL - Unknown identity received" \
3538 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003539
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003540# Tests for EC J-PAKE
3541
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003542requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003543run_test "ECJPAKE: client not configured" \
3544 "$P_SRV debug_level=3" \
3545 "$P_CLI debug_level=3" \
3546 0 \
3547 -C "add ciphersuite: c0ff" \
3548 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003549 -S "found ecjpake kkpp extension" \
3550 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003551 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003552 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003553 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003554 -S "None of the common ciphersuites is usable"
3555
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003556requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003557run_test "ECJPAKE: server not configured" \
3558 "$P_SRV debug_level=3" \
3559 "$P_CLI debug_level=3 ecjpake_pw=bla \
3560 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3561 1 \
3562 -c "add ciphersuite: c0ff" \
3563 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003564 -s "found ecjpake kkpp extension" \
3565 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003566 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003567 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003568 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003569 -s "None of the common ciphersuites is usable"
3570
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003571requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003572run_test "ECJPAKE: working, TLS" \
3573 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3574 "$P_CLI debug_level=3 ecjpake_pw=bla \
3575 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003576 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003577 -c "add ciphersuite: c0ff" \
3578 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003579 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003580 -s "found ecjpake kkpp extension" \
3581 -S "skip ecjpake kkpp extension" \
3582 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003583 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003584 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003585 -S "None of the common ciphersuites is usable" \
3586 -S "SSL - Verification of the message MAC failed"
3587
Janos Follath74537a62016-09-02 13:45:28 +01003588server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003589requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003590run_test "ECJPAKE: password mismatch, TLS" \
3591 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3592 "$P_CLI debug_level=3 ecjpake_pw=bad \
3593 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3594 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003595 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003596 -s "SSL - Verification of the message MAC failed"
3597
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003598requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003599run_test "ECJPAKE: working, DTLS" \
3600 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3601 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3602 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3603 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003604 -c "re-using cached ecjpake parameters" \
3605 -S "SSL - Verification of the message MAC failed"
3606
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003607requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003608run_test "ECJPAKE: working, DTLS, no cookie" \
3609 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3610 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3611 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3612 0 \
3613 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003614 -S "SSL - Verification of the message MAC failed"
3615
Janos Follath74537a62016-09-02 13:45:28 +01003616server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003617requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003618run_test "ECJPAKE: password mismatch, DTLS" \
3619 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3620 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3621 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3622 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003623 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003624 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003625
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003626# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003627requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003628run_test "ECJPAKE: working, DTLS, nolog" \
3629 "$P_SRV dtls=1 ecjpake_pw=bla" \
3630 "$P_CLI dtls=1 ecjpake_pw=bla \
3631 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3632 0
3633
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003634# Tests for ciphersuites per version
3635
Janos Follathe2681a42016-03-07 15:57:05 +00003636requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003637run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003638 "$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 +02003639 "$P_CLI force_version=ssl3" \
3640 0 \
3641 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003643run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003644 "$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 +01003645 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003646 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003647 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003649run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003650 "$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 +02003651 "$P_CLI force_version=tls1_1" \
3652 0 \
3653 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003655run_test "Per-version suites: TLS 1.2" \
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_2" \
3658 0 \
3659 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3660
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003661# Test for ClientHello without extensions
3662
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003663requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003664run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003665 "$P_SRV debug_level=3" \
3666 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3667 0 \
3668 -s "dumping 'client hello extensions' (0 bytes)"
3669
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003670requires_gnutls
3671run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3672 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3673 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3674 0 \
3675 -s "dumping 'client hello extensions' (0 bytes)"
3676
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003677# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003678
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003679run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003680 "$P_SRV" \
3681 "$P_CLI request_size=100" \
3682 0 \
3683 -s "Read from client: 100 bytes read$"
3684
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003685run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003686 "$P_SRV" \
3687 "$P_CLI request_size=500" \
3688 0 \
3689 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003690
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003691# Tests for small packets
3692
Janos Follathe2681a42016-03-07 15:57:05 +00003693requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003694run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003695 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003696 "$P_CLI request_size=1 force_version=ssl3 \
3697 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3698 0 \
3699 -s "Read from client: 1 bytes read"
3700
Janos Follathe2681a42016-03-07 15:57:05 +00003701requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003702run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003703 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003704 "$P_CLI request_size=1 force_version=ssl3 \
3705 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3706 0 \
3707 -s "Read from client: 1 bytes read"
3708
3709run_test "Small packet TLS 1.0 BlockCipher" \
3710 "$P_SRV" \
3711 "$P_CLI request_size=1 force_version=tls1 \
3712 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3713 0 \
3714 -s "Read from client: 1 bytes read"
3715
Hanno Becker8501f982017-11-10 08:59:04 +00003716run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003717 "$P_SRV" \
3718 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3719 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3720 0 \
3721 -s "Read from client: 1 bytes read"
3722
Hanno Becker32c55012017-11-10 08:42:54 +00003723requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003724run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003725 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003726 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003727 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003728 0 \
3729 -s "Read from client: 1 bytes read"
3730
Hanno Becker32c55012017-11-10 08:42:54 +00003731requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003732run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003733 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003734 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003735 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003736 0 \
3737 -s "Read from client: 1 bytes read"
3738
3739run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003740 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003741 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003742 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3743 0 \
3744 -s "Read from client: 1 bytes read"
3745
3746run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3747 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3748 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003749 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003750 0 \
3751 -s "Read from client: 1 bytes read"
3752
3753requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3754run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003755 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003756 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003757 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003758 0 \
3759 -s "Read from client: 1 bytes read"
3760
Hanno Becker8501f982017-11-10 08:59:04 +00003761requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3762run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003763 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3764 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3765 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003766 0 \
3767 -s "Read from client: 1 bytes read"
3768
3769run_test "Small packet TLS 1.1 BlockCipher" \
3770 "$P_SRV" \
3771 "$P_CLI request_size=1 force_version=tls1_1 \
3772 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3773 0 \
3774 -s "Read from client: 1 bytes read"
3775
Hanno Becker8501f982017-11-10 08:59:04 +00003776run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003777 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003778 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003779 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003780 0 \
3781 -s "Read from client: 1 bytes read"
3782
3783requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3784run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003785 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003786 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003787 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003788 0 \
3789 -s "Read from client: 1 bytes read"
3790
3791requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3792run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003793 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003794 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003795 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003796 0 \
3797 -s "Read from client: 1 bytes read"
3798
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003799run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003800 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003801 "$P_CLI request_size=1 force_version=tls1_1 \
3802 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3803 0 \
3804 -s "Read from client: 1 bytes read"
3805
Hanno Becker8501f982017-11-10 08:59:04 +00003806run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3807 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003808 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003809 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003810 0 \
3811 -s "Read from client: 1 bytes read"
3812
Hanno Becker8501f982017-11-10 08:59:04 +00003813requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3814run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003815 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003816 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003817 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003818 0 \
3819 -s "Read from client: 1 bytes read"
3820
Hanno Becker32c55012017-11-10 08:42:54 +00003821requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003822run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003823 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003824 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003825 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003826 0 \
3827 -s "Read from client: 1 bytes read"
3828
3829run_test "Small packet TLS 1.2 BlockCipher" \
3830 "$P_SRV" \
3831 "$P_CLI request_size=1 force_version=tls1_2 \
3832 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3833 0 \
3834 -s "Read from client: 1 bytes read"
3835
Hanno Becker8501f982017-11-10 08:59:04 +00003836run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003837 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003838 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003839 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003840 0 \
3841 -s "Read from client: 1 bytes read"
3842
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003843run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3844 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003845 "$P_CLI request_size=1 force_version=tls1_2 \
3846 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003847 0 \
3848 -s "Read from client: 1 bytes read"
3849
Hanno Becker32c55012017-11-10 08:42:54 +00003850requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003851run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003852 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003853 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003854 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003855 0 \
3856 -s "Read from client: 1 bytes read"
3857
Hanno Becker8501f982017-11-10 08:59:04 +00003858requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3859run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003860 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003861 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003862 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003863 0 \
3864 -s "Read from client: 1 bytes read"
3865
3866run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003867 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003868 "$P_CLI request_size=1 force_version=tls1_2 \
3869 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3870 0 \
3871 -s "Read from client: 1 bytes read"
3872
Hanno Becker8501f982017-11-10 08:59:04 +00003873run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003874 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003875 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003876 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003877 0 \
3878 -s "Read from client: 1 bytes read"
3879
Hanno Becker32c55012017-11-10 08:42:54 +00003880requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003881run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003882 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003883 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003884 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003885 0 \
3886 -s "Read from client: 1 bytes read"
3887
Hanno Becker8501f982017-11-10 08:59:04 +00003888requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3889run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003890 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003891 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003892 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003893 0 \
3894 -s "Read from client: 1 bytes read"
3895
3896run_test "Small packet TLS 1.2 AEAD" \
3897 "$P_SRV" \
3898 "$P_CLI request_size=1 force_version=tls1_2 \
3899 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3900 0 \
3901 -s "Read from client: 1 bytes read"
3902
3903run_test "Small packet TLS 1.2 AEAD shorter tag" \
3904 "$P_SRV" \
3905 "$P_CLI request_size=1 force_version=tls1_2 \
3906 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3907 0 \
3908 -s "Read from client: 1 bytes read"
3909
Hanno Beckere2148042017-11-10 08:59:18 +00003910# Tests for small packets in DTLS
3911
3912requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3913run_test "Small packet DTLS 1.0" \
3914 "$P_SRV dtls=1 force_version=dtls1" \
3915 "$P_CLI dtls=1 request_size=1 \
3916 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3917 0 \
3918 -s "Read from client: 1 bytes read"
3919
3920requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3921run_test "Small packet DTLS 1.0, without EtM" \
3922 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3923 "$P_CLI dtls=1 request_size=1 \
3924 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3925 0 \
3926 -s "Read from client: 1 bytes read"
3927
3928requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3929requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3930run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003931 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3932 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003933 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3934 0 \
3935 -s "Read from client: 1 bytes read"
3936
3937requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3938requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3939run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003940 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003941 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003942 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003943 0 \
3944 -s "Read from client: 1 bytes read"
3945
3946requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3947run_test "Small packet DTLS 1.2" \
3948 "$P_SRV dtls=1 force_version=dtls1_2" \
3949 "$P_CLI dtls=1 request_size=1 \
3950 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3951 0 \
3952 -s "Read from client: 1 bytes read"
3953
3954requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3955run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003956 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003957 "$P_CLI dtls=1 request_size=1 \
3958 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3959 0 \
3960 -s "Read from client: 1 bytes read"
3961
3962requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3963requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3964run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003965 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003966 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003967 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003968 0 \
3969 -s "Read from client: 1 bytes read"
3970
3971requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3972requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3973run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003974 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003975 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003976 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003977 0 \
3978 -s "Read from client: 1 bytes read"
3979
Janos Follath00efff72016-05-06 13:48:23 +01003980# A test for extensions in SSLv3
3981
3982requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3983run_test "SSLv3 with extensions, server side" \
3984 "$P_SRV min_version=ssl3 debug_level=3" \
3985 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3986 0 \
3987 -S "dumping 'client hello extensions'" \
3988 -S "server hello, total extension length:"
3989
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003990# Test for large packets
3991
Angus Grattonc4dd0732018-04-11 16:28:39 +10003992# How many fragments do we expect to write $1 bytes?
3993fragments_for_write() {
3994 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
3995}
3996
Janos Follathe2681a42016-03-07 15:57:05 +00003997requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003998run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003999 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004000 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004001 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4002 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004003 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4004 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004005
Janos Follathe2681a42016-03-07 15:57:05 +00004006requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004007run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004008 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004009 "$P_CLI request_size=16384 force_version=ssl3 \
4010 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4011 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004012 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4013 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004014
4015run_test "Large packet TLS 1.0 BlockCipher" \
4016 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004017 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004018 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4019 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004020 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4021 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004022
Hanno Becker278fc7a2017-11-10 09:16:28 +00004023run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004024 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004025 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4026 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4027 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004028 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004029
Hanno Becker32c55012017-11-10 08:42:54 +00004030requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004031run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004032 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004033 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004034 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004035 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004036 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4037 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004038
Hanno Becker32c55012017-11-10 08:42:54 +00004039requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004040run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004041 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004042 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004043 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004044 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004045 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004046
4047run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004048 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004049 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004050 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4051 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004052 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004053
4054run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
4055 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4056 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004057 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004058 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004059 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004060
4061requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4062run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004063 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004064 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004065 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004066 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004067 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004068
Hanno Becker278fc7a2017-11-10 09:16:28 +00004069requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4070run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004071 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004072 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004073 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004074 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004075 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4076 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004077
4078run_test "Large packet TLS 1.1 BlockCipher" \
4079 "$P_SRV" \
4080 "$P_CLI request_size=16384 force_version=tls1_1 \
4081 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4082 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004083 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4084 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004085
Hanno Becker278fc7a2017-11-10 09:16:28 +00004086run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
4087 "$P_SRV" \
4088 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4089 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004090 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004091 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004092
Hanno Becker32c55012017-11-10 08:42:54 +00004093requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004094run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004095 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004096 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004097 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004098 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004099 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004100
Hanno Becker32c55012017-11-10 08:42:54 +00004101requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004102run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004103 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004104 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004105 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004106 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004107 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004108
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004109run_test "Large packet TLS 1.1 StreamCipher" \
4110 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4111 "$P_CLI request_size=16384 force_version=tls1_1 \
4112 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4113 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004114 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4115 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004116
Hanno Becker278fc7a2017-11-10 09:16:28 +00004117run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
4118 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004119 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004120 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004121 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004122 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4123 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004124
Hanno Becker278fc7a2017-11-10 09:16:28 +00004125requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4126run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004127 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004128 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004129 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004130 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004131 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004132
Hanno Becker278fc7a2017-11-10 09:16:28 +00004133requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4134run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004135 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004136 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004137 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004138 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004139 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4140 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004141
4142run_test "Large packet TLS 1.2 BlockCipher" \
4143 "$P_SRV" \
4144 "$P_CLI request_size=16384 force_version=tls1_2 \
4145 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4146 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004147 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4148 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004149
Hanno Becker278fc7a2017-11-10 09:16:28 +00004150run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
4151 "$P_SRV" \
4152 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4153 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4154 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004155 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004156
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004157run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
4158 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004159 "$P_CLI request_size=16384 force_version=tls1_2 \
4160 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004161 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004162 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4163 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004164
Hanno Becker32c55012017-11-10 08:42:54 +00004165requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004166run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004167 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004168 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004169 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004170 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004171 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004172
Hanno Becker278fc7a2017-11-10 09:16:28 +00004173requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4174run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004175 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004176 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004177 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004178 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004179 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4180 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004181
4182run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004183 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004184 "$P_CLI request_size=16384 force_version=tls1_2 \
4185 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4186 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004187 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4188 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004189
Hanno Becker278fc7a2017-11-10 09:16:28 +00004190run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004191 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004192 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004193 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4194 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004195 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004196
Hanno Becker32c55012017-11-10 08:42:54 +00004197requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004198run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004199 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004200 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004201 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004202 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004203 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004204
Hanno Becker278fc7a2017-11-10 09:16:28 +00004205requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4206run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004207 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004208 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004209 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004210 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004211 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4212 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004213
4214run_test "Large packet TLS 1.2 AEAD" \
4215 "$P_SRV" \
4216 "$P_CLI request_size=16384 force_version=tls1_2 \
4217 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4218 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004219 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4220 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004221
4222run_test "Large packet TLS 1.2 AEAD shorter tag" \
4223 "$P_SRV" \
4224 "$P_CLI request_size=16384 force_version=tls1_2 \
4225 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4226 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004227 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4228 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004229
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004230# Tests of asynchronous private key support in SSL
4231
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004232requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004233run_test "SSL async private: sign, delay=0" \
4234 "$P_SRV \
4235 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004236 "$P_CLI" \
4237 0 \
4238 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004239 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004240
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004241requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004242run_test "SSL async private: sign, delay=1" \
4243 "$P_SRV \
4244 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004245 "$P_CLI" \
4246 0 \
4247 -s "Async sign callback: using key slot " \
4248 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004249 -s "Async resume (slot [0-9]): sign done, status=0"
4250
Gilles Peskine12d0cc12018-04-26 15:06:56 +02004251requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4252run_test "SSL async private: sign, delay=2" \
4253 "$P_SRV \
4254 async_operations=s async_private_delay1=2 async_private_delay2=2" \
4255 "$P_CLI" \
4256 0 \
4257 -s "Async sign callback: using key slot " \
4258 -U "Async sign callback: using key slot " \
4259 -s "Async resume (slot [0-9]): call 1 more times." \
4260 -s "Async resume (slot [0-9]): call 0 more times." \
4261 -s "Async resume (slot [0-9]): sign done, status=0"
4262
Gilles Peskined3268832018-04-26 06:23:59 +02004263# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
4264# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
4265requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4266requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4267run_test "SSL async private: sign, RSA, TLS 1.1" \
4268 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
4269 async_operations=s async_private_delay1=0 async_private_delay2=0" \
4270 "$P_CLI force_version=tls1_1" \
4271 0 \
4272 -s "Async sign callback: using key slot " \
4273 -s "Async resume (slot [0-9]): sign done, status=0"
4274
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004275requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02004276run_test "SSL async private: sign, SNI" \
4277 "$P_SRV debug_level=3 \
4278 async_operations=s async_private_delay1=0 async_private_delay2=0 \
4279 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4280 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4281 "$P_CLI server_name=polarssl.example" \
4282 0 \
4283 -s "Async sign callback: using key slot " \
4284 -s "Async resume (slot [0-9]): sign done, status=0" \
4285 -s "parse ServerName extension" \
4286 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4287 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4288
4289requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004290run_test "SSL async private: decrypt, delay=0" \
4291 "$P_SRV \
4292 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4293 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4294 0 \
4295 -s "Async decrypt callback: using key slot " \
4296 -s "Async resume (slot [0-9]): decrypt done, status=0"
4297
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004298requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004299run_test "SSL async private: decrypt, delay=1" \
4300 "$P_SRV \
4301 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4302 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4303 0 \
4304 -s "Async decrypt callback: using key slot " \
4305 -s "Async resume (slot [0-9]): call 0 more times." \
4306 -s "Async resume (slot [0-9]): decrypt done, status=0"
4307
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004308requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004309run_test "SSL async private: decrypt RSA-PSK, delay=0" \
4310 "$P_SRV psk=abc123 \
4311 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4312 "$P_CLI psk=abc123 \
4313 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4314 0 \
4315 -s "Async decrypt callback: using key slot " \
4316 -s "Async resume (slot [0-9]): decrypt done, status=0"
4317
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004318requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004319run_test "SSL async private: decrypt RSA-PSK, delay=1" \
4320 "$P_SRV psk=abc123 \
4321 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4322 "$P_CLI psk=abc123 \
4323 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4324 0 \
4325 -s "Async decrypt callback: using key slot " \
4326 -s "Async resume (slot [0-9]): call 0 more times." \
4327 -s "Async resume (slot [0-9]): decrypt done, status=0"
4328
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004329requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004330run_test "SSL async private: sign callback not present" \
4331 "$P_SRV \
4332 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4333 "$P_CLI; [ \$? -eq 1 ] &&
4334 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4335 0 \
4336 -S "Async sign callback" \
4337 -s "! mbedtls_ssl_handshake returned" \
4338 -s "The own private key or pre-shared key is not set, but needed" \
4339 -s "Async resume (slot [0-9]): decrypt done, status=0" \
4340 -s "Successful connection"
4341
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004342requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004343run_test "SSL async private: decrypt callback not present" \
4344 "$P_SRV debug_level=1 \
4345 async_operations=s async_private_delay1=1 async_private_delay2=1" \
4346 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
4347 [ \$? -eq 1 ] && $P_CLI" \
4348 0 \
4349 -S "Async decrypt callback" \
4350 -s "! mbedtls_ssl_handshake returned" \
4351 -s "got no RSA private key" \
4352 -s "Async resume (slot [0-9]): sign done, status=0" \
4353 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004354
4355# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004356requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004357run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004358 "$P_SRV \
4359 async_operations=s async_private_delay1=1 \
4360 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4361 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004362 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4363 0 \
4364 -s "Async sign callback: using key slot 0," \
4365 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004366 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004367
4368# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004369requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004370run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004371 "$P_SRV \
4372 async_operations=s async_private_delay2=1 \
4373 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4374 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004375 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4376 0 \
4377 -s "Async sign callback: using key slot 0," \
4378 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004379 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004380
4381# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004382requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02004383run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004384 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02004385 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004386 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4387 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004388 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4389 0 \
4390 -s "Async sign callback: using key slot 1," \
4391 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004392 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004393
4394# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004395requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004396run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004397 "$P_SRV \
4398 async_operations=s async_private_delay1=1 \
4399 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4400 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004401 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4402 0 \
4403 -s "Async sign callback: no key matches this certificate."
4404
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004405requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004406run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004407 "$P_SRV \
4408 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4409 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004410 "$P_CLI" \
4411 1 \
4412 -s "Async sign callback: injected error" \
4413 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004414 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004415 -s "! mbedtls_ssl_handshake returned"
4416
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004417requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004418run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004419 "$P_SRV \
4420 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4421 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004422 "$P_CLI" \
4423 1 \
4424 -s "Async sign callback: using key slot " \
4425 -S "Async resume" \
4426 -s "Async cancel"
4427
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004428requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004429run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004430 "$P_SRV \
4431 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4432 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004433 "$P_CLI" \
4434 1 \
4435 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004436 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004437 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004438 -s "! mbedtls_ssl_handshake returned"
4439
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004440requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004441run_test "SSL async private: decrypt, error in start" \
4442 "$P_SRV \
4443 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4444 async_private_error=1" \
4445 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4446 1 \
4447 -s "Async decrypt callback: injected error" \
4448 -S "Async resume" \
4449 -S "Async cancel" \
4450 -s "! mbedtls_ssl_handshake returned"
4451
4452requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4453run_test "SSL async private: decrypt, cancel after start" \
4454 "$P_SRV \
4455 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4456 async_private_error=2" \
4457 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4458 1 \
4459 -s "Async decrypt callback: using key slot " \
4460 -S "Async resume" \
4461 -s "Async cancel"
4462
4463requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4464run_test "SSL async private: decrypt, error in resume" \
4465 "$P_SRV \
4466 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4467 async_private_error=3" \
4468 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4469 1 \
4470 -s "Async decrypt callback: using key slot " \
4471 -s "Async resume callback: decrypt done but injected error" \
4472 -S "Async cancel" \
4473 -s "! mbedtls_ssl_handshake returned"
4474
4475requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004476run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004477 "$P_SRV \
4478 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4479 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004480 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4481 0 \
4482 -s "Async cancel" \
4483 -s "! mbedtls_ssl_handshake returned" \
4484 -s "Async resume" \
4485 -s "Successful connection"
4486
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004487requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004488run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004489 "$P_SRV \
4490 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4491 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004492 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4493 0 \
4494 -s "! mbedtls_ssl_handshake returned" \
4495 -s "Async resume" \
4496 -s "Successful connection"
4497
4498# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004499requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004500run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004501 "$P_SRV \
4502 async_operations=s async_private_delay1=1 async_private_error=-2 \
4503 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4504 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004505 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4506 [ \$? -eq 1 ] &&
4507 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4508 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02004509 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004510 -S "Async resume" \
4511 -s "Async cancel" \
4512 -s "! mbedtls_ssl_handshake returned" \
4513 -s "Async sign callback: no key matches this certificate." \
4514 -s "Successful connection"
4515
4516# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004517requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004518run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004519 "$P_SRV \
4520 async_operations=s async_private_delay1=1 async_private_error=-3 \
4521 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4522 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004523 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4524 [ \$? -eq 1 ] &&
4525 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4526 0 \
4527 -s "Async resume" \
4528 -s "! mbedtls_ssl_handshake returned" \
4529 -s "Async sign callback: no key matches this certificate." \
4530 -s "Successful connection"
4531
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004532requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004533requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004534run_test "SSL async private: renegotiation: client-initiated; sign" \
4535 "$P_SRV \
4536 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004537 exchanges=2 renegotiation=1" \
4538 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
4539 0 \
4540 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004541 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004542
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004543requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004544requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004545run_test "SSL async private: renegotiation: server-initiated; sign" \
4546 "$P_SRV \
4547 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004548 exchanges=2 renegotiation=1 renegotiate=1" \
4549 "$P_CLI exchanges=2 renegotiation=1" \
4550 0 \
4551 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004552 -s "Async resume (slot [0-9]): sign done, status=0"
4553
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004554requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004555requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4556run_test "SSL async private: renegotiation: client-initiated; decrypt" \
4557 "$P_SRV \
4558 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4559 exchanges=2 renegotiation=1" \
4560 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
4561 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4562 0 \
4563 -s "Async decrypt callback: using key slot " \
4564 -s "Async resume (slot [0-9]): decrypt done, status=0"
4565
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004566requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004567requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4568run_test "SSL async private: renegotiation: server-initiated; decrypt" \
4569 "$P_SRV \
4570 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4571 exchanges=2 renegotiation=1 renegotiate=1" \
4572 "$P_CLI exchanges=2 renegotiation=1 \
4573 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4574 0 \
4575 -s "Async decrypt callback: using key slot " \
4576 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004577
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004578# Tests for DTLS HelloVerifyRequest
4579
4580run_test "DTLS cookie: enabled" \
4581 "$P_SRV dtls=1 debug_level=2" \
4582 "$P_CLI dtls=1 debug_level=2" \
4583 0 \
4584 -s "cookie verification failed" \
4585 -s "cookie verification passed" \
4586 -S "cookie verification skipped" \
4587 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004588 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004589 -S "SSL - The requested feature is not available"
4590
4591run_test "DTLS cookie: disabled" \
4592 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4593 "$P_CLI dtls=1 debug_level=2" \
4594 0 \
4595 -S "cookie verification failed" \
4596 -S "cookie verification passed" \
4597 -s "cookie verification skipped" \
4598 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004599 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004600 -S "SSL - The requested feature is not available"
4601
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004602run_test "DTLS cookie: default (failing)" \
4603 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4604 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4605 1 \
4606 -s "cookie verification failed" \
4607 -S "cookie verification passed" \
4608 -S "cookie verification skipped" \
4609 -C "received hello verify request" \
4610 -S "hello verification requested" \
4611 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004612
4613requires_ipv6
4614run_test "DTLS cookie: enabled, IPv6" \
4615 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4616 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4617 0 \
4618 -s "cookie verification failed" \
4619 -s "cookie verification passed" \
4620 -S "cookie verification skipped" \
4621 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004622 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004623 -S "SSL - The requested feature is not available"
4624
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004625run_test "DTLS cookie: enabled, nbio" \
4626 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4627 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4628 0 \
4629 -s "cookie verification failed" \
4630 -s "cookie verification passed" \
4631 -S "cookie verification skipped" \
4632 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004633 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004634 -S "SSL - The requested feature is not available"
4635
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004636# Tests for client reconnecting from the same port with DTLS
4637
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004638not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004639run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004640 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4641 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004642 0 \
4643 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004644 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004645 -S "Client initiated reconnection from same port"
4646
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004647not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004648run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004649 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4650 "$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 +02004651 0 \
4652 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004653 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004654 -s "Client initiated reconnection from same port"
4655
Paul Bakker362689d2016-05-13 10:33:25 +01004656not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4657run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004658 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4659 "$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 +02004660 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004661 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004662 -s "Client initiated reconnection from same port"
4663
Paul Bakker362689d2016-05-13 10:33:25 +01004664only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4665run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4666 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4667 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4668 0 \
4669 -S "The operation timed out" \
4670 -s "Client initiated reconnection from same port"
4671
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004672run_test "DTLS client reconnect from same port: no cookies" \
4673 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004674 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4675 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004676 -s "The operation timed out" \
4677 -S "Client initiated reconnection from same port"
4678
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004679# Tests for various cases of client authentication with DTLS
4680# (focused on handshake flows and message parsing)
4681
4682run_test "DTLS client auth: required" \
4683 "$P_SRV dtls=1 auth_mode=required" \
4684 "$P_CLI dtls=1" \
4685 0 \
4686 -s "Verifying peer X.509 certificate... ok"
4687
4688run_test "DTLS client auth: optional, client has no cert" \
4689 "$P_SRV dtls=1 auth_mode=optional" \
4690 "$P_CLI dtls=1 crt_file=none key_file=none" \
4691 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004692 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004693
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004694run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004695 "$P_SRV dtls=1 auth_mode=none" \
4696 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
4697 0 \
4698 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004699 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004700
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02004701run_test "DTLS wrong PSK: badmac alert" \
4702 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
4703 "$P_CLI dtls=1 psk=abc124" \
4704 1 \
4705 -s "SSL - Verification of the message MAC failed" \
4706 -c "SSL - A fatal alert message was received from our peer"
4707
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02004708# Tests for receiving fragmented handshake messages with DTLS
4709
4710requires_gnutls
4711run_test "DTLS reassembly: no fragmentation (gnutls server)" \
4712 "$G_SRV -u --mtu 2048 -a" \
4713 "$P_CLI dtls=1 debug_level=2" \
4714 0 \
4715 -C "found fragmented DTLS handshake message" \
4716 -C "error"
4717
4718requires_gnutls
4719run_test "DTLS reassembly: some fragmentation (gnutls server)" \
4720 "$G_SRV -u --mtu 512" \
4721 "$P_CLI dtls=1 debug_level=2" \
4722 0 \
4723 -c "found fragmented DTLS handshake message" \
4724 -C "error"
4725
4726requires_gnutls
4727run_test "DTLS reassembly: more fragmentation (gnutls server)" \
4728 "$G_SRV -u --mtu 128" \
4729 "$P_CLI dtls=1 debug_level=2" \
4730 0 \
4731 -c "found fragmented DTLS handshake message" \
4732 -C "error"
4733
4734requires_gnutls
4735run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
4736 "$G_SRV -u --mtu 128" \
4737 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4738 0 \
4739 -c "found fragmented DTLS handshake message" \
4740 -C "error"
4741
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004742requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004743requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004744run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4745 "$G_SRV -u --mtu 256" \
4746 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4747 0 \
4748 -c "found fragmented DTLS handshake message" \
4749 -c "client hello, adding renegotiation extension" \
4750 -c "found renegotiation extension" \
4751 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004752 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004753 -C "error" \
4754 -s "Extra-header:"
4755
4756requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004757requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004758run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4759 "$G_SRV -u --mtu 256" \
4760 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4761 0 \
4762 -c "found fragmented DTLS handshake message" \
4763 -c "client hello, adding renegotiation extension" \
4764 -c "found renegotiation extension" \
4765 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004766 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004767 -C "error" \
4768 -s "Extra-header:"
4769
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004770run_test "DTLS reassembly: no fragmentation (openssl server)" \
4771 "$O_SRV -dtls1 -mtu 2048" \
4772 "$P_CLI dtls=1 debug_level=2" \
4773 0 \
4774 -C "found fragmented DTLS handshake message" \
4775 -C "error"
4776
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004777run_test "DTLS reassembly: some fragmentation (openssl server)" \
4778 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004779 "$P_CLI dtls=1 debug_level=2" \
4780 0 \
4781 -c "found fragmented DTLS handshake message" \
4782 -C "error"
4783
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004784run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004785 "$O_SRV -dtls1 -mtu 256" \
4786 "$P_CLI dtls=1 debug_level=2" \
4787 0 \
4788 -c "found fragmented DTLS handshake message" \
4789 -C "error"
4790
4791run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4792 "$O_SRV -dtls1 -mtu 256" \
4793 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4794 0 \
4795 -c "found fragmented DTLS handshake message" \
4796 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004797
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004798# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004799
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004800not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004801run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004802 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004803 "$P_SRV dtls=1 debug_level=2" \
4804 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004805 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004806 -C "replayed record" \
4807 -S "replayed record" \
4808 -C "record from another epoch" \
4809 -S "record from another epoch" \
4810 -C "discarding invalid record" \
4811 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004812 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004813 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004814 -c "HTTP/1.0 200 OK"
4815
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004816not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004817run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004818 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004819 "$P_SRV dtls=1 debug_level=2" \
4820 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004821 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004822 -c "replayed record" \
4823 -s "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004824 -c "record from another epoch" \
4825 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004826 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004827 -s "Extra-header:" \
4828 -c "HTTP/1.0 200 OK"
4829
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004830run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4831 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004832 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4833 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004834 0 \
4835 -c "replayed record" \
4836 -S "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004837 -c "record from another epoch" \
4838 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004839 -c "resend" \
4840 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004841 -s "Extra-header:" \
4842 -c "HTTP/1.0 200 OK"
4843
Hanno Becker72a4f032017-11-15 16:39:20 +00004844run_test "DTLS proxy: multiple records in same datagram" \
Hanno Becker8d832182018-03-15 10:14:19 +00004845 -p "$P_PXY pack=50" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004846 "$P_SRV dtls=1 debug_level=2" \
4847 "$P_CLI dtls=1 debug_level=2" \
4848 0 \
4849 -c "next record in same datagram" \
4850 -s "next record in same datagram"
4851
4852run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
Hanno Becker8d832182018-03-15 10:14:19 +00004853 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004854 "$P_SRV dtls=1 debug_level=2" \
4855 "$P_CLI dtls=1 debug_level=2" \
4856 0 \
4857 -c "next record in same datagram" \
4858 -s "next record in same datagram"
4859
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004860run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004861 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004862 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004863 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004864 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004865 -c "discarding invalid record (mac)" \
4866 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004867 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004868 -c "HTTP/1.0 200 OK" \
4869 -S "too many records with bad MAC" \
4870 -S "Verification of the message MAC failed"
4871
4872run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4873 -p "$P_PXY bad_ad=1" \
4874 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4875 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4876 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004877 -C "discarding invalid record (mac)" \
4878 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004879 -S "Extra-header:" \
4880 -C "HTTP/1.0 200 OK" \
4881 -s "too many records with bad MAC" \
4882 -s "Verification of the message MAC failed"
4883
4884run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4885 -p "$P_PXY bad_ad=1" \
4886 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4887 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4888 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004889 -c "discarding invalid record (mac)" \
4890 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004891 -s "Extra-header:" \
4892 -c "HTTP/1.0 200 OK" \
4893 -S "too many records with bad MAC" \
4894 -S "Verification of the message MAC failed"
4895
4896run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4897 -p "$P_PXY bad_ad=1" \
4898 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4899 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4900 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004901 -c "discarding invalid record (mac)" \
4902 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004903 -s "Extra-header:" \
4904 -c "HTTP/1.0 200 OK" \
4905 -s "too many records with bad MAC" \
4906 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004907
4908run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004909 -p "$P_PXY delay_ccs=1" \
4910 "$P_SRV dtls=1 debug_level=1" \
4911 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004912 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004913 -c "record from another epoch" \
4914 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004915 -s "Extra-header:" \
4916 -c "HTTP/1.0 200 OK"
4917
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004918# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004919
Janos Follath74537a62016-09-02 13:45:28 +01004920client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004921run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004922 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004923 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4924 psk=abc123" \
4925 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004926 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4927 0 \
4928 -s "Extra-header:" \
4929 -c "HTTP/1.0 200 OK"
4930
Janos Follath74537a62016-09-02 13:45:28 +01004931client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004932run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4933 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004934 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4935 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004936 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4937 0 \
4938 -s "Extra-header:" \
4939 -c "HTTP/1.0 200 OK"
4940
Janos Follath74537a62016-09-02 13:45:28 +01004941client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004942run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4943 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004944 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4945 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004946 0 \
4947 -s "Extra-header:" \
4948 -c "HTTP/1.0 200 OK"
4949
Janos Follath74537a62016-09-02 13:45:28 +01004950client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004951run_test "DTLS proxy: 3d, FS, client auth" \
4952 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004953 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4954 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004955 0 \
4956 -s "Extra-header:" \
4957 -c "HTTP/1.0 200 OK"
4958
Janos Follath74537a62016-09-02 13:45:28 +01004959client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004960run_test "DTLS proxy: 3d, FS, ticket" \
4961 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004962 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4963 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004964 0 \
4965 -s "Extra-header:" \
4966 -c "HTTP/1.0 200 OK"
4967
Janos Follath74537a62016-09-02 13:45:28 +01004968client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004969run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4970 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004971 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4972 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004973 0 \
4974 -s "Extra-header:" \
4975 -c "HTTP/1.0 200 OK"
4976
Janos Follath74537a62016-09-02 13:45:28 +01004977client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004978run_test "DTLS proxy: 3d, max handshake, nbio" \
4979 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004980 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4981 auth_mode=required" \
4982 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004983 0 \
4984 -s "Extra-header:" \
4985 -c "HTTP/1.0 200 OK"
4986
Janos Follath74537a62016-09-02 13:45:28 +01004987client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004988run_test "DTLS proxy: 3d, min handshake, resumption" \
4989 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4990 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4991 psk=abc123 debug_level=3" \
4992 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4993 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4994 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4995 0 \
4996 -s "a session has been resumed" \
4997 -c "a session has been resumed" \
4998 -s "Extra-header:" \
4999 -c "HTTP/1.0 200 OK"
5000
Janos Follath74537a62016-09-02 13:45:28 +01005001client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005002run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
5003 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5004 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5005 psk=abc123 debug_level=3 nbio=2" \
5006 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5007 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5008 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
5009 0 \
5010 -s "a session has been resumed" \
5011 -c "a session has been resumed" \
5012 -s "Extra-header:" \
5013 -c "HTTP/1.0 200 OK"
5014
Janos Follath74537a62016-09-02 13:45:28 +01005015client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005016requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005017run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005018 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005019 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5020 psk=abc123 renegotiation=1 debug_level=2" \
5021 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5022 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005023 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5024 0 \
5025 -c "=> renegotiate" \
5026 -s "=> renegotiate" \
5027 -s "Extra-header:" \
5028 -c "HTTP/1.0 200 OK"
5029
Janos Follath74537a62016-09-02 13:45:28 +01005030client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005031requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005032run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
5033 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005034 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5035 psk=abc123 renegotiation=1 debug_level=2" \
5036 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5037 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005038 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5039 0 \
5040 -c "=> renegotiate" \
5041 -s "=> renegotiate" \
5042 -s "Extra-header:" \
5043 -c "HTTP/1.0 200 OK"
5044
Janos Follath74537a62016-09-02 13:45:28 +01005045client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005046requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005047run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005048 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005049 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005050 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005051 debug_level=2" \
5052 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005053 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005054 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5055 0 \
5056 -c "=> renegotiate" \
5057 -s "=> renegotiate" \
5058 -s "Extra-header:" \
5059 -c "HTTP/1.0 200 OK"
5060
Janos Follath74537a62016-09-02 13:45:28 +01005061client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005062requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005063run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005064 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005065 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005066 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005067 debug_level=2 nbio=2" \
5068 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005069 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005070 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5071 0 \
5072 -c "=> renegotiate" \
5073 -s "=> renegotiate" \
5074 -s "Extra-header:" \
5075 -c "HTTP/1.0 200 OK"
5076
Janos Follath74537a62016-09-02 13:45:28 +01005077client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005078not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005079run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005080 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5081 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005082 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005083 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005084 -c "HTTP/1.0 200 OK"
5085
Janos Follath74537a62016-09-02 13:45:28 +01005086client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005087not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005088run_test "DTLS proxy: 3d, openssl server, fragmentation" \
5089 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5090 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005091 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005092 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005093 -c "HTTP/1.0 200 OK"
5094
Janos Follath74537a62016-09-02 13:45:28 +01005095client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005096not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005097run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
5098 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5099 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005100 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005101 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005102 -c "HTTP/1.0 200 OK"
5103
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005104requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005105client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005106not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005107run_test "DTLS proxy: 3d, gnutls server" \
5108 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5109 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005110 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005111 0 \
5112 -s "Extra-header:" \
5113 -c "Extra-header:"
5114
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005115requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005116client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005117not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005118run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
5119 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5120 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005121 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005122 0 \
5123 -s "Extra-header:" \
5124 -c "Extra-header:"
5125
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005126requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005127client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005128not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005129run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
5130 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5131 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005132 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005133 0 \
5134 -s "Extra-header:" \
5135 -c "Extra-header:"
5136
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01005137# Final report
5138
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005139echo "------------------------------------------------------------------------"
5140
5141if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005142 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005143else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005144 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005145fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02005146PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02005147echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005148
5149exit $FAILS