blob: 5863e77502f81a32f2c46eabff011bd0d3c837a3 [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
Jaeden Amero34730912019-07-03 13:51:04 +010024# Limit the size of each log to 10 GiB, in case of failures with this script
25# where it may output seemingly unlimited length error logs.
26ulimit -f 20971520
27
Antonin Décimo8fd91562019-01-23 15:24:37 +010028# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010029: ${P_SRV:=../programs/ssl/ssl_server2}
30: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020031: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010032: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020033: ${GNUTLS_CLI:=gnutls-cli}
34: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020035: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010036
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020037O_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 +010038O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020039G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010040G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020041TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010042
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010043TESTS=0
44FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020045SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010046
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000047CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020048
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010049MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010050FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020051EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052
Paul Bakkere20310a2016-05-10 11:18:17 +010053SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010054RUN_TEST_NUMBER=''
55
Paul Bakkeracaac852016-05-10 11:47:13 +010056PRESERVE_LOGS=0
57
Gilles Peskinef93c7d32017-04-14 17:55:28 +020058# Pick a "unique" server port in the range 10000-19999, and a proxy
59# port which is this plus 10000. Each port number may be independently
60# overridden by a command line option.
61SRV_PORT=$(($$ % 10000 + 10000))
62PXY_PORT=$((SRV_PORT + 10000))
63
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010064print_usage() {
65 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010066 printf " -h|--help\tPrint this help.\n"
67 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020068 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
69 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010070 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010071 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010072 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020073 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
74 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010075 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010076}
77
78get_options() {
79 while [ $# -gt 0 ]; do
80 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010081 -f|--filter)
82 shift; FILTER=$1
83 ;;
84 -e|--exclude)
85 shift; EXCLUDE=$1
86 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010087 -m|--memcheck)
88 MEMCHECK=1
89 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010090 -n|--number)
91 shift; RUN_TEST_NUMBER=$1
92 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010093 -s|--show-numbers)
94 SHOW_TEST_NUMBER=1
95 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010096 -p|--preserve-logs)
97 PRESERVE_LOGS=1
98 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020099 --port)
100 shift; SRV_PORT=$1
101 ;;
102 --proxy-port)
103 shift; PXY_PORT=$1
104 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100105 --seed)
106 shift; SEED="$1"
107 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100108 -h|--help)
109 print_usage
110 exit 0
111 ;;
112 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200113 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100114 print_usage
115 exit 1
116 ;;
117 esac
118 shift
119 done
120}
121
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100122# skip next test if the flag is not enabled in config.h
123requires_config_enabled() {
124 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
125 SKIP_NEXT="YES"
126 fi
127}
128
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200129# skip next test if the flag is enabled in config.h
130requires_config_disabled() {
131 if grep "^#define $1" $CONFIG_H > /dev/null; then
132 SKIP_NEXT="YES"
133 fi
134}
135
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200136# skip next test if OpenSSL doesn't support FALLBACK_SCSV
137requires_openssl_with_fallback_scsv() {
138 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
139 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
140 then
141 OPENSSL_HAS_FBSCSV="YES"
142 else
143 OPENSSL_HAS_FBSCSV="NO"
144 fi
145 fi
146 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
147 SKIP_NEXT="YES"
148 fi
149}
150
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151# skip next test if GnuTLS isn't available
152requires_gnutls() {
153 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200154 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200155 GNUTLS_AVAILABLE="YES"
156 else
157 GNUTLS_AVAILABLE="NO"
158 fi
159 fi
160 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
161 SKIP_NEXT="YES"
162 fi
163}
164
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200165# skip next test if IPv6 isn't available on this host
166requires_ipv6() {
167 if [ -z "${HAS_IPV6:-}" ]; then
168 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
169 SRV_PID=$!
170 sleep 1
171 kill $SRV_PID >/dev/null 2>&1
172 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
173 HAS_IPV6="NO"
174 else
175 HAS_IPV6="YES"
176 fi
177 rm -r $SRV_OUT
178 fi
179
180 if [ "$HAS_IPV6" = "NO" ]; then
181 SKIP_NEXT="YES"
182 fi
183}
184
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200185# skip the next test if valgrind is in use
186not_with_valgrind() {
187 if [ "$MEMCHECK" -gt 0 ]; then
188 SKIP_NEXT="YES"
189 fi
190}
191
Paul Bakker362689d2016-05-13 10:33:25 +0100192# skip the next test if valgrind is NOT in use
193only_with_valgrind() {
194 if [ "$MEMCHECK" -eq 0 ]; then
195 SKIP_NEXT="YES"
196 fi
197}
198
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200199# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100200client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200201 CLI_DELAY_FACTOR=$1
202}
203
Janos Follath74537a62016-09-02 13:45:28 +0100204# wait for the given seconds after the client finished in the next test
205server_needs_more_time() {
206 SRV_DELAY_SECONDS=$1
207}
208
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100209# print_name <name>
210print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100211 TESTS=$(( $TESTS + 1 ))
212 LINE=""
213
214 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
215 LINE="$TESTS "
216 fi
217
218 LINE="$LINE$1"
219 printf "$LINE "
220 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100221 for i in `seq 1 $LEN`; do printf '.'; done
222 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100223
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100224}
225
226# fail <message>
227fail() {
228 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100229 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100230
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200231 mv $SRV_OUT o-srv-${TESTS}.log
232 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200233 if [ -n "$PXY_CMD" ]; then
234 mv $PXY_OUT o-pxy-${TESTS}.log
235 fi
236 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100237
Azim Khan03da1212018-03-29 11:04:20 +0100238 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 +0200239 echo " ! server output:"
240 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200241 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200242 echo " ! client output:"
243 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200244 if [ -n "$PXY_CMD" ]; then
245 echo " ! ========================================================"
246 echo " ! proxy output:"
247 cat o-pxy-${TESTS}.log
248 fi
249 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200250 fi
251
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200252 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100253}
254
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100255# is_polar <cmd_line>
256is_polar() {
257 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
258}
259
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200260# openssl s_server doesn't have -www with DTLS
261check_osrv_dtls() {
262 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
263 NEEDS_INPUT=1
264 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
265 else
266 NEEDS_INPUT=0
267 fi
268}
269
270# provide input to commands that need it
271provide_input() {
272 if [ $NEEDS_INPUT -eq 0 ]; then
273 return
274 fi
275
276 while true; do
277 echo "HTTP/1.0 200 OK"
278 sleep 1
279 done
280}
281
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100282# has_mem_err <log_file_name>
283has_mem_err() {
284 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
285 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
286 then
287 return 1 # false: does not have errors
288 else
289 return 0 # true: has errors
290 fi
291}
292
Unknownb86bcb42019-09-02 10:42:57 -0400293# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100294if type lsof >/dev/null 2>/dev/null; then
Unknownb86bcb42019-09-02 10:42:57 -0400295 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100296 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200297 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100298 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200299 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100300 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200301 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100302 # Make a tight loop, server normally takes less than 1s to start.
303 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
304 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknownb86bcb42019-09-02 10:42:57 -0400305 echo "$3 START TIMEOUT"
306 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100307 break
308 fi
309 # Linux and *BSD support decimal arguments to sleep. On other
310 # OSes this may be a tight loop.
311 sleep 0.1 2>/dev/null || true
312 done
313 }
314else
Unknownb86bcb42019-09-02 10:42:57 -0400315 echo "Warning: lsof not available, wait_app_start = sleep"
316 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200317 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100318 }
319fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200320
Unknownb86bcb42019-09-02 10:42:57 -0400321# Wait for server process $2 to be listening on port $1.
322wait_server_start() {
323 wait_app_start $1 $2 "SERVER" $SRV_OUT
324}
325
326# Wait for proxy process $2 to be listening on port $1.
327wait_proxy_start() {
328 wait_app_start $1 $2 "PROXY" $PXY_OUT
329}
330
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100331# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100332# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100333# acceptable bounds
334check_server_hello_time() {
335 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100336 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100337 # Get the Unix timestamp for now
338 CUR_TIME=$(date +'%s')
339 THRESHOLD_IN_SECS=300
340
341 # Check if the ServerHello time was printed
342 if [ -z "$SERVER_HELLO_TIME" ]; then
343 return 1
344 fi
345
346 # Check the time in ServerHello is within acceptable bounds
347 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
348 # The time in ServerHello is at least 5 minutes before now
349 return 1
350 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100351 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100352 return 1
353 else
354 return 0
355 fi
356}
357
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200358# wait for client to terminate and set CLI_EXIT
359# must be called right after starting the client
360wait_client_done() {
361 CLI_PID=$!
362
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200363 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
364 CLI_DELAY_FACTOR=1
365
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200366 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200367 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200368
369 wait $CLI_PID
370 CLI_EXIT=$?
371
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200372 kill $DOG_PID >/dev/null 2>&1
373 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200374
375 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100376
377 sleep $SRV_DELAY_SECONDS
378 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200379}
380
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200381# check if the given command uses dtls and sets global variable DTLS
382detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200383 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200384 DTLS=1
385 else
386 DTLS=0
387 fi
388}
389
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200390# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100391# Options: -s pattern pattern that must be present in server output
392# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100393# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100394# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100395# -S pattern pattern that must be absent in server output
396# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100397# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100398# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100399run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100400 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200401 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100403 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
404 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200405 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100406 return
407 fi
408
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100409 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100410
Paul Bakkerb7584a52016-05-10 10:50:43 +0100411 # Do we only run numbered tests?
412 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
413 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
414 else
415 SKIP_NEXT="YES"
416 fi
417
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200418 # should we skip?
419 if [ "X$SKIP_NEXT" = "XYES" ]; then
420 SKIP_NEXT="NO"
421 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200422 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200423 return
424 fi
425
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200426 # does this test use a proxy?
427 if [ "X$1" = "X-p" ]; then
428 PXY_CMD="$2"
429 shift 2
430 else
431 PXY_CMD=""
432 fi
433
434 # get commands and client output
435 SRV_CMD="$1"
436 CLI_CMD="$2"
437 CLI_EXPECT="$3"
438 shift 3
439
440 # fix client port
441 if [ -n "$PXY_CMD" ]; then
442 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
443 else
444 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
445 fi
446
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200447 # update DTLS variable
448 detect_dtls "$SRV_CMD"
449
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100450 # prepend valgrind to our commands if active
451 if [ "$MEMCHECK" -gt 0 ]; then
452 if is_polar "$SRV_CMD"; then
453 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
454 fi
455 if is_polar "$CLI_CMD"; then
456 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
457 fi
458 fi
459
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200460 TIMES_LEFT=2
461 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200462 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200463
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200464 # run the commands
465 if [ -n "$PXY_CMD" ]; then
466 echo "$PXY_CMD" > $PXY_OUT
467 $PXY_CMD >> $PXY_OUT 2>&1 &
468 PXY_PID=$!
Unknownb86bcb42019-09-02 10:42:57 -0400469 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200470 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200471
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200472 check_osrv_dtls
473 echo "$SRV_CMD" > $SRV_OUT
474 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
475 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100476 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200477
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200478 echo "$CLI_CMD" > $CLI_OUT
479 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
480 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100481
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200482 # terminate the server (and the proxy)
483 kill $SRV_PID
484 wait $SRV_PID
485 if [ -n "$PXY_CMD" ]; then
486 kill $PXY_PID >/dev/null 2>&1
487 wait $PXY_PID
488 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100489
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200490 # retry only on timeouts
491 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
492 printf "RETRY "
493 else
494 TIMES_LEFT=0
495 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200496 done
497
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100498 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200499 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100500 # expected client exit to incorrectly succeed in case of catastrophic
501 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100502 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200503 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100504 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100505 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100506 return
507 fi
508 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100509 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200510 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100511 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100512 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100513 return
514 fi
515 fi
516
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100517 # check server exit code
518 if [ $? != 0 ]; then
519 fail "server fail"
520 return
521 fi
522
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100523 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100524 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
525 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100526 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200527 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100528 return
529 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100530
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100531 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200532 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100533 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100534 while [ $# -gt 0 ]
535 do
536 case $1 in
537 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100538 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 +0100539 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100540 return
541 fi
542 ;;
543
544 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100545 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 +0100546 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100547 return
548 fi
549 ;;
550
551 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100552 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 +0100553 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100554 return
555 fi
556 ;;
557
558 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100559 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 +0100560 fail "pattern '$2' MUST NOT be present in the Client output"
561 return
562 fi
563 ;;
564
565 # The filtering in the following two options (-u and -U) do the following
566 # - ignore valgrind output
Antonin Décimo8fd91562019-01-23 15:24:37 +0100567 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100568 # - keep one of each non-unique line
569 # - count how many lines remain
570 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
571 # if there were no duplicates.
572 "-U")
573 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
574 fail "lines following pattern '$2' must be unique in Server output"
575 return
576 fi
577 ;;
578
579 "-u")
580 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
581 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100582 return
583 fi
584 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100585 "-F")
586 if ! $2 "$SRV_OUT"; then
587 fail "function call to '$2' failed on Server output"
588 return
589 fi
590 ;;
591 "-f")
592 if ! $2 "$CLI_OUT"; then
593 fail "function call to '$2' failed on Client output"
594 return
595 fi
596 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100597
598 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200599 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100600 exit 1
601 esac
602 shift 2
603 done
604
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100605 # check valgrind's results
606 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200607 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100608 fail "Server has memory errors"
609 return
610 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200611 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100612 fail "Client has memory errors"
613 return
614 fi
615 fi
616
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100617 # if we're here, everything is ok
618 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100619 if [ "$PRESERVE_LOGS" -gt 0 ]; then
620 mv $SRV_OUT o-srv-${TESTS}.log
621 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Beckerdc6c0e42018-08-20 12:21:35 +0100622 if [ -n "$PXY_CMD" ]; then
623 mv $PXY_OUT o-pxy-${TESTS}.log
624 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100625 fi
626
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200627 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100628}
629
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100630cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200631 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200632 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
633 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
634 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
635 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100636 exit 1
637}
638
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100639#
640# MAIN
641#
642
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000643if cd $( dirname $0 ); then :; else
644 echo "cd $( dirname $0 ) failed" >&2
645 exit 1
646fi
647
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100648get_options "$@"
649
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100650# sanity checks, avoid an avalanche of errors
651if [ ! -x "$P_SRV" ]; then
652 echo "Command '$P_SRV' is not an executable file"
653 exit 1
654fi
655if [ ! -x "$P_CLI" ]; then
656 echo "Command '$P_CLI' is not an executable file"
657 exit 1
658fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200659if [ ! -x "$P_PXY" ]; then
660 echo "Command '$P_PXY' is not an executable file"
661 exit 1
662fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100663if [ "$MEMCHECK" -gt 0 ]; then
664 if which valgrind >/dev/null 2>&1; then :; else
665 echo "Memcheck not possible. Valgrind not found"
666 exit 1
667 fi
668fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100669if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
670 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100671 exit 1
672fi
673
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200674# used by watchdog
675MAIN_PID="$$"
676
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100677# We use somewhat arbitrary delays for tests:
678# - how long do we wait for the server to start (when lsof not available)?
679# - how long do we allow for the client to finish?
680# (not to check performance, just to avoid waiting indefinitely)
681# Things are slower with valgrind, so give extra time here.
682#
683# Note: without lsof, there is a trade-off between the running time of this
684# script and the risk of spurious errors because we didn't wait long enough.
685# The watchdog delay on the other hand doesn't affect normal running time of
686# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200687if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100688 START_DELAY=6
689 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200690else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100691 START_DELAY=2
692 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200693fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100694
695# some particular tests need more time:
696# - for the client, we multiply the usual watchdog limit by a factor
697# - for the server, we sleep for a number of seconds after the client exits
698# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200699CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100700SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200701
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200702# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000703# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200704P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
705P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100706P_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 +0200707O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200708O_CLI="$O_CLI -connect localhost:+SRV_PORT"
709G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000710G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200711
Gilles Peskine62469d92017-05-10 10:13:59 +0200712# Allow SHA-1, because many of our test certificates use it
713P_SRV="$P_SRV allow_sha1=1"
714P_CLI="$P_CLI allow_sha1=1"
715
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200716# Also pick a unique name for intermediate files
717SRV_OUT="srv_out.$$"
718CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200719PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200720SESSION="session.$$"
721
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200722SKIP_NEXT="NO"
723
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100724trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100725
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200726# Basic test
727
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200728# Checks that:
729# - things work with all ciphersuites active (used with config-full in all.sh)
730# - the expected (highest security) parameters are selected
731# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200732run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200733 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200734 "$P_CLI" \
735 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200736 -s "Protocol is TLSv1.2" \
737 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
738 -s "client hello v3, signature_algorithm ext: 6" \
739 -s "ECDHE curve: secp521r1" \
740 -S "error" \
741 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200742
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000743run_test "Default, DTLS" \
744 "$P_SRV dtls=1" \
745 "$P_CLI dtls=1" \
746 0 \
747 -s "Protocol is DTLSv1.2" \
748 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
749
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100750# Test current time in ServerHello
751requires_config_enabled MBEDTLS_HAVE_TIME
752run_test "Default, ServerHello contains gmt_unix_time" \
753 "$P_SRV debug_level=3" \
754 "$P_CLI debug_level=3" \
755 0 \
756 -s "Protocol is TLSv1.2" \
757 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
758 -s "client hello v3, signature_algorithm ext: 6" \
759 -s "ECDHE curve: secp521r1" \
760 -S "error" \
761 -C "error" \
762 -f "check_server_hello_time" \
763 -F "check_server_hello_time"
764
Simon Butcher8e004102016-10-14 00:48:33 +0100765# Test for uniqueness of IVs in AEAD ciphersuites
766run_test "Unique IV in GCM" \
767 "$P_SRV exchanges=20 debug_level=4" \
768 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
769 0 \
770 -u "IV used" \
771 -U "IV used"
772
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100773# Tests for rc4 option
774
Simon Butchera410af52016-05-19 22:12:18 +0100775requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100776run_test "RC4: server disabled, client enabled" \
777 "$P_SRV" \
778 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
779 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100780 -s "SSL - The server has no ciphersuites in common"
781
Simon Butchera410af52016-05-19 22:12:18 +0100782requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100783run_test "RC4: server half, client enabled" \
784 "$P_SRV arc4=1" \
785 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
786 1 \
787 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100788
789run_test "RC4: server enabled, client disabled" \
790 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
791 "$P_CLI" \
792 1 \
793 -s "SSL - The server has no ciphersuites in common"
794
795run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100796 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100797 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
798 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100799 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100800 -S "SSL - The server has no ciphersuites in common"
801
Hanno Becker3a333a52018-08-17 09:54:10 +0100802# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
803
804requires_gnutls
805requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
806run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
807 "$G_SRV"\
808 "$P_CLI force_version=tls1_1" \
809 0
810
811requires_gnutls
812requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
813run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
814 "$G_SRV"\
815 "$P_CLI force_version=tls1" \
816 0
817
Gilles Peskinebc70a182017-05-09 15:59:24 +0200818# Tests for SHA-1 support
819
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200820requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200821run_test "SHA-1 forbidden by default in server certificate" \
822 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
823 "$P_CLI debug_level=2 allow_sha1=0" \
824 1 \
825 -c "The certificate is signed with an unacceptable hash"
826
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200827requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
828run_test "SHA-1 forbidden by default in server certificate" \
829 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
830 "$P_CLI debug_level=2 allow_sha1=0" \
831 0
832
Gilles Peskinebc70a182017-05-09 15:59:24 +0200833run_test "SHA-1 explicitly allowed in server certificate" \
834 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
835 "$P_CLI allow_sha1=1" \
836 0
837
838run_test "SHA-256 allowed by default in server certificate" \
839 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
840 "$P_CLI allow_sha1=0" \
841 0
842
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200843requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200844run_test "SHA-1 forbidden by default in client certificate" \
845 "$P_SRV auth_mode=required allow_sha1=0" \
846 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
847 1 \
848 -s "The certificate is signed with an unacceptable hash"
849
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200850requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
851run_test "SHA-1 forbidden by default in client certificate" \
852 "$P_SRV auth_mode=required allow_sha1=0" \
853 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
854 0
855
Gilles Peskinebc70a182017-05-09 15:59:24 +0200856run_test "SHA-1 explicitly allowed in client certificate" \
857 "$P_SRV auth_mode=required allow_sha1=1" \
858 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
859 0
860
861run_test "SHA-256 allowed by default in client certificate" \
862 "$P_SRV auth_mode=required allow_sha1=0" \
863 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
864 0
865
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100866# Tests for Truncated HMAC extension
867
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100868run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200869 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100870 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100871 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000872 -s "dumping 'expected mac' (20 bytes)" \
873 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100874
Hanno Becker32c55012017-11-10 08:42:54 +0000875requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100876run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200877 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000878 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100879 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000880 -s "dumping 'expected mac' (20 bytes)" \
881 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100882
Hanno Becker32c55012017-11-10 08:42:54 +0000883requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100884run_test "Truncated HMAC: client enabled, server default" \
885 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000886 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100887 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000888 -s "dumping 'expected mac' (20 bytes)" \
889 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100890
Hanno Becker32c55012017-11-10 08:42:54 +0000891requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100892run_test "Truncated HMAC: client enabled, server disabled" \
893 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000894 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100895 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000896 -s "dumping 'expected mac' (20 bytes)" \
897 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100898
Hanno Becker32c55012017-11-10 08:42:54 +0000899requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000900run_test "Truncated HMAC: client disabled, server enabled" \
901 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000902 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000903 0 \
904 -s "dumping 'expected mac' (20 bytes)" \
905 -S "dumping 'expected mac' (10 bytes)"
906
907requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100908run_test "Truncated HMAC: client enabled, server enabled" \
909 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000910 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100911 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000912 -S "dumping 'expected mac' (20 bytes)" \
913 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100914
Hanno Becker4c4f4102017-11-10 09:16:05 +0000915run_test "Truncated HMAC, DTLS: client default, server default" \
916 "$P_SRV dtls=1 debug_level=4" \
917 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
918 0 \
919 -s "dumping 'expected mac' (20 bytes)" \
920 -S "dumping 'expected mac' (10 bytes)"
921
922requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
923run_test "Truncated HMAC, DTLS: client disabled, server default" \
924 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000925 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000926 0 \
927 -s "dumping 'expected mac' (20 bytes)" \
928 -S "dumping 'expected mac' (10 bytes)"
929
930requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
931run_test "Truncated HMAC, DTLS: client enabled, server default" \
932 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000933 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000934 0 \
935 -s "dumping 'expected mac' (20 bytes)" \
936 -S "dumping 'expected mac' (10 bytes)"
937
938requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
939run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
940 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000941 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000942 0 \
943 -s "dumping 'expected mac' (20 bytes)" \
944 -S "dumping 'expected mac' (10 bytes)"
945
946requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
947run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
948 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000949 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000950 0 \
951 -s "dumping 'expected mac' (20 bytes)" \
952 -S "dumping 'expected mac' (10 bytes)"
953
954requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
955run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
956 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000957 "$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 +0100958 0 \
959 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100960 -s "dumping 'expected mac' (10 bytes)"
961
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100962# Tests for Encrypt-then-MAC extension
963
964run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100965 "$P_SRV debug_level=3 \
966 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100967 "$P_CLI debug_level=3" \
968 0 \
969 -c "client hello, adding encrypt_then_mac extension" \
970 -s "found encrypt then mac extension" \
971 -s "server hello, adding encrypt then mac extension" \
972 -c "found encrypt_then_mac extension" \
973 -c "using encrypt then mac" \
974 -s "using encrypt then mac"
975
976run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100977 "$P_SRV debug_level=3 etm=0 \
978 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100979 "$P_CLI debug_level=3 etm=1" \
980 0 \
981 -c "client hello, adding encrypt_then_mac extension" \
982 -s "found encrypt then mac extension" \
983 -S "server hello, adding encrypt then mac extension" \
984 -C "found encrypt_then_mac extension" \
985 -C "using encrypt then mac" \
986 -S "using encrypt then mac"
987
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100988run_test "Encrypt then MAC: client enabled, aead cipher" \
989 "$P_SRV debug_level=3 etm=1 \
990 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
991 "$P_CLI debug_level=3 etm=1" \
992 0 \
993 -c "client hello, adding encrypt_then_mac extension" \
994 -s "found encrypt then mac extension" \
995 -S "server hello, adding encrypt then mac extension" \
996 -C "found encrypt_then_mac extension" \
997 -C "using encrypt then mac" \
998 -S "using encrypt then mac"
999
1000run_test "Encrypt then MAC: client enabled, stream cipher" \
1001 "$P_SRV debug_level=3 etm=1 \
1002 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001003 "$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 +01001004 0 \
1005 -c "client hello, adding encrypt_then_mac extension" \
1006 -s "found encrypt then mac extension" \
1007 -S "server hello, adding encrypt then mac extension" \
1008 -C "found encrypt_then_mac extension" \
1009 -C "using encrypt then mac" \
1010 -S "using encrypt then mac"
1011
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001012run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001013 "$P_SRV debug_level=3 etm=1 \
1014 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001015 "$P_CLI debug_level=3 etm=0" \
1016 0 \
1017 -C "client hello, adding encrypt_then_mac extension" \
1018 -S "found encrypt then mac extension" \
1019 -S "server hello, adding encrypt then mac extension" \
1020 -C "found encrypt_then_mac extension" \
1021 -C "using encrypt then mac" \
1022 -S "using encrypt then mac"
1023
Janos Follathe2681a42016-03-07 15:57:05 +00001024requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001025run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001026 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001027 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001028 "$P_CLI debug_level=3 force_version=ssl3" \
1029 0 \
1030 -C "client hello, adding encrypt_then_mac extension" \
1031 -S "found encrypt then mac extension" \
1032 -S "server hello, adding encrypt then mac extension" \
1033 -C "found encrypt_then_mac extension" \
1034 -C "using encrypt then mac" \
1035 -S "using encrypt then mac"
1036
Janos Follathe2681a42016-03-07 15:57:05 +00001037requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001038run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001039 "$P_SRV debug_level=3 force_version=ssl3 \
1040 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001041 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001042 0 \
1043 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001044 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001045 -S "server hello, adding encrypt then mac extension" \
1046 -C "found encrypt_then_mac extension" \
1047 -C "using encrypt then mac" \
1048 -S "using encrypt then mac"
1049
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001050# Tests for Extended Master Secret extension
1051
1052run_test "Extended Master Secret: default" \
1053 "$P_SRV debug_level=3" \
1054 "$P_CLI debug_level=3" \
1055 0 \
1056 -c "client hello, adding extended_master_secret extension" \
1057 -s "found extended master secret extension" \
1058 -s "server hello, adding extended master secret extension" \
1059 -c "found extended_master_secret extension" \
1060 -c "using extended master secret" \
1061 -s "using extended master secret"
1062
1063run_test "Extended Master Secret: client enabled, server disabled" \
1064 "$P_SRV debug_level=3 extended_ms=0" \
1065 "$P_CLI debug_level=3 extended_ms=1" \
1066 0 \
1067 -c "client hello, adding extended_master_secret extension" \
1068 -s "found extended master secret extension" \
1069 -S "server hello, adding extended master secret extension" \
1070 -C "found extended_master_secret extension" \
1071 -C "using extended master secret" \
1072 -S "using extended master secret"
1073
1074run_test "Extended Master Secret: client disabled, server enabled" \
1075 "$P_SRV debug_level=3 extended_ms=1" \
1076 "$P_CLI debug_level=3 extended_ms=0" \
1077 0 \
1078 -C "client hello, adding extended_master_secret extension" \
1079 -S "found extended master secret extension" \
1080 -S "server hello, adding extended master secret extension" \
1081 -C "found extended_master_secret extension" \
1082 -C "using extended master secret" \
1083 -S "using extended master secret"
1084
Janos Follathe2681a42016-03-07 15:57:05 +00001085requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001086run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001087 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001088 "$P_CLI debug_level=3 force_version=ssl3" \
1089 0 \
1090 -C "client hello, adding extended_master_secret extension" \
1091 -S "found extended master secret extension" \
1092 -S "server hello, adding extended master secret extension" \
1093 -C "found extended_master_secret extension" \
1094 -C "using extended master secret" \
1095 -S "using extended master secret"
1096
Janos Follathe2681a42016-03-07 15:57:05 +00001097requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001098run_test "Extended Master Secret: client enabled, server SSLv3" \
1099 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001100 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001101 0 \
1102 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001103 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001104 -S "server hello, adding extended master secret extension" \
1105 -C "found extended_master_secret extension" \
1106 -C "using extended master secret" \
1107 -S "using extended master secret"
1108
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001109# Tests for FALLBACK_SCSV
1110
1111run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001112 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001113 "$P_CLI debug_level=3 force_version=tls1_1" \
1114 0 \
1115 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001116 -S "received FALLBACK_SCSV" \
1117 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001118 -C "is a fatal alert message (msg 86)"
1119
1120run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001121 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001122 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1123 0 \
1124 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001125 -S "received FALLBACK_SCSV" \
1126 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001127 -C "is a fatal alert message (msg 86)"
1128
1129run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001130 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001131 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001132 1 \
1133 -c "adding FALLBACK_SCSV" \
1134 -s "received FALLBACK_SCSV" \
1135 -s "inapropriate fallback" \
1136 -c "is a fatal alert message (msg 86)"
1137
1138run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001139 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001140 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001141 0 \
1142 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001143 -s "received FALLBACK_SCSV" \
1144 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001145 -C "is a fatal alert message (msg 86)"
1146
1147requires_openssl_with_fallback_scsv
1148run_test "Fallback SCSV: default, openssl server" \
1149 "$O_SRV" \
1150 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1151 0 \
1152 -C "adding FALLBACK_SCSV" \
1153 -C "is a fatal alert message (msg 86)"
1154
1155requires_openssl_with_fallback_scsv
1156run_test "Fallback SCSV: enabled, openssl server" \
1157 "$O_SRV" \
1158 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1159 1 \
1160 -c "adding FALLBACK_SCSV" \
1161 -c "is a fatal alert message (msg 86)"
1162
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001163requires_openssl_with_fallback_scsv
1164run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001165 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001166 "$O_CLI -tls1_1" \
1167 0 \
1168 -S "received FALLBACK_SCSV" \
1169 -S "inapropriate fallback"
1170
1171requires_openssl_with_fallback_scsv
1172run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001173 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001174 "$O_CLI -tls1_1 -fallback_scsv" \
1175 1 \
1176 -s "received FALLBACK_SCSV" \
1177 -s "inapropriate fallback"
1178
1179requires_openssl_with_fallback_scsv
1180run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001181 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001182 "$O_CLI -fallback_scsv" \
1183 0 \
1184 -s "received FALLBACK_SCSV" \
1185 -S "inapropriate fallback"
1186
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001187# Test sending and receiving empty application data records
1188
1189run_test "Encrypt then MAC: empty application data record" \
1190 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1191 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1192 0 \
1193 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1194 -s "dumping 'input payload after decrypt' (0 bytes)" \
1195 -c "0 bytes written in 1 fragments"
1196
1197run_test "Default, no Encrypt then MAC: empty application data record" \
1198 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1199 "$P_CLI auth_mode=none etm=0 request_size=0" \
1200 0 \
1201 -s "dumping 'input payload after decrypt' (0 bytes)" \
1202 -c "0 bytes written in 1 fragments"
1203
1204run_test "Encrypt then MAC, DTLS: empty application data record" \
1205 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1206 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1207 0 \
1208 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1209 -s "dumping 'input payload after decrypt' (0 bytes)" \
1210 -c "0 bytes written in 1 fragments"
1211
1212run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
1213 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1214 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1215 0 \
1216 -s "dumping 'input payload after decrypt' (0 bytes)" \
1217 -c "0 bytes written in 1 fragments"
1218
Gilles Peskined50177f2017-05-16 17:53:03 +02001219## ClientHello generated with
1220## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1221## then manually twiddling the ciphersuite list.
1222## The ClientHello content is spelled out below as a hex string as
1223## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1224## The expected response is an inappropriate_fallback alert.
1225requires_openssl_with_fallback_scsv
1226run_test "Fallback SCSV: beginning of list" \
1227 "$P_SRV debug_level=2" \
1228 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1229 0 \
1230 -s "received FALLBACK_SCSV" \
1231 -s "inapropriate fallback"
1232
1233requires_openssl_with_fallback_scsv
1234run_test "Fallback SCSV: end of list" \
1235 "$P_SRV debug_level=2" \
1236 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1237 0 \
1238 -s "received FALLBACK_SCSV" \
1239 -s "inapropriate fallback"
1240
1241## Here the expected response is a valid ServerHello prefix, up to the random.
1242requires_openssl_with_fallback_scsv
1243run_test "Fallback SCSV: not in list" \
1244 "$P_SRV debug_level=2" \
1245 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1246 0 \
1247 -S "received FALLBACK_SCSV" \
1248 -S "inapropriate fallback"
1249
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001250# Tests for CBC 1/n-1 record splitting
1251
1252run_test "CBC Record splitting: TLS 1.2, no splitting" \
1253 "$P_SRV" \
1254 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1255 request_size=123 force_version=tls1_2" \
1256 0 \
1257 -s "Read from client: 123 bytes read" \
1258 -S "Read from client: 1 bytes read" \
1259 -S "122 bytes read"
1260
1261run_test "CBC Record splitting: TLS 1.1, no splitting" \
1262 "$P_SRV" \
1263 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1264 request_size=123 force_version=tls1_1" \
1265 0 \
1266 -s "Read from client: 123 bytes read" \
1267 -S "Read from client: 1 bytes read" \
1268 -S "122 bytes read"
1269
1270run_test "CBC Record splitting: TLS 1.0, splitting" \
1271 "$P_SRV" \
1272 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1273 request_size=123 force_version=tls1" \
1274 0 \
1275 -S "Read from client: 123 bytes read" \
1276 -s "Read from client: 1 bytes read" \
1277 -s "122 bytes read"
1278
Janos Follathe2681a42016-03-07 15:57:05 +00001279requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001280run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001281 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001282 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1283 request_size=123 force_version=ssl3" \
1284 0 \
1285 -S "Read from client: 123 bytes read" \
1286 -s "Read from client: 1 bytes read" \
1287 -s "122 bytes read"
1288
1289run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001290 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001291 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1292 request_size=123 force_version=tls1" \
1293 0 \
1294 -s "Read from client: 123 bytes read" \
1295 -S "Read from client: 1 bytes read" \
1296 -S "122 bytes read"
1297
1298run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1299 "$P_SRV" \
1300 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1301 request_size=123 force_version=tls1 recsplit=0" \
1302 0 \
1303 -s "Read from client: 123 bytes read" \
1304 -S "Read from client: 1 bytes read" \
1305 -S "122 bytes read"
1306
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001307run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1308 "$P_SRV nbio=2" \
1309 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1310 request_size=123 force_version=tls1" \
1311 0 \
1312 -S "Read from client: 123 bytes read" \
1313 -s "Read from client: 1 bytes read" \
1314 -s "122 bytes read"
1315
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001316# Tests for Session Tickets
1317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001318run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001319 "$P_SRV debug_level=3 tickets=1" \
1320 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001321 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001322 -c "client hello, adding session ticket extension" \
1323 -s "found session ticket extension" \
1324 -s "server hello, adding session ticket extension" \
1325 -c "found session_ticket extension" \
1326 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001327 -S "session successfully restored from cache" \
1328 -s "session successfully restored from ticket" \
1329 -s "a session has been resumed" \
1330 -c "a session has been resumed"
1331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001332run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1334 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001335 0 \
1336 -c "client hello, adding session ticket extension" \
1337 -s "found session ticket extension" \
1338 -s "server hello, adding session ticket extension" \
1339 -c "found session_ticket extension" \
1340 -c "parse new session ticket" \
1341 -S "session successfully restored from cache" \
1342 -s "session successfully restored from ticket" \
1343 -s "a session has been resumed" \
1344 -c "a session has been resumed"
1345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1348 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001349 0 \
1350 -c "client hello, adding session ticket extension" \
1351 -s "found session ticket extension" \
1352 -s "server hello, adding session ticket extension" \
1353 -c "found session_ticket extension" \
1354 -c "parse new session ticket" \
1355 -S "session successfully restored from cache" \
1356 -S "session successfully restored from ticket" \
1357 -S "a session has been resumed" \
1358 -C "a session has been resumed"
1359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001360run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001361 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001362 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001363 0 \
1364 -c "client hello, adding session ticket extension" \
1365 -c "found session_ticket extension" \
1366 -c "parse new session ticket" \
1367 -c "a session has been resumed"
1368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001369run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001370 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001371 "( $O_CLI -sess_out $SESSION; \
1372 $O_CLI -sess_in $SESSION; \
1373 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001374 0 \
1375 -s "found session ticket extension" \
1376 -s "server hello, adding session ticket extension" \
1377 -S "session successfully restored from cache" \
1378 -s "session successfully restored from ticket" \
1379 -s "a session has been resumed"
1380
Hanno Beckerb5546362018-08-21 13:55:22 +01001381# Tests for Session Tickets with DTLS
1382
1383run_test "Session resume using tickets, DTLS: basic" \
1384 "$P_SRV debug_level=3 dtls=1 tickets=1" \
1385 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
1386 0 \
1387 -c "client hello, adding session ticket extension" \
1388 -s "found session ticket extension" \
1389 -s "server hello, adding session ticket extension" \
1390 -c "found session_ticket extension" \
1391 -c "parse new session ticket" \
1392 -S "session successfully restored from cache" \
1393 -s "session successfully restored from ticket" \
1394 -s "a session has been resumed" \
1395 -c "a session has been resumed"
1396
1397run_test "Session resume using tickets, DTLS: cache disabled" \
1398 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
1399 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
1400 0 \
1401 -c "client hello, adding session ticket extension" \
1402 -s "found session ticket extension" \
1403 -s "server hello, adding session ticket extension" \
1404 -c "found session_ticket extension" \
1405 -c "parse new session ticket" \
1406 -S "session successfully restored from cache" \
1407 -s "session successfully restored from ticket" \
1408 -s "a session has been resumed" \
1409 -c "a session has been resumed"
1410
1411run_test "Session resume using tickets, DTLS: timeout" \
1412 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
1413 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \
1414 0 \
1415 -c "client hello, adding session ticket extension" \
1416 -s "found session ticket extension" \
1417 -s "server hello, adding session ticket extension" \
1418 -c "found session_ticket extension" \
1419 -c "parse new session ticket" \
1420 -S "session successfully restored from cache" \
1421 -S "session successfully restored from ticket" \
1422 -S "a session has been resumed" \
1423 -C "a session has been resumed"
1424
1425run_test "Session resume using tickets, DTLS: openssl server" \
1426 "$O_SRV -dtls1" \
1427 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1428 0 \
1429 -c "client hello, adding session ticket extension" \
1430 -c "found session_ticket extension" \
1431 -c "parse new session ticket" \
1432 -c "a session has been resumed"
1433
1434run_test "Session resume using tickets, DTLS: openssl client" \
1435 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1436 "( $O_CLI -dtls1 -sess_out $SESSION; \
1437 $O_CLI -dtls1 -sess_in $SESSION; \
1438 rm -f $SESSION )" \
1439 0 \
1440 -s "found session ticket extension" \
1441 -s "server hello, adding session ticket extension" \
1442 -S "session successfully restored from cache" \
1443 -s "session successfully restored from ticket" \
1444 -s "a session has been resumed"
1445
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001446# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001448run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001449 "$P_SRV debug_level=3 tickets=0" \
1450 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001451 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001452 -c "client hello, adding session ticket extension" \
1453 -s "found session ticket extension" \
1454 -S "server hello, adding session ticket extension" \
1455 -C "found session_ticket extension" \
1456 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001457 -s "session successfully restored from cache" \
1458 -S "session successfully restored from ticket" \
1459 -s "a session has been resumed" \
1460 -c "a session has been resumed"
1461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001462run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001463 "$P_SRV debug_level=3 tickets=1" \
1464 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001465 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001466 -C "client hello, adding session ticket extension" \
1467 -S "found session ticket extension" \
1468 -S "server hello, adding session ticket extension" \
1469 -C "found session_ticket extension" \
1470 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001471 -s "session successfully restored from cache" \
1472 -S "session successfully restored from ticket" \
1473 -s "a session has been resumed" \
1474 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001475
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001476run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001477 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1478 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001479 0 \
1480 -S "session successfully restored from cache" \
1481 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001482 -S "a session has been resumed" \
1483 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001485run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001486 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1487 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001488 0 \
1489 -s "session successfully restored from cache" \
1490 -S "session successfully restored from ticket" \
1491 -s "a session has been resumed" \
1492 -c "a session has been resumed"
1493
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001494run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001495 "$P_SRV debug_level=3 tickets=0" \
1496 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001497 0 \
1498 -s "session successfully restored from cache" \
1499 -S "session successfully restored from ticket" \
1500 -s "a session has been resumed" \
1501 -c "a session has been resumed"
1502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001503run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001504 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1505 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001506 0 \
1507 -S "session successfully restored from cache" \
1508 -S "session successfully restored from ticket" \
1509 -S "a session has been resumed" \
1510 -C "a session has been resumed"
1511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001512run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001513 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1514 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001515 0 \
1516 -s "session successfully restored from cache" \
1517 -S "session successfully restored from ticket" \
1518 -s "a session has been resumed" \
1519 -c "a session has been resumed"
1520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001521run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001522 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001523 "( $O_CLI -sess_out $SESSION; \
1524 $O_CLI -sess_in $SESSION; \
1525 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001526 0 \
1527 -s "found session ticket extension" \
1528 -S "server hello, adding session ticket extension" \
1529 -s "session successfully restored from cache" \
1530 -S "session successfully restored from ticket" \
1531 -s "a session has been resumed"
1532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001533run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001534 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001535 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001536 0 \
1537 -C "found session_ticket extension" \
1538 -C "parse new session ticket" \
1539 -c "a session has been resumed"
1540
Hanno Beckerb5546362018-08-21 13:55:22 +01001541# Tests for Session Resume based on session-ID and cache, DTLS
1542
1543run_test "Session resume using cache, DTLS: tickets enabled on client" \
1544 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1545 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1546 0 \
1547 -c "client hello, adding session ticket extension" \
1548 -s "found session ticket extension" \
1549 -S "server hello, adding session ticket extension" \
1550 -C "found session_ticket extension" \
1551 -C "parse new session ticket" \
1552 -s "session successfully restored from cache" \
1553 -S "session successfully restored from ticket" \
1554 -s "a session has been resumed" \
1555 -c "a session has been resumed"
1556
1557run_test "Session resume using cache, DTLS: tickets enabled on server" \
1558 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1559 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1560 0 \
1561 -C "client hello, adding session ticket extension" \
1562 -S "found session ticket extension" \
1563 -S "server hello, adding session ticket extension" \
1564 -C "found session_ticket extension" \
1565 -C "parse new session ticket" \
1566 -s "session successfully restored from cache" \
1567 -S "session successfully restored from ticket" \
1568 -s "a session has been resumed" \
1569 -c "a session has been resumed"
1570
1571run_test "Session resume using cache, DTLS: cache_max=0" \
1572 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
1573 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1574 0 \
1575 -S "session successfully restored from cache" \
1576 -S "session successfully restored from ticket" \
1577 -S "a session has been resumed" \
1578 -C "a session has been resumed"
1579
1580run_test "Session resume using cache, DTLS: cache_max=1" \
1581 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
1582 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1583 0 \
1584 -s "session successfully restored from cache" \
1585 -S "session successfully restored from ticket" \
1586 -s "a session has been resumed" \
1587 -c "a session has been resumed"
1588
1589run_test "Session resume using cache, DTLS: timeout > delay" \
1590 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1591 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
1592 0 \
1593 -s "session successfully restored from cache" \
1594 -S "session successfully restored from ticket" \
1595 -s "a session has been resumed" \
1596 -c "a session has been resumed"
1597
1598run_test "Session resume using cache, DTLS: timeout < delay" \
1599 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
1600 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
1601 0 \
1602 -S "session successfully restored from cache" \
1603 -S "session successfully restored from ticket" \
1604 -S "a session has been resumed" \
1605 -C "a session has been resumed"
1606
1607run_test "Session resume using cache, DTLS: no timeout" \
1608 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
1609 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
1610 0 \
1611 -s "session successfully restored from cache" \
1612 -S "session successfully restored from ticket" \
1613 -s "a session has been resumed" \
1614 -c "a session has been resumed"
1615
1616run_test "Session resume using cache, DTLS: openssl client" \
1617 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1618 "( $O_CLI -dtls1 -sess_out $SESSION; \
1619 $O_CLI -dtls1 -sess_in $SESSION; \
1620 rm -f $SESSION )" \
1621 0 \
1622 -s "found session ticket extension" \
1623 -S "server hello, adding session ticket extension" \
1624 -s "session successfully restored from cache" \
1625 -S "session successfully restored from ticket" \
1626 -s "a session has been resumed"
1627
1628run_test "Session resume using cache, DTLS: openssl server" \
1629 "$O_SRV -dtls1" \
1630 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1631 0 \
1632 -C "found session_ticket extension" \
1633 -C "parse new session ticket" \
1634 -c "a session has been resumed"
1635
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001636# Tests for Max Fragment Length extension
1637
Hanno Becker6428f8d2017-09-22 16:58:50 +01001638MAX_CONTENT_LEN_EXPECT='16384'
1639MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1640
1641if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1642 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1643 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1644 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1645 printf "\n"
1646 printf "The tests assume this value and if it changes, the tests in this\n"
1647 printf "script should also be adjusted.\n"
1648 printf "\n"
1649
1650 exit 1
1651fi
1652
Hanno Becker4aed27e2017-09-18 15:00:34 +01001653requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001654run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001655 "$P_SRV debug_level=3" \
1656 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001657 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001658 -c "Maximum fragment length is 16384" \
1659 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001660 -C "client hello, adding max_fragment_length extension" \
1661 -S "found max fragment length extension" \
1662 -S "server hello, max_fragment_length extension" \
1663 -C "found max_fragment_length extension"
1664
Hanno Becker4aed27e2017-09-18 15:00:34 +01001665requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001666run_test "Max fragment length: enabled, default, larger message" \
1667 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001668 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001669 0 \
1670 -c "Maximum fragment length is 16384" \
1671 -s "Maximum fragment length is 16384" \
1672 -C "client hello, adding max_fragment_length extension" \
1673 -S "found max fragment length extension" \
1674 -S "server hello, max_fragment_length extension" \
1675 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001676 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001677 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001678 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001679
1680requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1681run_test "Max fragment length, DTLS: enabled, default, larger message" \
1682 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001683 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001684 1 \
1685 -c "Maximum fragment length is 16384" \
1686 -s "Maximum fragment length is 16384" \
1687 -C "client hello, adding max_fragment_length extension" \
1688 -S "found max fragment length extension" \
1689 -S "server hello, max_fragment_length extension" \
1690 -C "found max_fragment_length extension" \
1691 -c "fragment larger than.*maximum "
1692
1693requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1694run_test "Max fragment length: disabled, larger message" \
1695 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001696 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001697 0 \
1698 -C "Maximum fragment length is 16384" \
1699 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001700 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001701 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001702 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001703
1704requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1705run_test "Max fragment length DTLS: disabled, larger message" \
1706 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001707 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001708 1 \
1709 -C "Maximum fragment length is 16384" \
1710 -S "Maximum fragment length is 16384" \
1711 -c "fragment larger than.*maximum "
1712
1713requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001714run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001715 "$P_SRV debug_level=3" \
1716 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001717 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001718 -c "Maximum fragment length is 4096" \
1719 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001720 -c "client hello, adding max_fragment_length extension" \
1721 -s "found max fragment length extension" \
1722 -s "server hello, max_fragment_length extension" \
1723 -c "found max_fragment_length extension"
1724
Hanno Becker4aed27e2017-09-18 15:00:34 +01001725requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001727 "$P_SRV debug_level=3 max_frag_len=4096" \
1728 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001729 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001730 -c "Maximum fragment length is 16384" \
1731 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001732 -C "client hello, adding max_fragment_length extension" \
1733 -S "found max fragment length extension" \
1734 -S "server hello, max_fragment_length extension" \
1735 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001736
Hanno Becker4aed27e2017-09-18 15:00:34 +01001737requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001738requires_gnutls
1739run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001740 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001741 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001742 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001743 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001744 -c "client hello, adding max_fragment_length extension" \
1745 -c "found max_fragment_length extension"
1746
Hanno Becker4aed27e2017-09-18 15:00:34 +01001747requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001748run_test "Max fragment length: client, message just fits" \
1749 "$P_SRV debug_level=3" \
1750 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1751 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001752 -c "Maximum fragment length is 2048" \
1753 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001754 -c "client hello, adding max_fragment_length extension" \
1755 -s "found max fragment length extension" \
1756 -s "server hello, max_fragment_length extension" \
1757 -c "found max_fragment_length extension" \
1758 -c "2048 bytes written in 1 fragments" \
1759 -s "2048 bytes read"
1760
Hanno Becker4aed27e2017-09-18 15:00:34 +01001761requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001762run_test "Max fragment length: client, larger message" \
1763 "$P_SRV debug_level=3" \
1764 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1765 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001766 -c "Maximum fragment length is 2048" \
1767 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001768 -c "client hello, adding max_fragment_length extension" \
1769 -s "found max fragment length extension" \
1770 -s "server hello, max_fragment_length extension" \
1771 -c "found max_fragment_length extension" \
1772 -c "2345 bytes written in 2 fragments" \
1773 -s "2048 bytes read" \
1774 -s "297 bytes read"
1775
Hanno Becker4aed27e2017-09-18 15:00:34 +01001776requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001777run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001778 "$P_SRV debug_level=3 dtls=1" \
1779 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1780 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001781 -c "Maximum fragment length is 2048" \
1782 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001783 -c "client hello, adding max_fragment_length extension" \
1784 -s "found max fragment length extension" \
1785 -s "server hello, max_fragment_length extension" \
1786 -c "found max_fragment_length extension" \
1787 -c "fragment larger than.*maximum"
1788
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001789# Tests for renegotiation
1790
Hanno Becker6a243642017-10-12 15:18:45 +01001791# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001792run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001793 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001794 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001795 0 \
1796 -C "client hello, adding renegotiation extension" \
1797 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1798 -S "found renegotiation extension" \
1799 -s "server hello, secure renegotiation extension" \
1800 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001801 -C "=> renegotiate" \
1802 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001803 -S "write hello request"
1804
Hanno Becker6a243642017-10-12 15:18:45 +01001805requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001806run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001807 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001808 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001809 0 \
1810 -c "client hello, adding renegotiation extension" \
1811 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1812 -s "found renegotiation extension" \
1813 -s "server hello, secure renegotiation extension" \
1814 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001815 -c "=> renegotiate" \
1816 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001817 -S "write hello request"
1818
Hanno Becker6a243642017-10-12 15:18:45 +01001819requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001820run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001821 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001822 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001823 0 \
1824 -c "client hello, adding renegotiation extension" \
1825 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1826 -s "found renegotiation extension" \
1827 -s "server hello, secure renegotiation extension" \
1828 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001829 -c "=> renegotiate" \
1830 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001831 -s "write hello request"
1832
Janos Follathb0f148c2017-10-05 12:29:42 +01001833# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1834# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1835# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001836requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001837run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1838 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1839 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1840 0 \
1841 -c "client hello, adding renegotiation extension" \
1842 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1843 -s "found renegotiation extension" \
1844 -s "server hello, secure renegotiation extension" \
1845 -c "found renegotiation extension" \
1846 -c "=> renegotiate" \
1847 -s "=> renegotiate" \
1848 -S "write hello request" \
1849 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1850
1851# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1852# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1853# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001854requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001855run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1856 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1857 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1858 0 \
1859 -c "client hello, adding renegotiation extension" \
1860 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1861 -s "found renegotiation extension" \
1862 -s "server hello, secure renegotiation extension" \
1863 -c "found renegotiation extension" \
1864 -c "=> renegotiate" \
1865 -s "=> renegotiate" \
1866 -s "write hello request" \
1867 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1868
Hanno Becker6a243642017-10-12 15:18:45 +01001869requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001870run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001871 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001872 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001873 0 \
1874 -c "client hello, adding renegotiation extension" \
1875 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1876 -s "found renegotiation extension" \
1877 -s "server hello, secure renegotiation extension" \
1878 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001879 -c "=> renegotiate" \
1880 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001881 -s "write hello request"
1882
Hanno Becker6a243642017-10-12 15:18:45 +01001883requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001884run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001885 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001886 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001887 1 \
1888 -c "client hello, adding renegotiation extension" \
1889 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1890 -S "found renegotiation extension" \
1891 -s "server hello, secure renegotiation extension" \
1892 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001893 -c "=> renegotiate" \
1894 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001895 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001896 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001897 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001898
Hanno Becker6a243642017-10-12 15:18:45 +01001899requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001900run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001901 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001902 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001903 0 \
1904 -C "client hello, adding renegotiation extension" \
1905 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1906 -S "found renegotiation extension" \
1907 -s "server hello, secure renegotiation extension" \
1908 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001909 -C "=> renegotiate" \
1910 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001911 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001912 -S "SSL - An unexpected message was received from our peer" \
1913 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001914
Hanno Becker6a243642017-10-12 15:18:45 +01001915requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001916run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001917 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001918 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001919 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001920 0 \
1921 -C "client hello, adding renegotiation extension" \
1922 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1923 -S "found renegotiation extension" \
1924 -s "server hello, secure renegotiation extension" \
1925 -c "found renegotiation extension" \
1926 -C "=> renegotiate" \
1927 -S "=> renegotiate" \
1928 -s "write hello request" \
1929 -S "SSL - An unexpected message was received from our peer" \
1930 -S "failed"
1931
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001932# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001933requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001934run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001935 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001936 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001937 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001938 0 \
1939 -C "client hello, adding renegotiation extension" \
1940 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1941 -S "found renegotiation extension" \
1942 -s "server hello, secure renegotiation extension" \
1943 -c "found renegotiation extension" \
1944 -C "=> renegotiate" \
1945 -S "=> renegotiate" \
1946 -s "write hello request" \
1947 -S "SSL - An unexpected message was received from our peer" \
1948 -S "failed"
1949
Hanno Becker6a243642017-10-12 15:18:45 +01001950requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001951run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001952 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001953 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001954 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001955 0 \
1956 -C "client hello, adding renegotiation extension" \
1957 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1958 -S "found renegotiation extension" \
1959 -s "server hello, secure renegotiation extension" \
1960 -c "found renegotiation extension" \
1961 -C "=> renegotiate" \
1962 -S "=> renegotiate" \
1963 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001964 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001965
Hanno Becker6a243642017-10-12 15:18:45 +01001966requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001967run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001968 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001969 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001970 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001971 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 -c "found renegotiation extension" \
1977 -c "=> renegotiate" \
1978 -s "=> renegotiate" \
1979 -s "write hello request" \
1980 -S "SSL - An unexpected message was received from our peer" \
1981 -S "failed"
1982
Hanno Becker6a243642017-10-12 15:18:45 +01001983requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001984run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001985 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001986 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1987 0 \
1988 -C "client hello, adding renegotiation extension" \
1989 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1990 -S "found renegotiation extension" \
1991 -s "server hello, secure renegotiation extension" \
1992 -c "found renegotiation extension" \
1993 -S "record counter limit reached: renegotiate" \
1994 -C "=> renegotiate" \
1995 -S "=> renegotiate" \
1996 -S "write hello request" \
1997 -S "SSL - An unexpected message was received from our peer" \
1998 -S "failed"
1999
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002000# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002001requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002002run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002003 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002004 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002005 0 \
2006 -c "client hello, adding renegotiation extension" \
2007 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2008 -s "found renegotiation extension" \
2009 -s "server hello, secure renegotiation extension" \
2010 -c "found renegotiation extension" \
2011 -s "record counter limit reached: renegotiate" \
2012 -c "=> renegotiate" \
2013 -s "=> renegotiate" \
2014 -s "write hello request" \
2015 -S "SSL - An unexpected message was received from our peer" \
2016 -S "failed"
2017
Hanno Becker6a243642017-10-12 15:18:45 +01002018requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002019run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002020 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002021 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002022 0 \
2023 -c "client hello, adding renegotiation extension" \
2024 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2025 -s "found renegotiation extension" \
2026 -s "server hello, secure renegotiation extension" \
2027 -c "found renegotiation extension" \
2028 -s "record counter limit reached: renegotiate" \
2029 -c "=> renegotiate" \
2030 -s "=> renegotiate" \
2031 -s "write hello request" \
2032 -S "SSL - An unexpected message was received from our peer" \
2033 -S "failed"
2034
Hanno Becker6a243642017-10-12 15:18:45 +01002035requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002036run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002037 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002038 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2039 0 \
2040 -C "client hello, adding renegotiation extension" \
2041 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2042 -S "found renegotiation extension" \
2043 -s "server hello, secure renegotiation extension" \
2044 -c "found renegotiation extension" \
2045 -S "record counter limit reached: renegotiate" \
2046 -C "=> renegotiate" \
2047 -S "=> renegotiate" \
2048 -S "write hello request" \
2049 -S "SSL - An unexpected message was received from our peer" \
2050 -S "failed"
2051
Hanno Becker6a243642017-10-12 15:18:45 +01002052requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002053run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002054 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002055 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002056 0 \
2057 -c "client hello, adding renegotiation extension" \
2058 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2059 -s "found renegotiation extension" \
2060 -s "server hello, secure renegotiation extension" \
2061 -c "found renegotiation extension" \
2062 -c "=> renegotiate" \
2063 -s "=> renegotiate" \
2064 -S "write hello request"
2065
Hanno Becker6a243642017-10-12 15:18:45 +01002066requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002067run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002068 "$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 +02002069 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002070 0 \
2071 -c "client hello, adding renegotiation extension" \
2072 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2073 -s "found renegotiation extension" \
2074 -s "server hello, secure renegotiation extension" \
2075 -c "found renegotiation extension" \
2076 -c "=> renegotiate" \
2077 -s "=> renegotiate" \
2078 -s "write hello request"
2079
Hanno Becker6a243642017-10-12 15:18:45 +01002080requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002081run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002082 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002083 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002084 0 \
2085 -c "client hello, adding renegotiation extension" \
2086 -c "found renegotiation extension" \
2087 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002088 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002089 -C "error" \
2090 -c "HTTP/1.0 200 [Oo][Kk]"
2091
Paul Bakker539d9722015-02-08 16:18:35 +01002092requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002093requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002094run_test "Renegotiation: gnutls server strict, client-initiated" \
2095 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002096 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002097 0 \
2098 -c "client hello, adding renegotiation extension" \
2099 -c "found renegotiation extension" \
2100 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002101 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002102 -C "error" \
2103 -c "HTTP/1.0 200 [Oo][Kk]"
2104
Paul Bakker539d9722015-02-08 16:18:35 +01002105requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002106requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002107run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2108 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2109 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2110 1 \
2111 -c "client hello, adding renegotiation extension" \
2112 -C "found renegotiation extension" \
2113 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002114 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002115 -c "error" \
2116 -C "HTTP/1.0 200 [Oo][Kk]"
2117
Paul Bakker539d9722015-02-08 16:18:35 +01002118requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002119requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002120run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2121 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2122 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2123 allow_legacy=0" \
2124 1 \
2125 -c "client hello, adding renegotiation extension" \
2126 -C "found renegotiation extension" \
2127 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002128 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002129 -c "error" \
2130 -C "HTTP/1.0 200 [Oo][Kk]"
2131
Paul Bakker539d9722015-02-08 16:18:35 +01002132requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002133requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002134run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2135 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2136 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2137 allow_legacy=1" \
2138 0 \
2139 -c "client hello, adding renegotiation extension" \
2140 -C "found renegotiation extension" \
2141 -c "=> renegotiate" \
2142 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002143 -C "error" \
2144 -c "HTTP/1.0 200 [Oo][Kk]"
2145
Hanno Becker6a243642017-10-12 15:18:45 +01002146requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002147run_test "Renegotiation: DTLS, client-initiated" \
2148 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2149 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2150 0 \
2151 -c "client hello, adding renegotiation extension" \
2152 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2153 -s "found renegotiation extension" \
2154 -s "server hello, secure renegotiation extension" \
2155 -c "found renegotiation extension" \
2156 -c "=> renegotiate" \
2157 -s "=> renegotiate" \
2158 -S "write hello request"
2159
Hanno Becker6a243642017-10-12 15:18:45 +01002160requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002161run_test "Renegotiation: DTLS, server-initiated" \
2162 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002163 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2164 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002165 0 \
2166 -c "client hello, adding renegotiation extension" \
2167 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2168 -s "found renegotiation extension" \
2169 -s "server hello, secure renegotiation extension" \
2170 -c "found renegotiation extension" \
2171 -c "=> renegotiate" \
2172 -s "=> renegotiate" \
2173 -s "write hello request"
2174
Hanno Becker6a243642017-10-12 15:18:45 +01002175requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002176run_test "Renegotiation: DTLS, renego_period overflow" \
2177 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2178 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2179 0 \
2180 -c "client hello, adding renegotiation extension" \
2181 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2182 -s "found renegotiation extension" \
2183 -s "server hello, secure renegotiation extension" \
2184 -s "record counter limit reached: renegotiate" \
2185 -c "=> renegotiate" \
2186 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002187 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002188
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002189requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002190requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002191run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2192 "$G_SRV -u --mtu 4096" \
2193 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2194 0 \
2195 -c "client hello, adding renegotiation extension" \
2196 -c "found renegotiation extension" \
2197 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002198 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002199 -C "error" \
2200 -s "Extra-header:"
2201
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002202# Test for the "secure renegotation" extension only (no actual renegotiation)
2203
Paul Bakker539d9722015-02-08 16:18:35 +01002204requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002205run_test "Renego ext: gnutls server strict, client default" \
2206 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2207 "$P_CLI debug_level=3" \
2208 0 \
2209 -c "found renegotiation extension" \
2210 -C "error" \
2211 -c "HTTP/1.0 200 [Oo][Kk]"
2212
Paul Bakker539d9722015-02-08 16:18:35 +01002213requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002214run_test "Renego ext: gnutls server unsafe, client default" \
2215 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2216 "$P_CLI debug_level=3" \
2217 0 \
2218 -C "found renegotiation extension" \
2219 -C "error" \
2220 -c "HTTP/1.0 200 [Oo][Kk]"
2221
Paul Bakker539d9722015-02-08 16:18:35 +01002222requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002223run_test "Renego ext: gnutls server unsafe, client break legacy" \
2224 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2225 "$P_CLI debug_level=3 allow_legacy=-1" \
2226 1 \
2227 -C "found renegotiation extension" \
2228 -c "error" \
2229 -C "HTTP/1.0 200 [Oo][Kk]"
2230
Paul Bakker539d9722015-02-08 16:18:35 +01002231requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002232run_test "Renego ext: gnutls client strict, server default" \
2233 "$P_SRV debug_level=3" \
2234 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2235 0 \
2236 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2237 -s "server hello, secure renegotiation extension"
2238
Paul Bakker539d9722015-02-08 16:18:35 +01002239requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002240run_test "Renego ext: gnutls client unsafe, server default" \
2241 "$P_SRV debug_level=3" \
2242 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2243 0 \
2244 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2245 -S "server hello, secure renegotiation extension"
2246
Paul Bakker539d9722015-02-08 16:18:35 +01002247requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002248run_test "Renego ext: gnutls client unsafe, server break legacy" \
2249 "$P_SRV debug_level=3 allow_legacy=-1" \
2250 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2251 1 \
2252 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2253 -S "server hello, secure renegotiation extension"
2254
Janos Follath0b242342016-02-17 10:11:21 +00002255# Tests for silently dropping trailing extra bytes in .der certificates
2256
2257requires_gnutls
2258run_test "DER format: no trailing bytes" \
2259 "$P_SRV crt_file=data_files/server5-der0.crt \
2260 key_file=data_files/server5.key" \
2261 "$G_CLI " \
2262 0 \
2263 -c "Handshake was completed" \
2264
2265requires_gnutls
2266run_test "DER format: with a trailing zero byte" \
2267 "$P_SRV crt_file=data_files/server5-der1a.crt \
2268 key_file=data_files/server5.key" \
2269 "$G_CLI " \
2270 0 \
2271 -c "Handshake was completed" \
2272
2273requires_gnutls
2274run_test "DER format: with a trailing random byte" \
2275 "$P_SRV crt_file=data_files/server5-der1b.crt \
2276 key_file=data_files/server5.key" \
2277 "$G_CLI " \
2278 0 \
2279 -c "Handshake was completed" \
2280
2281requires_gnutls
2282run_test "DER format: with 2 trailing random bytes" \
2283 "$P_SRV crt_file=data_files/server5-der2.crt \
2284 key_file=data_files/server5.key" \
2285 "$G_CLI " \
2286 0 \
2287 -c "Handshake was completed" \
2288
2289requires_gnutls
2290run_test "DER format: with 4 trailing random bytes" \
2291 "$P_SRV crt_file=data_files/server5-der4.crt \
2292 key_file=data_files/server5.key" \
2293 "$G_CLI " \
2294 0 \
2295 -c "Handshake was completed" \
2296
2297requires_gnutls
2298run_test "DER format: with 8 trailing random bytes" \
2299 "$P_SRV crt_file=data_files/server5-der8.crt \
2300 key_file=data_files/server5.key" \
2301 "$G_CLI " \
2302 0 \
2303 -c "Handshake was completed" \
2304
2305requires_gnutls
2306run_test "DER format: with 9 trailing random bytes" \
2307 "$P_SRV crt_file=data_files/server5-der9.crt \
2308 key_file=data_files/server5.key" \
2309 "$G_CLI " \
2310 0 \
2311 -c "Handshake was completed" \
2312
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002313# Tests for auth_mode
2314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002315run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002316 "$P_SRV crt_file=data_files/server5-badsign.crt \
2317 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002318 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002319 1 \
2320 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002321 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002322 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002323 -c "X509 - Certificate verification failed"
2324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002325run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002326 "$P_SRV crt_file=data_files/server5-badsign.crt \
2327 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002328 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002329 0 \
2330 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002331 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002332 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002333 -C "X509 - Certificate verification failed"
2334
Hanno Beckere6706e62017-05-15 16:05:15 +01002335run_test "Authentication: server goodcert, client optional, no trusted CA" \
2336 "$P_SRV" \
2337 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2338 0 \
2339 -c "x509_verify_cert() returned" \
2340 -c "! The certificate is not correctly signed by the trusted CA" \
2341 -c "! Certificate verification flags"\
2342 -C "! mbedtls_ssl_handshake returned" \
2343 -C "X509 - Certificate verification failed" \
2344 -C "SSL - No CA Chain is set, but required to operate"
2345
2346run_test "Authentication: server goodcert, client required, no trusted CA" \
2347 "$P_SRV" \
2348 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2349 1 \
2350 -c "x509_verify_cert() returned" \
2351 -c "! The certificate is not correctly signed by the trusted CA" \
2352 -c "! Certificate verification flags"\
2353 -c "! mbedtls_ssl_handshake returned" \
2354 -c "SSL - No CA Chain is set, but required to operate"
2355
2356# The purpose of the next two tests is to test the client's behaviour when receiving a server
2357# certificate with an unsupported elliptic curve. This should usually not happen because
2358# the client informs the server about the supported curves - it does, though, in the
2359# corner case of a static ECDH suite, because the server doesn't check the curve on that
2360# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2361# different means to have the server ignoring the client's supported curve list.
2362
2363requires_config_enabled MBEDTLS_ECP_C
2364run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2365 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2366 crt_file=data_files/server5.ku-ka.crt" \
2367 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2368 1 \
2369 -c "bad certificate (EC key curve)"\
2370 -c "! Certificate verification flags"\
2371 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2372
2373requires_config_enabled MBEDTLS_ECP_C
2374run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2375 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2376 crt_file=data_files/server5.ku-ka.crt" \
2377 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2378 1 \
2379 -c "bad certificate (EC key curve)"\
2380 -c "! Certificate verification flags"\
2381 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002383run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002384 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002385 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002386 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002387 0 \
2388 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002389 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002390 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002391 -C "X509 - Certificate verification failed"
2392
Simon Butcher99000142016-10-13 17:21:01 +01002393run_test "Authentication: client SHA256, server required" \
2394 "$P_SRV auth_mode=required" \
2395 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2396 key_file=data_files/server6.key \
2397 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2398 0 \
2399 -c "Supported Signature Algorithm found: 4," \
2400 -c "Supported Signature Algorithm found: 5,"
2401
2402run_test "Authentication: client SHA384, server required" \
2403 "$P_SRV auth_mode=required" \
2404 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2405 key_file=data_files/server6.key \
2406 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2407 0 \
2408 -c "Supported Signature Algorithm found: 4," \
2409 -c "Supported Signature Algorithm found: 5,"
2410
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002411requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2412run_test "Authentication: client has no cert, server required (SSLv3)" \
2413 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2414 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2415 key_file=data_files/server5.key" \
2416 1 \
2417 -S "skip write certificate request" \
2418 -C "skip parse certificate request" \
2419 -c "got a certificate request" \
2420 -c "got no certificate to send" \
2421 -S "x509_verify_cert() returned" \
2422 -s "client has no certificate" \
2423 -s "! mbedtls_ssl_handshake returned" \
2424 -c "! mbedtls_ssl_handshake returned" \
2425 -s "No client certification received from the client, but required by the authentication mode"
2426
2427run_test "Authentication: client has no cert, server required (TLS)" \
2428 "$P_SRV debug_level=3 auth_mode=required" \
2429 "$P_CLI debug_level=3 crt_file=none \
2430 key_file=data_files/server5.key" \
2431 1 \
2432 -S "skip write certificate request" \
2433 -C "skip parse certificate request" \
2434 -c "got a certificate request" \
2435 -c "= write certificate$" \
2436 -C "skip write certificate$" \
2437 -S "x509_verify_cert() returned" \
2438 -s "client has no certificate" \
2439 -s "! mbedtls_ssl_handshake returned" \
2440 -c "! mbedtls_ssl_handshake returned" \
2441 -s "No client certification received from the client, but required by the authentication mode"
2442
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002443run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002444 "$P_SRV debug_level=3 auth_mode=required" \
2445 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002446 key_file=data_files/server5.key" \
2447 1 \
2448 -S "skip write certificate request" \
2449 -C "skip parse certificate request" \
2450 -c "got a certificate request" \
2451 -C "skip write certificate" \
2452 -C "skip write certificate verify" \
2453 -S "skip parse certificate verify" \
2454 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002455 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002456 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002457 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002458 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002459 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002460# We don't check that the client receives the alert because it might
2461# detect that its write end of the connection is closed and abort
2462# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002463
Janos Follath89baba22017-04-10 14:34:35 +01002464run_test "Authentication: client cert not trusted, server required" \
2465 "$P_SRV debug_level=3 auth_mode=required" \
2466 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2467 key_file=data_files/server5.key" \
2468 1 \
2469 -S "skip write certificate request" \
2470 -C "skip parse certificate request" \
2471 -c "got a certificate request" \
2472 -C "skip write certificate" \
2473 -C "skip write certificate verify" \
2474 -S "skip parse certificate verify" \
2475 -s "x509_verify_cert() returned" \
2476 -s "! The certificate is not correctly signed by the trusted CA" \
2477 -s "! mbedtls_ssl_handshake returned" \
2478 -c "! mbedtls_ssl_handshake returned" \
2479 -s "X509 - Certificate verification failed"
2480
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002481run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002482 "$P_SRV debug_level=3 auth_mode=optional" \
2483 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002484 key_file=data_files/server5.key" \
2485 0 \
2486 -S "skip write certificate request" \
2487 -C "skip parse certificate request" \
2488 -c "got a certificate request" \
2489 -C "skip write certificate" \
2490 -C "skip write certificate verify" \
2491 -S "skip parse certificate verify" \
2492 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002493 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002494 -S "! mbedtls_ssl_handshake returned" \
2495 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002496 -S "X509 - Certificate verification failed"
2497
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002498run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002499 "$P_SRV debug_level=3 auth_mode=none" \
2500 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002501 key_file=data_files/server5.key" \
2502 0 \
2503 -s "skip write certificate request" \
2504 -C "skip parse certificate request" \
2505 -c "got no certificate request" \
2506 -c "skip write certificate" \
2507 -c "skip write certificate verify" \
2508 -s "skip parse certificate verify" \
2509 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002510 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002511 -S "! mbedtls_ssl_handshake returned" \
2512 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002513 -S "X509 - Certificate verification failed"
2514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002515run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002516 "$P_SRV debug_level=3 auth_mode=optional" \
2517 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002518 0 \
2519 -S "skip write certificate request" \
2520 -C "skip parse certificate request" \
2521 -c "got a certificate request" \
2522 -C "skip write certificate$" \
2523 -C "got no certificate to send" \
2524 -S "SSLv3 client has no certificate" \
2525 -c "skip write certificate verify" \
2526 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002527 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002528 -S "! mbedtls_ssl_handshake returned" \
2529 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002530 -S "X509 - Certificate verification failed"
2531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002532run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002533 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002534 "$O_CLI" \
2535 0 \
2536 -S "skip write certificate request" \
2537 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002538 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002539 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002540 -S "X509 - Certificate verification failed"
2541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002542run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002543 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002544 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002545 0 \
2546 -C "skip parse certificate request" \
2547 -c "got a certificate request" \
2548 -C "skip write certificate$" \
2549 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002550 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002551
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002552run_test "Authentication: client no cert, openssl server required" \
2553 "$O_SRV -Verify 10" \
2554 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2555 1 \
2556 -C "skip parse certificate request" \
2557 -c "got a certificate request" \
2558 -C "skip write certificate$" \
2559 -c "skip write certificate verify" \
2560 -c "! mbedtls_ssl_handshake returned"
2561
Janos Follathe2681a42016-03-07 15:57:05 +00002562requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002563run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002564 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002565 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002566 0 \
2567 -S "skip write certificate request" \
2568 -C "skip parse certificate request" \
2569 -c "got a certificate request" \
2570 -C "skip write certificate$" \
2571 -c "skip write certificate verify" \
2572 -c "got no certificate to send" \
2573 -s "SSLv3 client has no certificate" \
2574 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002575 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002576 -S "! mbedtls_ssl_handshake returned" \
2577 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002578 -S "X509 - Certificate verification failed"
2579
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002580# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2581# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002582
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002583MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002584MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002585
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002586if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002587 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002588 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002589 printf "test value of ${MAX_IM_CA}. \n"
2590 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002591 printf "The tests assume this value and if it changes, the tests in this\n"
2592 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002593 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002594
2595 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002596fi
2597
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002598run_test "Authentication: server max_int chain, client default" \
2599 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2600 key_file=data_files/dir-maxpath/09.key" \
2601 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2602 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002603 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002604
2605run_test "Authentication: server max_int+1 chain, client default" \
2606 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2607 key_file=data_files/dir-maxpath/10.key" \
2608 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2609 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002610 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002611
2612run_test "Authentication: server max_int+1 chain, client optional" \
2613 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2614 key_file=data_files/dir-maxpath/10.key" \
2615 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2616 auth_mode=optional" \
2617 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002618 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002619
2620run_test "Authentication: server max_int+1 chain, client none" \
2621 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2622 key_file=data_files/dir-maxpath/10.key" \
2623 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2624 auth_mode=none" \
2625 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002626 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002627
2628run_test "Authentication: client max_int+1 chain, server default" \
2629 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2630 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2631 key_file=data_files/dir-maxpath/10.key" \
2632 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002633 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002634
2635run_test "Authentication: client max_int+1 chain, server optional" \
2636 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2637 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2638 key_file=data_files/dir-maxpath/10.key" \
2639 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002640 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002641
2642run_test "Authentication: client max_int+1 chain, server required" \
2643 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2644 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2645 key_file=data_files/dir-maxpath/10.key" \
2646 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002647 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002648
2649run_test "Authentication: client max_int chain, server required" \
2650 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2651 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2652 key_file=data_files/dir-maxpath/09.key" \
2653 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002654 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002655
Janos Follath89baba22017-04-10 14:34:35 +01002656# Tests for CA list in CertificateRequest messages
2657
2658run_test "Authentication: send CA list in CertificateRequest (default)" \
2659 "$P_SRV debug_level=3 auth_mode=required" \
2660 "$P_CLI crt_file=data_files/server6.crt \
2661 key_file=data_files/server6.key" \
2662 0 \
2663 -s "requested DN"
2664
2665run_test "Authentication: do not send CA list in CertificateRequest" \
2666 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2667 "$P_CLI crt_file=data_files/server6.crt \
2668 key_file=data_files/server6.key" \
2669 0 \
2670 -S "requested DN"
2671
2672run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2673 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2674 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2675 key_file=data_files/server5.key" \
2676 1 \
2677 -S "requested DN" \
2678 -s "x509_verify_cert() returned" \
2679 -s "! The certificate is not correctly signed by the trusted CA" \
2680 -s "! mbedtls_ssl_handshake returned" \
2681 -c "! mbedtls_ssl_handshake returned" \
2682 -s "X509 - Certificate verification failed"
2683
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002684# Tests for certificate selection based on SHA verson
2685
2686run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2687 "$P_SRV crt_file=data_files/server5.crt \
2688 key_file=data_files/server5.key \
2689 crt_file2=data_files/server5-sha1.crt \
2690 key_file2=data_files/server5.key" \
2691 "$P_CLI force_version=tls1_2" \
2692 0 \
2693 -c "signed using.*ECDSA with SHA256" \
2694 -C "signed using.*ECDSA with SHA1"
2695
2696run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2697 "$P_SRV crt_file=data_files/server5.crt \
2698 key_file=data_files/server5.key \
2699 crt_file2=data_files/server5-sha1.crt \
2700 key_file2=data_files/server5.key" \
2701 "$P_CLI force_version=tls1_1" \
2702 0 \
2703 -C "signed using.*ECDSA with SHA256" \
2704 -c "signed using.*ECDSA with SHA1"
2705
2706run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2707 "$P_SRV crt_file=data_files/server5.crt \
2708 key_file=data_files/server5.key \
2709 crt_file2=data_files/server5-sha1.crt \
2710 key_file2=data_files/server5.key" \
2711 "$P_CLI force_version=tls1" \
2712 0 \
2713 -C "signed using.*ECDSA with SHA256" \
2714 -c "signed using.*ECDSA with SHA1"
2715
2716run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2717 "$P_SRV crt_file=data_files/server5.crt \
2718 key_file=data_files/server5.key \
2719 crt_file2=data_files/server6.crt \
2720 key_file2=data_files/server6.key" \
2721 "$P_CLI force_version=tls1_1" \
2722 0 \
2723 -c "serial number.*09" \
2724 -c "signed using.*ECDSA with SHA256" \
2725 -C "signed using.*ECDSA with SHA1"
2726
2727run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2728 "$P_SRV crt_file=data_files/server6.crt \
2729 key_file=data_files/server6.key \
2730 crt_file2=data_files/server5.crt \
2731 key_file2=data_files/server5.key" \
2732 "$P_CLI force_version=tls1_1" \
2733 0 \
2734 -c "serial number.*0A" \
2735 -c "signed using.*ECDSA with SHA256" \
2736 -C "signed using.*ECDSA with SHA1"
2737
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002738# tests for SNI
2739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002740run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002741 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002742 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002743 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002744 0 \
2745 -S "parse ServerName extension" \
2746 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2747 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002749run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002750 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002751 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002752 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 +02002753 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002754 0 \
2755 -s "parse ServerName extension" \
2756 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2757 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002759run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002760 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002761 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002762 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 +02002763 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002764 0 \
2765 -s "parse ServerName extension" \
2766 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2767 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002769run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002770 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002771 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002772 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 +02002773 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002774 1 \
2775 -s "parse ServerName extension" \
2776 -s "ssl_sni_wrapper() returned" \
2777 -s "mbedtls_ssl_handshake returned" \
2778 -c "mbedtls_ssl_handshake returned" \
2779 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002780
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002781run_test "SNI: client auth no override: optional" \
2782 "$P_SRV debug_level=3 auth_mode=optional \
2783 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2784 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2785 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002786 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002787 -S "skip write certificate request" \
2788 -C "skip parse certificate request" \
2789 -c "got a certificate request" \
2790 -C "skip write certificate" \
2791 -C "skip write certificate verify" \
2792 -S "skip parse certificate verify"
2793
2794run_test "SNI: client auth override: none -> optional" \
2795 "$P_SRV debug_level=3 auth_mode=none \
2796 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2797 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2798 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002799 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002800 -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
2807run_test "SNI: client auth override: optional -> none" \
2808 "$P_SRV debug_level=3 auth_mode=optional \
2809 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2810 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2811 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002812 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002813 -s "skip write certificate request" \
2814 -C "skip parse certificate request" \
2815 -c "got no certificate request" \
2816 -c "skip write certificate" \
2817 -c "skip write certificate verify" \
2818 -s "skip parse certificate verify"
2819
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002820run_test "SNI: CA no override" \
2821 "$P_SRV debug_level=3 auth_mode=optional \
2822 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2823 ca_file=data_files/test-ca.crt \
2824 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2825 "$P_CLI debug_level=3 server_name=localhost \
2826 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2827 1 \
2828 -S "skip write certificate request" \
2829 -C "skip parse certificate request" \
2830 -c "got a certificate request" \
2831 -C "skip write certificate" \
2832 -C "skip write certificate verify" \
2833 -S "skip parse certificate verify" \
2834 -s "x509_verify_cert() returned" \
2835 -s "! The certificate is not correctly signed by the trusted CA" \
2836 -S "The certificate has been revoked (is on a CRL)"
2837
2838run_test "SNI: CA override" \
2839 "$P_SRV debug_level=3 auth_mode=optional \
2840 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2841 ca_file=data_files/test-ca.crt \
2842 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2843 "$P_CLI debug_level=3 server_name=localhost \
2844 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2845 0 \
2846 -S "skip write certificate request" \
2847 -C "skip parse certificate request" \
2848 -c "got a certificate request" \
2849 -C "skip write certificate" \
2850 -C "skip write certificate verify" \
2851 -S "skip parse certificate verify" \
2852 -S "x509_verify_cert() returned" \
2853 -S "! The certificate is not correctly signed by the trusted CA" \
2854 -S "The certificate has been revoked (is on a CRL)"
2855
2856run_test "SNI: CA override with CRL" \
2857 "$P_SRV debug_level=3 auth_mode=optional \
2858 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2859 ca_file=data_files/test-ca.crt \
2860 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2861 "$P_CLI debug_level=3 server_name=localhost \
2862 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2863 1 \
2864 -S "skip write certificate request" \
2865 -C "skip parse certificate request" \
2866 -c "got a certificate request" \
2867 -C "skip write certificate" \
2868 -C "skip write certificate verify" \
2869 -S "skip parse certificate verify" \
2870 -s "x509_verify_cert() returned" \
2871 -S "! The certificate is not correctly signed by the trusted CA" \
2872 -s "The certificate has been revoked (is on a CRL)"
2873
Andres AGe8b07742016-12-07 10:01:30 +00002874# Tests for SNI and DTLS
2875
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002876run_test "SNI: DTLS, no SNI callback" \
2877 "$P_SRV debug_level=3 dtls=1 \
2878 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2879 "$P_CLI server_name=localhost dtls=1" \
2880 0 \
2881 -S "parse ServerName extension" \
2882 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2883 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2884
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002885run_test "SNI: DTLS, matching cert 1" \
Andres AGe8b07742016-12-07 10:01:30 +00002886 "$P_SRV debug_level=3 dtls=1 \
2887 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2888 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2889 "$P_CLI server_name=localhost dtls=1" \
2890 0 \
2891 -s "parse ServerName extension" \
2892 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2893 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2894
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002895run_test "SNI: DTLS, matching cert 2" \
2896 "$P_SRV debug_level=3 dtls=1 \
2897 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2898 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2899 "$P_CLI server_name=polarssl.example dtls=1" \
2900 0 \
2901 -s "parse ServerName extension" \
2902 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2903 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2904
2905run_test "SNI: DTLS, no matching cert" \
2906 "$P_SRV debug_level=3 dtls=1 \
2907 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2908 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2909 "$P_CLI server_name=nonesuch.example dtls=1" \
2910 1 \
2911 -s "parse ServerName extension" \
2912 -s "ssl_sni_wrapper() returned" \
2913 -s "mbedtls_ssl_handshake returned" \
2914 -c "mbedtls_ssl_handshake returned" \
2915 -c "SSL - A fatal alert message was received from our peer"
2916
2917run_test "SNI: DTLS, client auth no override: optional" \
2918 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2919 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2920 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2921 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2922 0 \
2923 -S "skip write certificate request" \
2924 -C "skip parse certificate request" \
2925 -c "got a certificate request" \
2926 -C "skip write certificate" \
2927 -C "skip write certificate verify" \
2928 -S "skip parse certificate verify"
2929
2930run_test "SNI: DTLS, client auth override: none -> optional" \
2931 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2932 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2933 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2934 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2935 0 \
2936 -S "skip write certificate request" \
2937 -C "skip parse certificate request" \
2938 -c "got a certificate request" \
2939 -C "skip write certificate" \
2940 -C "skip write certificate verify" \
2941 -S "skip parse certificate verify"
2942
2943run_test "SNI: DTLS, client auth override: optional -> none" \
2944 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2945 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2946 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2947 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2948 0 \
2949 -s "skip write certificate request" \
2950 -C "skip parse certificate request" \
2951 -c "got no certificate request" \
2952 -c "skip write certificate" \
2953 -c "skip write certificate verify" \
2954 -s "skip parse certificate verify"
2955
2956run_test "SNI: DTLS, CA no override" \
2957 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2958 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2959 ca_file=data_files/test-ca.crt \
2960 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2961 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2962 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2963 1 \
2964 -S "skip write certificate request" \
2965 -C "skip parse certificate request" \
2966 -c "got a certificate request" \
2967 -C "skip write certificate" \
2968 -C "skip write certificate verify" \
2969 -S "skip parse certificate verify" \
2970 -s "x509_verify_cert() returned" \
2971 -s "! The certificate is not correctly signed by the trusted CA" \
2972 -S "The certificate has been revoked (is on a CRL)"
2973
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002974run_test "SNI: DTLS, CA override" \
Andres AGe8b07742016-12-07 10:01:30 +00002975 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2976 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2977 ca_file=data_files/test-ca.crt \
2978 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2979 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2980 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2981 0 \
2982 -S "skip write certificate request" \
2983 -C "skip parse certificate request" \
2984 -c "got a certificate request" \
2985 -C "skip write certificate" \
2986 -C "skip write certificate verify" \
2987 -S "skip parse certificate verify" \
2988 -S "x509_verify_cert() returned" \
2989 -S "! The certificate is not correctly signed by the trusted CA" \
2990 -S "The certificate has been revoked (is on a CRL)"
2991
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002992run_test "SNI: DTLS, CA override with CRL" \
Andres AGe8b07742016-12-07 10:01:30 +00002993 "$P_SRV debug_level=3 auth_mode=optional \
2994 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2995 ca_file=data_files/test-ca.crt \
2996 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2997 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2998 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2999 1 \
3000 -S "skip write certificate request" \
3001 -C "skip parse certificate request" \
3002 -c "got a certificate request" \
3003 -C "skip write certificate" \
3004 -C "skip write certificate verify" \
3005 -S "skip parse certificate verify" \
3006 -s "x509_verify_cert() returned" \
3007 -S "! The certificate is not correctly signed by the trusted CA" \
3008 -s "The certificate has been revoked (is on a CRL)"
3009
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003010# Tests for non-blocking I/O: exercise a variety of handshake flows
3011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003012run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003013 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3014 "$P_CLI nbio=2 tickets=0" \
3015 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003016 -S "mbedtls_ssl_handshake returned" \
3017 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003018 -c "Read from server: .* bytes read"
3019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003020run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003021 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3022 "$P_CLI nbio=2 tickets=0" \
3023 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003024 -S "mbedtls_ssl_handshake returned" \
3025 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003026 -c "Read from server: .* bytes read"
3027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003028run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003029 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3030 "$P_CLI nbio=2 tickets=1" \
3031 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003032 -S "mbedtls_ssl_handshake returned" \
3033 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003034 -c "Read from server: .* bytes read"
3035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003036run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003037 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3038 "$P_CLI nbio=2 tickets=1" \
3039 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003040 -S "mbedtls_ssl_handshake returned" \
3041 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003042 -c "Read from server: .* bytes read"
3043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003044run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003045 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3046 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3047 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003048 -S "mbedtls_ssl_handshake returned" \
3049 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003050 -c "Read from server: .* bytes read"
3051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003052run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003053 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3054 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3055 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003056 -S "mbedtls_ssl_handshake returned" \
3057 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003058 -c "Read from server: .* bytes read"
3059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003060run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003061 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3062 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3063 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003064 -S "mbedtls_ssl_handshake returned" \
3065 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003066 -c "Read from server: .* bytes read"
3067
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003068# Tests for version negotiation
3069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003070run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003071 "$P_SRV" \
3072 "$P_CLI" \
3073 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003074 -S "mbedtls_ssl_handshake returned" \
3075 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003076 -s "Protocol is TLSv1.2" \
3077 -c "Protocol is TLSv1.2"
3078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003079run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003080 "$P_SRV" \
3081 "$P_CLI max_version=tls1_1" \
3082 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003083 -S "mbedtls_ssl_handshake returned" \
3084 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003085 -s "Protocol is TLSv1.1" \
3086 -c "Protocol is TLSv1.1"
3087
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003088run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003089 "$P_SRV max_version=tls1_1" \
3090 "$P_CLI" \
3091 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003092 -S "mbedtls_ssl_handshake returned" \
3093 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003094 -s "Protocol is TLSv1.1" \
3095 -c "Protocol is TLSv1.1"
3096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003097run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003098 "$P_SRV max_version=tls1_1" \
3099 "$P_CLI max_version=tls1_1" \
3100 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003101 -S "mbedtls_ssl_handshake returned" \
3102 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003103 -s "Protocol is TLSv1.1" \
3104 -c "Protocol is TLSv1.1"
3105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003106run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003107 "$P_SRV min_version=tls1_1" \
3108 "$P_CLI max_version=tls1_1" \
3109 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003110 -S "mbedtls_ssl_handshake returned" \
3111 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003112 -s "Protocol is TLSv1.1" \
3113 -c "Protocol is TLSv1.1"
3114
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003115run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003116 "$P_SRV max_version=tls1_1" \
3117 "$P_CLI min_version=tls1_1" \
3118 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003119 -S "mbedtls_ssl_handshake returned" \
3120 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003121 -s "Protocol is TLSv1.1" \
3122 -c "Protocol is TLSv1.1"
3123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003124run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003125 "$P_SRV max_version=tls1_1" \
3126 "$P_CLI min_version=tls1_2" \
3127 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003128 -s "mbedtls_ssl_handshake returned" \
3129 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003130 -c "SSL - Handshake protocol not within min/max boundaries"
3131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003132run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003133 "$P_SRV min_version=tls1_2" \
3134 "$P_CLI max_version=tls1_1" \
3135 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003136 -s "mbedtls_ssl_handshake returned" \
3137 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003138 -s "SSL - Handshake protocol not within min/max boundaries"
3139
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003140# Tests for ALPN extension
3141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003142run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003143 "$P_SRV debug_level=3" \
3144 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003145 0 \
3146 -C "client hello, adding alpn extension" \
3147 -S "found alpn extension" \
3148 -C "got an alert message, type: \\[2:120]" \
3149 -S "server hello, adding alpn extension" \
3150 -C "found alpn extension " \
3151 -C "Application Layer Protocol is" \
3152 -S "Application Layer Protocol is"
3153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003154run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003155 "$P_SRV debug_level=3" \
3156 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003157 0 \
3158 -c "client hello, adding alpn extension" \
3159 -s "found alpn extension" \
3160 -C "got an alert message, type: \\[2:120]" \
3161 -S "server hello, adding alpn extension" \
3162 -C "found alpn extension " \
3163 -c "Application Layer Protocol is (none)" \
3164 -S "Application Layer Protocol is"
3165
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003166run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003167 "$P_SRV debug_level=3 alpn=abc,1234" \
3168 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003169 0 \
3170 -C "client hello, adding alpn extension" \
3171 -S "found alpn extension" \
3172 -C "got an alert message, type: \\[2:120]" \
3173 -S "server hello, adding alpn extension" \
3174 -C "found alpn extension " \
3175 -C "Application Layer Protocol is" \
3176 -s "Application Layer Protocol is (none)"
3177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003178run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003179 "$P_SRV debug_level=3 alpn=abc,1234" \
3180 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003181 0 \
3182 -c "client hello, adding alpn extension" \
3183 -s "found alpn extension" \
3184 -C "got an alert message, type: \\[2:120]" \
3185 -s "server hello, adding alpn extension" \
3186 -c "found alpn extension" \
3187 -c "Application Layer Protocol is abc" \
3188 -s "Application Layer Protocol is abc"
3189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003190run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003191 "$P_SRV debug_level=3 alpn=abc,1234" \
3192 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003193 0 \
3194 -c "client hello, adding alpn extension" \
3195 -s "found alpn extension" \
3196 -C "got an alert message, type: \\[2:120]" \
3197 -s "server hello, adding alpn extension" \
3198 -c "found alpn extension" \
3199 -c "Application Layer Protocol is abc" \
3200 -s "Application Layer Protocol is abc"
3201
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003202run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003203 "$P_SRV debug_level=3 alpn=abc,1234" \
3204 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003205 0 \
3206 -c "client hello, adding alpn extension" \
3207 -s "found alpn extension" \
3208 -C "got an alert message, type: \\[2:120]" \
3209 -s "server hello, adding alpn extension" \
3210 -c "found alpn extension" \
3211 -c "Application Layer Protocol is 1234" \
3212 -s "Application Layer Protocol is 1234"
3213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003214run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003215 "$P_SRV debug_level=3 alpn=abc,123" \
3216 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003217 1 \
3218 -c "client hello, adding alpn extension" \
3219 -s "found alpn extension" \
3220 -c "got an alert message, type: \\[2:120]" \
3221 -S "server hello, adding alpn extension" \
3222 -C "found alpn extension" \
3223 -C "Application Layer Protocol is 1234" \
3224 -S "Application Layer Protocol is 1234"
3225
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003226
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003227# Tests for keyUsage in leaf certificates, part 1:
3228# server-side certificate/suite selection
3229
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003230run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003231 "$P_SRV key_file=data_files/server2.key \
3232 crt_file=data_files/server2.ku-ds.crt" \
3233 "$P_CLI" \
3234 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003235 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003236
3237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003238run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003239 "$P_SRV key_file=data_files/server2.key \
3240 crt_file=data_files/server2.ku-ke.crt" \
3241 "$P_CLI" \
3242 0 \
3243 -c "Ciphersuite is TLS-RSA-WITH-"
3244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003245run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003246 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003247 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003248 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003249 1 \
3250 -C "Ciphersuite is "
3251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003252run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003253 "$P_SRV key_file=data_files/server5.key \
3254 crt_file=data_files/server5.ku-ds.crt" \
3255 "$P_CLI" \
3256 0 \
3257 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3258
3259
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003260run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003261 "$P_SRV key_file=data_files/server5.key \
3262 crt_file=data_files/server5.ku-ka.crt" \
3263 "$P_CLI" \
3264 0 \
3265 -c "Ciphersuite is TLS-ECDH-"
3266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003267run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003268 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003269 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003270 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003271 1 \
3272 -C "Ciphersuite is "
3273
3274# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003275# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003277run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003278 "$O_SRV -key data_files/server2.key \
3279 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003280 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003281 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3282 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003283 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003284 -C "Processing of the Certificate handshake message failed" \
3285 -c "Ciphersuite is TLS-"
3286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003287run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003288 "$O_SRV -key data_files/server2.key \
3289 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003290 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003291 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3292 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003293 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003294 -C "Processing of the Certificate handshake message failed" \
3295 -c "Ciphersuite is TLS-"
3296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003297run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003298 "$O_SRV -key data_files/server2.key \
3299 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003300 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003301 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3302 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003303 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003304 -C "Processing of the Certificate handshake message failed" \
3305 -c "Ciphersuite is TLS-"
3306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003307run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003308 "$O_SRV -key data_files/server2.key \
3309 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003310 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003311 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3312 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003313 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003314 -c "Processing of the Certificate handshake message failed" \
3315 -C "Ciphersuite is TLS-"
3316
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003317run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3318 "$O_SRV -key data_files/server2.key \
3319 -cert data_files/server2.ku-ke.crt" \
3320 "$P_CLI debug_level=1 auth_mode=optional \
3321 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3322 0 \
3323 -c "bad certificate (usage extensions)" \
3324 -C "Processing of the Certificate handshake message failed" \
3325 -c "Ciphersuite is TLS-" \
3326 -c "! Usage does not match the keyUsage extension"
3327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003328run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003329 "$O_SRV -key data_files/server2.key \
3330 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003331 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003332 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3333 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003334 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003335 -C "Processing of the Certificate handshake message failed" \
3336 -c "Ciphersuite is TLS-"
3337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003338run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003339 "$O_SRV -key data_files/server2.key \
3340 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003341 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003342 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3343 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003344 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003345 -c "Processing of the Certificate handshake message failed" \
3346 -C "Ciphersuite is TLS-"
3347
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003348run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3349 "$O_SRV -key data_files/server2.key \
3350 -cert data_files/server2.ku-ds.crt" \
3351 "$P_CLI debug_level=1 auth_mode=optional \
3352 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3353 0 \
3354 -c "bad certificate (usage extensions)" \
3355 -C "Processing of the Certificate handshake message failed" \
3356 -c "Ciphersuite is TLS-" \
3357 -c "! Usage does not match the keyUsage extension"
3358
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003359# Tests for keyUsage in leaf certificates, part 3:
3360# server-side checking of client cert
3361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003362run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003363 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003364 "$O_CLI -key data_files/server2.key \
3365 -cert data_files/server2.ku-ds.crt" \
3366 0 \
3367 -S "bad certificate (usage extensions)" \
3368 -S "Processing of the Certificate handshake message failed"
3369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003370run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003371 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003372 "$O_CLI -key data_files/server2.key \
3373 -cert data_files/server2.ku-ke.crt" \
3374 0 \
3375 -s "bad certificate (usage extensions)" \
3376 -S "Processing of the Certificate handshake message failed"
3377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003378run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003379 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003380 "$O_CLI -key data_files/server2.key \
3381 -cert data_files/server2.ku-ke.crt" \
3382 1 \
3383 -s "bad certificate (usage extensions)" \
3384 -s "Processing of the Certificate handshake message failed"
3385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003386run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003387 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003388 "$O_CLI -key data_files/server5.key \
3389 -cert data_files/server5.ku-ds.crt" \
3390 0 \
3391 -S "bad certificate (usage extensions)" \
3392 -S "Processing of the Certificate handshake message failed"
3393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003394run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003395 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003396 "$O_CLI -key data_files/server5.key \
3397 -cert data_files/server5.ku-ka.crt" \
3398 0 \
3399 -s "bad certificate (usage extensions)" \
3400 -S "Processing of the Certificate handshake message failed"
3401
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003402# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3403
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003404run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003405 "$P_SRV key_file=data_files/server5.key \
3406 crt_file=data_files/server5.eku-srv.crt" \
3407 "$P_CLI" \
3408 0
3409
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003410run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003411 "$P_SRV key_file=data_files/server5.key \
3412 crt_file=data_files/server5.eku-srv.crt" \
3413 "$P_CLI" \
3414 0
3415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003416run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003417 "$P_SRV key_file=data_files/server5.key \
3418 crt_file=data_files/server5.eku-cs_any.crt" \
3419 "$P_CLI" \
3420 0
3421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003422run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003423 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003424 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003425 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003426 1
3427
3428# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003430run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003431 "$O_SRV -key data_files/server5.key \
3432 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003433 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003434 0 \
3435 -C "bad certificate (usage extensions)" \
3436 -C "Processing of the Certificate handshake message failed" \
3437 -c "Ciphersuite is TLS-"
3438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003439run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003440 "$O_SRV -key data_files/server5.key \
3441 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003442 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003443 0 \
3444 -C "bad certificate (usage extensions)" \
3445 -C "Processing of the Certificate handshake message failed" \
3446 -c "Ciphersuite is TLS-"
3447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003448run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003449 "$O_SRV -key data_files/server5.key \
3450 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003451 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003452 0 \
3453 -C "bad certificate (usage extensions)" \
3454 -C "Processing of the Certificate handshake message failed" \
3455 -c "Ciphersuite is TLS-"
3456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003457run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003458 "$O_SRV -key data_files/server5.key \
3459 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003460 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003461 1 \
3462 -c "bad certificate (usage extensions)" \
3463 -c "Processing of the Certificate handshake message failed" \
3464 -C "Ciphersuite is TLS-"
3465
3466# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003468run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003469 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003470 "$O_CLI -key data_files/server5.key \
3471 -cert data_files/server5.eku-cli.crt" \
3472 0 \
3473 -S "bad certificate (usage extensions)" \
3474 -S "Processing of the Certificate handshake message failed"
3475
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003476run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003477 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003478 "$O_CLI -key data_files/server5.key \
3479 -cert data_files/server5.eku-srv_cli.crt" \
3480 0 \
3481 -S "bad certificate (usage extensions)" \
3482 -S "Processing of the Certificate handshake message failed"
3483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003484run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003485 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003486 "$O_CLI -key data_files/server5.key \
3487 -cert data_files/server5.eku-cs_any.crt" \
3488 0 \
3489 -S "bad certificate (usage extensions)" \
3490 -S "Processing of the Certificate handshake message failed"
3491
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003492run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003493 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003494 "$O_CLI -key data_files/server5.key \
3495 -cert data_files/server5.eku-cs.crt" \
3496 0 \
3497 -s "bad certificate (usage extensions)" \
3498 -S "Processing of the Certificate handshake message failed"
3499
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003500run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003501 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003502 "$O_CLI -key data_files/server5.key \
3503 -cert data_files/server5.eku-cs.crt" \
3504 1 \
3505 -s "bad certificate (usage extensions)" \
3506 -s "Processing of the Certificate handshake message failed"
3507
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003508# Tests for DHM parameters loading
3509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003510run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003511 "$P_SRV" \
3512 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3513 debug_level=3" \
3514 0 \
3515 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003516 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003517
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003518run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003519 "$P_SRV dhm_file=data_files/dhparams.pem" \
3520 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3521 debug_level=3" \
3522 0 \
3523 -c "value of 'DHM: P ' (1024 bits)" \
3524 -c "value of 'DHM: G ' (2 bits)"
3525
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003526# Tests for DHM client-side size checking
3527
3528run_test "DHM size: server default, client default, OK" \
3529 "$P_SRV" \
3530 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3531 debug_level=1" \
3532 0 \
3533 -C "DHM prime too short:"
3534
3535run_test "DHM size: server default, client 2048, OK" \
3536 "$P_SRV" \
3537 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3538 debug_level=1 dhmlen=2048" \
3539 0 \
3540 -C "DHM prime too short:"
3541
3542run_test "DHM size: server 1024, client default, OK" \
3543 "$P_SRV dhm_file=data_files/dhparams.pem" \
3544 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3545 debug_level=1" \
3546 0 \
3547 -C "DHM prime too short:"
3548
3549run_test "DHM size: server 1000, client default, rejected" \
3550 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3551 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3552 debug_level=1" \
3553 1 \
3554 -c "DHM prime too short:"
3555
3556run_test "DHM size: server default, client 2049, rejected" \
3557 "$P_SRV" \
3558 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3559 debug_level=1 dhmlen=2049" \
3560 1 \
3561 -c "DHM prime too short:"
3562
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003563# Tests for PSK callback
3564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003565run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003566 "$P_SRV psk=abc123 psk_identity=foo" \
3567 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3568 psk_identity=foo psk=abc123" \
3569 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003570 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003571 -S "SSL - Unknown identity received" \
3572 -S "SSL - Verification of the message MAC failed"
3573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003574run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003575 "$P_SRV" \
3576 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3577 psk_identity=foo psk=abc123" \
3578 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003579 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003580 -S "SSL - Unknown identity received" \
3581 -S "SSL - Verification of the message MAC failed"
3582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003583run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003584 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3585 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3586 psk_identity=foo psk=abc123" \
3587 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003588 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003589 -s "SSL - Unknown identity received" \
3590 -S "SSL - Verification of the message MAC failed"
3591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003592run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003593 "$P_SRV psk_list=abc,dead,def,beef" \
3594 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3595 psk_identity=abc psk=dead" \
3596 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003597 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003598 -S "SSL - Unknown identity received" \
3599 -S "SSL - Verification of the message MAC failed"
3600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003601run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003602 "$P_SRV psk_list=abc,dead,def,beef" \
3603 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3604 psk_identity=def psk=beef" \
3605 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003606 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003607 -S "SSL - Unknown identity received" \
3608 -S "SSL - Verification of the message MAC failed"
3609
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003610run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003611 "$P_SRV psk_list=abc,dead,def,beef" \
3612 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3613 psk_identity=ghi psk=beef" \
3614 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003615 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003616 -s "SSL - Unknown identity received" \
3617 -S "SSL - Verification of the message MAC failed"
3618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003619run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003620 "$P_SRV psk_list=abc,dead,def,beef" \
3621 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3622 psk_identity=abc psk=beef" \
3623 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003624 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003625 -S "SSL - Unknown identity received" \
3626 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003627
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003628# Tests for EC J-PAKE
3629
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003630requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003631run_test "ECJPAKE: client not configured" \
3632 "$P_SRV debug_level=3" \
3633 "$P_CLI debug_level=3" \
3634 0 \
3635 -C "add ciphersuite: c0ff" \
3636 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003637 -S "found ecjpake kkpp extension" \
3638 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003639 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003640 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003641 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003642 -S "None of the common ciphersuites is usable"
3643
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003644requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003645run_test "ECJPAKE: server not configured" \
3646 "$P_SRV debug_level=3" \
3647 "$P_CLI debug_level=3 ecjpake_pw=bla \
3648 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3649 1 \
3650 -c "add ciphersuite: c0ff" \
3651 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003652 -s "found ecjpake kkpp extension" \
3653 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003654 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003655 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003656 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003657 -s "None of the common ciphersuites is usable"
3658
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003659requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003660run_test "ECJPAKE: working, TLS" \
3661 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3662 "$P_CLI debug_level=3 ecjpake_pw=bla \
3663 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003664 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003665 -c "add ciphersuite: c0ff" \
3666 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003667 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003668 -s "found ecjpake kkpp extension" \
3669 -S "skip ecjpake kkpp extension" \
3670 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003671 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003672 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003673 -S "None of the common ciphersuites is usable" \
3674 -S "SSL - Verification of the message MAC failed"
3675
Janos Follath74537a62016-09-02 13:45:28 +01003676server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003677requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003678run_test "ECJPAKE: password mismatch, TLS" \
3679 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3680 "$P_CLI debug_level=3 ecjpake_pw=bad \
3681 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3682 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003683 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003684 -s "SSL - Verification of the message MAC failed"
3685
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003686requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003687run_test "ECJPAKE: working, DTLS" \
3688 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3689 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3690 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3691 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003692 -c "re-using cached ecjpake parameters" \
3693 -S "SSL - Verification of the message MAC failed"
3694
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003695requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003696run_test "ECJPAKE: working, DTLS, no cookie" \
3697 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3698 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3699 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3700 0 \
3701 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003702 -S "SSL - Verification of the message MAC failed"
3703
Janos Follath74537a62016-09-02 13:45:28 +01003704server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003705requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003706run_test "ECJPAKE: password mismatch, DTLS" \
3707 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3708 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3709 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3710 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003711 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003712 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003713
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003714# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003715requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003716run_test "ECJPAKE: working, DTLS, nolog" \
3717 "$P_SRV dtls=1 ecjpake_pw=bla" \
3718 "$P_CLI dtls=1 ecjpake_pw=bla \
3719 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3720 0
3721
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003722# Tests for ciphersuites per version
3723
Janos Follathe2681a42016-03-07 15:57:05 +00003724requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003725requires_config_enabled MBEDTLS_CAMELLIA_C
3726requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003727run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003728 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-CAMELLIA-128-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 +02003729 "$P_CLI force_version=ssl3" \
3730 0 \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003731 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003732
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003733requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
3734requires_config_enabled MBEDTLS_CAMELLIA_C
3735requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003736run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003737 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-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 +01003738 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003739 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003740 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003741
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003742requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
3743requires_config_enabled MBEDTLS_CAMELLIA_C
3744requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003745run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003746 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-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 +02003747 "$P_CLI force_version=tls1_1" \
3748 0 \
3749 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3750
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003751requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
3752requires_config_enabled MBEDTLS_CAMELLIA_C
3753requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003754run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003755 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-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 +02003756 "$P_CLI force_version=tls1_2" \
3757 0 \
3758 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3759
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003760# Test for ClientHello without extensions
3761
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003762requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003763run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnarda92990a2020-01-30 11:19:45 +01003764 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003765 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3766 0 \
3767 -s "dumping 'client hello extensions' (0 bytes)"
3768
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003769requires_gnutls
3770run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
Manuel Pégourié-Gonnarda92990a2020-01-30 11:19:45 +01003771 "$P_SRV debug_level=3 allow_sha1=0" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003772 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3773 0 \
3774 -s "dumping 'client hello extensions' (0 bytes)"
3775
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003776# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003777
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003778run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003779 "$P_SRV" \
3780 "$P_CLI request_size=100" \
3781 0 \
3782 -s "Read from client: 100 bytes read$"
3783
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003784run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003785 "$P_SRV" \
3786 "$P_CLI request_size=500" \
3787 0 \
3788 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003789
Andrzej Kurekd731a632018-06-19 09:37:30 -04003790# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003791
Janos Follathe2681a42016-03-07 15:57:05 +00003792requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekd731a632018-06-19 09:37:30 -04003793run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003794 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003795 "$P_CLI request_size=1 force_version=ssl3 \
3796 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3797 0 \
3798 -s "Read from client: 1 bytes read"
3799
Janos Follathe2681a42016-03-07 15:57:05 +00003800requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekd731a632018-06-19 09:37:30 -04003801run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003802 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003803 "$P_CLI request_size=1 force_version=ssl3 \
3804 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3805 0 \
3806 -s "Read from client: 1 bytes read"
3807
Andrzej Kurekd731a632018-06-19 09:37:30 -04003808run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003809 "$P_SRV" \
3810 "$P_CLI request_size=1 force_version=tls1 \
3811 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3812 0 \
3813 -s "Read from client: 1 bytes read"
3814
Andrzej Kurekd731a632018-06-19 09:37:30 -04003815run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003816 "$P_SRV" \
3817 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3818 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3819 0 \
3820 -s "Read from client: 1 bytes read"
3821
Hanno Becker32c55012017-11-10 08:42:54 +00003822requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003823run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003824 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003825 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003826 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003827 0 \
3828 -s "Read from client: 1 bytes read"
3829
Hanno Becker32c55012017-11-10 08:42:54 +00003830requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003831run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003832 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003833 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003834 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003835 0 \
3836 -s "Read from client: 1 bytes read"
3837
Andrzej Kurekd731a632018-06-19 09:37:30 -04003838run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003839 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003840 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003841 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3842 0 \
3843 -s "Read from client: 1 bytes read"
3844
Andrzej Kurekd731a632018-06-19 09:37:30 -04003845run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003846 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3847 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003848 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003849 0 \
3850 -s "Read from client: 1 bytes read"
3851
3852requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003853run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003854 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003855 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003856 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003857 0 \
3858 -s "Read from client: 1 bytes read"
3859
Hanno Becker8501f982017-11-10 08:59:04 +00003860requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003861run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003862 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3863 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3864 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003865 0 \
3866 -s "Read from client: 1 bytes read"
3867
Andrzej Kurekd731a632018-06-19 09:37:30 -04003868run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003869 "$P_SRV" \
3870 "$P_CLI request_size=1 force_version=tls1_1 \
3871 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3872 0 \
3873 -s "Read from client: 1 bytes read"
3874
Andrzej Kurekd731a632018-06-19 09:37:30 -04003875run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003876 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003877 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003878 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003879 0 \
3880 -s "Read from client: 1 bytes read"
3881
3882requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003883run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003884 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003885 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003886 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003887 0 \
3888 -s "Read from client: 1 bytes read"
3889
3890requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003891run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003892 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003893 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003894 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003895 0 \
3896 -s "Read from client: 1 bytes read"
3897
Andrzej Kurekd731a632018-06-19 09:37:30 -04003898run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003899 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003900 "$P_CLI request_size=1 force_version=tls1_1 \
3901 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3902 0 \
3903 -s "Read from client: 1 bytes read"
3904
Andrzej Kurekd731a632018-06-19 09:37:30 -04003905run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003906 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003907 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003908 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003909 0 \
3910 -s "Read from client: 1 bytes read"
3911
Hanno Becker8501f982017-11-10 08:59:04 +00003912requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003913run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003914 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003915 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003916 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003917 0 \
3918 -s "Read from client: 1 bytes read"
3919
Hanno Becker32c55012017-11-10 08:42:54 +00003920requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003921run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003922 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003923 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003924 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003925 0 \
3926 -s "Read from client: 1 bytes read"
3927
Andrzej Kurekd731a632018-06-19 09:37:30 -04003928run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003929 "$P_SRV" \
3930 "$P_CLI request_size=1 force_version=tls1_2 \
3931 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3932 0 \
3933 -s "Read from client: 1 bytes read"
3934
Andrzej Kurekd731a632018-06-19 09:37:30 -04003935run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003936 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003937 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003938 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003939 0 \
3940 -s "Read from client: 1 bytes read"
3941
Andrzej Kurekd731a632018-06-19 09:37:30 -04003942run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003943 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003944 "$P_CLI request_size=1 force_version=tls1_2 \
3945 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003946 0 \
3947 -s "Read from client: 1 bytes read"
3948
Hanno Becker32c55012017-11-10 08:42:54 +00003949requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003950run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003951 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003952 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003953 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003954 0 \
3955 -s "Read from client: 1 bytes read"
3956
Hanno Becker8501f982017-11-10 08:59:04 +00003957requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003958run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003959 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003960 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003961 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003962 0 \
3963 -s "Read from client: 1 bytes read"
3964
Andrzej Kurekd731a632018-06-19 09:37:30 -04003965run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003966 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003967 "$P_CLI request_size=1 force_version=tls1_2 \
3968 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3969 0 \
3970 -s "Read from client: 1 bytes read"
3971
Andrzej Kurekd731a632018-06-19 09:37:30 -04003972run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003973 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003974 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003975 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003976 0 \
3977 -s "Read from client: 1 bytes read"
3978
Hanno Becker32c55012017-11-10 08:42:54 +00003979requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003980run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003981 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003982 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003983 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003984 0 \
3985 -s "Read from client: 1 bytes read"
3986
Hanno Becker8501f982017-11-10 08:59:04 +00003987requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003988run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003989 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003990 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003991 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003992 0 \
3993 -s "Read from client: 1 bytes read"
3994
Andrzej Kurekd731a632018-06-19 09:37:30 -04003995run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003996 "$P_SRV" \
3997 "$P_CLI request_size=1 force_version=tls1_2 \
3998 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3999 0 \
4000 -s "Read from client: 1 bytes read"
4001
Andrzej Kurekd731a632018-06-19 09:37:30 -04004002run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004003 "$P_SRV" \
4004 "$P_CLI request_size=1 force_version=tls1_2 \
4005 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4006 0 \
4007 -s "Read from client: 1 bytes read"
4008
Andrzej Kurekd731a632018-06-19 09:37:30 -04004009# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004010
4011requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004012run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004013 "$P_SRV dtls=1 force_version=dtls1" \
4014 "$P_CLI dtls=1 request_size=1 \
4015 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4016 0 \
4017 -s "Read from client: 1 bytes read"
4018
4019requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004020run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004021 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4022 "$P_CLI dtls=1 request_size=1 \
4023 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4024 0 \
4025 -s "Read from client: 1 bytes read"
4026
4027requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4028requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004029run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004030 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4031 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004032 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4033 0 \
4034 -s "Read from client: 1 bytes read"
4035
4036requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4037requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004038run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004039 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004040 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004041 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004042 0 \
4043 -s "Read from client: 1 bytes read"
4044
4045requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004046run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004047 "$P_SRV dtls=1 force_version=dtls1_2" \
4048 "$P_CLI dtls=1 request_size=1 \
4049 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4050 0 \
4051 -s "Read from client: 1 bytes read"
4052
4053requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004054run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004055 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004056 "$P_CLI dtls=1 request_size=1 \
4057 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4058 0 \
4059 -s "Read from client: 1 bytes read"
4060
4061requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4062requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004063run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004064 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004065 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004066 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004067 0 \
4068 -s "Read from client: 1 bytes read"
4069
4070requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4071requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004072run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004073 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004074 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004075 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004076 0 \
4077 -s "Read from client: 1 bytes read"
4078
Andrzej Kurekd731a632018-06-19 09:37:30 -04004079# Tests for small server packets
4080
4081requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4082run_test "Small server packet SSLv3 BlockCipher" \
4083 "$P_SRV response_size=1 min_version=ssl3" \
4084 "$P_CLI force_version=ssl3 \
4085 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4086 0 \
4087 -c "Read from server: 1 bytes read"
4088
4089requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4090run_test "Small server packet SSLv3 StreamCipher" \
4091 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4092 "$P_CLI force_version=ssl3 \
4093 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4094 0 \
4095 -c "Read from server: 1 bytes read"
4096
4097run_test "Small server packet TLS 1.0 BlockCipher" \
4098 "$P_SRV response_size=1" \
4099 "$P_CLI force_version=tls1 \
4100 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4101 0 \
4102 -c "Read from server: 1 bytes read"
4103
4104run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4105 "$P_SRV response_size=1" \
4106 "$P_CLI force_version=tls1 etm=0 \
4107 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4108 0 \
4109 -c "Read from server: 1 bytes read"
4110
4111requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4112run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4113 "$P_SRV response_size=1 trunc_hmac=1" \
4114 "$P_CLI force_version=tls1 \
4115 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4116 0 \
4117 -c "Read from server: 1 bytes read"
4118
4119requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4120run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4121 "$P_SRV response_size=1 trunc_hmac=1" \
4122 "$P_CLI force_version=tls1 \
4123 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4124 0 \
4125 -c "Read from server: 1 bytes read"
4126
4127run_test "Small server packet TLS 1.0 StreamCipher" \
4128 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4129 "$P_CLI force_version=tls1 \
4130 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4131 0 \
4132 -c "Read from server: 1 bytes read"
4133
4134run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4135 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4136 "$P_CLI force_version=tls1 \
4137 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4138 0 \
4139 -c "Read from server: 1 bytes read"
4140
4141requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4142run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4143 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4144 "$P_CLI force_version=tls1 \
4145 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4146 0 \
4147 -c "Read from server: 1 bytes read"
4148
4149requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4150run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4151 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4152 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4153 trunc_hmac=1 etm=0" \
4154 0 \
4155 -c "Read from server: 1 bytes read"
4156
4157run_test "Small server packet TLS 1.1 BlockCipher" \
4158 "$P_SRV response_size=1" \
4159 "$P_CLI force_version=tls1_1 \
4160 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4161 0 \
4162 -c "Read from server: 1 bytes read"
4163
4164run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4165 "$P_SRV response_size=1" \
4166 "$P_CLI force_version=tls1_1 \
4167 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4168 0 \
4169 -c "Read from server: 1 bytes read"
4170
4171requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4172run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4173 "$P_SRV response_size=1 trunc_hmac=1" \
4174 "$P_CLI force_version=tls1_1 \
4175 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4176 0 \
4177 -c "Read from server: 1 bytes read"
4178
4179requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4180run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4181 "$P_SRV response_size=1 trunc_hmac=1" \
4182 "$P_CLI force_version=tls1_1 \
4183 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4184 0 \
4185 -c "Read from server: 1 bytes read"
4186
4187run_test "Small server packet TLS 1.1 StreamCipher" \
4188 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4189 "$P_CLI force_version=tls1_1 \
4190 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4191 0 \
4192 -c "Read from server: 1 bytes read"
4193
4194run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4195 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4196 "$P_CLI force_version=tls1_1 \
4197 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4198 0 \
4199 -c "Read from server: 1 bytes read"
4200
4201requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4202run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4203 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4204 "$P_CLI force_version=tls1_1 \
4205 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4206 0 \
4207 -c "Read from server: 1 bytes read"
4208
4209requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4210run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4211 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4212 "$P_CLI force_version=tls1_1 \
4213 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4214 0 \
4215 -c "Read from server: 1 bytes read"
4216
4217run_test "Small server packet TLS 1.2 BlockCipher" \
4218 "$P_SRV response_size=1" \
4219 "$P_CLI force_version=tls1_2 \
4220 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4221 0 \
4222 -c "Read from server: 1 bytes read"
4223
4224run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4225 "$P_SRV response_size=1" \
4226 "$P_CLI force_version=tls1_2 \
4227 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4228 0 \
4229 -c "Read from server: 1 bytes read"
4230
4231run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4232 "$P_SRV response_size=1" \
4233 "$P_CLI force_version=tls1_2 \
4234 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4235 0 \
4236 -c "Read from server: 1 bytes read"
4237
4238requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4239run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4240 "$P_SRV response_size=1 trunc_hmac=1" \
4241 "$P_CLI force_version=tls1_2 \
4242 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4243 0 \
4244 -c "Read from server: 1 bytes read"
4245
4246requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4247run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4248 "$P_SRV response_size=1 trunc_hmac=1" \
4249 "$P_CLI force_version=tls1_2 \
4250 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4251 0 \
4252 -c "Read from server: 1 bytes read"
4253
4254run_test "Small server packet TLS 1.2 StreamCipher" \
4255 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4256 "$P_CLI force_version=tls1_2 \
4257 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4258 0 \
4259 -c "Read from server: 1 bytes read"
4260
4261run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4262 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4263 "$P_CLI force_version=tls1_2 \
4264 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4265 0 \
4266 -c "Read from server: 1 bytes read"
4267
4268requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4269run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4270 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4271 "$P_CLI force_version=tls1_2 \
4272 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4273 0 \
4274 -c "Read from server: 1 bytes read"
4275
4276requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4277run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4278 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4279 "$P_CLI force_version=tls1_2 \
4280 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4281 0 \
4282 -c "Read from server: 1 bytes read"
4283
4284run_test "Small server packet TLS 1.2 AEAD" \
4285 "$P_SRV response_size=1" \
4286 "$P_CLI force_version=tls1_2 \
4287 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4288 0 \
4289 -c "Read from server: 1 bytes read"
4290
4291run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4292 "$P_SRV response_size=1" \
4293 "$P_CLI force_version=tls1_2 \
4294 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4295 0 \
4296 -c "Read from server: 1 bytes read"
4297
4298# Tests for small server packets in DTLS
4299
4300requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4301run_test "Small server packet DTLS 1.0" \
4302 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4303 "$P_CLI dtls=1 \
4304 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4305 0 \
4306 -c "Read from server: 1 bytes read"
4307
4308requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4309run_test "Small server packet DTLS 1.0, without EtM" \
4310 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4311 "$P_CLI dtls=1 \
4312 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4313 0 \
4314 -c "Read from server: 1 bytes read"
4315
4316requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4317requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4318run_test "Small server packet DTLS 1.0, truncated hmac" \
4319 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4320 "$P_CLI dtls=1 trunc_hmac=1 \
4321 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4322 0 \
4323 -c "Read from server: 1 bytes read"
4324
4325requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4326requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4327run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4328 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4329 "$P_CLI dtls=1 \
4330 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4331 0 \
4332 -c "Read from server: 1 bytes read"
4333
4334requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4335run_test "Small server packet DTLS 1.2" \
4336 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4337 "$P_CLI dtls=1 \
4338 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4339 0 \
4340 -c "Read from server: 1 bytes read"
4341
4342requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4343run_test "Small server packet DTLS 1.2, without EtM" \
4344 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4345 "$P_CLI dtls=1 \
4346 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4347 0 \
4348 -c "Read from server: 1 bytes read"
4349
4350requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4351requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4352run_test "Small server packet DTLS 1.2, truncated hmac" \
4353 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4354 "$P_CLI dtls=1 \
4355 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4356 0 \
4357 -c "Read from server: 1 bytes read"
4358
4359requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4360requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4361run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4362 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4363 "$P_CLI dtls=1 \
4364 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4365 0 \
4366 -c "Read from server: 1 bytes read"
4367
Janos Follath00efff72016-05-06 13:48:23 +01004368# A test for extensions in SSLv3
4369
4370requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4371run_test "SSLv3 with extensions, server side" \
4372 "$P_SRV min_version=ssl3 debug_level=3" \
4373 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4374 0 \
4375 -S "dumping 'client hello extensions'" \
4376 -S "server hello, total extension length:"
4377
Andrzej Kurek557335e2018-06-28 04:03:10 -04004378# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004379
Janos Follathe2681a42016-03-07 15:57:05 +00004380requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek557335e2018-06-28 04:03:10 -04004381run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004382 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004383 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004384 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4385 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004386 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004387 -s "Read from client: 16384 bytes read"
4388
Janos Follathe2681a42016-03-07 15:57:05 +00004389requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek557335e2018-06-28 04:03:10 -04004390run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004391 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004392 "$P_CLI request_size=16384 force_version=ssl3 \
4393 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4394 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004395 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004396 -s "Read from client: 16384 bytes read"
4397
Andrzej Kurek557335e2018-06-28 04:03:10 -04004398run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004399 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004400 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004401 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4402 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004403 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004404 -s "Read from client: 16384 bytes read"
4405
Andrzej Kurek557335e2018-06-28 04:03:10 -04004406run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004407 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004408 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4409 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4410 0 \
4411 -s "Read from client: 16384 bytes read"
4412
Hanno Becker32c55012017-11-10 08:42:54 +00004413requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004414run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004415 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004416 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004417 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004418 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004419 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004420 -s "Read from client: 16384 bytes read"
4421
Hanno Becker32c55012017-11-10 08:42:54 +00004422requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004423run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004424 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004425 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004426 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004427 0 \
4428 -s "Read from client: 16384 bytes read"
4429
Andrzej Kurek557335e2018-06-28 04:03:10 -04004430run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004431 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004432 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004433 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4434 0 \
4435 -s "Read from client: 16384 bytes read"
4436
Andrzej Kurek557335e2018-06-28 04:03:10 -04004437run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004438 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4439 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004440 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004441 0 \
4442 -s "Read from client: 16384 bytes read"
4443
4444requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004445run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004446 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004447 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004448 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004449 0 \
4450 -s "Read from client: 16384 bytes read"
4451
Hanno Becker278fc7a2017-11-10 09:16:28 +00004452requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004453run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004454 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004455 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004456 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004457 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004458 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004459 -s "Read from client: 16384 bytes read"
4460
Andrzej Kurek557335e2018-06-28 04:03:10 -04004461run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004462 "$P_SRV" \
4463 "$P_CLI request_size=16384 force_version=tls1_1 \
4464 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4465 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004466 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004467 -s "Read from client: 16384 bytes read"
4468
Andrzej Kurek557335e2018-06-28 04:03:10 -04004469run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004470 "$P_SRV" \
4471 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4472 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004473 0 \
4474 -s "Read from client: 16384 bytes read"
4475
Hanno Becker32c55012017-11-10 08:42:54 +00004476requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004477run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004478 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004479 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004480 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004481 0 \
4482 -s "Read from client: 16384 bytes read"
4483
Hanno Becker32c55012017-11-10 08:42:54 +00004484requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004485run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004486 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004487 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004488 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004489 0 \
4490 -s "Read from client: 16384 bytes read"
4491
Andrzej Kurek557335e2018-06-28 04:03:10 -04004492run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004493 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4494 "$P_CLI request_size=16384 force_version=tls1_1 \
4495 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4496 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004497 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004498 -s "Read from client: 16384 bytes read"
4499
Andrzej Kurek557335e2018-06-28 04:03:10 -04004500run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004501 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004502 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004503 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004504 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004505 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004506 -s "Read from client: 16384 bytes read"
4507
Hanno Becker278fc7a2017-11-10 09:16:28 +00004508requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004509run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004510 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004511 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004512 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004513 0 \
4514 -s "Read from client: 16384 bytes read"
4515
Hanno Becker278fc7a2017-11-10 09:16:28 +00004516requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004517run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004518 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004519 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004520 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004521 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004522 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004523 -s "Read from client: 16384 bytes read"
4524
Andrzej Kurek557335e2018-06-28 04:03:10 -04004525run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004526 "$P_SRV" \
4527 "$P_CLI request_size=16384 force_version=tls1_2 \
4528 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4529 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004530 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004531 -s "Read from client: 16384 bytes read"
4532
Andrzej Kurek557335e2018-06-28 04:03:10 -04004533run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004534 "$P_SRV" \
4535 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4536 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4537 0 \
4538 -s "Read from client: 16384 bytes read"
4539
Andrzej Kurek557335e2018-06-28 04:03:10 -04004540run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004541 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004542 "$P_CLI request_size=16384 force_version=tls1_2 \
4543 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004544 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004545 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004546 -s "Read from client: 16384 bytes read"
4547
Hanno Becker32c55012017-11-10 08:42:54 +00004548requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004549run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004550 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004551 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004552 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004553 0 \
4554 -s "Read from client: 16384 bytes read"
4555
Hanno Becker278fc7a2017-11-10 09:16:28 +00004556requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004557run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004558 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004559 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004560 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004561 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004562 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004563 -s "Read from client: 16384 bytes read"
4564
Andrzej Kurek557335e2018-06-28 04:03:10 -04004565run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004566 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004567 "$P_CLI request_size=16384 force_version=tls1_2 \
4568 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4569 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004570 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004571 -s "Read from client: 16384 bytes read"
4572
Andrzej Kurek557335e2018-06-28 04:03:10 -04004573run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004574 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004575 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004576 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4577 0 \
4578 -s "Read from client: 16384 bytes read"
4579
Hanno Becker32c55012017-11-10 08:42:54 +00004580requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004581run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004582 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004583 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004584 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004585 0 \
4586 -s "Read from client: 16384 bytes read"
4587
Hanno Becker278fc7a2017-11-10 09:16:28 +00004588requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004589run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004590 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004591 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004592 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004593 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004594 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004595 -s "Read from client: 16384 bytes read"
4596
Andrzej Kurek557335e2018-06-28 04:03:10 -04004597run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004598 "$P_SRV" \
4599 "$P_CLI request_size=16384 force_version=tls1_2 \
4600 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4601 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004602 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004603 -s "Read from client: 16384 bytes read"
4604
Andrzej Kurek557335e2018-06-28 04:03:10 -04004605run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004606 "$P_SRV" \
4607 "$P_CLI request_size=16384 force_version=tls1_2 \
4608 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4609 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004610 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004611 -s "Read from client: 16384 bytes read"
4612
Ron Eldorc7f15232018-06-28 13:22:05 +03004613# Tests for ECC extensions (rfc 4492)
4614
Ron Eldor94226d82018-06-28 16:17:00 +03004615requires_config_enabled MBEDTLS_AES_C
4616requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4617requires_config_enabled MBEDTLS_SHA256_C
4618requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004619run_test "Force a non ECC ciphersuite in the client side" \
4620 "$P_SRV debug_level=3" \
Ron Eldor94226d82018-06-28 16:17:00 +03004621 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004622 0 \
4623 -C "client hello, adding supported_elliptic_curves extension" \
4624 -C "client hello, adding supported_point_formats extension" \
4625 -S "found supported elliptic curves extension" \
4626 -S "found supported point formats extension"
4627
Ron Eldor94226d82018-06-28 16:17:00 +03004628requires_config_enabled MBEDTLS_AES_C
4629requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4630requires_config_enabled MBEDTLS_SHA256_C
4631requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004632run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor94226d82018-06-28 16:17:00 +03004633 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004634 "$P_CLI debug_level=3" \
4635 0 \
4636 -C "found supported_point_formats extension" \
4637 -S "server hello, supported_point_formats extension"
4638
Ron Eldor94226d82018-06-28 16:17:00 +03004639requires_config_enabled MBEDTLS_AES_C
4640requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4641requires_config_enabled MBEDTLS_SHA256_C
4642requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004643run_test "Force an ECC ciphersuite in the client side" \
4644 "$P_SRV debug_level=3" \
4645 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4646 0 \
4647 -c "client hello, adding supported_elliptic_curves extension" \
4648 -c "client hello, adding supported_point_formats extension" \
4649 -s "found supported elliptic curves extension" \
4650 -s "found supported point formats extension"
4651
Ron Eldor94226d82018-06-28 16:17:00 +03004652requires_config_enabled MBEDTLS_AES_C
4653requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4654requires_config_enabled MBEDTLS_SHA256_C
4655requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004656run_test "Force an ECC ciphersuite in the server side" \
4657 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4658 "$P_CLI debug_level=3" \
4659 0 \
4660 -c "found supported_point_formats extension" \
4661 -s "server hello, supported_point_formats extension"
4662
Andrzej Kurek557335e2018-06-28 04:03:10 -04004663# Test for large server packets
Andrzej Kurek557335e2018-06-28 04:03:10 -04004664requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4665run_test "Large server packet SSLv3 StreamCipher" \
4666 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4667 "$P_CLI force_version=ssl3 \
4668 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4669 0 \
4670 -c "Read from server: 16384 bytes read"
4671
Andrzej Kurekc8958212018-08-27 08:00:13 -04004672# Checking next 4 tests logs for 1n-1 split against BEAST too
4673requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4674run_test "Large server packet SSLv3 BlockCipher" \
4675 "$P_SRV response_size=16384 min_version=ssl3" \
4676 "$P_CLI force_version=ssl3 recsplit=0 \
4677 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4678 0 \
4679 -c "Read from server: 1 bytes read"\
4680 -c "16383 bytes read"\
4681 -C "Read from server: 16384 bytes read"
4682
Andrzej Kurek557335e2018-06-28 04:03:10 -04004683run_test "Large server packet TLS 1.0 BlockCipher" \
4684 "$P_SRV response_size=16384" \
4685 "$P_CLI force_version=tls1 recsplit=0 \
4686 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4687 0 \
4688 -c "Read from server: 1 bytes read"\
4689 -c "16383 bytes read"\
4690 -C "Read from server: 16384 bytes read"
4691
Andrzej Kurekd731a632018-06-19 09:37:30 -04004692run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
4693 "$P_SRV response_size=16384" \
4694 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
4695 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4696 0 \
4697 -c "Read from server: 1 bytes read"\
4698 -c "16383 bytes read"\
4699 -C "Read from server: 16384 bytes read"
4700
Andrzej Kurek557335e2018-06-28 04:03:10 -04004701requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4702run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
4703 "$P_SRV response_size=16384" \
4704 "$P_CLI force_version=tls1 recsplit=0 \
4705 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4706 trunc_hmac=1" \
4707 0 \
4708 -c "Read from server: 1 bytes read"\
4709 -c "16383 bytes read"\
4710 -C "Read from server: 16384 bytes read"
4711
4712requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4713run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
4714 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4715 "$P_CLI force_version=tls1 \
4716 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4717 trunc_hmac=1" \
4718 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004719 -s "16384 bytes written in 1 fragments" \
4720 -c "Read from server: 16384 bytes read"
4721
4722run_test "Large server packet TLS 1.0 StreamCipher" \
4723 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4724 "$P_CLI force_version=tls1 \
4725 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4726 0 \
4727 -s "16384 bytes written in 1 fragments" \
4728 -c "Read from server: 16384 bytes read"
4729
4730run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
4731 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4732 "$P_CLI force_version=tls1 \
4733 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4734 0 \
4735 -s "16384 bytes written in 1 fragments" \
4736 -c "Read from server: 16384 bytes read"
4737
4738requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4739run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
4740 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4741 "$P_CLI force_version=tls1 \
4742 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4743 0 \
4744 -s "16384 bytes written in 1 fragments" \
4745 -c "Read from server: 16384 bytes read"
4746
4747requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4748run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4749 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4750 "$P_CLI force_version=tls1 \
4751 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4752 0 \
4753 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004754 -c "Read from server: 16384 bytes read"
4755
4756run_test "Large server packet TLS 1.1 BlockCipher" \
4757 "$P_SRV response_size=16384" \
4758 "$P_CLI force_version=tls1_1 \
4759 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4760 0 \
4761 -c "Read from server: 16384 bytes read"
4762
Andrzej Kurekd731a632018-06-19 09:37:30 -04004763run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
4764 "$P_SRV response_size=16384" \
4765 "$P_CLI force_version=tls1_1 etm=0 \
4766 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004767 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004768 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004769 -c "Read from server: 16384 bytes read"
4770
4771requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4772run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
4773 "$P_SRV response_size=16384" \
4774 "$P_CLI force_version=tls1_1 \
4775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4776 trunc_hmac=1" \
4777 0 \
4778 -c "Read from server: 16384 bytes read"
4779
4780requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004781run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4782 "$P_SRV response_size=16384 trunc_hmac=1" \
4783 "$P_CLI force_version=tls1_1 \
4784 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4785 0 \
4786 -s "16384 bytes written in 1 fragments" \
4787 -c "Read from server: 16384 bytes read"
4788
4789run_test "Large server packet TLS 1.1 StreamCipher" \
4790 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4791 "$P_CLI force_version=tls1_1 \
4792 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4793 0 \
4794 -c "Read from server: 16384 bytes read"
4795
4796run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
4797 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4798 "$P_CLI force_version=tls1_1 \
4799 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4800 0 \
4801 -s "16384 bytes written in 1 fragments" \
4802 -c "Read from server: 16384 bytes read"
4803
4804requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004805run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
4806 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4807 "$P_CLI force_version=tls1_1 \
4808 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4809 trunc_hmac=1" \
4810 0 \
4811 -c "Read from server: 16384 bytes read"
4812
Andrzej Kurekd731a632018-06-19 09:37:30 -04004813run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4814 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4815 "$P_CLI force_version=tls1_1 \
4816 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4817 0 \
4818 -s "16384 bytes written in 1 fragments" \
4819 -c "Read from server: 16384 bytes read"
4820
Andrzej Kurek557335e2018-06-28 04:03:10 -04004821run_test "Large server packet TLS 1.2 BlockCipher" \
4822 "$P_SRV response_size=16384" \
4823 "$P_CLI force_version=tls1_2 \
4824 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4825 0 \
4826 -c "Read from server: 16384 bytes read"
4827
Andrzej Kurekd731a632018-06-19 09:37:30 -04004828run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
4829 "$P_SRV response_size=16384" \
4830 "$P_CLI force_version=tls1_2 etm=0 \
4831 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4832 0 \
4833 -s "16384 bytes written in 1 fragments" \
4834 -c "Read from server: 16384 bytes read"
4835
Andrzej Kurek557335e2018-06-28 04:03:10 -04004836run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
4837 "$P_SRV response_size=16384" \
4838 "$P_CLI force_version=tls1_2 \
4839 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4840 0 \
4841 -c "Read from server: 16384 bytes read"
4842
4843requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4844run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
4845 "$P_SRV response_size=16384" \
4846 "$P_CLI force_version=tls1_2 \
4847 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4848 trunc_hmac=1" \
4849 0 \
4850 -c "Read from server: 16384 bytes read"
4851
Andrzej Kurekd731a632018-06-19 09:37:30 -04004852run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4853 "$P_SRV response_size=16384 trunc_hmac=1" \
4854 "$P_CLI force_version=tls1_2 \
4855 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4856 0 \
4857 -s "16384 bytes written in 1 fragments" \
4858 -c "Read from server: 16384 bytes read"
4859
Andrzej Kurek557335e2018-06-28 04:03:10 -04004860run_test "Large server packet TLS 1.2 StreamCipher" \
4861 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4862 "$P_CLI force_version=tls1_2 \
4863 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4864 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004865 -s "16384 bytes written in 1 fragments" \
4866 -c "Read from server: 16384 bytes read"
4867
4868run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
4869 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4870 "$P_CLI force_version=tls1_2 \
4871 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4872 0 \
4873 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004874 -c "Read from server: 16384 bytes read"
4875
4876requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4877run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
4878 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4879 "$P_CLI force_version=tls1_2 \
4880 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4881 trunc_hmac=1" \
4882 0 \
4883 -c "Read from server: 16384 bytes read"
4884
Andrzej Kurekd731a632018-06-19 09:37:30 -04004885requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4886run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4887 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4888 "$P_CLI force_version=tls1_2 \
4889 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4890 0 \
4891 -s "16384 bytes written in 1 fragments" \
4892 -c "Read from server: 16384 bytes read"
4893
Andrzej Kurek557335e2018-06-28 04:03:10 -04004894run_test "Large server packet TLS 1.2 AEAD" \
4895 "$P_SRV response_size=16384" \
4896 "$P_CLI force_version=tls1_2 \
4897 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4898 0 \
4899 -c "Read from server: 16384 bytes read"
4900
4901run_test "Large server packet TLS 1.2 AEAD shorter tag" \
4902 "$P_SRV response_size=16384" \
4903 "$P_CLI force_version=tls1_2 \
4904 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4905 0 \
4906 -c "Read from server: 16384 bytes read"
4907
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004908# Tests for DTLS HelloVerifyRequest
4909
4910run_test "DTLS cookie: enabled" \
4911 "$P_SRV dtls=1 debug_level=2" \
4912 "$P_CLI dtls=1 debug_level=2" \
4913 0 \
4914 -s "cookie verification failed" \
4915 -s "cookie verification passed" \
4916 -S "cookie verification skipped" \
4917 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004918 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004919 -S "SSL - The requested feature is not available"
4920
4921run_test "DTLS cookie: disabled" \
4922 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4923 "$P_CLI dtls=1 debug_level=2" \
4924 0 \
4925 -S "cookie verification failed" \
4926 -S "cookie verification passed" \
4927 -s "cookie verification skipped" \
4928 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004929 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004930 -S "SSL - The requested feature is not available"
4931
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004932run_test "DTLS cookie: default (failing)" \
4933 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4934 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4935 1 \
4936 -s "cookie verification failed" \
4937 -S "cookie verification passed" \
4938 -S "cookie verification skipped" \
4939 -C "received hello verify request" \
4940 -S "hello verification requested" \
4941 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004942
4943requires_ipv6
4944run_test "DTLS cookie: enabled, IPv6" \
4945 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4946 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4947 0 \
4948 -s "cookie verification failed" \
4949 -s "cookie verification passed" \
4950 -S "cookie verification skipped" \
4951 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004952 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004953 -S "SSL - The requested feature is not available"
4954
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004955run_test "DTLS cookie: enabled, nbio" \
4956 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4957 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4958 0 \
4959 -s "cookie verification failed" \
4960 -s "cookie verification passed" \
4961 -S "cookie verification skipped" \
4962 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004963 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004964 -S "SSL - The requested feature is not available"
4965
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004966# Tests for client reconnecting from the same port with DTLS
4967
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004968not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004969run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004970 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4971 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004972 0 \
4973 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004974 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004975 -S "Client initiated reconnection from same port"
4976
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004977not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004978run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004979 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4980 "$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 +02004981 0 \
4982 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004983 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004984 -s "Client initiated reconnection from same port"
4985
Paul Bakker362689d2016-05-13 10:33:25 +01004986not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4987run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004988 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4989 "$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 +02004990 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004991 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004992 -s "Client initiated reconnection from same port"
4993
Paul Bakker362689d2016-05-13 10:33:25 +01004994only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4995run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4996 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4997 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4998 0 \
4999 -S "The operation timed out" \
5000 -s "Client initiated reconnection from same port"
5001
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005002run_test "DTLS client reconnect from same port: no cookies" \
5003 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005004 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5005 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005006 -s "The operation timed out" \
5007 -S "Client initiated reconnection from same port"
5008
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005009# Tests for various cases of client authentication with DTLS
5010# (focused on handshake flows and message parsing)
5011
5012run_test "DTLS client auth: required" \
5013 "$P_SRV dtls=1 auth_mode=required" \
5014 "$P_CLI dtls=1" \
5015 0 \
5016 -s "Verifying peer X.509 certificate... ok"
5017
5018run_test "DTLS client auth: optional, client has no cert" \
5019 "$P_SRV dtls=1 auth_mode=optional" \
5020 "$P_CLI dtls=1 crt_file=none key_file=none" \
5021 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005022 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005023
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005024run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005025 "$P_SRV dtls=1 auth_mode=none" \
5026 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5027 0 \
5028 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005029 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005030
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005031run_test "DTLS wrong PSK: badmac alert" \
5032 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5033 "$P_CLI dtls=1 psk=abc124" \
5034 1 \
5035 -s "SSL - Verification of the message MAC failed" \
5036 -c "SSL - A fatal alert message was received from our peer"
5037
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005038# Tests for receiving fragmented handshake messages with DTLS
5039
5040requires_gnutls
5041run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5042 "$G_SRV -u --mtu 2048 -a" \
5043 "$P_CLI dtls=1 debug_level=2" \
5044 0 \
5045 -C "found fragmented DTLS handshake message" \
5046 -C "error"
5047
5048requires_gnutls
5049run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5050 "$G_SRV -u --mtu 512" \
5051 "$P_CLI dtls=1 debug_level=2" \
5052 0 \
5053 -c "found fragmented DTLS handshake message" \
5054 -C "error"
5055
5056requires_gnutls
5057run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5058 "$G_SRV -u --mtu 128" \
5059 "$P_CLI dtls=1 debug_level=2" \
5060 0 \
5061 -c "found fragmented DTLS handshake message" \
5062 -C "error"
5063
5064requires_gnutls
5065run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5066 "$G_SRV -u --mtu 128" \
5067 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5068 0 \
5069 -c "found fragmented DTLS handshake message" \
5070 -C "error"
5071
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005072requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005073requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005074run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5075 "$G_SRV -u --mtu 256" \
5076 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5077 0 \
5078 -c "found fragmented DTLS handshake message" \
5079 -c "client hello, adding renegotiation extension" \
5080 -c "found renegotiation extension" \
5081 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005082 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005083 -C "error" \
5084 -s "Extra-header:"
5085
5086requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005087requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005088run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5089 "$G_SRV -u --mtu 256" \
5090 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5091 0 \
5092 -c "found fragmented DTLS handshake message" \
5093 -c "client hello, adding renegotiation extension" \
5094 -c "found renegotiation extension" \
5095 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005096 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005097 -C "error" \
5098 -s "Extra-header:"
5099
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005100run_test "DTLS reassembly: no fragmentation (openssl server)" \
5101 "$O_SRV -dtls1 -mtu 2048" \
5102 "$P_CLI dtls=1 debug_level=2" \
5103 0 \
5104 -C "found fragmented DTLS handshake message" \
5105 -C "error"
5106
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005107run_test "DTLS reassembly: some fragmentation (openssl server)" \
5108 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005109 "$P_CLI dtls=1 debug_level=2" \
5110 0 \
5111 -c "found fragmented DTLS handshake message" \
5112 -C "error"
5113
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005114run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005115 "$O_SRV -dtls1 -mtu 256" \
5116 "$P_CLI dtls=1 debug_level=2" \
5117 0 \
5118 -c "found fragmented DTLS handshake message" \
5119 -C "error"
5120
5121run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5122 "$O_SRV -dtls1 -mtu 256" \
5123 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5124 0 \
5125 -c "found fragmented DTLS handshake message" \
5126 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005127
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005128# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005129
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005130not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005131run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005132 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005133 "$P_SRV dtls=1 debug_level=2" \
5134 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005135 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005136 -C "replayed record" \
5137 -S "replayed record" \
5138 -C "record from another epoch" \
5139 -S "record from another epoch" \
5140 -C "discarding invalid record" \
5141 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005142 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005143 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005144 -c "HTTP/1.0 200 OK"
5145
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005146not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005147run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005148 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005149 "$P_SRV dtls=1 debug_level=2" \
5150 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005151 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005152 -c "replayed record" \
5153 -s "replayed record" \
Hanno Beckera34cc6b2017-05-26 16:07:36 +01005154 -c "record from another epoch" \
5155 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005156 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005157 -s "Extra-header:" \
5158 -c "HTTP/1.0 200 OK"
5159
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005160run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
5161 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005162 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
5163 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005164 0 \
5165 -c "replayed record" \
5166 -S "replayed record" \
Hanno Beckera34cc6b2017-05-26 16:07:36 +01005167 -c "record from another epoch" \
5168 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005169 -c "resend" \
5170 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005171 -s "Extra-header:" \
5172 -c "HTTP/1.0 200 OK"
5173
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005174run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005175 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005176 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005177 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005178 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005179 -c "discarding invalid record (mac)" \
5180 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005181 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005182 -c "HTTP/1.0 200 OK" \
5183 -S "too many records with bad MAC" \
5184 -S "Verification of the message MAC failed"
5185
5186run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
5187 -p "$P_PXY bad_ad=1" \
5188 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
5189 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5190 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005191 -C "discarding invalid record (mac)" \
5192 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005193 -S "Extra-header:" \
5194 -C "HTTP/1.0 200 OK" \
5195 -s "too many records with bad MAC" \
5196 -s "Verification of the message MAC failed"
5197
5198run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
5199 -p "$P_PXY bad_ad=1" \
5200 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
5201 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5202 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005203 -c "discarding invalid record (mac)" \
5204 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005205 -s "Extra-header:" \
5206 -c "HTTP/1.0 200 OK" \
5207 -S "too many records with bad MAC" \
5208 -S "Verification of the message MAC failed"
5209
5210run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
5211 -p "$P_PXY bad_ad=1" \
5212 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
5213 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
5214 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005215 -c "discarding invalid record (mac)" \
5216 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005217 -s "Extra-header:" \
5218 -c "HTTP/1.0 200 OK" \
5219 -s "too many records with bad MAC" \
5220 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005221
5222run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005223 -p "$P_PXY delay_ccs=1" \
5224 "$P_SRV dtls=1 debug_level=1" \
5225 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005226 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005227 -c "record from another epoch" \
5228 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005229 -s "Extra-header:" \
5230 -c "HTTP/1.0 200 OK"
5231
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005232# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005233
Janos Follath74537a62016-09-02 13:45:28 +01005234client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005235run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005236 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005237 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5238 psk=abc123" \
5239 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005240 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5241 0 \
5242 -s "Extra-header:" \
5243 -c "HTTP/1.0 200 OK"
5244
Janos Follath74537a62016-09-02 13:45:28 +01005245client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005246run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
5247 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005248 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
5249 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005250 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5251 0 \
5252 -s "Extra-header:" \
5253 -c "HTTP/1.0 200 OK"
5254
Janos Follath74537a62016-09-02 13:45:28 +01005255client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005256run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
5257 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005258 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
5259 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005260 0 \
5261 -s "Extra-header:" \
5262 -c "HTTP/1.0 200 OK"
5263
Janos Follath74537a62016-09-02 13:45:28 +01005264client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005265run_test "DTLS proxy: 3d, FS, client auth" \
5266 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005267 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
5268 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005269 0 \
5270 -s "Extra-header:" \
5271 -c "HTTP/1.0 200 OK"
5272
Janos Follath74537a62016-09-02 13:45:28 +01005273client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005274run_test "DTLS proxy: 3d, FS, ticket" \
5275 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005276 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
5277 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005278 0 \
5279 -s "Extra-header:" \
5280 -c "HTTP/1.0 200 OK"
5281
Janos Follath74537a62016-09-02 13:45:28 +01005282client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005283run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
5284 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005285 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
5286 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005287 0 \
5288 -s "Extra-header:" \
5289 -c "HTTP/1.0 200 OK"
5290
Janos Follath74537a62016-09-02 13:45:28 +01005291client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005292run_test "DTLS proxy: 3d, max handshake, nbio" \
5293 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005294 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
5295 auth_mode=required" \
5296 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005297 0 \
5298 -s "Extra-header:" \
5299 -c "HTTP/1.0 200 OK"
5300
Janos Follath74537a62016-09-02 13:45:28 +01005301client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005302run_test "DTLS proxy: 3d, min handshake, resumption" \
5303 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5304 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5305 psk=abc123 debug_level=3" \
5306 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5307 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5308 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5309 0 \
5310 -s "a session has been resumed" \
5311 -c "a session has been resumed" \
5312 -s "Extra-header:" \
5313 -c "HTTP/1.0 200 OK"
5314
Janos Follath74537a62016-09-02 13:45:28 +01005315client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005316run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
5317 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5318 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5319 psk=abc123 debug_level=3 nbio=2" \
5320 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5321 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5322 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
5323 0 \
5324 -s "a session has been resumed" \
5325 -c "a session has been resumed" \
5326 -s "Extra-header:" \
5327 -c "HTTP/1.0 200 OK"
5328
Janos Follath74537a62016-09-02 13:45:28 +01005329client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005330requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005331run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005332 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005333 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5334 psk=abc123 renegotiation=1 debug_level=2" \
5335 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5336 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005337 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5338 0 \
5339 -c "=> renegotiate" \
5340 -s "=> renegotiate" \
5341 -s "Extra-header:" \
5342 -c "HTTP/1.0 200 OK"
5343
Janos Follath74537a62016-09-02 13:45:28 +01005344client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005345requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005346run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
5347 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005348 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5349 psk=abc123 renegotiation=1 debug_level=2" \
5350 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5351 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005352 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5353 0 \
5354 -c "=> renegotiate" \
5355 -s "=> renegotiate" \
5356 -s "Extra-header:" \
5357 -c "HTTP/1.0 200 OK"
5358
Janos Follath74537a62016-09-02 13:45:28 +01005359client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005360requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005361run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005362 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005363 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005364 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005365 debug_level=2" \
5366 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005367 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005368 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5369 0 \
5370 -c "=> renegotiate" \
5371 -s "=> renegotiate" \
5372 -s "Extra-header:" \
5373 -c "HTTP/1.0 200 OK"
5374
Janos Follath74537a62016-09-02 13:45:28 +01005375client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005376requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005377run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005378 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005379 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005380 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005381 debug_level=2 nbio=2" \
5382 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005383 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005384 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5385 0 \
5386 -c "=> renegotiate" \
5387 -s "=> renegotiate" \
5388 -s "Extra-header:" \
5389 -c "HTTP/1.0 200 OK"
5390
Janos Follath74537a62016-09-02 13:45:28 +01005391client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005392not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005393run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005394 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5395 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005396 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005397 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005398 -c "HTTP/1.0 200 OK"
5399
Janos Follath74537a62016-09-02 13:45:28 +01005400client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005401not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005402run_test "DTLS proxy: 3d, openssl server, fragmentation" \
5403 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5404 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005405 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005406 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005407 -c "HTTP/1.0 200 OK"
5408
Janos Follath74537a62016-09-02 13:45:28 +01005409client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005410not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005411run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
5412 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5413 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005414 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005415 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005416 -c "HTTP/1.0 200 OK"
5417
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005418requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005419client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005420not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005421run_test "DTLS proxy: 3d, gnutls server" \
5422 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5423 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005424 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005425 0 \
5426 -s "Extra-header:" \
5427 -c "Extra-header:"
5428
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005429requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005430client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005431not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005432run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
5433 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5434 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005435 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005436 0 \
5437 -s "Extra-header:" \
5438 -c "Extra-header:"
5439
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005440requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005441client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005442not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005443run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
5444 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5445 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005446 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005447 0 \
5448 -s "Extra-header:" \
5449 -c "Extra-header:"
5450
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01005451# Final report
5452
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005453echo "------------------------------------------------------------------------"
5454
5455if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005456 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005457else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005458 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005459fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02005460PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02005461echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005462
5463exit $FAILS